Control flow from one STEP to another

In this Mainframe Forum - You can post your queries on JCL, OS/390 JCL, MVS JCL, z/OS JCL, JES2 & JES3

Moderators: Frank Yaeger, DikDude, Moderator Group

Post Reply
pkaushi
Member
Posts: 9
Joined: Mon Feb 06, 2006 1:45 pm

Control flow from one STEP to another

Post by pkaushi » Tue Feb 07, 2006 9:51 am

Hi,

I have a query...

Think of a cobol program which generates output file say file A. Now the jcl has two steps say STEP1 and STEP2. STEP1 executes the COBOL program.

Now whenever the program Writes some records into fileA only then step2 should execute and if nothing is written to the output file (Think of ity as a dummy O/P) being created then program should terminate.

How do I handle the above case in a JCL.....
Thanks and Regards,
Prashant

User avatar
prasad
Member
Posts: 7
Joined: Mon Feb 06, 2006 12:04 am

use RETURN-CODE in COBOL program

Post by prasad » Tue Feb 07, 2006 10:30 am

Hi pkaushi,

Use RETURN-CODE in cobol program. At end of the program,
if no record written to output file, move 7 to RETURN-CODE.
You can move any number to RETURN-CODE.

Code: Select all

    IF OUT-RECORD-CNT = 0
        MOVE 7  TO RETURN-CODE
    END-IF
    
Here RETURN-CODE is predefined cobol variable. whatever
value program move into this field, same value will be return by the
jcl step.


In jcl step2 include COND parameter like

Code: Select all

   
   //STEP2 EXEC PGM=ABCD,COND=(0,LT)   
  
so that step2 wont get executed, If step1 returned any value other than zero.

Let me know if i am not answered your question fully.


Thanks,
Prasad

pkaushi
Member
Posts: 9
Joined: Mon Feb 06, 2006 1:45 pm

Post by pkaushi » Tue Feb 07, 2006 10:59 am

thanks prasad its working :D
Thanks and Regards,
Prashant

Guest

Post by Guest » Thu Feb 16, 2006 5:56 pm

HI,

Adding to Prasad's Answer you can alsoe use following code to check file is empy or not

Code: Select all

//STEP1000 EXEC PGM=IDCAMS                        
//SYSPRINT DD SYSOUT=*                            
//INDD1    DD DSN=File name,      
//            DISP=SHR                            
//SYSIN    DD *                                   
 PRINT INFILE(INDD1) COUNT(1)                     
//*                                               
//***** IF EMPTY FILE (RC = 4), DO NOT CONTINUE   
//*                                               
// IF (STEP1000.RC=0) THEN                        
//*                                               
//*-----------------------------------------------
//*-- 2ND PART :              
//*------------------------------------------
Hope this helps
Regards
Rupesh

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Nov 26, 2008 4:18 am

Hi,

I had been using the second option over the years, IF THEN ELSE constuct are better than COND.
Regards,
Anuj

ramana murthy
Member
Posts: 10
Joined: Thu Jul 21, 2011 1:34 pm

Post by ramana murthy » Thu Jul 21, 2011 7:49 pm

There is also another way
in jcl

//STEP1 EXEC PGM=PRG1
//STEP2 EXEC PGM=PRG2, COND=(8,LE)


In PRG2, the program should be written in such a way that it check fileA for records .if not found it terminates.
the above JCL,STEP2 works only if STEP1 executes.

any queries mail me at: ramanamurthyt87@gmail.com :D

ramana murthy
Member
Posts: 10
Joined: Thu Jul 21, 2011 1:34 pm

Post by ramana murthy » Thu Jul 21, 2011 7:49 pm

There is also another way
in jcl

//STEP1 EXEC PGM=PRG1
//STEP2 EXEC PGM=PRG2, COND=(8,LE)


In PRG2, the program should be written in such a way that it check fileA for records .if not found it terminates.
the above JCL,STEP2 works only if STEP1 executes.

any queries mail me at: ramanamurthyt87@gmail.com :D

User avatar
dbzTHEdinosauer
Moderator
Posts: 981
Joined: Mon Oct 02, 2006 8:31 pm

Post by dbzTHEdinosauer » Thu Jul 21, 2011 10:31 pm

ramana murthy,
you made 8 posts today,
most of which were either inaccurate,
or simply useless as this one is. what you are saying makes no sense.

please make your posts accurate and useable.
Dick Brenholtz
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Sat Jul 30, 2011 2:17 pm

I agree with Dick and also, why do you post your e-mail ID all the times?
Regards,
Anuj

academyindia4

Topic deleted by Admin

Post by academyindia4 » Mon Feb 01, 2016 10:55 pm

<< Content deleted By Admin >>

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others