Control flow from one STEP to another
Moderators: Frank Yaeger, DikDude, Moderator Group
Control flow from one STEP to another
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.....
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
Prashant
use RETURN-CODE in COBOL program
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.
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
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
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
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)
Let me know if i am not answered your question fully.
Thanks,
Prasad
HI,
Adding to Prasad's Answer you can alsoe use following code to check file is empy or not
Hope this helps
Regards
Rupesh
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 :
//*------------------------------------------
Regards
Rupesh
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Member
- Posts: 10
- Joined: Thu Jul 21, 2011 1:34 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
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
-
- Member
- Posts: 10
- Joined: Thu Jul 21, 2011 1:34 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
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
- dbzTHEdinosauer
- Moderator
- Posts: 981
- Joined: Mon Oct 02, 2006 8: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.
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.
JCL, SQL and code in programs have an irritating habit of doing what you say,
not what you meant.
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
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
- Cobol Interview Questions
50+ Interview Questions - JCL Interview Questions
50+ Interview Questions - DB2 Interview Questions
100+ Interview Questions - CICS Interview Questions
70+ Interview Questions - VSAM Interview Questions
27 Interview Questions
Other References
Mainframe Tools and others
- XPEDITER Reference
Explains how we can debug a program - FILEAID Reference
Explains how to browse , edit and delete datasets - Change Man Reference
Quick Start tutorial on Changeman - Abend Reference
Important Abend codes explained - FaceBook Page
MainframeGurukul FaceBook Page - LinkedIn Page
MainframeGurkul Linkedin Page