View previous topic :: View next topic
|
Author |
Message |
kranthikumarb
Active User
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
|
|
|
|
Code: |
0155555
02ADRS1
02ADRS2
02ADRS3
0166666
02ADRS4
02ADRS5
|
Hi,
I have the file like above.
.
Bytes 1,2 identifies the record type. 01 record is the group head till it finds another 01 record.
All the 02 records belong to the previous 01 record type.
If record type is 01, then byte 3 thru 7 is the key.
Is there a way get the file like the below using sort/icetool?
Code: |
555550155555
5555502ADRS1
5555502ADRS2
5555502ADRS3
666660166666
6666602ADRS4
6666602ADRS5
|
The key from 01 record has to be copied to all it's corresponding records (including that 01 record) till it finds another 01 record.
I found this can be done using inrec overlay for 01 record type alone. But can some please help me to get an idea on how to do this for all it's 02 records till it finds another 01 record. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Use IFTHEN=(WHEN=GROUP with BEGIN for the C'01' value and PUSH the key to the position you. The PUSH gets done for each record. |
|
Back to top |
|
|
kranthikumarb
Active User
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
|
|
|
|
Thanks Bill for a prompt response. How about this?
Code: |
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=GROUP,BEGIN=(1,2,CH,EQ,C'01'),PUSH=(1:3,5))
|
I'm home, I cant test it till tomorrow morning. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
That's along the right lines. Problem is that PUSH is like OVERLAY, so you need something to overlay:
Code: |
INREC IFTHEN=(WHEN=INIT,
BUILD=(5X,1,length)), |
and then your GROUP and PUSH, remembering in the PUSH that the position is five to the right of where it was originally. |
|
Back to top |
|
|
kranthikumarb
Active User
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
|
|
|
|
Thanks bill. I am ok to get the key at the end of each record also. So, I modified "push" accordingly.
Do you have any link where latest SORT manual is located. I would like to learn more about these advanced sort techniques. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
If you click on the DFSORT/ICETOOL link above your question, it'll take you to the forum itself, which includes a number of "stickies" you may find useful, as well as links to the documentation. |
|
Back to top |
|
|
kranthikumarb
Active User
Joined: 02 Jan 2009 Posts: 115 Location: Hyderabad
|
|
|
|
Thankyou. Links provided are very useful. |
|
Back to top |
|
|
|