MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Execute same step again

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL)
View previous topic :: View next topic  
Author Message
chuck
Beginner


Joined: 30 Nov 2007
Posts: 25
Topics: 11

PostPosted: Fri Mar 06, 2020 3:57 pm    Post subject: Execute same step again Reply with quote

I have a situation in a job as follows.
Execute a step. The step produces an output file. If the file is not empty execute the step again. Repeat till file is empty. AFAIK there is no concept of a GOTO in JCL Smile

The specifics are as follows.
The step is a load for a DB2 table. This table has rows that are parents to other rows. Sometimes a load will not complete since the parents are not present. But the initial load will load some of the parents. The failed rows are written to a discard file. if the discard file is not empty you retry the load. If you do it enough times the load will finish with the discard file being empty.

I guess the solution may not be in JCL? But any thoughts are appreciated.
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12367
Topics: 75
Location: San Jose

PostPosted: Fri Mar 06, 2020 8:08 pm    Post subject: Re: Execute same step again Reply with quote

chuck wrote:
I have a situation in a job as follows.
Execute a step. The step produces an output file. If the file is not empty execute the step again. Repeat till file is empty. AFAIK there is no concept of a GOTO in JCL Smile

The specifics are as follows.
The step is a load for a DB2 table. This table has rows that are parents to other rows. Sometimes a load will not complete since the parents are not present. But the initial load will load some of the parents. The failed rows are written to a discard file. if the discard file is not empty you retry the load. If you do it enough times the load will finish with the discard file being empty.

I guess the solution may not be in JCL? But any thoughts are appreciated.


Chuck,

It is quite simple.

1. Check if input DISCARD file is empty. will get RC=4 if the file is empty
2. If empty check returns RC=0 then it is NOT empty and you need to run your load step.
3. You can once again submit this JCL as is

here is a sample.

Code:

//***************************************************************
//*  SETS RC=0000 IF DATASET HAS RECORDS                        *
//*  SETS RC=0004 IF DATASET IS EMPTY                           *
//***************************************************************
//STEP0100 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//MYFILE   DD DISP=SHR,DSN=<datasetname>
//SYSIN    DD *
  PRINT INFILE(MYFILE) CHARACTER COUNT(1)
/*
//***************************************************************
//* RUN THE LOAD JOB                                            *
//***************************************************************
//STEP0200 EXEC  PGM=loadtodb2,COND=(4,EQ,STEP0100)
....
//***************************************************************
//* SUBMIT THIS JCL TO INTERNAL READER UNTIL DISCARD FILE IS    *
//* EMPTY                                                       *
//***************************************************************
//STEP0300 EXEC PGM=IKJEFT01,COND=(4,EQ,STEP0100)
//SYSTSPRT DD SYSOUT=*                                           
//SYSTSIN  DD *
SUBMIT 'YOUR.PDS.JCL(JCLNAME)'     
/*

_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chuck
Beginner


Joined: 30 Nov 2007
Posts: 25
Topics: 11

PostPosted: Mon Mar 09, 2020 9:58 am    Post subject: Re: Execute same step again Reply with quote

kolusu wrote:
chuck wrote:
I have a situation in a job as follows.
Execute a step. The step produces an output file. If the file is not empty execute the step again. Repeat till file is empty. AFAIK there is no concept of a GOTO in JCL Smile

The specifics are as follows.
The step is a load for a DB2 table. This table has rows that are parents to other rows. Sometimes a load will not complete since the parents are not present. But the initial load will load some of the parents. The failed rows are written to a discard file. if the discard file is not empty you retry the load. If you do it enough times the load will finish with the discard file being empty.

I guess the solution may not be in JCL? But any thoughts are appreciated.


Chuck,

It is quite simple.

1. Check if input DISCARD file is empty. will get RC=4 if the file is empty
2. If empty check returns RC=0 then it is NOT empty and you need to run your load step.
3. You can once again submit this JCL as is

here is a sample.

Code:

//***************************************************************
//*  SETS RC=0000 IF DATASET HAS RECORDS                        *
//*  SETS RC=0004 IF DATASET IS EMPTY                           *
//***************************************************************
//STEP0100 EXEC PGM=IDCAMS
//SYSPRINT DD SYSOUT=*
//MYFILE   DD DISP=SHR,DSN=<datasetname>
//SYSIN    DD *
  PRINT INFILE(MYFILE) CHARACTER COUNT(1)
/*
//***************************************************************
//* RUN THE LOAD JOB                                            *
//***************************************************************
//STEP0200 EXEC  PGM=loadtodb2,COND=(4,EQ,STEP0100)
....
//***************************************************************
//* SUBMIT THIS JCL TO INTERNAL READER UNTIL DISCARD FILE IS    *
//* EMPTY                                                       *
//***************************************************************
//STEP0300 EXEC PGM=IKJEFT01,COND=(4,EQ,STEP0100)
//SYSTSPRT DD SYSOUT=*                                           
//SYSTSIN  DD *
SUBMIT 'YOUR.PDS.JCL(JCLNAME)'     
/*


Hi,
Thanks for that. I wasn't familiar with SUBMIT verb at all.

Just curious about one thing. The step that checks if file is empty- wouldn't that be after the load step?
The load step would potentially populate the discards dataset and I would want to check if it's empty or not after the load step has run, right?

Regards
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12367
Topics: 75
Location: San Jose

PostPosted: Mon Mar 09, 2020 10:05 am    Post subject: Re: Execute same step again Reply with quote

chuck wrote:


Hi,
Thanks for that. I wasn't familiar with SUBMIT verb at all.

Just curious about one thing. The step that checks if file is empty- wouldn't that be after the load step?
The load step would potentially populate the discards dataset and I would want to check if it's empty or not after the load step has run, right?

Regards


Chuck,

You can move it after the load step provided the load step handles the empty file case. I had the empty file check first as I wanted to skip the load step in case the file is empty. The COND check skips the LOAD and SUBMIT steps if the file is empty. If you move the file check after the LOAD step, then you will execute the LOAD step unconditionally.
_________________
Kolusu - DFSORT Development Team (IBM)
DFSORT is on the Web at:
www.ibm.com/storage/dfsort

www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
chuck
Beginner


Joined: 30 Nov 2007
Posts: 25
Topics: 11

PostPosted: Fri Mar 13, 2020 9:12 am    Post subject: Re: Execute same step again Reply with quote

kolusu wrote:
chuck wrote:


Hi,
Thanks for that. I wasn't familiar with SUBMIT verb at all.

Just curious about one thing. The step that checks if file is empty- wouldn't that be after the load step?
The load step would potentially populate the discards dataset and I would want to check if it's empty or not after the load step has run, right?

Regards


Chuck,

You can move it after the load step provided the load step handles the empty file case. I had the empty file check first as I wanted to skip the load step in case the file is empty. The COND check skips the LOAD and SUBMIT steps if the file is empty. If you move the file check after the LOAD step, then you will execute the LOAD step unconditionally.


Cool- yeah, the LOAD will be performed at least once unconditionally. I am bit more of an IF/ENDIF fan, never really came to grips with COND Smile
Thanks!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Job Control Language(JCL) All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group