View previous topic :: View next topic
|
Author |
Message |
harithb
New User
Joined: 08 Jun 2009 Posts: 15 Location: Bangalore
|
|
|
|
Hi All,
I have a flat file. The file has a header, trailer and some detail records.
The header and trailer has characters 706 in the first 3 positions and the detail records have 706 in the 3rd, 4th and 5th position. I want to replace this 706 with 047 in all of them - header, trailer and detail records.
Is there any other way to do this other than splitting the file into 3 workfiles - one having only the header, one having only the trailer and 3rd having all the detail records and then use OUTREC and CHANGE of SORT utility and again merge these to a single file. If yes, could someone provide me the sort card to do this in a single step.
Thanks,
Haritha. |
|
Back to top |
|
|
km_abdullah
New User
Joined: 03 Nov 2008 Posts: 60
|
|
|
|
Try this sort card.
Code: |
//SYSIN DD *
OPTION COPY
OUTREC FINDREP=(IN=C'706',OUT=C'047') |
FINDREP parameter may not be working in older versions of sort product(DFSORT and SYNCSORT). |
|
Back to top |
|
|
Arun Raj
Moderator
Joined: 17 Oct 2006 Posts: 2481 Location: @my desk
|
|
|
|
Haritha,
You can do this using the FINDREP feature of SyncSort if you have the latest release of Syncsort. Post here the sort product release info available in your SYSOUT. And what about your input RECFM,LRECL? |
|
Back to top |
|
|
harithb
New User
Joined: 08 Jun 2009 Posts: 15 Location: Bangalore
|
|
|
|
The sort card which has been mentioned using FINDREP will actually replace all the 706 in the file to 047. The input file may have 706 in other positions also.
But I want to replace only the 706 in 1st,2nd and 3rd positions in the header and trailer and the 706 in 3rd, 4th and 5th position in the detail records. |
|
Back to top |
|
|
harithb
New User
Joined: 08 Jun 2009 Posts: 15 Location: Bangalore
|
|
|
|
Will it be possible to accomplish this using IFTHEN, PARSE, BUILD and OVERLAY functions in the sort card. If yes, could someone let me know the syntax of this? |
|
Back to top |
|
|
harithb
New User
Joined: 08 Jun 2009 Posts: 15 Location: Bangalore
|
|
|
|
Hi all,
I am able to do this using the overlay option as shown below and it is working fine.
Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC IFTHEN=(WHEN=(1,3,CH,EQ,C'706'),OVERLAY=(1:C'047')),
IFTHEN=(WHEN=(3,5,CH,EQ,C'706'),OVERLAY=(1:C'047'))
/* |
Thanks,
Haritha.
Edited for applying Code-Ekta |
|
Back to top |
|
|
|