Figure 9 EDIVPROCESS CL Program

/************************************************************/
/***  Source: DIVPROCESS                                  ***/
/***  Author: Mike Pavlak                                 ***/
/***  Description: Process each division, balance inter-  ***/
/***               divisional x-acts and print reports...  ***/
/************************************************************/
             PGM &LIB

             DCL        VAR(&LIB) TYPE(*CHAR) LEN(10)
             DCL        VAR(&DIVD) TYPE(*DEC) LEN(10 0)
             DCL        VAR(&DIVI) TYPE(*INT)
             DCL        VAR(&X) TYPE(*INT)
             DCLF       FILE(DIVMAST) OPNID(A)

  /* Process each division for batch work...                 */
             RTVMBRD    FILE(DIVMAST) NBRCURRCD(&DIVD)
             CHGVAR     VAR(&DIVI) VALUE(&DIVD)
             CALLSUBR   SUBR(PROCESSDIV)

  /* Process interdivision transactions...                    */

             CALL       PGM(GLB098)
             CLOSE      OPNID(A)

  /* Process each division for reports...                 */
             CALLSUBR   SUBR(REPORTDIV)


             SUBR       SUBR(PROCESSDIV)  /* Division Batch */

             DOFOR      VAR(&X) FROM(1) TO(&DIVI)
             RCVF       OPNID(A)
             MONMSG     MSGID(CPF0864) EXEC(LEAVE)
             CALL       PGM(DIV0010) PARM(&A_DIVISION#)
             ENDDO

             ENDSUBR

             SUBR       SUBR(REPORTDIV)   /* Division reports */

             DOFOR      VAR(&X) FROM(1) TO(&DIVI)
             RCVF       OPNID(A)
             MONMSG     MSGID(CPF0864) EXEC(LEAVE)
             CALL       PGM(DIV0020) PARM(&A_DIVISION#)
             ENDDO

             ENDSUBR

 END:        ENDPGM