Problem solve Get help with specific problems with your technologies, process and projects.

Restarting a CL batch job

After an abort, restarting a CL batch job with multiple steps can sometimes be a headache. Here's a quick workaround.

After an abort, restarting a CL batch job with multiple steps can sometimes be a headache. You could restart the job from the beginning after you correct the problem. However, if each step is long running that takes time. To solve that problem I have created a data area and after each job step I update the data area to indicate successful completion of each step. The data area then can help you find out at what step a problem occurred. Also, when you rerun the job, the steps that have completed successfully would not get rerun. The job would pick up at the step the abort occurred.


 
PGM

/* Declarations area  */
DCL  &JOBSTATUS  TYPE(*CHAR) LEN(8) 

/* Get data area    */
RTVDTAARA DTAARA(JOBDATAREA) RTNVAR(&JOBSTATUS)

/* Check job completion steps */
IF (&JOBSTATUS *EQ 'STEP1OK') THEN(DO)
    GOTO STEP2
    ENDDO
ELSE   IF (&JOBSTATUS *EQ 'STEP2OK') (DO)
          GOTO STEP3
       ENDDO
ELSE   IF (&JOBSTATUS *EQ 'STEP3OK') (DO)
          GOTO EOJ
       ENDDO

STEP1:
     CALL PGM(PGM1)
     MONOMSG MSGID(CPF0000) EXEC(GOTO SEND_ERR)
     CHGDTAARA DTAARA(JOBDATAREA) VALUE('STEP1OK')

STEP2: 
     CALL PGM(PGM2)
     MONOMSG MSGID(CPF0000) EXEC(GOTO SEND_ERR)
     CHGDTAARA DTAARA(JOBDATAREA) VALUE('STEP2OK')

STEP3: 
     CALL PGM(PGM3)
     MONOMSG MSGID(CPF0000) EXEC(GOTO SEND_ERR)
     CHGDTAARA DTAARA(JOBDATAREA) VALUE('STEP3OK')
     GOTO EOJ:

SEND_ERR:
    /* Place your error routine here */
    GOTO END
   
EOJ:
 /* RESET DATA AREA FOR NEXT TIME */
     CHGDTAARA DTAARA(JOBDATAREA) VALUE(' ')

END: ENDPGM 

==================================
MORE INFORMATION ON THIS TOPIC
==================================

The Best Web Links: tips, tutorials and more.

Ask your programming questions--or help out your peers by answering them--in our live discussion forums.

Ask the Experts yourself: Our application development gurus are waiting to answer your programming questions.

Dig Deeper on iSeries CL programming

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close