Page 1 of 1

Control flow from one STEP to another

Posted: Tue Feb 07, 2006 9:51 am
by pkaushi
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.....

use RETURN-CODE in COBOL program

Posted: Tue Feb 07, 2006 10:30 am
by prasad
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

Posted: Tue Feb 07, 2006 10:59 am
by pkaushi
thanks prasad its working :D

Posted: Thu Feb 16, 2006 5:56 pm
by Guest
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

Posted: Wed Nov 26, 2008 4:18 am
by Anuj Dhawan
Hi,

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

Posted: Thu Jul 21, 2011 7:49 pm
by ramana murthy
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

Posted: Thu Jul 21, 2011 7:49 pm
by ramana murthy
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

Posted: Thu Jul 21, 2011 10:31 pm
by dbzTHEdinosauer
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.

Posted: Sat Jul 30, 2011 2:17 pm
by Anuj Dhawan
I agree with Dick and also, why do you post your e-mail ID all the times?

Topic deleted by Admin

Posted: Mon Feb 01, 2016 10:55 pm
by academyindia4
<< Content deleted By Admin >>