Page 1 of 1

Empty dataset and step execution

PostPosted: Tue Feb 26, 2019 7:28 pm
by samb01
Hello,

in my jobcard, there is : COND=(4,LT)
So my job ended in error if a step is equal or higher the RC = 4

if my DATASET.A have at least a record, the execute :

STEP1A

STEP2A

STEP3A

if my DATASET.B have at least a record, the execute :

STEP1B

STEP2B

STEP3B

is it possible without using IF THEN ELSE ?

Re: Empty dataset and step execution

PostPosted: Tue Feb 26, 2019 9:05 pm
by prino
samb01 wrote:in my jobcard, there is : COND=(4,LT)
So my job ended in error if a step is equal or higher the RC = 4


And why is that an error? A job can end with RC=4095 and still be OK!

[quote="samb01"]
if my DATASET.A have at least a record, the execute :

STEP1A
STEP2A
STEP3A

if my DATASET.B have at least a record, the execute :

STEP1B
STEP2B
STEP3B

is it possible without using IF THEN ELSE ?
IF-THEN-ELSE logic cannot look at the contents of datasets. In other words, the answer is NO!

Re: Empty dataset and step execution

PostPosted: Tue Feb 26, 2019 9:16 pm
by willy jensen
I assuming that you intend to use something like ICETOOL .. COUNT to set a return code of an early step. As you want to control running of steps, then the job statement COND is not the way to go, you must use the IF/THEN/ELSE/ENDIF statement constructs between steps.

Re: Empty dataset and step execution

PostPosted: Tue Feb 26, 2019 9:20 pm
by samb01
But i can test if the dataset is empty (at least on record) or not empty ?

Re: Empty dataset and step execution

PostPosted: Tue Feb 26, 2019 10:09 pm
by willy jensen
Certainly:
//* COUNT .. EMPTY|NOTEMPTY -> RC 12 IF CONDITION IS MET
//C1    EXEC PGM=ICETOOL                                
//TOOLMSG  DD SYSOUT=*                                  
//DFSMSG   DD SYSOUT=*                                  
//DD1      DD DISP=SHR,DSN=dataset.name                  
//TOOLIN   DD *                                          
  COUNT FROM(DD1) EMPTY                                  

But that wasn't your question, as I understood the subject.

Re: Empty dataset and step execution

PostPosted: Wed Feb 27, 2019 1:51 pm
by samb01
Hello willy jensen.
You're right, i want to control running of steps, then the job statement COND.
But i can't anderstand why it is not the right way to do.

With IF THEN ELSE, it might have probleme with rerun the job wich abended. I thought it easier to resstart the job with Code Condition...

Re: Empty dataset and step execution

PostPosted: Wed Feb 27, 2019 2:18 pm
by willy jensen
Because the JOBCOND applies to all steps in a job, except the first. Or in other words, depending on the cc of the first step then either all or none of the following steps will be executed, depending on cc from the exected steps.
You can choose between the step COND statement or the IF/THEN/ELSE construct, I will definitely recommand the latter.

Re: Empty dataset and step execution

PostPosted: Wed Feb 27, 2019 2:49 pm
by NicC
If this is a job controlled by a scheduler then you stop the job after discerning that the data set is empty or not. Then the scheduler will submit the 'A' job or the 'B' job depending on the return code from this job.

Re: Empty dataset and step execution

PostPosted: Thu Feb 28, 2019 12:28 pm
by expat
samb01 wrote:Hello,

in my jobcard, there is : COND=(4,LT)
So my job ended in error if a step is equal or higher the RC = 4

I would say that if the RC issued was 4, which is NOT less than 4 then the condition would not be met.
perhaps using 4,LE would be better.

Re: Empty dataset and step execution

PostPosted: Thu Feb 28, 2019 1:44 pm
by samb01
Hello expat, you are right !!! Thank's for your vigilance :D