I am posting this here to see if I may get some help on my issue.
I have an input file that is 920 bytes.
There are four(4) record types (E05, E06, E07, and E10) within the file. The record type is in pos 61,3.
Each record also has a Member id at position 323,15.
For record types E05 and E06, I want to eliminate duplicates based on the Member ID and Record Type fields only.
For record type E07, an additional Date field is in position 397,8. For this record type, I want to eliminate duplicates as the other record types with the added requirement to keep the record with the most recent Date.
Record type E10 will be eliminated with this process. This is OK.
A final sort orders the file by Member ID, Record Type and also reorganizes the record to move Member ID and Record Type to the beginning of the record.
Below are my sort cards.
Code:
//*INPUT FILE
//INFIL1 DD DSN=WTSO.INPUT.FILE,
// DISP=SHR
//*
//*TEMP FILE
//TEMPDD DD DSN=&TEMPDD,
// DISP=(NEW,PASS),
// SPACE=(CYL,(100,100),RLSE)
//*
//*OUTPUT FILE
//OUTFL1 DD DSN=WTSO.OUTPUT.FILE,
// DISP=(NEW,CATLG,DELETE),
// DCB=(RECFM=FB,LRECL=920,BLKSIZE=0),
// UNIT=SYSDA,SPACE=(CYL,(100,100),RLSE),
// VOL=SER=
//*
//TOOLIN DD *
* SELECT 'E05' TYPE RECORDS AND PUT IN TEMP FILE
SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
USING(SRT1)
*
* SELECT 'E06' TYPE RECORDS AND PUT IN TEMP FILE
SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
USING(SRT2)
*
* SELECT 'E07' TYPE RECORDS AND PUT IN TEMP FILE
SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
USING(SRT3)
*
* SORT TEMP FILE AND PUT IN OUTPUT FILE
COPY FROM(TEMPDD) TO(OUTFL1) USING(SRT4)
/*
//SRT1CNTL DD *
* WRITE MATCHING RECORDS(E05) TO TEMP FILE 1
SORT FIELDS=(61,3,CH,A,323,15,CH,A)
OUTFIL FNAMES=TEMPDD,INCLUDE=(61,3,CH,EQ,C'E05')
/*
//SRT2CNTL DD *
* WRITE MATCHING RECORDS(E06) TO TEMP FILE 2
SORT FIELDS=(61,3,CH,A,323,15,CH,A)
OUTFIL FNAMES=TEMPDD,INCLUDE=(61,3,CH,EQ,C'E06')
/*
//SRT3CNTL DD *
* WRITE MATCHING RECORDS(E07) TO TEMP FILE 3
SORT FIELDS=(61,3,CH,A,323,15,CH,A,397,8,BI,D)
OUTFIL FNAMES=TEMPDD,INCLUDE=(61,3,CH,EQ,C'E07')
/*
//SRT4CNTL DD *
* SORT FINAL OUTPUT FILE
SORT FIELDS=(323,15,CH,A,61,3,CH,A)
OUTREC FIELDS=(323,15,
61,3,
1,60,
64,256,
320,3,
338,256,
594,256,
850,71)
/*
//*
For my output, I am only getting type E07 records. The output appears correct for the record type, however I need all record types in the output. I can't put my finger on where my problem is.
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
Your job is not very efficient. For one thing, you should use an INCLUDE statement to keep only the records you need for the SELECT to reduce the number of records that are sorted. An INCLUDE statement removes records before sorting, whereas an INCLUDE operand of OUTFIL doesn't remove the records until after sorting.
It looks like you could replace the first two SELECT operators with one SELECT operator, e.g.
Code:
SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
USING(SRT1)
SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
USING(SRT3)
SORT FROM(TEMPDD) TO(OUTFL1) USING(SRT4)
/*
//SRT1CNTL DD *
INCLUDE COND=(61,3,SS,EQ,C'E05,E06')
SORT FIELDS=(61,3,CH,A,323,15,CH,A)
...
You may even be able to replace the first three SELECT operators with one SELECT operator, but it depends on whether sorting on the third field would make any difference for 'E05' and 'E06' - it might make a difference but I can't tell since you haven't shown your input and output records:
Code:
SELECT FROM(INFIL1) TO(TEMPDD) ON(323,15,CH) FIRST -
USING(SRT1)
SORT FROM(TEMPDD) TO(OUTFL1) USING(SRT4)
/*
//SRT1CNTL DD *
INCLUDE COND=(61,3,SS,EQ,C'E05,E06,E07')
SORT FIELDS=(61,3,CH,A,323,15,CH,A,397,8,BI,D)
...
Although it's probably not likely, you may be able to eliminate the extra SORT operator as well, but again I can't tell since you haven't shown your input and output records.
I do see where combining the first 2 sorts will make the sort more efficient.
I wasn't aware of the implications of using INCLUDE in the manner I did. I have modified the sort accordingly to put the INCLUDE before the sort.
I will also look into the impact of including the 3rd sort field with the other record types to see if this can be simplified further as per your recommendation. Each record type has a different layout and the Member Id and record type are the only common fields (for my purposes).