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

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


IBM Mainframe Forums -> HomeWorks & Requests
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Fri Jun 22, 2007 12:10 am
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
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

Moderator Emeritus


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

PostPosted: Sat Jun 23, 2007 12:23 am
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> HomeWorks & Requests

 


Similar Topics
Topic Forum Replies
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts SFTP Issue - destination file record ... All Other Mainframe Topics 2
Search our Forums:

Back to Top