Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set JCL cond code from within COBOL program 2

Status
Not open for further replies.
M

Member 310024

Guest
My environment is IBM mainframe DB2/COBOL TSO batch program.
Say you've got a -803 sqlcode for example, and you want to display a message to that effect, and then terminate the program.
What if under these circumstances, you also want to set the JCL cond code to 8 (or whatever).
Is there a way of doing this from within the program?
In other words how do you normally set the JCL cond code, so that after the program finishes, the JCL can then use that cond code?
Thanks.
 
I believe you can move the value you wish to set to the RETURN-CODE special register just before you STOP RUN (or GOBACK).

Regards.

Glenn
 
In a little greater detail...

********************* Text Below Copyright (c) 2005, IBM *********************
RETURN-CODE

The RETURN-CODE special register can be used to pass a return code to the
calling program or operating system when the current COBOL program ends.
When a COBOL program ends:

o If control returns to the operating system, the value of the
RETURN-CODE special register is passed to the operating system as a
user return code. The supported user return code values are
determined by the operating system, and might not include the full
range of RETURN-CODE special register values.

o If control returns to a calling program, the value of the RETURN-CODE
special register is passed to the calling program. If the calling
program is a COBOL program, the RETURN-CODE special register in the
calling program is set to the value of the RETURN-CODE special
register in the called program.

The RETURN-CODE special register has the implicit definition:

01 RETURN-CODE GLOBAL PICTURE S9(4) USAGE BINARY VALUE ZERO

The following are examples of how to set the RETURN-CODE special register:

COMPUTE RETURN-CODE = 8

or

MOVE 8 to RETURN-CODE.

When used in nested programs, this special register is implicitly defined
with the GLOBAL attribute in the outermost program.
Depending on the severity of the error and how I want the system to respond, I have also used ILBOABN0:

3.2.7 Using ILBOABN0 to force an abend


| This section applies to the following compiler options:


| RES
| NORES Linked

With OS/VS COBOL, you can use a CALL to ILBOABN0 to force an immediate abend and obtain a system dump. With Language Environment, a CALL to ILBOABN0 will continue to force an immediate abend. To produce a system dump, see "Obtaining a system dump or a CICS transaction dump" in topic 3.1.4.
If you use the Language Environment version of ILBOABN0, the save area of the program issuing ILBOABN0 is located two levels back from the save area where the actual abend was issued.

OS/VS COBOL programs that use a CALL to ILBOABN0 can continue to call ILBOABN0 when compiled with Enterprise COBOL. However, it is recommended that you use the Language Environment CEE3ABD callable service instead.
(above quote taken from
Enterprise COBOL for z/OS
Compiler and Run-Time Migration Guide
Version 3 Release 3
Document Number GC27-1409-02)

There's always more than one way to skin a cat! :)

Ever onward,
jar
 
Thanks to 3gm and jrohrbach for their quick and helpful responses. I appreciate it. Stars allocated!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top