v should put the returncode in the file from the spool area only. use XDC in the spool area to send it in to the file. else check in the forum. then after u need to read it from the file using the cobol coding. i dont think there is any other way. let me search again. if any solution let me know.
There is no direct way to pass a return code of a step to a COBOL program. But if you are good at Control Blocks (TCB - Task Control Block, JCB - Job Control Block) then you can retrieve the RC of any previous step (in the same job) by a COBOL / REXX program and process it.
This is a small REXX program which captures the RC of a given Step in the same job (Note: Your REXX program must also be in the same job. It can capture the RC of any steps prior to your REXX step).
Tailor this code to write the RC to a dataset and read the dataset using COBOL.
/* REXX */
/* GET THE STEP NAME AND RETURN CODE */
NUMERIC DIGITS(32) /* ENSURE MAX PRECISION */
TCB=STORAGE(D2X(540),4) /* PSATOLD IN PSA */
JSCB =STORAGE(D2X(C2D(TCB)+180),4) /* TCBJSCB IN TCB */
JCT = STORAGE(D2X(C2D(JSCB)+261),3) /* JSCBJCTA IN JSCB */
THIS_STEP_NO = X2D(C2X(STORAGE(D2X(C2D(JSCB)+228),1)))
/* THIS STEP NO. */
FSCT = STORAGE(D2X(C2D(JCT)+48),3) /* JCTSDKAD IN JCT */
/* IS FIRST SCT */
TEMP_SCT = FSCT
DO I = 1 TO (THIS_STEP_NO - 1)
STEP = STORAGE(D2X(C2D(TEMP_SCT)+68),8)
RCSTEP = X2D(C2X(STORAGE(D2X(C2D(TEMP_SCT)+24),2)))
/* SCTSEXEC IN SCT */
BYPASS = STORAGE(D2X(C2D(TEMP_SCT)+188),1)
IF X2D(C2X(BYPASS)) = 80 THEN /* CHECK IF STEP WAS NOT EXECUTED */
RCSTEP = 'FLUSHED '
SAY 'STEP ==>' STEP ' RC ==>' RCSTEP
TEMP_SCT = STORAGE(D2X(C2D(TEMP_SCT)+36),3)