kolusu Site Admin
![Site Admin Site Admin](images/ranks/adminpic.jpg)
Joined: 26 Nov 2002 Posts: 12369 Topics: 75 Location: San Jose
|
Posted: Fri Aug 20, 2004 5:46 am Post subject: |
|
|
Pzmohanty,
The following DFSORT/ICETOOL Jcl will give you the desired results. I assumed that your input file is of 80 bytes in length and is of FB format. I also assumed that the indicator to identify the records is in pos 1.
A brief explanation of the job. This job is based on the trick of sequentially numbering the like records. for more explanation check this link
http://www.mvsforums.com/helpboards/viewtopic.php?p=12751
The first sort operator sorts the file on the identifier which is in the first byte. We add a seqnum to all the records using OUTREC FIELDS. Now using sections and MIN on the trailer3 parm we get the lowest of the seqnum for each equal group key. We also create another file with all the records. we also write the indicator at 81st byte and using a change command we only change the subheader indicator 'B' to a 'D' so that we can sort on that indicator later.
The SPLICE operator then takes in these 2 files concatenated and populates the key break seqnum for all the records. The formula is to get the key break seqnum is Seqnum - min + 1
The last SORT operator takes in the output of splice which has the records numbered, we just sort on the indicator and record number to acheive the desired results. And using OUTREC we remove the additional bytes we added at the end.
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
A-MAIN-HEADER
B-SUBHEADER-1
B-SUBHEADER-2
B-SUBHEADER-3
D-DETAIL-LINE-1
D-DETAIL-LINE-2
D-DETAIL-LINE-3
//T1 DD DSN=&T1,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(1,1),RLSE)
//T2 DD DSN=&T2,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(X,Y),RLSE)
//CON DD DSN=&T1,DISP=OLD,VOL=REF=*.T1
// DD DSN=&T2,DISP=OLD,VOL=REF=*.T2
//T3 DD DSN=&T3,DISP=(,PASS),UNIT=SYSDA,SPACE=(CYL,(X,Y),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SPLICE FROM(CON) TO(T3) ON(1,1,CH) -
WITH(1,89) WITHALL USING(CTL2)
SORT FROM(T3) USING(CTL3)
//CTL1CNTL DD *
SORT FIELDS=(1,1,CH,A)
OUTREC FIELDS=(1,80,
81:1,1,CHANGE=(1,C'B',C'D'),NOMATCH=(1,1),
SEQNUM,8,ZD,8X)
OUTFIL FNAMES=T1,NODETAIL,REMOVECC,
SECTIONS=(1,1,TRAILER3=(1,89,MIN=(82,8,ZD,M11,LENGTH=8)))
OUTFIL FNAMES=T2
//CTL2CNTL DD *
OUTFIL FNAMES=T3,
OUTREC=(1,81,
((82,8,ZD,SUB,90,8,ZD),ADD,+1),EDIT=(TTTTTTTT))
//CTL3CNTL DD *
OPTION EQUALS
SORT FIELDS=(81,9,CH,A)
OUTFIL FNAMES=OUT,OUTREC=(1,80)
/*
|
Hope this helps...
Cheers
Kolusu
Ps: If your shop has syncsort then change the pgm name synctool. But you need to have the latest version of syncsort(atleast syncsort z/os 1.1CRI TPF3 ) _________________ Kolusu
www.linkedin.com/in/kolusu |
|