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
 

 

How to set the return code in cobol for empty output file

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> HomeWorks & Requests
View previous topic :: :: View next topic  
Author Message
Prabha
Warnings : 2

New User


Joined: 05 Dec 2005
Posts: 79

PostPosted: Thu Jun 21, 2007 10:46 pm    Post subject: How to set the return code in cobol for empty output file
Reply with quote

Hi all,

If my program generates empty output file in jcl, then next step in that jcl should not run. For that how will you set the return code in program and how will you pass it thru JCL.

Step1 Exec Pgm=cobol1
Step2 exec Pgm=cobol2

If cobol1 produces empty output file, then step2 should not run.

Help me out this..
Back to top
View user's profile Send private message

superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Fri Jun 22, 2007 12:10 am    Post subject: Re: How to set the return code in cobol for empty output fil
Reply with quote

See this previous topic.
Back to top
View user's profile Send private message
twissi

Active User


Joined: 01 Aug 2005
Posts: 105
Location: Somerset, NJ

PostPosted: Fri Jun 22, 2007 10:23 pm    Post subject:
Reply with quote

Praba,

As Kevin suggested, it's been discussed earlier.
If you still need some explanation, here you go -

In COBOL1 program, add a step in the end to READ the output file you mentioned. If the number of records read is zero
Code:
MOVE 4 TO RETURN-CODE ELSE MOVE 0 TO RETURN-CODE
.

RETURN-CODE is a special register used to pass a return code from sub programs to main program and it has a definition of GLOBAL PIC S9(4) COMP VALUE 0.

In the JCL, you put a condition such that
Code:
IF (STEP1.RC = 0)
    give STEP2 lines
ENDIF


nice and easy!
Cheers, Twissi
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Sat Jun 23, 2007 12:23 am    Post subject:
Reply with quote

Hello,

Or possibly add a counter to the code and increment the counter each time you write a record. When the job is finished, you could compare the counter to zero and issue the return-code as suggested by Twissi.
Back to top
View user's profile Send private message
Prabha
Warnings : 2

New User


Joined: 05 Dec 2005
Posts: 79

PostPosted: Sat Jun 23, 2007 11:36 am    Post subject: Re: How to set the return code in cobol for empty output fil
Reply with quote

Many Thanks for all yr help !!!!
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 -> HomeWorks & Requests All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. Full Time COBOL Software Development ... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:24 am
This topic is locked: you cannot edit posts or make replies. COBOL Software Development Lead at Fi... shally Mainframe Jobs 0 Fri Jan 20, 2017 5:21 am
No new posts SORTJOIN - Copy Matched and Unmatched... Steve Ironmonger DFSORT/ICETOOL 5 Tue Jan 17, 2017 4:26 pm
No new posts Incorrect output when trying to add n... monica1 PL/I & Assembler 10 Fri Jan 13, 2017 5:02 pm
No new posts How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm


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