View previous topic :: View next topic
|
Author |
Message |
sahaanup
New User
Joined: 16 Feb 2006 Posts: 9
|
|
|
|
my in put file is needs to be sorted on certain fields. and in the output file it should populate the last occurance (if any duplicate is there against a particular chracter set) of that record. for ex. if the in put record format is as follows:
aaabb1113333
abaaa1113333
aaaaa1113333
abbba1113333
then the output shoud be
abaaa1113333
aaabb1113333
abbba1113333
here it should sort the records on the basis of 4th and 5th chracter and later picks the latest record (on higher value of first 3 chracter set )
thanks,
anup |
|
Back to top |
|
|
IQofaGerbil
Active User
Joined: 05 May 2006 Posts: 183 Location: Scotland
|
|
|
|
when I run a sort on this data, assuming I have understood your requirements (sort the records on the basis of 4th and 5th character)
ie
//SYSIN DD *
SORT FIELDS=(4,2,CH,A)
the the output data is in this order
abaaa1113333
aaaaa1113333
abbba1113333
aaabb1113333
your example output shows bb comeing before ba ?
then , 2nd requirement
(picks the latest record (on higher value of first 3 chracter set ) )
or is it
in the output file it should populate the last occurance (if any duplicate is there against a particular chracter set) of that record
not clear what you mean here as your output example shows that the record
aaaaa1113333
has been dropped.
Now it is a duplicate (on 1st 3 characters) of
aaabb1113333
but it does not have a higher value as aaa equals aaa
and it fails on the 2nd alternate rule as it is the last occurrance (based on the 1st 3 characters) but has been dropped.
I am very confused , you need to give a clearer specification with examples that actually follow the specification. |
|
Back to top |
|
|
sahaanup
New User
Joined: 16 Feb 2006 Posts: 9
|
|
|
|
Sorry,
i give wrong input. the correct one should be as follows;
aabaa1113334
aaaab1113333
aaaaa1113333
abbba1113333
aaabb1113333
and the output should be
aabaa1113334
aaaab1113333
abbba1113333
aaabb1113333
the sort criteria is same as previous
sitll i am describing it : here it should first sort on 4th & 5th character and then in for multiple records these 4th & 5th character are same then it has to pick the record which has higher value for the first 3 characters.
as here in the example the record aaaaa1113333 is skipped as it is matching with aabaa1113334 for the 4th & 5th character and first 3 character (aaa) is lower then (aab).
both the things (sorting and picking one record) need to be done in one step.
hope this time it is clear.
Thanks & regards,
Anup |
|
Back to top |
|
|
Frank Yaeger
DFSORT Developer
Joined: 15 Feb 2005 Posts: 7129 Location: San Jose, CA
|
|
|
|
Anup,
Here's a DFSORT/ICETOOL job that will do what you asked for:
Code: |
//S1 EXEC PGM=ICETOOL
//TOOLMSG DD SYSOUT=*
//DFSMSG DD SYSOUT=*
//IN DD DSN=... input file
//OUT DD DSN=... output file
//TOOLIN DD *
SELECT FROM(IN) TO(OUT) ON(4,2,CH) FIRST USING(CTL1)
/*
//CTL1CNTL DD *
SORT FIELDS=(4,2,CH,A,1,3,CH,D)
/*
|
|
|
Back to top |
|
|
|