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

Help with calling a COBOL subprogram from either CICS or batch environments

CICS expert Robert Crawford helps troubleshoot a COBOL subprogram call from CICS or batch environments.

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 last published in March 2002

Dig Deeper on IBM system z and mainframe systems

PRO+

Content

Find more PRO+ content and other member only offers, here.

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

SearchServerVirtualization

SearchCloudComputing

Close