Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Passing Return code from COBOL to JCL

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
abdulrafi

Active User


Joined: 14 Sep 2009
Posts: 135
Location: Coimbatore

PostPosted: Mon Feb 04, 2013 5:51 pm    Post subject: Passing Return code from COBOL to JCL
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Feb 04, 2013 6:04 pm    Post subject: Reply to: passing return code from cobol to jcl
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    Post subject:
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: 135
Location: Coimbatore

PostPosted: Mon Feb 04, 2013 6:55 pm    Post subject:
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    Post subject:
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

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Mon Feb 04, 2013 7:07 pm    Post subject: Reply to: passing return code from cobol to jcl
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Feb 04, 2013 7:20 pm    Post subject: Reply to: passing return code from cobol to jcl
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Feb 04, 2013 7:37 pm    Post subject: Reply to: passing return code from cobol to jcl
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: 110
Location: Puerto Rico

PostPosted: Mon Feb 04, 2013 7:47 pm    Post subject: Reply to: passing return code from cobol to jcl
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: 7913
Location: Bellevue, IA

PostPosted: Mon Feb 04, 2013 7:59 pm    Post subject:
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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Feb 04, 2013 8:01 pm    Post subject: Reply to: passing return code from cobol to jcl
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: 135
Location: Coimbatore

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

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

Global Moderator


Joined: 14 Mar 2007
Posts: 10203
Location: italy

PostPosted: Mon Feb 04, 2013 9:06 pm    Post subject: Reply to: passing return code from cobol to jcl
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: 7913
Location: Bellevue, IA

PostPosted: Mon Feb 04, 2013 9:59 pm    Post subject:
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
No new posts FTP - JCL failed while passing FTP co... Suneetha1612 JCL & VSAM 12 Wed Nov 16, 2016 7:33 pm
This topic is locked: you cannot edit posts or make replies. RANDOM Function in COBOL swapnil781 COBOL Programming 2 Tue Nov 15, 2016 6:17 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us