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: 2239
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 Innovations in Your Mainframe Sort Arun Raj PC Guides & IT News 4 Wed Mar 15, 2017 10:38 pm
No new posts SORT VSAM file with each field one by... maxsubrat DFSORT/ICETOOL 6 Tue Mar 14, 2017 1:07 pm
No new posts SORT requirement sjiraga COBOL Programming 6 Thu Mar 09, 2017 9:11 pm
No new posts SORT to append Month and YEAR in MMYY... tisamf DFSORT/ICETOOL 1 Wed Mar 08, 2017 4:46 pm
No new posts Replacing same string with different ... vickey_dw DFSORT/ICETOOL 6 Wed Feb 22, 2017 10:44 pm


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