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

Run program based on condition code


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Global Moderator


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

PostPosted: Tue Feb 23, 2010 6:59 pm
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Tue Feb 23, 2010 7:01 pm
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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Using API Gateway from CICS program CICS 0
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts DB2 Event passed to the Application P... DB2 1
No new posts How to pass the PARM value to my targ... COBOL Programming 8
Search our Forums:

Back to Top