Reset Condition Code.
Moderators: Frank Yaeger, DikDude, Moderator Group
-
- Member
- Posts: 21
- Joined: Wed Jan 21, 2009 2:21 pm
- Location: Hyderabad
Reset Condition Code.
Can we reset the condition code returned by one step in subsequent steps in a JCL?
Pratik Ranjan.
You can use SET command.
Refer following jcl tutorial for IF condition
http://www.mainframegurukul.com/srcsinc ... ter10.html
Using that IF condition & SET command you may change the return code. Try it.
Refer following jcl tutorial for IF condition
http://www.mainframegurukul.com/srcsinc ... ter10.html
Using that IF condition & SET command you may change the return code. Try it.
Natarajan
Chennai
Chennai
-
- Active Member
- Posts: 52
- Joined: Wed Mar 25, 2009 11:56 pm
- Location: Banglore
We can't set return code of previous step, in the later part of JCL.
I already tried with IF & SET in JCL, It is not working.
But, some of my jobs are using set. When I am trying to delete a Vsam dataset by Using IDCAMS, if it not existing i used to get RC=08.
In the same control card, after deletion step if we use IF & Set MAXCC=0, it will set that return RC as 0.
So, I belive we need to use IF & Set in the same step, not in other part of the JCL.
Someone please correct me if I am wrong.
I already tried with IF & SET in JCL, It is not working.
Code: Select all
// IF (Step1.RC=12) THEN
// SET MAXCC=0
// ENDIF
In the same control card, after deletion step if we use IF & Set MAXCC=0, it will set that return RC as 0.
So, I belive we need to use IF & Set in the same step, not in other part of the JCL.
Someone please correct me if I am wrong.
Thanks
MaheshVamsi
MaheshVamsi
-
- Member
- Posts: 21
- Joined: Wed Jan 21, 2009 2:21 pm
- Location: Hyderabad
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
-
- Member
- Posts: 21
- Joined: Wed Jan 21, 2009 2:21 pm
- Location: Hyderabad
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
This can be done with COND or IF/THEN/ELSE consturct - I prefer IF/THEN/ELSE consturct though.pratik Ranjan wrote:to execute a step based on the return code from another step,
Read about MAXCC, LASTCC in IDCMAS manual.and at the same time when the job completes, the MAXCC must be zero".
Regards,
Anuj
Anuj
-
- Member
- Posts: 21
- Joined: Wed Jan 21, 2009 2:21 pm
- Location: Hyderabad
Hi Anuj,
Actually i am aware of IF/THEN/ELSE construct. I have used them already. But still the question is the same.
If a step generates some condition code, then based upon that, using IF/THEN/ELSE construct or, COND we can invoke some other step. But after the completion of the job, the job will throw a maxcc code generated by the prior step, and that violates our requirement. That's why i was trying to find out some way to reset the condition code of a step in some other step which is actually invoked based upon the RC from the prior one.
Previously i thought that we can achieve this with the help of SET command, but it's not working out.
Thanks.
Actually i am aware of IF/THEN/ELSE construct. I have used them already. But still the question is the same.
If a step generates some condition code, then based upon that, using IF/THEN/ELSE construct or, COND we can invoke some other step. But after the completion of the job, the job will throw a maxcc code generated by the prior step, and that violates our requirement. That's why i was trying to find out some way to reset the condition code of a step in some other step which is actually invoked based upon the RC from the prior one.
Previously i thought that we can achieve this with the help of SET command, but it's not working out.
Thanks.
Pratik Ranjan.
-
- Moderator
- Posts: 1625
- Joined: Sat Aug 09, 2008 9:02 am
- Location: Mumbai, India
The program that is being executed in a step is the ONLY entity that can control the value of the return-code for that step. Nothing else can influence the value contained in the return-code register for that step -- so if some step has RC not equal to zero then MAXCC can not be zero. On top of mind, just now, I'm not getting if there is way -- I'll check, may be playing around a bit with IDCAMS can work.
Regards,
Anuj
Anuj
-
- Member
- Posts: 21
- Joined: Wed Jan 21, 2009 2:21 pm
- Location: Hyderabad
Anuj,
Actually i better tell you the exact business requirement, so that we can find one or the other solution.
Our job creates a generation of a GDG everyday. Depending upon the input to the job, the genaration may or, may not be empty. So our requirement is that, if at all the genaration is empty, at the end of the job we need to copy data into it from the prior gen.
So i added an IDCAMS step at the end, to check if the new gen is empty, which will set an RC of 4 if the gen is empty. Using IF/THEN/ELSE construct, i tried to execute another copy step, and wanted to reset the RC of 4 to 0 in that step.
Now that this option is ruled out, as a workaround, i tried achieving the same in a single step as below, but i do not know, why it's not working out.
//CHECK EXEC PGM=IDCAMS
//PREVINV DD DSN=PREV GEN
//CURRINV DD DSN=CURR GEN
//SYSPRINT DD SYSOUT=*
//SYSIN DD DATA
PRINT INFILE(CURRINV) COUNT(1)
IF LASTCC NE 0 THEN
REPRO INFILE(PREVINV) OUTFILE(CURRINV)
SET MAXCC=0
/*
In this step, irrespective of the return code value, the REPRO command is getting executed. Though is sets the RC to 0, but its not working for REPRO. Could you please suggest what may be the reason?
Thanks.
Actually i better tell you the exact business requirement, so that we can find one or the other solution.
Our job creates a generation of a GDG everyday. Depending upon the input to the job, the genaration may or, may not be empty. So our requirement is that, if at all the genaration is empty, at the end of the job we need to copy data into it from the prior gen.
So i added an IDCAMS step at the end, to check if the new gen is empty, which will set an RC of 4 if the gen is empty. Using IF/THEN/ELSE construct, i tried to execute another copy step, and wanted to reset the RC of 4 to 0 in that step.
Now that this option is ruled out, as a workaround, i tried achieving the same in a single step as below, but i do not know, why it's not working out.
//CHECK EXEC PGM=IDCAMS
//PREVINV DD DSN=PREV GEN
//CURRINV DD DSN=CURR GEN
//SYSPRINT DD SYSOUT=*
//SYSIN DD DATA
PRINT INFILE(CURRINV) COUNT(1)
IF LASTCC NE 0 THEN
REPRO INFILE(PREVINV) OUTFILE(CURRINV)
SET MAXCC=0
/*
In this step, irrespective of the return code value, the REPRO command is getting executed. Though is sets the RC to 0, but its not working for REPRO. Could you please suggest what may be the reason?
Thanks.
Pratik Ranjan.
-
- Member
- Posts: 21
- Joined: Wed Jan 21, 2009 2:21 pm
- Location: Hyderabad
-
- Member
- Posts: 21
- Joined: Wed Jan 21, 2009 2:21 pm
- Location: Hyderabad
Hi,
I have found out a way, and achieved my requirement. I did some changes in the SYSIN card i.e.
//SYSIN DD DATA
PRINT INFILE(CURRINV) COUNT(1)
IF LASTCC EQ 0 THEN CANCEL
REPRO INFILE(PREVINV) OUTFILE(CURRINV)
SET MAXCC=0
/*
Now it's working fine. But still has not got my answer that in previous case why that IF statement was not working out. Any thoughts??
Thanks.
I have found out a way, and achieved my requirement. I did some changes in the SYSIN card i.e.
//SYSIN DD DATA
PRINT INFILE(CURRINV) COUNT(1)
IF LASTCC EQ 0 THEN CANCEL
REPRO INFILE(PREVINV) OUTFILE(CURRINV)
SET MAXCC=0
/*
Now it's working fine. But still has not got my answer that in previous case why that IF statement was not working out. Any thoughts??
Thanks.
Pratik Ranjan.
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