Page 1 of 1

Repeated records using Sorttool

PostPosted: Sun Dec 20, 2009 2:22 am
by Sanda
Urgent Help Required!

I have a input file as below with 6 records (first four chars as the cust_id and the 7th char as the comm_ref <sorted on cust_id,Comm_ref>)

1221 1
1221 2
1222 1
1223 1
1223 2
1223 3

I need to create a test file with records for each of the cust_id to be repeated 3 times ( in above case there are 3 different cust_id) and the new records created to have the cust_id starting from 5001
The ouput file should have the below 18 records.

5001 1
5001 2
5002 1
5002 2
5003 1
5003 2
5004 1
5005 1
5006 1
5007 1
5007 2
5007 3
5008 1
5008 2
5008 3
5009 1
5009 2
5009 3


Is this possible using sort tool?
Thanks

Re: Repeated records using Sorttool

PostPosted: Sun Dec 20, 2009 3:56 am
by dick scherrer
Hello and welcome to the forum,

Urgent Help Required!
Perceptions vary. . . If this was truly urgent, you would have already written the code rather than posting on some forum where the request might not be seen for hours or days. . .

Many things can be done with the sort products (and you did not mention which sort is used on your system). However, what you have posted will be more difficult (if even possible - via the sort or even a programming language). This is beacuse your sample data and your "rules" are inconsistent (at least to me).

The "rules" say each record is to be repeated 3 times. Why are there only 2 records with 5001? Why is there only 1 record with 5004?

Hopefully, you know what is really needed and can implement cobol or something else to generate the needed output. . .

Re: Repeated records using Sorttool

PostPosted: Sun Dec 20, 2009 11:09 am
by Sanda
Many thanks Dick for your reply!
I am using SyncSORT
And sorry for not being clear on my requirement

The rule is to repeat the records of each of the Cust_ID to 3 times with the Cust_id in the repeated records to start from 5001 and incremented by 1

Records for cust_id 1221
Input

1221 1
1221 2

Output

5001 1
5001 2
5002 1
5002 2
5003 1
5003 2


Records for cust_id 1222

Input
1222 1

Output
5004 1
5005 1
5006 1

Records for Cust_id 1223

Input
1223 1
1223 2
1223 3

Output
5007 1
5007 2
5007 3
5008 1
5008 2
5008 3
5009 1
5009 2
5009 3

Hope I am clear enough
Thanks

Re: Repeated records using Sorttool

PostPosted: Sun Dec 20, 2009 11:35 am
by dick scherrer
Hello,

Much more clear :)

Possibly one of our Syncsort "heavies" will be online soon/later and have a suggestion.

If may help if you also post what version of Syncsort is being used. If you are not sure, this is printed at the top of the informational output generated by the sort.

If this is truly needed quickly, i'd suggest writing the procedural code to do this. . .