IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Passing Return code from COBOL to JCL


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Mon Feb 04, 2013 5:51 pm
Reply with quote

Hi,

I have a code like this,

WORKING-STORAGE SECTION.

01 A PIC S9(5) COMP-3 VALUE 0.
01 B PIC S9(5) COMP-3 VALUE 1.

PROCEDURE DIVISION.

IF A < B
MOVE 16 TO RETURN-CODE
DISPLAY 'THE RETURN-CODE IS:' RETURN-CODE
ELSE
MOVE 0 TO RETURN-CODE
DISPLAY 'THE RETURN-CODE IS:' RETURN-CODE
END-IF.

GOBACK.


When I execute it, I am unable to get the return code which was set in my cobol program.. Should I do any changes in my jcl for receiving it.

Please help....
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10833
Location: italy

PostPosted: Mon Feb 04, 2013 6:04 pm
Reply with quote

Quote:
When I execute it, I am unable to get the return code which was set in my cobol program.. Should I do any changes in my jcl for receiving it.


what do You mean by get ... receiving ???

a return code can be <tested> in the subsequent steps using the appropriate COND and/or IF

You can see the return code by looking at the jes log for the jcl
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Mon Feb 04, 2013 6:54 pm
Reply with quote

What is the RETURN-CODE from your DISPLAY 'THE RETURN-CODE IS:'?

Your JCL should have something like the following too:
//SYSOUD DD SYSOUT=*
//SYSOUT DD SYSOUT=*
//SYSPRINT DD SYSOUT=*,OUTLIM=10000
//SYSUDUMP DD SYSOUT=*
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Mon Feb 04, 2013 6:55 pm
Reply with quote

No. I am setting a return code 1 in my program based on a scenario. I need to receive that return code when I submit my jcl from my cobol program. But my jcl always shows RC of zero.

Plz help me.
Back to top
View user's profile Send private message
Gary McDowell

Active User


Joined: 15 Oct 2012
Posts: 139
Location: USA

PostPosted: Mon Feb 04, 2013 7:01 pm
Reply with quote

RC of zero...

So, "A" was equal or greater than "B" according to your code?

Maybe I'm missing something here.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon Feb 04, 2013 7:07 pm
Reply with quote

Quote:
when I submit my jcl from my cobol program


You'd best explain this.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10833
Location: italy

PostPosted: Mon Feb 04, 2013 7:20 pm
Reply with quote

why don' t You simply run

Code:
 ****** ***************************** Top of Data ******************************
 000001        IDENTIFICATION DIVISION.
 000002        PROGRAM-ID     RETCODE.
 000003        AUTHOR.        <SOME AUTHOR>
 000004        ENVIRONMENT    DIVISION.
 000005        DATA           DIVISION.
 000006        WORKING-STORAGE SECTION.
 000007        PROCEDURE      DIVISION.
 000008            MOVE 4 to RETURN-CODE .
 000009            GOBACK.
 ****** **************************** Bottom of Data ****************************


and see the
Code:
IEF142I RETCODE  G GO - STEP WAS EXECUTED - COND CODE 0004


so You will see that COBOL/JCL and friends behave as expected,
and realize that there might be something wrong somewhere in Your code.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10833
Location: italy

PostPosted: Mon Feb 04, 2013 7:37 pm
Reply with quote

telling us
Quote:
I have a code like this,


it is not enough to provide an answer .

IT is pretty deterministic and it does not appreciate like descriptions

I was curious and as expected from a nice compiler

Code:
 ****** ***************************** Top of Data ******************************
 000001        IDENTIFICATION DIVISION.
 000002        PROGRAM-ID     RETCOD2.
 000003        AUTHOR.        <SOME AUTHOR>
 000004        ENVIRONMENT    DIVISION.
 000005        DATA           DIVISION.
 000006        WORKING-STORAGE SECTION.
 000007        01 A PIC S9(5) COMP-3 VALUE 0.
 000008        01 B PIC S9(5) COMP-3 VALUE 1.
 000009        PROCEDURE      DIVISION.
 000010            IF  A < B
 000011                DISPLAY ' A IS LESS THAN B'
 000012                MOVE 4 TO RETURN-CODE
 000013            ELSE
 000014                DISPLAY ' A IS GRTR THAN B'
 000015                MOVE 8 TO RETURN-CODE
 000016            END-IF.
 000017            GOBACK.
 ****** **************************** Bottom of Data ****************************


ended with ...

Code:
 SDSF OUTPUT DISPLAY ENRICO1  JOB01282  DSID   106 LINE 0       COLUMNS 02- 81
 COMMAND INPUT ===>                                            SCROLL ===> CSR
********************************* TOP OF DATA **********************************
 A IS LESS THAN B
******************************** BOTTOM OF DATA ********************************


and ( the obvious )

Code:
IEF142I ENRICO1 G GO - STEP WAS EXECUTED - COND CODE 0004


if You want good answers learn to post good questions

icon_cool.gif
Back to top
View user's profile Send private message
Jose Mateo

Active User


Joined: 29 Oct 2010
Posts: 121
Location: Puerto Rico

PostPosted: Mon Feb 04, 2013 7:47 pm
Reply with quote

Good day to all!

Abdulrafi, is this a sub-program which you are calling from a main program?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8651
Location: Dubuque, Iowa, USA

PostPosted: Mon Feb 04, 2013 7:59 pm
Reply with quote

Quote:
No. I am setting a return code 1 in my program based on a scenario. I need to receive that return code when I submit my jcl from my cobol program. But my jcl always shows RC of zero.
Let's see if this is what you are trying to do:
1. You submit JCL to execute job A that executes program A
2. Program A has the code you posted to set RETURN-CODE based on some variable values
3. Critical question: are you expecting the rest of job A that executes program A to use the return code set by program A, or are you submitting a new job B via your COBOL program A?

For the critical question, if you are submtiting job B via your program A and expecting job B to be able to access the return code set in program A, then you are going to be disappointed because job B is completely and totally distinct from job A and the return code cannot be passed across. You can modify job B JCL to include a SET statement (BEFORE you submit the JCL), but that will not be a return code.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10833
Location: italy

PostPosted: Mon Feb 04, 2013 8:01 pm
Reply with quote

that' s what I asked

Quote:
what do You mean by get ... receiving ???


but the TS never cared to aknowledge icon_evil.gif
Back to top
View user's profile Send private message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 184
Location: Coimbatore

PostPosted: Mon Feb 04, 2013 9:00 pm
Reply with quote

Thanks for your help... I got it done :-)
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10833
Location: italy

PostPosted: Mon Feb 04, 2013 9:06 pm
Reply with quote

Quote:
Thanks for your help... I got it done


thanks &deity
but You still did not care to explain anything icon_evil.gif
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8651
Location: Dubuque, Iowa, USA

PostPosted: Mon Feb 04, 2013 9:59 pm
Reply with quote

abdulrafi, you did not respond to requests for explanations and now all of a sudden you've resolved the issue -- without ever clearly identifying the issue nor its resolution. Do you really think your behavior in this thread is conducive to you getting more help the next time you post a question?
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Cobol prog to put an indicator on the... JCL & VSAM 1
No new posts COBOL Ascending and descending sort n... COBOL Programming 5
No new posts Help needed to assemble IMS sample co... ABENDS & Debugging 4
No new posts COBOL program logic for comparisipn o... COBOL Programming 2
No new posts COBOL - create and write to output fi... COBOL Programming 0
Search our Forums:

Back to Top