Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
You haven't described your situation well enough for anyone to help.
You need to tell us more about the records in input file2. What is the range for the batch numbers in those records? Is it always 61-65, or what? What is the maximum number of records in input file2? Is there only one missing batch number in input file2 or can there be many?
The range of the batch number in input file 2 will differ daily. The next day the batch number can only be 0066 and 0067 (4 bytes) in I/P 2. The logic should be like this - Read the batch no. from I/P 1 and compares with batch no. I/P 2 and it should be +1. In this case it is 62, then if it has more batches like 63 and 65, it should validate and write last batch i.e.65 into the output 1. This Output 1 will become input 1 on next day batch cycle. The Missing batch 64 should be written into another ouput file which will be validated and sends a notification to users.
I think I have explained what ever you have expected. If not, pls let me know.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Quote:
I think I have explained what ever you have expected. If not, pls let me know.
Not really. And you didn't answer these questions:
What is the maximum number of records in input file2?
Is there only one missing batch number in input file2 or can there be many?
Quote:
Read the batch no. from I/P 1 and compares with batch no. I/P 2 and it should be +1. In this case it is 62, then if it has more batches like 63 and 65, it should validate and write last batch i.e.65 into the output 1.
If I/P record 2 batch number + 1 is equal to I/P record 1 batch number, what exactly do you want to do? Please show a couple of examples of input and output for this situation.
If I/P record 2 batch number + 1 is not equal to I/P record 1 batch number, what exactly do you want to do? Please show a couple of examples of input and output for this situation.
What is the maximum number of records in input file2?
We cannot predict the exact count because this I/P 2 comes from external application and may vary.
In above example, it has 4 records i.e. batch 61, 62, 63, and 65.
The next day it can have only 2 records i.e. batch 66 & 67
Quote:
Is there only one missing batch number in input file2 or can there be many?
No, it can have more missing batches.
Quote:
If I/P record 2 batch number + 1 is equal to I/P record 1 batch number, what exactly do you want to do? Please show a couple of examples of input and output for this situation.
If I/P record 2 batch number + 1 is not equal to I/P record 1 batch number, what exactly do you want to do? Please show a couple of examples of input and output for this situation.
I/P 1 will always have a single record. For example, if it has 61, the I/P 2 should start with 62. Here the validation should be N+1 i.e. 61+1=62 which is correct and should write to O/P 1 and not equal should write to O/P 2. Since we have more records in I/P 2, it should validate the record like 62+1=63 and goes on. Whenever it doesn't find any valid record number i.e. not equal, it should write to the O/P 2.
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
byearun,
The following DFSORT JCL will give you the desired results
Code:
//*************************************************************
//* RUN THIS STEP ONLY ONCE WHICH WILL GENERATE THE BATCH *
//* NUMBERS FROM 1 THRU 9999. *
//*************************************************************
//RUN1TIME EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
DUMMY RECORD
//SORTOUT DD DSN=your constant batch num file,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REPEAT=9999,
BUILD=(C'BATCH NUMBER',15:SEQNUM,4,ZD,80:X)
//*
Your job would have the following steps. I assumed that the batch number starts at postion 15 for 4 bytes
Code:
//*************************************************************
//* GET THE BEGIN BATCH NUMBER FROM YOUR FILE 1 AND CREATE *
//* A SYMBOLIC BLIMIT WHICH WILL BE BATCH NUMBER + 1 *
//*************************************************************
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3-
BATCH NUMBER 0061
//SORTOUT DD DSN=&&S1,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *
OPTION STOPAFT=1
SORT FIELDS=COPY
OUTREC OVERLAY=(15:+1,ADD,15,4,ZD,M11,LENGTH=4)
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('BLIMIT,+',MAX=(15,4,ZD,M11,LENGTH=4))
//*
//*************************************************************
//* GET THE ENDING BATCH NUMBER FROM YOUR FILE2 AND CREATE *
//* A SYMBOLIC ELIMIT WHICH WILL BE MAX BATCH NUMBER *
//*************************************************************
//STEP0200 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3-
BATCH NUMBER 0061
BATCH NUMBER 0062
BATCH NUMBER 0063
BATCH NUMBER 0065
BATCH NUMBER 0066
//SORTOUT DD DSN=&&S2,DISP=(,PASS),SPACE=(TRK,(1,1),RLSE)
//SYSIN DD *
SORT FIELDS=COPY
OUTFIL REMOVECC,NODETAIL,
TRAILER1=('ELIMIT,+',MAX=(15,4,ZD,M11,LENGTH=4))
/*
//*************************************************************
//* CONCATENATE THE FULL BATCH NUMBER FILE CREATED IN RUN1TIME*
//* (RUN THAT STEP ONLY ONCE) AND YOUR FILE2. THE SYMBOLS *
//* BLIMIT AND ELIMIT WILL ELIMINATE THE UNNECESSARY RECORDS. *
//* ANY MATCHING BATCH NUMBER IN FILE2 WILL BE A DUPLICATE. *
//* SO USING A SELECT OPERATOR WE PICK THE NODUPS WHICH ARE *
//* THE MISSING BATCH NUMBERS. WE ALSO CREATE ANOTHER FILE *
//* WITH THE MAX BATCH NUMBER WHICH WILL BE YOUR FILE1 FOR *
//* NEXT RUN. *
//*************************************************************
//STEP0300 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//SYMNAMES DD DSN=&&S1,DISP=SHR
// DD DSN=&&S2,DISP=SHR
//IN DD DSN=your constant batch num file,
// DISP=SHR
// DD DSN=your file2,DISP=SHR
//OUT DD DSN=your missing batch num file,
// DISP=(NEW,CATLG,DELETE),
// UNIT=SYSDA,
// SPACE=(CYL,(1,1),RLSE)
//CYCLE DD DSN=your FILE1,DISP=SHR
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(15,4,CH) -
DISCARD(CYCLE) NODUPS USING(CTL1)
//CTL1CNTL DD *
INCLUDE COND=(15,4,ZD,GE,BLIMIT,AND,15,4,ZD,LE,ELIMIT)
OUTFIL FNAMES=OUT
OUTFIL FNAMES=CYCLE,REMOVECC,NODETAIL,
TRAILER1=(C'BATCH NUMBER',15:MAX=(15,4,ZD,M11,LENGTH=4),80:X)
//*
Excellent stuff Skolusu....The code worked perfectly...I have one doubt...You have mentioned that run
Quote:
//*************************************************************
//* RUN THIS STEP ONLY ONCE WHICH WILL GENERATE THE BATCH *
//* NUMBERS FROM 1 THRU 9999. *
//*************************************************************
Is there any particular reason for this?? Can't we schedule this daily??