Posted: Wed Jun 30, 2004 8:31 am Post subject: How to eliminate duplicates if input looks like this...
Hi All,
I need a small help on DFSORT.
My input file looks like this.
Code:
a1 b1 c1 a2 b2 c2 a3 b3 c3 a4 b4 c4
1 a 2 1 a 2 8 f 7 8 f 7
3 b 4 3 b 4 6 g 9 6 g 9
5 c 6 5 c 6 4 h 3 4 h 3
7 d 8 7 d 8 2 i 5 2 i 5
I want the output in this form shown below.
i.e. it has to compare a1 with a2, b1 with b2, c1 with c2 for each row and if they are same it needs to put spaces for in a2, b2, c2 for all rows.
Similarly it has to compare a3 with a4, b3 with b4, c3 with c4 for each row and if they are same it needs to put spaces for in a4, b4, c4 for all rows.
Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
Posted: Wed Jun 30, 2004 9:06 am Post subject:
vkPhani,
Try this job.
Code:
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
----+----1----+----2----+----3----+----4----+----5--
1 A 2 1 A 2 8 F 7 8 F 7
3 B 4 3 B 4 6 G 9 6 G 9
5 C 6 5 C 6 4 H 3 4 H 3
7 D 8 7 D 8 2 I 5 2 I 5
//SORTOUT DD SYSOUT=*
//SYSIN DD *
SORT FIELDS=COPY
INCLUDE COND=(01,1,CH,EQ,10,1,CH,AND,
04,1,CH,EQ,13,1,CH,AND,
07,1,CH,EQ,16,1,CH,AND,
19,1,CH,EQ,28,1,CH,AND,
22,1,CH,EQ,31,1,CH,AND,
25,1,CH,EQ,34,1,CH)
OUTREC FIELDS=(1,9, $ FIRST 9 BYTES AS IS
X, $ SPACE OUT A2
11,2, $ NEXT 2 BYTES AS IS
X, $ SPACE OUT B2
14,2, $ NEXT 2 BYTES AS IS
X, $ SPACE OUT C2
17,11, $ NEXT 11 BYTES AS IS
X, $ SPACE OUT A4
29,2, $ NEXT 2 BYTES AS IS
X, $ SPACE OUT B4
32,2, $ NEXT 2 BYTES AS IS
X, $ SPACE OUT C4
35,46) $ REST OF THE DATA
/*
With this code it will just put spaces for A2,B2,C2,A4,B4,C4.
It is not putting spaces by comparing a1 with a2, b1 with b2, c1 with c2 ,a3 with a4, b3 with b4, c3 with c4.
If and only if it meets the above crieteria it needs to put spaces.
Joined: 26 Nov 2002 Posts: 12382 Topics: 75 Location: San Jose
Posted: Wed Jun 30, 2004 11:47 am Post subject:
Vkphani,
You just can replicate the above posted job to meet your requirements. Try to understand the job and by doing so you will learn a lot. Don't blindly copy the sample code.
The include cond is self explanatory.
Code:
INCLUDE COND=(01,1,CH,EQ,10,1,CH,AND,
04,1,CH,EQ,13,1,CH,AND,
07,1,CH,EQ,16,1,CH,AND,
19,1,CH,EQ,28,1,CH,AND,
22,1,CH,EQ,31,1,CH,AND,
25,1,CH,EQ,34,1,CH)
In the above code, sort will include only records
Code:
1.when pos1(A1) for a length of 1 byte is equal , the field at pos 10(A2) for a length of 1 byte AND
2.when pos4(B1) for a length of 1 byte is equal , the field at pos 13(B2) for a length of 1 byte AND
3.when pos7(C1) for a length of 1 byte is equal , the field at pos 16(C2) for a length of 1 byte AND
4.when pos19(A3) for a length of 1 byte is equal , the field at pos 28(A4) for a length of 1 byte AND
5.when pos22(B3) for a length of 1 byte is equal , the field at pos 31(B4) for a length of 1 byte AND
6.when pos25(C3) for a length of 1 byte is equal , the field at pos 34(C4) for a length of 1 byte
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum