Mohamad Heydari
Mohamad Heydari

Reputation: 3

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.

Upvotes: 0

Views: 110

Answers (1)

Bruce Martin
Bruce Martin

Reputation: 10553

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

Upvotes: 0

Related Questions