View previous topic :: View next topic
Author
Message
liangl New User Joined: 23 Mar 2008Posts: 13 Location: china
Hi all:
I got requirement like this,
input file:
aaa 111 222
bbb 333 444
aaa 555 666
bbb 777 888
ccc 999 000
output file(the number of dup shoud be list on left side):
aaa 111 222
aaa 555 666 2
bbb 333 444
bbb 777 888 2
ccc 999 000 1
OR output file can be like this:
aaa 111 222 2
aaa 555 666 2
bbb 333 444 2
bbb 777 888 2
ccc 999 000 1
either one is acceptable, so can anyone help me come up with a solution?
Back to top
enrico-sorichetti Superior Member Joined: 14 Mar 2007Posts: 10872 Location: italy
did You care to search the forum for hints ??
- i know I am reusing the same answer,
- but since the questions are most of the time related to already discussed topics
- I found useful to have a reply ready and simply paste it in the box
Back to top
liangl New User Joined: 23 Mar 2008Posts: 13 Location: china
I've search the forum, but I didn't find out the answer, I know some topic may help me such as 'Icetool sort for proper trailer totals', but after I read that, it is different with my request. Can you point out which subject is more helpful for me? Thanks
Back to top
Skolusu Senior Member Joined: 07 Dec 2007Posts: 2205 Location: San Jose
liangl,
The following DFSORT/ICETOOL JCL will give you the desired results.
Code:
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
AAA 111 222
BBB 333 444
AAA 555 666
BBB 777 888
CCC 999 000
//T1 DD DSN=&&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SORT FROM(T1) TO(OUT) USING(CTL2)
//CTL1CNTL DD *
OPTION EQUALS
SORT FIELDS=(1,3,CH,A)
OUTREC BUILD=(1,12,SEQNUM,2,ZD,RESTART=(1,3),2X)
OUTFIL REMOVECC,
SECTIONS=(1,3,TRAILER3=(1,3,15:MAX=(13,2,ZD,M11,LENGTH=2)))
/*
//CTL2CNTL DD *
OPTION EQUALS
SORT FIELDS=(1,3,CH,A,15,2,CH,D)
OUTREC IFTHEN=(WHEN=GROUP,BEGIN=(15,2,CH,GT,C' '),PUSH=(15:15,2)),
IFTHEN=(WHEN=(13,2,ZD,LT,15,2,ZD),OVERLAY=(13:2X))
OUTFIL OMIT=(4,11,CH,EQ,C' '),BUILD=(1,14)
/*
The output from this job is
Code:
AAA 111 222
AAA 555 666 02
BBB 333 444
BBB 777 888 02
CCC 999 000 01
If you want the following output
Code:
AAA 111 222 02
AAA 555 666 02
BBB 333 444 02
BBB 777 888 02
CCC 999 000 01
Change the build statement in CTL2CNTL as follows
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
liangl,
Here's another way of achieving the same. Output will be as per format-1.
Code:
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//OUT DD SYSOUT=*
//T1 DD DSN=&&T1,DISP=(,PASS)
//IN DD *
AAA 111 222
AAA 111 222
BBB 333 444
AAA 555 666
BBB 777 888
CCC 999 000
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(1,11,CH) LAST
//CTL1CNTL DD *
SORT FIELDS=(1,11,CH,A)
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(1,3,TRAILER3=(1,12,COUNT=(M11,LENGTH=2)))
OUT
Code:
AAA 111 222
AAA 555 666 03
BBB 333 444
BBB 777 888 02
CCC 999 000 01
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
liangl,
The above ICETOOL assumes that a record will not occur multiple times. My bad...I dint notice that my own example violates that.
For your sample data, it gives the required output.
Code:
AAA 111 222
AAA 555 666 02
BBB 333 444
BBB 777 888 02
CCC 999 000 01
Back to top
liangl New User Joined: 23 Mar 2008Posts: 13 Location: china
right, I also tried input like this:
AAA 111 222
BBB 333 444
BBB 333 444
AAA 555 666
BBB 777 888
CCC 999 000
you control statement can't handle it, but we can add more flags to indetify the orignal records.
Back to top
Frank Yaeger DFSORT Developer Joined: 15 Feb 2005Posts: 7129 Location: San Jose, CA
Note that Kolusu's job can handle all of these situations.
Back to top
Arun Raj Moderator Joined: 17 Oct 2006Posts: 2481 Location: @my desk
liangl,
Here's a modified version which handles "entire record" duplicates.
Code:
//STEP01 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//OUT DD SYSOUT=*
//T1 DD DSN=&&T1,DISP=(,PASS)
//IN DD *
AAA 111 222
AAA 111 222
BBB 333 444
AAA 555 666
BBB 777 888
BBB 333 444
CCC 999 000
//TOOLIN DD *
SORT FROM(IN) TO(T1) USING(CTL1)
SELECT FROM(T1) TO(OUT) ON(1,11,CH) ON(15,2,CH) LAST USING(CTL2)
//CTL1CNTL DD *
SORT FIELDS=(1,11,CH,A)
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(1,3,TRAILER3=(1,12,COUNT=(M11,LENGTH=2))),
BUILD=(1,14,SEQNUM,2,ZD,RESTART=(1,3))
//CTL2CNTL DD *
INREC IFTHEN=(WHEN=(15,2,CH,EQ,C' '),OVERLAY=(15:13,2))
OUTFIL FNAMES=OUT,BUILD=(1,14)
Back to top
Please enable JavaScript!