View previous topic :: View next topic
|
Author |
Message |
Ayyappan
New User
Joined: 05 Jul 2005 Posts: 31 Location: India
|
|
|
|
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 |
|
|
MGIndaco
Active User
Joined: 10 Mar 2005 Posts: 432 Location: Milan, Italy
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
Back to top |
|
|
Ayyappan
New User
Joined: 05 Jul 2005 Posts: 31 Location: India
|
|
|
|
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 |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
The SET JCL statement sets a variable equal to the value specified. In your example:
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 |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Ayyappan,
To give you the short answer, sort of
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 |
|
|
Ayyappan
New User
Joined: 05 Jul 2005 Posts: 31 Location: India
|
|
|
|
Hi All,
Thanks for all your replies.
Thanks.
Ayyappan |
|
Back to top |
|
|
|