View previous topic :: View next topic |
Author |
Message |
chuck Beginner
Joined: 30 Nov 2007 Posts: 26 Topics: 12
|
Posted: Fri Mar 06, 2020 3:57 pm Post subject: Execute same step again |
|
|
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
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Fri Mar 06, 2020 8:08 pm Post subject: Re: Execute same step again |
|
|
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
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
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
chuck Beginner
Joined: 30 Nov 2007 Posts: 26 Topics: 12
|
Posted: Mon Mar 09, 2020 9:58 am Post subject: Re: Execute same step again |
|
|
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
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 |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Mon Mar 09, 2020 10:05 am Post subject: Re: Execute same step again |
|
|
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
www.linkedin.com/in/kolusu |
|
Back to top |
|
|
chuck Beginner
Joined: 30 Nov 2007 Posts: 26 Topics: 12
|
Posted: Fri Mar 13, 2020 9:12 am Post subject: Re: Execute same step again |
|
|
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
Thanks! |
|
Back to top |
|
|
|
|