Sometimes we have to deal with monitoring batch jobs in AS400 and it will be very difficult to predict the job run time especially when the number of records to process vary on daily basis. This case land us into a situation where we end up pressing F5 button until the job finishes.
To simplify our monitoring task, we can create a screen which shows the progress of job and percentage it completed (as shown below)
Enough talk, lets jump to code -
Display file source -
RPGLE source -
01.00 Hoption(*nodebugio:*srcstmt)
02.00 *
03.00 FDUTIL001 cf e workstn
04.00 *
05.00 D cmdstring s 512
06.00 D cmdlen s 15p 5
07.00 D i s 2p 0
08.00 *
09.00 Dqcmdexc pr extpgm('QCMDEXC')
10.00 D cmd 3000a const options(*varsize)
11.00 D cmdlen 15p 5 const
12.00 D 3a const options(*nopass)
13.00 /free
14.00 cmdstring = 'DLYJOB DLY(1)';
15.00 cmdlen = %len(%trim(cmdstring));
16.00 for i = 1 to 60 by 10;
17.00 %subst(pgrbar:1:i) = *ALL'*';
18.00 pct = (i/60)*100;
19.00 write dsprcd;
20.00 qcmdexc(cmdstring:cmdlen);
21.00 endfor;
22.00 exfmt dummy;
23.00 *inlr = *on;
Here the trickiest part is - how to update the value of field without user interaction on screen.
While dong all these we have to make sure that the DFRWRT parameter should be *NO while compiling display file. Bingo.. there you go..
To simplify our monitoring task, we can create a screen which shows the progress of job and percentage it completed (as shown below)
![]() |
Progress Bar |
Display file source -
RPGLE source -
01.00 Hoption(*nodebugio:*srcstmt)
02.00 *
03.00 FDUTIL001 cf e workstn
04.00 *
05.00 D cmdstring s 512
06.00 D cmdlen s 15p 5
07.00 D i s 2p 0
08.00 *
09.00 Dqcmdexc pr extpgm('QCMDEXC')
10.00 D cmd 3000a const options(*varsize)
11.00 D cmdlen 15p 5 const
12.00 D 3a const options(*nopass)
13.00 /free
14.00 cmdstring = 'DLYJOB DLY(1)';
15.00 cmdlen = %len(%trim(cmdstring));
16.00 for i = 1 to 60 by 10;
17.00 %subst(pgrbar:1:i) = *ALL'*';
18.00 pct = (i/60)*100;
19.00 write dsprcd;
20.00 qcmdexc(cmdstring:cmdlen);
21.00 endfor;
22.00 exfmt dummy;
23.00 *inlr = *on;
Here the trickiest part is - how to update the value of field without user interaction on screen.
While dong all these we have to make sure that the DFRWRT parameter should be *NO while compiling display file. Bingo.. there you go..
No comments:
Post a Comment