View previous topic :: View next topic
|
Author |
Message |
somapradeep1
New User
Joined: 07 Sep 2010 Posts: 22 Location: hyderabad
|
|
|
|
Hello,
I have a file like below.
Header 123456789 ABCDEFGHIJ
hello world
hello world
hello world
-
-
Trailer 11111111 XYZ12345678
So, the requirement is to update the particular position in trailer record with header information. Lets say XYZ to be updated with ABC
My final trailer would be like below...
Trailer 11111111 ABC12345678
Could anybody in the group please let me know how to achieve this by using SORT utility. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
INREC IFHTHEN=(WHEN=GROUP it identify the header, then PUSH to a temporary extension of the record. IFTHEN=(WHEN=(logical-expression to identify the trailer, and copy the content from the extension. Use IFOUTLEN (fixed-length records) or BUILD to remove the extension. |
|
Back to top |
|
|
somapradeep1
New User
Joined: 07 Sep 2010 Posts: 22 Location: hyderabad
|
|
|
|
Thanks Bill. If possible, Could you please provide me a sample code of the logic |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
INREC IFTHEN=(WHEN=GROUP,
BEGIN=(1,6,CH,EQ,C'Header'),
PUSH=(81:19,3)),
IFTHEN=(WHEN=(1,7,CH,EQ,C'Trailer'),
OVERLAY=(19:81,3)),
IFOUTLEN=80 |
Should be close. That assumes fixed-length 80-byte records. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
Code: |
INREC IFTHEN=(WHEN=INIT,
BUILD=(1,4,3X,5)),
IFTHEN=(WHEN=GROUP,
BEGIN=(8,6,CH,EQ,C'Header'),
PUSH=(5:26,3)),
IFTHEN=(WHEN=(8,7,CH,EQ,C'Trailer'),
OVERLAY=(26:5,3))
OUTFIL BUILD=(1,4,8)
|
That's for variable-length records. Done quickly, so fix any typos yourself if possible. |
|
Back to top |
|
|
somapradeep1
New User
Joined: 07 Sep 2010 Posts: 22 Location: hyderabad
|
|
|
|
Excellent Bill. The logic is working fine. Thanks a lot!!! |
|
Back to top |
|
|
|