Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

How to change the return code of a step?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
View previous topic :: :: View next topic  
Author Message
Ayyappan

New User


Joined: 05 Jul 2005
Posts: 31
Location: India

PostPosted: Wed Nov 30, 2005 11:57 am    Post subject: How to change the return code of a step?
Reply with quote

Hi,

My requirement is that I need to check if a file is empty or not. We have a program in our shop which will check the file and give a return code 8 if a file is empty and 0 if it is having any data. Using this return code, I need to execute a set of steps and then I need to change the return code to 2 from 8. I used IF statement and SET statement. But the SET is not working. I am getting only RC 8 if the file is empty. My sample code is:
Code:

//STEP010  EXEC  PGM=T60130                         
//*THIS STEP WILL RETURN 8 IF FILE IS EMPTY         
//IN       DD  DSN=&HLQ..NEW.LIST,                   
//             DISP=SHR                             
//*                                                 
//IFSTART  IF (STEP010.RC = 8) THEN                 
//SETRC    SET RC='2'                               
//ELSE     ELSE                                     
//STEP01   EXEC  SORTD5                             
//SORTIN   DD  DSN=&HLQ..NEW.LIST,                   
//             DISP=SHR                             
//SORTOUT  DD  DSN=&HLQ..NEW.LIST1,                 
//             DISP=(NEW,CATLG,DELETE),             
//             UNIT=SYSDA,SPACE=(CYL,(800,200),RLSE),
//             DCB=(*.SORTIN)                       
//SYSIN    DD  *                                     
  SORT FIELDS=COPY                                   
/*                                                   
//IFEND    ENDIF                 


Could anyone help me on this?
Thanks.
Ayyappan
Back to top
View user's profile Send private message

MGIndaco

Active User


Joined: 10 Mar 2005
Posts: 432
Location: Milan, Italy

PostPosted: Wed Nov 30, 2005 2:32 pm    Post subject:
Reply with quote

This sample change the return code for empty file(2 for empty and 0 for full) but if you want to change the Rc within the same jcl I suggest you to change the cond because the Rc can be set only from a utility or a program (IDCAMS COBOL or other) and not in the JCL. If I'm wrong I will apologize but, please post a correct sample.
Sample to set the rc = 2 for Empty File:
Code:
//STEP010I EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//IN         DD DISP=SHR,DSN=MY DATASET
//SYSIN    DD *
  PRINT INFILE(IN) COUNT(1)
  IF LASTCC = 4 THEN
    DO
       SET MAXCC = 2
    END
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Wed Nov 30, 2005 4:46 pm    Post subject: Re: How to change the return code of a step?
Reply with quote

Ayyappan, you may want to follow-up on how to use a SET statement in the JCL. SET statements are not executed conditionally, as described here:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IEA2B660/25.1.9?SHELF=&DT=20050713232151&CASE=

therefore, your statement:
Code:

//IFSTART  IF (STEP010.RC = 8) THEN                 
//SETRC    SET RC='2'               


can be coded as just:

Code:
           
//SETRC    SET RC='2'               
Back to top
View user's profile Send private message
Ayyappan

New User


Joined: 05 Jul 2005
Posts: 31
Location: India

PostPosted: Fri Dec 02, 2005 5:28 pm    Post subject:
Reply with quote

Hi,

I want to know, if there is any difference between the SET mentioned in the statement "//SETRC SET RC='2'" and the SET inside IDCAMS. I ran the job given by MGIndago and it is giving me the return code of 2 for all the cases irrespective of the input file. Whether the input file is having any data or not, i am getting return code 2. So, as superK mentioned, the set in IDCAMS is running regardless of the IF logic. Please correct me if i am wrong.

Thanks,
Ayyappan
Back to top
View user's profile Send private message
superk

Moderator Team Head


Joined: 26 Apr 2004
Posts: 4648
Location: Raleigh, NC, USA

PostPosted: Fri Dec 02, 2005 7:27 pm    Post subject: Re: How to change the return code of a step?
Reply with quote

The SET JCL statement sets a variable equal to the value specified. In your example:
Code:

//SETRC SET RC='2'

you are setting a variable named RC equal to the value 2. You can then use this variable somewhere in the JCL, and the value you specified in your SET statement will be substituted:
Code:

//SETRC SET RC='2'
//STEPX EXEC PGM=MYPROG,PARM='&RC'
//MYDD DD DSN=HLQ.MYPROG.RC&RC,DISP=(,CATLG,DELETE),...

would result in the runtime values of:
Code:

//SETRC SET RC='2'
//STEPX EXEC PGM=MYPROG,PARM='2'
//MYDD DD DSN=HLQ.MYPROG.RC2,DISP=(,CATLG,DELETE),...


There is nothing in JCL itself that can affect the value of the Return-Code special register. Only a program can set a value in this register. The JCL can only interrogate its value and take an appropriate action based on the value.

The SET command of the IDCAMS program allows the user to set a specific value in the Return-Code special register:
Quote:

The SET command is used to change or reset a previously defined condition code.

Condition codes that are tested in the IF-THEN-ELSE command sequence or set by the SET command cannot be passed from one job step to the next. However, the maximum condition code value established by any previous functional command or SET command is passed to the operating system when the access method services processor returns control to the system.

This is taken from the "DFSMS/MVS V1R5 Access Method Services for VSAM Catalogs" manual, this page:

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/dgt1v403/2.4?DT=19990113080956
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Dec 03, 2005 10:02 am    Post subject:
Reply with quote

Hi Ayyappan,

To give you the short answer, sort of icon_neutral.gif

What you're really asking is: can I RESET the RC of a job step.

The ans is only in an IDCAMS step and only for THAT step. You can't reset a RC of another step from an IDCAMS step.
Back to top
View user's profile Send private message
Ayyappan

New User


Joined: 05 Jul 2005
Posts: 31
Location: India

PostPosted: Tue Dec 06, 2005 2:54 pm    Post subject:
Reply with quote

Hi All,

Thanks for all your replies.

Thanks.
Ayyappan
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to Capture the Max return code of... anilkumar922 All Other Mainframe Topics 0 Thu Jan 12, 2017 12:02 pm
This topic is locked: you cannot edit posts or make replies. Calling REXX code from ISPF panel sanchita dey TSO/ISPF 4 Mon Jan 02, 2017 5:13 pm
No new posts PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us