srajanbose
New User
Joined: 11 Oct 2004 Posts: 69 Location: chennai
|
|
|
|
Hi,
I have an requirement as below.
A file have multiple headers under which have multiple detailed records will be present.
If we have duplicates from column 5-8, then the corresponding header and all the corresponding detailed records needs to be written in to an output file.
If we dont have duplicates from column 5-8, then the corresponding header and all the corresponding detailed records needs to be written in to another output file.
Sample input and output files below.
Input file:
Code: |
----+----1--
HEADER1
ABCD1234
ABCD2345
ABCD1234
HEADER2
ABCD4567
ABCD8765
ABCD1234
HEADER3
ABCD4567
ABCD8765
ABCD4567
|
Expected Output1:
Code: |
HEADER1
ABCD1234
ABCD2345
ABCD1234
HEADER3
ABCD4567
ABCD8765
ABCD4567 |
Output2:
Code: |
HEADER2
ABCD4567
ABCD8765
ABCD1234
|
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
You can use a DFSORT/ICETOOL job like the following to do what you asked for. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file (FB/80)
//T1 DD DSN=&&T1,UNIT=SYSDA,SPACE=(CYL,(5,5)),DISP=(,PASS)
//OUT1 DD DSN=... output file1 (FB/80)
//OUT2 DD DSN=... output file2 (FB/80)
//TOOLIN DD *
SELECT FROM(IN) TO(T1) ON(81,8,ZD) ON(5,4,CH) FIRSTDUP USING(CTL1)
COPY JKFROM USING(CTL2)
/*
//CTL1CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),
PUSH=(81:ID=8))
OUTFIL FNAMES=T1,BUILD=(81,8)
/*
//CTL2CNTL DD *
JOINKEYS F1=T1,FIELDS=(1,8,A),SORTED,NOSEQCK
JOINKEYS F2=IN,FIELDS=(81,8,A),SORTED,NOSEQCK
JOIN UNPAIRED,F2
REFORMAT FIELDS=(F2:1,80,?)
OUTFIL FNAMES=OUT1,INCLUDE=(81,1,CH,EQ,C'B'),BUILD=(1,80)
OUTFIL FNAMES=OUT2,SAVE,BUILD=(1,80)
/*
//JNF2CNTL DD *
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,6,CH,EQ,C'HEADER'),
PUSH=(81:ID=8))
/*
|
|
|