Control Flow after empty file check



JES, JES2, JCL utilities, IDCAMS, Compile & Run JCLs, PROCs etc...

Control Flow after empty file check

Postby WitBlitz » Mon Oct 16, 2017 7:20 am

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?
WitBlitz
 
Posts: 2
Joined: Mon Oct 16, 2017 3:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: Control Flow after empty file check

Postby prino » Mon Oct 16, 2017 11:13 am

Suggest you RTFM or STFW!
Robert AH Prins
robert.ah.prins @ the.17+Gb.Google thingy
User avatar
prino
 
Posts: 641
Joined: Wed Mar 11, 2009 12:22 am
Location: Vilnius, Lithuania
Has thanked: 3 times
Been thanked: 29 times

Re: Control Flow after empty file check

Postby NicC » Mon Oct 16, 2017 1:47 pm

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.
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 3025
Joined: Sun Jul 04, 2010 12:13 am
Location: Pushing up the daisies (almost)
Has thanked: 4 times
Been thanked: 136 times

Re: Control Flow after empty file check

Postby WitBlitz » Tue Oct 17, 2017 4:52 am

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
WitBlitz
 
Posts: 2
Joined: Mon Oct 16, 2017 3:44 am
Has thanked: 0 time
Been thanked: 0 time

Re: Control Flow after empty file check

Postby Robert Sample » Tue Oct 17, 2017 5:12 am

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).
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times


Return to JCL

 


  • Related topics
    Replies
    Views
    Last post