I want to have a COBOL subprogram called from either CICS or batch environments. The subprogram has no CICS commands in it and is simply a COBOL table lookup routine. I passed the subprogram through the CICS translator which inserted the DFHEIBLK and DFHCOMMAREA into the program for me. This works fine when I call from a CICS main program but I get an 0C4 abend when I call the sibprogram from a batch COBOL main program.
I inserted dummy WS field in the batch main program to account for dfheiblk and dfhcommarea so that the CALL prog USING dfheiblk dfhcommare parm1 would referr to the proper areas in the called sub. Am I doing something wrong?
From your description of the technique you used to call the same COBOL
sub-program from CICS and batch I would have expected it to work. To check
we ran the following code (which worked as expected):-
COBOL Subroutine translated:
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOBSUB.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
LINKAGE SECTION.
01 LINK-PARM PIC X(10).
PROCEDURE DIVISION USING LINK-PARM.
IN-THE-BEGINNING.
MOVE 'TERRY' TO LINK-PARM.
GOBACK.
END PROGRAM TCOBSUB.
COBOL Batch caller:
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOBBTCH.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 DFHEIBLK PIC X.
01 DFHCOMMAREA PIC X.
01 WORK-PARM PIC X(10) VALUE 'NAME'.
PROCEDURE DIVISION.
IN-THE-BEGINNING.
DISPLAY WORK-PARM.
CALL 'TCOBSUB' USING DFHEIBLK DFHCOMMAREA WORK-PARM.
DISPLAY WORK-PARM.
GOBACK.
END PROGRAM TCOBBTCH.
COBOL CICS caller translated:
IDENTIFICATION DIVISION.
PROGRAM-ID. TCOBCICS.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 WORK-PARM PIC X(10) VALUE 'NAME'.
PROCEDURE DIVISION.
IN-THE-BEGINNING.
EXEC CICS SEND TEXT FROM(WORK-PARM) ERASE END-EXEC.
CALL 'TCOBSUB' USING DFHEIBLK DFHCOMMAREA WORK-PARM.
EXEC CICS SEND TEXT FROM(WORK-PARM) END-EXEC.
GOBACK.
END PROGRAM TCOBCICS.
If your programs were essentially the same as this example then I do not
understand why the batch invocation failed.
I should also point out that it is NOT necessary to translate the COBOL
sub-program. You can call it from batch or from CICS using exactly the same
CALL statement as you would normally (ie with no DFHEIBLK or DFHCOMMAREA
parameters in either the CICS or batch calling program).
This was first published in March 2002