Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how the change the value of return code 1

Status
Not open for further replies.

deveshjogal

Programmer
Dec 30, 2002
61
Hi everybody

I have a requirement. I dont know how to change the value of Return Code parameter (RC) in JCL. My requirement is that if previous step's RC < 13 then dont execute the next step but the final RC should be zero. I am able to skip the step using the COND parameter. Also I know the syntax IF RC < 13 THEN to check return code but dont know how to set it to value zero. Appreciate any help.

Thanks
Devesh
 
You mean from COBOL? This is a cobol forum so you'll get a cobol answer.
Tty this:
Code:
move zero to RETURN-CODE.
STOP  RUN

or this:
Code:
GOBACK  0
 
You can execute IEFBR14 to get a return code of zero. The orginal version of IEFBR14 returned a very high random return code, but IBM has since fixed it.
 
Each job step has its own return-code. You can set a return code the way the other posts say, but you're still going to have a return code of 13 from your previous step.
 
Hi Dev,

Why do you need a zero RC at EOJ (you said &quot;final RC&quot;, so I'm assuming EOJ)? What good things are you expecting to happen? It might help us to devise a solution.

Thanx, Jack.
 
Hi eveybody

Its look like I have confused you to some extent. Let me put in simple words.

This Job checks for existance of a file and if it exists then it FTP the file. Now the first step which check for the existance of a file returns 12 if the file doesnt exists. The next step which FTP the file will check this RC and will execute only if the RC is zero. So in case if the file doesnot exist(This is a valid condition), then the job returns 12. And this sometime disturbs my job monitoring people and they call me at midnight. The Job documention does discuss this. But they are not suppose to look at it.
So its better if I can set the MAXCC to zero irrespective of the existance of file.
 
They are not supposed to look at the job documentation!? That is what the job documentation is for!
 
In a COBOL progam you can set the RETURN-CODE system variable which will populate that value in the LASTCC and MAXCC variables in the JCL.

You can check LASTCC (the return code of the last step) or MAXCC (the highest return code for all steps) implicitly by coding the COND= statement on the EXEC card or explicity by IF THEN ELSE LOGIC with LASTCC or MAXCC as the argument.

You can also SET MAXCC and SET LASTCC within the JCL if you want the job to always end with a zero return code.
 
What routine are you using to check for the file existing? Sound like using DFSORT, this will return a 12 if file is empty, this will mess up most shops that look at 8 and greater as an error.

I have used the following for quite a few application like this:

This will attempt to print 1 line out of the dataset. if unable to do that then set the MAX RC to 1. This return code can then be check to allow processing to continue. The

Code:
//*
//****************************************************
//* CHECK IF E-MAIL HAS BEEN GENERATED OUT OF MCEPO02
//****************************************************
//DSCNT1   EXEC PGM=IDCAMS,REGION=4096K
//SYSPRINT DD SYSOUT=*
//PRTDD    DD DSN=MC.PERM.EDI.EMAIL,DISP=SHR
//SYSIN    DD *
   PRINT IFILE(PRTDD) COUNT(1)
   IF LASTCC NE 0 THEN SET MAXCC = 1
/*
//DSCNT1A  IF  DSCNT1.RC = 0 THEN
//*
//*   Add addional step here
//*
//DSCNT1F   END

We have even got this very usefull in determing which steps in a job to perform based off data in none of the files, 1st file, 2nd file or both by the following code (comments in () and need to be removed):

Code:
PRINT IFILE(PRTDD) COUNT(1)
IF LASTCC EQ 0 THEN DO -
   SET MAXCC = 2                 (default to second file)
   PRINT IFILE(PRTD1) COUNT(1)
   IF LASTCC EQ 0 THEN -
      SET MAXCC = 0              (both files data)
   ELSE -
      SET MAXCC = 1              (1st file only has data)
END
ELSE DO                      (only here if 1st empty)
   PRINT IFILE(PRTD1) COUNT(1)
   IF LASTCC EQ 0 THEN -
      SET MAXCC = 2              (2nd file has data only)
   ELSE -
      SET MAXCC = 3              (no files have data)
END


As you can see the use of Idcams to check if the file has data can be very useful.
 
Hi,

I was surprised about the GOBACK statement with an extra option. It seems to be that this option is not available on the mainframe, looking at the COBOL 390 2.2 manual.

Regards,

Crox

Code:
X 6.2.17 GOBACK statement





X The GOBACK statement functions like the EXIT PROGRAM statement when it is
X coded as part of a called program (or the EXIT METHOD statement when it is
X coded as part of an invoked method) and like the STOP RUN statement when
X coded in a main program.



X The GOBACK statement specifies the logical end of a called program or
X invoked method.


 X  ___ Format _____________________________________________________________
 X |                                                                        |
 X | >>__GOBACK__________________________________________________________>< |
   |                                                                        |
   |________________________________________________________________________|


X A GOBACK statement should appear as the only statement or as the last of a
X series of imperative statements in a sentence because any statements
X following the GOBACK are not executed. It must not be used in a
X declarative procedure in which the GLOBAL phrase is specified.



X If control reaches a GOBACK statement while a CALL statement is active,
X control returns to the point in the calling program immediately following
X the CALL statement, as in the EXIT PROGRAM statement.



X If control reaches a GOBACK statement while an INVOKE statement is active,
X control returns to the point in the invoking program or method immediately
X following the INVOKE statement, as in the EXIT METHOD statement.



X In addition, the execution of a GOBACK statement in a called program that
X possesses the INITIAL attribute is equivalent to executing a CANCEL
X statement referencing that program.



X The table below shows the action taken for the GOBACK statement in both a
X main program and a subprogram.


    _____________ ______________________________ ______________________________
 X | Termination |                              |                              |
 X | statement   | Main program                 | Subprogram                   |
   |_____________|______________________________|______________________________|
 X | GOBACK      | Return to calling program.   | Return to calling program.   |
 X |             | (Can be the system and thus  |                              |
 X |             | causes the application to    |                              |
 X |             | end.)                        |                              |
   |_____________|______________________________|______________________________|
 
Just before the end of your job, can't you insert the following:

// SET MAXCC = 0

???

Regards.

Glenn
 
Hi Glen,

As far as I know &quot;// SET MAXCC = 0&quot; cannot be used in the JCL stream. It can be used in IDCAMS SYSIN, but I'm not sure if MAXCC refers to the RC for the entire job or just the functions executed by IDCAMS for that step.

Also, in spite of the fact that it might reset the job RC, the original MAXCC may be retained and displayed in SYSOUT for the job monitoring people to see.

Devesh might want to give it a try though.

Regards, Jack.
 
Hello Devesh,

Hope you have found the answer till now but I can tell you how I would have solved such problems:

1)If your job is just to check the file is there or not and if its there it will do an FTP,you can put a file dependency on the job ie as soon as the file will be there JOBTRAC will trigger the job else it will wait till it gets the file.

2)Or you can introduce a SELCOPY step just after the file check step,that in case the RC is 12 to SET RC=0,but for that you should be using SELCOPY.I generally use SELCOPY to avoid such hassles.

3) If you are telling it is related to job abend then execute a WATCHMSG step for RC=12.If RC=12 the step will execute else it will get flushed.

There can be lots of ideas to avoid this but I am not sure of your code.

regards,
Samik
 
Hi everybody

I tried most of the option, but what Slade mentioned is absolutely true. I cant use //SET MAXCC = 0 directly in JCL it gives me unknown operator error. Also as he mentioned its look like u cannot set MAXXCC value in other step. When I tried to set the MAXCC inside a step executing IDCAMS it sets for that step only and not for the entire job. The final MAXCC is always the highest RC of all executed steps.
Also failed with SET MRCZERO giving the same unknown op.. error.

The only option I didnt try was using IEFBR14. Webrabbit can you post the code for me ??

For anyones interest, here is my code

//********************************************************
//* CHECK IF THE FILE IS EMPTY OR NOT
//********************************************************
//MR100010 EXEC PGM=IDCAMS
//DD1 DD DSN=xyz.MR100010.abcTRAN,DISP=SHR
//DD2 DD SYSOUT=*
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
REPRO -
INFILE(DD1) -
OUTFILE(DD2) SKIP(1) COUNT(0)
//********************************************************
//* FTP PBMS EDUCATION FILE IF NOT EMPTY
//********************************************************
//MR100020 EXEC PGM=FTP,COND=(4,LT),REGION=2048K,
// PARM='133.165.198.356 (TIMEOUT 720 EXIT'
//SYSPRINT DD SYSOUT=*
//OUTPUT DD SYSOUT=*
//INPUT DD *
jfdfjl
fjkdjfd
PUT 'xyz.MR100010.abcTRAN' /univid_mail/pbmsemp.txt
QUIT
/*
//*_______________________________________________________
//* ZEKE STEP
//*_______________________________________________________
//STEPCHK EXEC PGM=ZEKESET
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
SET ABEND 99 IF HIGHCOND GT 12
/*
//*_______________________________________________________

I guess it may be possible in case of FTP to use some other way to check whether there are records or not. But what I feel more important now is it possible to set the MAXCC variable or not.


Thanks all

Devesh
 
set maxcc and set lastcc work directly in the jcl without forward slashes
 
Hi dhecht,

Could you point me to a manual that discusses this feature. I couldn't find anything in the JCL manuals.

Thanx, Jack.
 
Hi Devesh,

HAVE YOU TRIED THIS AS YOUR LAST STEP?
It might work; worth a shot.

//MR100030 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//SYSIN DD *
IF MAXCC GE 0 THEN -
SET MAXCC = 0 -
SET LASTCC = 0
/*

Regards, Jack.
 
Hi Jack

Yes, I tried that yesterday. But that changes Rc of that particular step only not the MAXCC of the job.

The only option I didnt try was using IEFBR14 as suggested by webrabbit. Webrabbit can you post the code for me ??

Thanks in advance
Devesh
 
IIRC, you only need the following to execute IEFBR14:

//STEPX EXEC PGM=IEFBR14

The program gets its name because (at least as it was originally designed), it executes one instruction: BR 14 (Branch Register 14, i.e. return to the caller). I'm guessing it has since been changed and at least sets Register 15 to zero to give the step a return code of zero. It likely doesn't change MAXCC in any way.

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top