IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to change the return code of a step?


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
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
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
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

Global Moderator


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

PostPosted: Wed Nov 30, 2005 4:46 pm
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:

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
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

Global Moderator


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

PostPosted: Fri Dec 02, 2005 7:27 pm
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:

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
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts Return codes-Normal & Abnormal te... JCL & VSAM 7
No new posts How to append a PS file into multiple... JCL & VSAM 3
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
Search our Forums:

Back to Top