View previous topic :: View next topic
|
Author |
Message |
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
Hi All,
I have the below problem.
I have a 80 byte fb file. The records look like this,
Input
------
Code: |
1 1129184420 00000
2 3159856786 00001
3 6756746546 20100723 00001
4 3157658372 00001
2 5647456455 00002
3 6744565462 20100728 00002
3 3345252211 20100723 00002
4 3545325235 00002
2 1526521431 00003
3 5425364756 20100729 00003
3 5683452243 20100721 00003
3 7454632245 20100710 00003
4 6546325542 00003
2 3465365476 00004
3 3566888646 20100711 00004
4 3125363636 00004
5 8758567454 00005 |
The Fourth field is a counter field where the counter value changes only when record 2 is encountered. Record 1 and 5 are header and trailer records respectively.
I want to sort the date (3rd field) which only occurs on record 3. Rest of the records should remain as it is. The order of the records should not changes.... record 3 should always come between 2 and 4. But in a sorted order by date.
Required Output
----------------
Code: |
1 1129184420
2 3159856786
3 6756746546 20100723
4 3157658372
2 5647456455
3 3345252211 20100723
3 6744565462 20100728
4 3545325235
2 1526521431
3 7454632245 20100710
3 5683452243 20100721
3 5425364756 20100729
4 6546325542
2 3465365476
3 3566888646 20100711
4 3125363636
5 8758567454 |
Output i am getting
---------------------
Code: |
1 1129184420
2 3159856786
4 3157658372
3 6756746546 20100723
2 5647456455
4 3545325235
3 3345252211 20100723
3 6744565462 20100728
2 1526521431
4 6546325542
3 7454632245 20100710
3 5683452243 20100721
3 5425364756 20100729
2 3465365476
4 3125363636
3 3566888646 20100711
5 8758567454 |
Can somebody help me achieve the required output. The input file is a 80 byte fb file. This needs to be done using syncsort . |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
Quote: |
Output i am getting
---------------------
|
what do the SYSIN control statements look like to get your result ?
Gerry |
|
Back to top |
|
|
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
The Sysin include the below sort statement
sort fields=(30,5,CH,A,14,8,CH,A)
It first sorts on counter field to keep the record structure same as it is and then sorts on date field to sort record 3.
When sort of date field is done, since record 2 and 4 have spaces in the date field , after the sort they come one after the another. whereas there should always be a sorted record 3 in between them. |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
what about
Code: |
SORT FIELDS=(30,5,CH,A,1,1,CH,A,14,8,CH,A)
|
Gerry |
|
Back to top |
|
|
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
Its looks like it'll work. I'll try tomorow and get back to you.
Thanks Gerry, u have been very helpful |
|
Back to top |
|
|
baljinders
New User
Joined: 21 Aug 2006 Posts: 72
|
|
|
|
Gerry,
It worked perfectly... Thanks a lot |
|
Back to top |
|
|
|