Reset Condition Code.

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

pratik Ranjan
Member
Posts: 21
Joined: Wed Jan 21, 2009 2:21 pm
Location: Hyderabad

Reset Condition Code.

Post by pratik Ranjan » Wed May 06, 2009 2:35 pm

Can we reset the condition code returned by one step in subsequent steps in a JCL?
Pratik Ranjan.

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Wed May 06, 2009 4:16 pm

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.
Natarajan
Chennai

maheshvamsi
Active Member
Posts: 52
Joined: Wed Mar 25, 2009 11:56 pm
Location: Banglore

Post by maheshvamsi » Wed May 06, 2009 6:24 pm

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.

Code: Select all

// IF (Step1.RC=12) THEN  
// SET MAXCC=0             
// ENDIF
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.
Thanks

MaheshVamsi

MrSpock
Active Member
Posts: 273
Joined: Wed Jun 27, 2007 5:37 pm

Post by MrSpock » Wed May 06, 2009 7:39 pm

maheshvamsi wrote:We can't set return code of previous step, in the later part of JCL.
I concur. It can't be done.

pratik Ranjan
Member
Posts: 21
Joined: Wed Jan 21, 2009 2:21 pm
Location: Hyderabad

Post by pratik Ranjan » Thu May 07, 2009 12:22 pm

Hi All,

I tried almost all the possibilities related to IF THEN, and SET statements. But it is turning out to be the same answer that we can't reset a condition code of one step in subsequent steps. Please let me know if there is any other way to achieve this.

Thanks.
Pratik Ranjan.

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

Post by Anuj Dhawan » Thu May 07, 2009 9:13 pm

Hi,

No there is no way to do that. Is this
Can we reset the condition code returned by one step in subsequent steps in a JCL
an "actual" business requirement or you asked this out of curiosity?
Regards,
Anuj

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

Post by Anuj Dhawan » Thu May 07, 2009 9:24 pm

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.
Regards,
Anuj

pratik Ranjan
Member
Posts: 21
Joined: Wed Jan 21, 2009 2:21 pm
Location: Hyderabad

Post by pratik Ranjan » Fri May 08, 2009 11:08 am

No Anuj, Of course it was a business requirement. See the requirement was "to execute a step based on the return code from another step, and at the same time when the job completes, the MAXCC must be zero". I hope the requirement is clear. Please suggest if something can be done.
Pratik Ranjan.

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

Post by Anuj Dhawan » Fri May 08, 2009 6:30 pm

pratik Ranjan wrote:to execute a step based on the return code from another step,
This can be done with COND or IF/THEN/ELSE consturct - I prefer IF/THEN/ELSE consturct though.
and at the same time when the job completes, the MAXCC must be zero".
Read about MAXCC, LASTCC in IDCMAS manual.
Regards,
Anuj

pratik Ranjan
Member
Posts: 21
Joined: Wed Jan 21, 2009 2:21 pm
Location: Hyderabad

Post by pratik Ranjan » Wed May 13, 2009 11:30 am

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.
Pratik Ranjan.

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

Post by Anuj Dhawan » Wed May 13, 2009 12:30 pm

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

pratik Ranjan
Member
Posts: 21
Joined: Wed Jan 21, 2009 2:21 pm
Location: Hyderabad

Post by pratik Ranjan » Wed May 13, 2009 5:26 pm

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.
Pratik Ranjan.

pratik Ranjan
Member
Posts: 21
Joined: Wed Jan 21, 2009 2:21 pm
Location: Hyderabad

Post by pratik Ranjan » Thu May 14, 2009 9:49 am

Hi,

Does any one have any idea, how it can be done in an easy way?

Thanks.
Pratik Ranjan.

pratik Ranjan
Member
Posts: 21
Joined: Wed Jan 21, 2009 2:21 pm
Location: Hyderabad

Post by pratik Ranjan » Thu May 14, 2009 12:21 pm

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.
Pratik Ranjan.

User avatar
Natarajan
Moderator
Posts: 537
Joined: Fri Oct 10, 2008 12:57 pm
Location: chennai
Contact:

Post by Natarajan » Thu May 14, 2009 1:22 pm

Thanks Pratik for sharing the information.
Natarajan
Chennai

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