kaushik8205
New User
Joined: 10 Nov 2006 Posts: 49 Location: Canada
|
|
|
|
Hi,
I have an input file:
Input:
Code: |
A B C D
----------------------
C1111 A P11 080711
C1111 A P11 080711
C1111 A P11 070711
C1111 A P11 070711
C1111 A P22 080511
C1111 A P22 080511
C1111 B P11 080711
C1111 B P11 080711
C1111 B P11 060711
C1111 B P11 060711
C1111 B P22 060711
C1111 B P22 060711
|
Output should like:
Code: |
A B C D
----------------------
C1111 A P11 080711
C1111 A P11 080711
C1111 A P22 080511
C1111 A P22 080511
C1111 B P11 080711
C1111 B P11 080711
C1111 B P22 060711
C1111 B P22 060711
|
The requirement is for all records having Col A, B and C matching; check Col D. , and out records having greatest value of Col D.
Now if Col A and Col B are matching and Col C is different no need to check Col D.
Thanks. |
|
Skolusu
Senior Member
Joined: 07 Dec 2007 Posts: 2205 Location: San Jose
|
|
|
|
Code: |
//STEP0100 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD *
----+----1----+----2----+----3
C1111 A P11 080711
C1111 A P11 080711
C1111 A P11 070711
C1111 A P11 070711
C1111 A P22 080511
C1111 A P22 080511
C1111 B P11 080711
C1111 B P11 080711
C1111 B P11 060711
C1111 B P11 060711
C1111 B P22 060711
C1111 B P22 060711
//T1 DD DSN=&T1,DISP=(,PASS),SPACE=(CYL,(1,1),RLSE)
//OUT DD SYSOUT=*
//TOOLIN DD *
SORT FROM(IN) USING(CTL1)
SPLICE FROM(T1) TO(OUT) ON(1,12,CH) WITH(1,19) WITHALL USING(CTL2)
//CTL1CNTL DD *
SORT FIELDS=(01,11,CH,A)
OUTREC OVERLAY=(20:6X)
OUTFIL FNAMES=T1,REMOVECC,
SECTIONS=(01,11,
TRAILER3=(01,12,20:MAX=(13,6,ZD,M11,LENGTH=6)))
//CTL2CNTL DD *
SORT FIELDS=(01,12,CH,A,
20,06,CH,D)
OUTFIL FNAMES=OUT,BUILD=(01,19),
INCLUDE=(13,06,CH,EQ,20,06,CH)
/*
|
Hope this helps... |
|
kaushik8205
New User
Joined: 10 Nov 2006 Posts: 49 Location: Canada
|
|
|
|
Thanks for the response.
There is a bit of modification in the requirement.
Input file:
X C1111 A P11 080711 Y
Y C1111 A P11 080711 X
X C1111 A P11 070711 X
Y C1111 A P11 070711 Y
Z C1111 A P22 080511 Z
S C1111 A P22 080511 S
AZ C1111 B P11 080711 AZ
ZA C1111 B P11 080711 ZA
AZ C1111 B P11 060711 AZ
ZA C1111 B P11 060711 ZA
A C1111 B P22 060711 A
B C1111 B P22 060711 B
Output file should like:
X C1111 A P11 080711 Y
Y C1111 A P11 080711 X
Z C1111 A P22 080511 Z
S C1111 A P22 080511 S
AZ C1111 B P11 080711 AZ
ZA C1111 B P11 080711 ZA
A C1111 B P22 060711 A
B C1111 B P22 060711 B
i.e if Col A, B and C matching; check Col D. , and out records having greatest value of Col D.
So all other values of the record being selected should be from the records having greatest value of Col D.
With your solution I am getting output as:
Y C1111 A P11 080711 Y
Y C1111 A P11 080711 Y
S C1111 A P22 080511 S
S C1111 A P22 080511 S
ZA C1111 B P11 080711 ZA
ZA C1111 B P11 080711 ZA
B C1111 B P22 060711 B
B C1111 B P22 060711 B
Please let me know if you have a solution to above requirement.
Thanks |
|