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
 

 

Run program based on condition code

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

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Tue Feb 23, 2010 6:55 pm    Post subject: Run program based on condition code
Reply with quote

The requirement is listed below-

1. One COBOL program - PRG1

2. One JCL - JCL1. This JCL runs the program PRG1 twice - in two different steps. Each run of the same program executes different code.

Example-

STEP10 'executes PRG1'

STEP20 'executes PRG1'


PRG1 has two PARA'S - PARA1 and PARA2. When program runs under STEP10,
code under PARA1 is run, under STEP20, code under PARA2 is run based on condition code returned from STEP10.

This can be done easily using two different programs, but wondering if the condition code returned in STEP10 can be passed into the program.
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: Tue Feb 23, 2010 6:59 pm    Post subject: Reply to: Run program based on condition code
Reply with quote

No it can't. You'll have to look into reading and interpreting the JSCB control blocks from STEP10.

Wouldn't it be easier to just have PRG1 in STEP10 write it's final RETURN-CODE value into a dataset so it can then read that in STEP20?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7931
Location: Bellevue, IA

PostPosted: Tue Feb 23, 2010 7:01 pm    Post subject:
Reply with quote

You could use a JCL parameter to pass into the COBOL program to indicate which execution path to take. I don't believe the step condition code can be directly passed to the COBOL code, though. You could use condition checking in your JCL to execute different steps with different parameters based on the first step's condition code -- as long as there's not a large number of possible condition codes.
Back to top
View user's profile Send private message
Suresh Shankarakrishnan

New User


Joined: 11 Jul 2008
Posts: 42
Location: USA

PostPosted: Tue Feb 23, 2010 8:32 pm    Post subject:
Reply with quote

Thanks Robert and superk.

Of course, one way could be to write different values in a dataset after the program executes each time, and control the logic in the program based on that.

Or, another option could be to control the logic when the program runs a second time based on condition code and parm value..somethuing like this.

STEP10 'executes PRG1'


STEP20 IF cond code from STEP10 = 0
'execute PRG1 parm='xxx''


As an aside, did not know that COBOL could handle full classes, objects etc. like JAVA programs.
Back to top
View user's profile Send private message
ridgewalker58

New User


Joined: 26 Sep 2008
Posts: 51
Location: New York

PostPosted: Wed Feb 24, 2010 3:30 am    Post subject: Reply to: Run program based on condition code
Reply with quote

Check the JCL manuals -- my computer is down now otherwise i would send you an example of the syntax

But in PSEUDO-JCL it looks somewhat like this
//run1 if (rc.stepname=04) then
//step01 exec pgm=yourpgmname
// end-if
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 How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm
No new posts Executing OO COBOL program invoking J... Virendra Shambharkar COBOL Programming 2 Tue Jan 10, 2017 6:37 pm
No new posts Need Suggestion on COBOL program vickey_dw COBOL Programming 5 Thu Jan 05, 2017 10:55 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts Removing Duplicates based on certain ... chandracdac DFSORT/ICETOOL 8 Fri Dec 09, 2016 4:40 am


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