coboljclrcjesreturn-code

How to pass Job Max RC / Last CC to COBOL Program


Imagine there is a PGM=SORT step in a job that ends with RC=8 after execution, I need to send that RC value (or last CC) through a parameter to a COBOL program in the next step.

How can I use/send the RC?

I've tried: //Step2 EXEC PGM=MYPROG,PARM=&RC

Also // SET MYRC=RC //Step2 EXEC PGM=MYPROG,PARM=&MYRC

And they didn't work.


Solution

  • Unless things have changed since I last used the mainframe, as @Kolsu said you can not pass the return code to the next program.

    Return Codes are a JCL thing. Normally you would use the JCL if statement like

    //  IF (SORT.RC < 8) THEN
    //MYSTEM EXEC PGM=MYPROG
    //  ENDIF
    

    you could do something silly like

    //  IF (SORT.RC = 0) THEN
    //MYSTEM EXEC PGM=MYPROG,PARM="00"
    //  ENDIF
    //  IF (SORT.RC = 4) THEN
    //MYSTEM EXEC PGM=MYPROG,PARM="04"
    //  ENDIF
    //  IF (SORT.RC = 8) THEN
    //MYSTEM EXEC PGM=MYPROG,PARM="08"
    //  ENDIF