Page 1 of 1

Control Flow after empty file check

PostPosted: Mon Oct 16, 2017 7:20 am
by WitBlitz
Hi Everyone,
I have extensively researched the problem and tried various combinations to no avail.
I want to check a file to see if it empty,
Then depending if it empty perform the next step.
Now the problem I run into is that the job still fails if I leave the return code more than 0
Here is the code:
/SYSIN    DD  *
/CHECK    EXEC PGM=IDCAMS
/SYSPRINT DD SYSOUT=*
/INDD     DD DSN=MYFILE,DISP=OLD
/SYSIN    DD *
PRINT INFILE(INDD) CHARACTER COUNT(1)
IF LASTCC NE 0 THEN SET MAXCC = 1

//COND01   IF CHECK.RC EQ 0 THEN
Perform Step
//CONDEL ELSE
//EMPTY    EXEC PGM=IDCAMS,COND=EVEN
//SYSPRINT DD  SYSOUT=*
// SET JOBRC=0
//SYSIN    DD *
//ENDCOND ENDIF

//WTOOK   EXEC PGM=TEST01,COND=(0,NE)
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
 SE '*** JOB TEST01 PROGRAM COMPLETED SUCCESSFULLY'
/*
//WTOFAIL EXEC PGM= TEST01,COND=((0,EQ,WTOOK),EVEN)
//SYSTSPRT DD SYSOUT=*
//SYSTSIN  DD *
 SE '+++ JOB TEST01 PROGRAM HAS FAILED =='


I tried using a user variable but it seems the steps condition code has not been set as yet
Did do the following // SET EF=0 in a previous step

PRINT INFILE(INDD) CHARACTER COUNT(1)
 IF LASTCC NE 0 THEN SET MAXCC = 1
//COND01   IF RC EQ 1 THEN
//         SET EF=5
//         SET MAXCC=0
//         SET LASTCC=0
//ENDCOND ENDIF


And

//IF LASTCC NE 0 THEN SET MAXCC = 1
//DO
//       SET &EF = '5'
//       SET MAXCC = 0
// END

//COND01   IF &EF EQ 0 THEN
Perform step


Any susgestions?

Re: Control Flow after empty file check

PostPosted: Mon Oct 16, 2017 11:13 am
by prino
Suggest you RTFM or STFW!

Re: Control Flow after empty file check

PostPosted: Mon Oct 16, 2017 1:47 pm
by NicC
Why are you trying t bypass the program if the data set (it is not a file) is empty? The program should cater for that - a nice message saying no data and terminate witha return code of 0. Problem solved.

As far as I am aware the JCL SET keyword, unlike the IDCAMS SET keyword, is resolved at the time the job is read onto the system. These are two different keywords doing two completely different things. If you had read up on both of them in their respective manuals you would have seen this.

Re: Control Flow after empty file check

PostPosted: Tue Oct 17, 2017 4:52 am
by WitBlitz
Hi Nic,
An other project is currently changing the program.
This would be an interim solution to stop the program from running.
The problem is not to use SET of IDCAMS SET, it is how to get hold of the current steps max cc before the step has finished.
Regards,
Wit

Re: Control Flow after empty file check

PostPosted: Tue Oct 17, 2017 5:12 am
by Robert Sample
MAXCC is a term specific to IDCAMS. Using it in reference to JCL or to any other program is WRONG.

There may be a step condition code, or an abend code, but the step condition code is NOT "MAXCC".

it is how to get hold of the current steps max cc before the step has finished.
You are asking for the impossible here. A step does not have a condition code UNTIL THE STEP COMPLETES. IDCAMS can generate an interim condition code, but not all utilities or programs do so. Only reference a step condition code AFTER THE STEP COMPLETES -- any other reference may not work or may be incorrect. Give up on the idea of attempting to reference a step condition code before the step completes, and move on to some real task (that is, one that can be accomplished).