| 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. |
| 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 wrote: | ||||
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.
|
| 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 |
| kolusu wrote: | ||
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. |
output generated using printer-friendly topic mod. All times are GMT - 5 Hours