Often, when I'm running a long job in batch, I want to check the status of the job. Fortunately, with certain types of jobs, it's possible to determine the job's progress. For example, if I'm running a Copy File (CPYF) command, I know that the job will be complete when the number of records specified in the TOFILE parameter is equal to the number of records in the FROMFILE parameter. Likewise, if I'm running a job which builds a work file, and I know how many records are supposed to be in the work file when the job has completed, I can tell how far the job has progressed.
To make this calculation easy, I wrote a utility called Display Percent Complete (DSPPCTCMP). The source code for the command is shown in 3. The command processing program, PCT001CL, is shown in 4; and the display file, PCT001DF, is shown in 5.
To make this calculation easy, I wrote a utility called Display Percent Complete (DSPPCTCMP). The source code for the command is shown in Figure 3. The command processing program, PCT001CL, is shown in Figure 4; and the display file, PCT001DF, is shown in Figure 5.
This utility presents you with a window which shows you the percentage of completion for a job. An auto-refresh technique is used to keep the information in the window constantly updated.
The DSPPCTCMP command has three parameters. The first parameter contains the qualified name of a file. The second parameter specifies a member name within the file. The third parameter indicates the number of records you expect to have in the file when a particular job completes.
Let's look at a simple example. Suppose you submit a CPYF command to batch to copy FILEA, which contains 32,768 records, to FILEB. At some point during the execution of that job, you issue the following command:
DSPPCTCMP FILE(FILEB) + CMPNBR(32768)
You would then be presented with a window showing an automatically incrementing percent value. When the value reaches 100 percent, the job is complete.
The PCT001CL program calculates the percent complete by retrieving the number of active records in the specified file. It then divides that number by the specified completion number and multiplies the results by 100. This number, which is always between 0 and 100, represents the percentage of the job that is complete. Be aware that this calculation is only as accurate as the completion number you supply. But when you know the number of records you expect to have, this utility can be very useful.
The Display Percent Complete Utility
Figure 3 Command DSPPCTCMP
/*===============================================================*/ /* To compile: */ /* */ /* CRTCMD CMD(XXX/DSPPCTCMP) PGM(XXX/PCT001CL) + */ /* SRCFILE(XXX/QCMDSRC) */ /* */ /*===============================================================*/ DSPPCTCMP: CMD PROMPT('Display Percent Complete') PARM KWD(FILE) TYPE(QUAL) PROMPT('File name') PARM KWD(MBR) TYPE(*NAME) LEN(10) DFT(*FIRST) + SPCVAL((*FIRST)) PROMPT('Member') PARM KWD(CMPNBR) TYPE(*DEC) LEN(7) + PROMPT('Completion number') QUAL: QUAL TYPE(*NAME) LEN(10) MIN(1) QUAL TYPE(*NAME) LEN(10) DFT(*LIBL) + SPCVAL((*LIBL)) PROMPT('Library')
The Display Percent Complete Utility
Figure 4 CL Program PCT001CL
/*===============================================================*/ /* To compile: */ /* */ /* CRTCLPGM PGM(XXX/PCT001CL) SRCFILE(XXX/QCLSRC) */ /* */ /*===============================================================*/ PGM PARM(&FILE &MBR &CMPRCD) DCL VAR(&FILE) TYPE(*CHAR) LEN(20) DCL VAR(&LIB) TYPE(*CHAR) LEN(10) DCL VAR(&MBR) TYPE(*CHAR) LEN(10) DCL VAR(&ARCDS) TYPE(*DEC) LEN(10 0) DCL VAR(&WORK) TYPE(*DEC) LEN(7 4) DCL VAR(&MSG) TYPE(*CHAR) LEN(80) DCLF FILE(PCT001DF) MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERROR)) OVRDSPF FILE(PCT001DF) WAITRCD(1) CHGVAR VAR(&FILNAM) VALUE(%SST(&FILE 1 10)) CHGVAR VAR(&LIB) VALUE(%SST(&FILE 11 10)) LOOP: + RTVMBRD FILE(&LIB/&FILNAM) MBR(&MBR) RTNLIB(&LIBNAM) + RTNMBR(&MBRNAM) NBRCURRCD(&ARCDS) CHGVAR VAR(&ACTRCD) VALUE(&ARCDS) IF COND(&CMPRCD *GT 0) THEN(DO) CHGVAR VAR(&WORK) VALUE(&ARCDS / &CMPRCD) CHGVAR VAR(&PCTCMP) VALUE(&WORK * 100) ENDDO SNDRCVF RCDFMT(PCT001FM) WAIT(*NO) MONMSG MSGID(CPF0887) IF COND(&IN03) THEN(GOTO CMDLBL(ENDPGM)) RMVMSG CLEAR(*ALL) WAIT MONMSG MSGID(CPF0889) GOTO CMDLBL(LOOP) ERROR: + RCVMSG MSGTYPE(*ANY) MSG(&MSG) SNDPGMMSG MSG(&MSG) ENDPGM: + ENDPGM
The Display Percent Complete Utility
Figure 5 Display File PCT001DF
*=============================================================== * To compile: * * CRTDSPF FILE(XXX/PCT001DF) SRCFILE(XXX/QDDSSRC) * *=============================================================== *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7 A DSPSIZ(24 80 *DS3) A CF03(03) A CF12(03) A R PCT001FM LOCK A WINDOW(6 28 11 20) A WDWBORDER((*COLOR GRN) - A (*DSPATR RI) - A (*CHAR ' ')) A 1 3'Percent Complete' A DSPATR(HI) A 3 1'File....:' A FILNAM 10 O 3 11 A 4 1'Library.:' A LIBNAM 10 O 4 11 A 5 1'Member..:' A MBRNAM 10 O 5 11 A 6 1'Records.:' A ACTRCD 7Y 0O 6 11EDTCDE(3) A 7 1'Complete:' A CMPRCD 7Y 0O 7 11EDTCDE(3) A 8 1'Percent.:' A PCTCMP 5Y 2O 8 12EDTWRD(' 0. %') A DSPATR(HI) A 10 1'F3=Exit' A COLOR(BLU) A 10 11'F12=Cancel' A COLOR(BLU) A R DUMMY ASSUME A 1 2' ' *. 1 ...+... 2 ...+... 3 ...+... 4 ...+... 5 ...+... 6 ...+... 7
LATEST COMMENTS
MC Press Online