IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Replace a String of characters with another using SORT


IBM Mainframe Forums -> JCL & VSAM
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
harithb

New User


Joined: 08 Jun 2009
Posts: 15
Location: Bangalore

PostPosted: Tue Mar 23, 2010 12:43 pm
Reply with quote

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
View user's profile Send private message
km_abdullah

New User


Joined: 03 Nov 2008
Posts: 60

PostPosted: Tue Mar 23, 2010 1:23 pm
Reply with quote

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
View user's profile Send private message
Arun Raj

Moderator


Joined: 17 Oct 2006
Posts: 2481
Location: @my desk

PostPosted: Tue Mar 23, 2010 1:27 pm
Reply with quote

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
View user's profile Send private message
harithb

New User


Joined: 08 Jun 2009
Posts: 15
Location: Bangalore

PostPosted: Tue Mar 23, 2010 1:43 pm
Reply with quote

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
View user's profile Send private message
harithb

New User


Joined: 08 Jun 2009
Posts: 15
Location: Bangalore

PostPosted: Tue Mar 23, 2010 2:07 pm
Reply with quote

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
View user's profile Send private message
harithb

New User


Joined: 08 Jun 2009
Posts: 15
Location: Bangalore

PostPosted: Tue Mar 23, 2010 3:11 pm
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> JCL & VSAM

 


Similar Topics
Topic Forum Replies
No new posts Sort w/OUTREC Question DFSORT/ICETOOL 2
No new posts Getting error S000 U0016 (Cn Internal... JCL & VSAM 4
No new posts Cobol code- to find a string in a str... COBOL Programming 3
No new posts Is the Output of Sort/Join dependent ... DFSORT/ICETOOL 2
No new posts Trying to use sort to do two function... DFSORT/ICETOOL 14
Search our Forums:

Back to Top