Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Replace a String of characters with another using SORT

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> JCL & VSAM
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    Post subject: Replace a String of characters with another using SORT
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    Post subject:
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: 2275
Location: @my desk

PostPosted: Tue Mar 23, 2010 1:27 pm    Post subject:
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    Post subject: Reply to: Replace a String of characters with another using
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    Post subject: Reply to: Replace a String of characters with another using
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    Post subject: Reply to: Replace a String of characters with another using
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    IBMMAINFRAMES.com Support Forums -> JCL & VSAM All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts How to change 'K' or 'M' use Sort vice_versa DFSORT/ICETOOL 5 Thu May 18, 2017 7:11 am
No new posts Fileaid Update Replace with null string descann Compuware & Other Tools 4 Mon May 15, 2017 3:00 pm
No new posts Replace values in the input data Vikas Maharnawar DFSORT/ICETOOL 10 Thu May 11, 2017 2:18 pm
No new posts Adding big TEXT lines to each record ... bshkris SYNCSORT 4 Sat May 06, 2017 1:40 am
This topic is locked: you cannot edit posts or make replies. SORT trick needed bshkris SYNCSORT 6 Tue May 02, 2017 4:35 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us