Joined: 10 Apr 2005 Posts: 12 Topics: 5 Location: India
Posted: Wed Sep 21, 2005 11:55 pm Post subject: Help needed in sorting.
Hi Team
I have got a problem in sorting.
My Input record looks something like this
Code:
1234ABCD 20040920 C 20050921 000
1234ABCD 20040920 A 20050921 000
1234ABCD 20040920 I 20050921 000
1234ABCD 20040920 R 20050921 000
1234ABCD 20040920 R 20050922 000
1234ABCD 20040920 A 20050921 000
5678UVWX 20040712 R 20050921 000
5678UVWX 20040712 R 20050921 000
5678UVWX 20040712 A 20050921 000
My desired Output is as follows
Code:
1234ABCD 20040920 I 20050921 001
1234ABCD 20040920 A 20050921 002
1234ABCD 20040920 A 20050921 003
1234ABCD 20040920 R 20050921 004
1234ABCD 20040920 C 20050921 005
1234ABCD 20040920 R 20050922 001
5678UVWX 20040712 A 20050921 001
5678UVWX 20040712 R 20050921 002
5678UVWX 20040712 R 20050921 003
The first 8 bytes is the number followed by a filler and then 8 bytes of registration date adn then a filler. Then it is the type of number with a filler and then followed by the entry date and a filler.
The last 3 bytes are the sequence number.
The requirement is for each number and registration date if the entry date changes then the sequence number starts again from one. else if it is the same number, entry date and registration date then depending on the type of number the sequence number needs to be increased. (If I is present it always takes first position, followed by A the R and the C).
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Thu Sep 22, 2005 12:09 am Post subject:
gauthaman_mech,
This is a bit too tricky to do with Sort. First of all, I need to know what Sort product (DFSORT / Syncsort) you are using and also the version of Sort you are running on ?
To find out the version of Sort, just write any dummy sort step (use PGM=SORT), go to Sysout and look at the first line. (Better paste the entire line for us).
Joined: 10 Apr 2005 Posts: 12 Topics: 5 Location: India
Posted: Thu Sep 22, 2005 12:59 am Post subject:
Phantom
Thanks for the link.
It is fine if I need to break on the key. But here even if I break on the key (entry date) I need to check if the type of number takes its appropriate position, which makes the problem worse.
So what I think would ultimately happen is that for the same entry date the sequence number would be put either in ascending or descending order of the type of number. But the sequnce should be put according to the order as I then A then R and then C.
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
Posted: Thu Sep 22, 2005 8:00 am Post subject:
Kolusu,
Thanks a lot for the solution. I need to learn how to use SPLICE. I have seen many posts, but never tried to work on that till date....Need to update myself soon.
Joined: 10 Apr 2005 Posts: 12 Topics: 5 Location: India
Posted: Thu Sep 22, 2005 11:22 am Post subject:
Kolusu, Phantom
Thanks a lot for all the help given. It worked.
Just had one more doubt if I add some data (basically some amounts) in the input file after the sequence number then i loose the control. Could you please tell me where I am going wrong.
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