I promised to myself not to post technical stuff on this blog. But as Seth Godin said not that long ago, never’s not such a long time. And also, why shouldn’t I share a piece of useful advice if I have it. So here it goes.
Have you ever started a lengthy NAV batch job, and then wondered how much longer it is really going to take? Me too.
NAV forms usually have progress bars. Good. But how about something like this:
Instead of just sporting a progress bar, it gives you estimated time left. Now you really know if you can go grab that sandwich while NAV munches on its bytes.
Here’s how I did it:
- At every row, calculate the difference between current time and batch job starting time
- Based on this, the number of records completed and total number of records, you calculate the total estimated operation time length
- Add the total estimated length time to starting time
- Calculate the difference between estimated ending time, and current time
- Display the number
In C/AL, it looks like this:
iTotal := lrSomeTable.COUNT;
i := 0;
iPctg := 0;
dtStart := CURRENTDATETIME;
dtDiff := 0;
dWindow.OPEN(Text001,i,iTotal,iPctg,dtDiff);
// Text001 =
// Copying parameters: #1####### of #2#######\
// @3@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@\\
// Estimated time left: #4###################
IF lrSomeTable.FIND(’-') THEN
REPEAT
// do something
i := i + 1;
iPctg := ROUND((i / iTotal) * 10000,1,’<’);
dtDiff := ROUND((CURRENTDATETIME - dtStart) * (iTotal / i),1,’<’);
dtEnd := dtStart + dtDiff;
// We don’t care about milliseconds
dtDiff := ROUND((dtEnd - CURRENTDATETIME) / 1000,1,’<’) * 1000;
dWindow.UPDATE();
UNTIL lrSomeTable.NEXT = 0;
Of course, this is just a rough estimation, it totally depends on statistics, and that each operation of whatever you do with your records will take roughly equal amount of time.
How about including this in status forms of your next NAV 4.0 to 5.0 upgrade project?
