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 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 JCL sort Match and NoMatch rakeshsekar1987 SYNCSORT 2 Thu Feb 02, 2017 10:26 pm


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