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 using sort

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DFSORT/ICETOOL
View previous topic :: :: View next topic  
Author Message
chitra_chaturvedi

New User


Joined: 24 Jul 2007
Posts: 18
Location: india

PostPosted: Thu Feb 18, 2010 3:58 am    Post subject: Replace using sort
Reply with quote

Hello,

I need to replace a value in my file based on certain condition. Can I accomplish this with sort

input is something like:

1L042009A1
1L042009C1
1L042009C1
1L042009C4
1L042009C4
1L042009E1
1L042009G1
1L042009G1
1L042009G1

if the value at the position 9 is same for consecutive records, the value at position 1 (which is '1') should be changed to '2' for the second record onwards

expected output

1L042009A1
1L042009C1
2L042009C1
1L042009C4
2L042009C4
1L042009E1
1L042009G1
2L042009G1
2L042009G1

Thanks for the help in advance!
Back to top
View user's profile Send private message

Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Feb 18, 2010 4:11 am    Post subject:
Reply with quote

In your expected output, why do you show the 4th record with a '1' instead of a '2'? Records 2-5 have a 'C' in position 9, so records 3-5 should have a '2' in position 1 - right?

According to your description, the expected output should be:

Code:

1L042009A1     
1L042009C1     
2L042009C1     
2L042009C4     
2L042009C4     
1L042009E1     
1L042009G1     
2L042009G1     
2L042009G1     


If that's what you want, then here's a DFSORT job that will do it. I assumed your input file has RECFM=FB and LRECL=80, but the job can be changed appropriately for other attributes.

Code:

//S1    EXEC  PGM=SORT                                         
//SYSOUT    DD  SYSOUT=*                                       
//SORTIN DD *                                                   
1L042009A1                                                     
1L042009C1                                                     
1L042009C1                                                     
1L042009C4                                                     
1L042009C4                                                     
1L042009E1                                                     
1L042009G1                                                     
1L042009G1                                                     
1L042009G1                                                     
//SORTOUT DD SYSOUT=*                                           
//SYSIN    DD    *                                             
  OPTION COPY                                                   
  INREC IFOUTLEN=80,                                           
    IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(9,1))), 
    IFTHEN=(WHEN=(81,8,ZD,GT,1),OVERLAY=(1:C'2'))             
/*
Back to top
View user's profile Send private message
chitra_chaturvedi

New User


Joined: 24 Jul 2007
Posts: 18
Location: india

PostPosted: Thu Feb 18, 2010 4:52 am    Post subject: Reply to: Replace using sort
Reply with quote

It was actually position 9 and 10 ( eg C1, C4 etc..). My apologies for incomplete information.

But it certainly works !!

Thankyou Frank.. icon_smile.gif
Back to top
View user's profile Send private message
Frank Yaeger

DFSORT Moderator


Joined: 15 Feb 2005
Posts: 7130
Location: San Jose, CA

PostPosted: Thu Feb 18, 2010 5:11 am    Post subject:
Reply with quote

If it's 9 and 10, then the DFSORT control statements would be:

Code:

  OPTION COPY                                                     
  INREC IFOUTLEN=80,                                             
    IFTHEN=(WHEN=INIT,OVERLAY=(81:SEQNUM,8,ZD,RESTART=(9,2))),   
    IFTHEN=(WHEN=(81,8,ZD,GT,1),OVERLAY=(1:C'2'))                 


and SORTOUT would have:

Code:

1L042009A1       
1L042009C1       
2L042009C1       
1L042009C4       
2L042009C4       
1L042009E1       
1L042009G1       
2L042009G1       
2L042009G1       
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 -> DFSORT/ICETOOL 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