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

Replace using sort


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
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
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 Developer


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

PostPosted: Thu Feb 18, 2010 4:11 am
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
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 Developer


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

PostPosted: Thu Feb 18, 2010 5:11 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DFSORT/ICETOOL

 


Similar Topics
Topic Forum Replies
No new posts Need to set RC4 through JCL SORT DFSORT/ICETOOL 5
No new posts How to split large record length file... DFSORT/ICETOOL 10
No new posts Replace each space in cobol string wi... COBOL Programming 3
No new posts Replace Multiple Field values to Othe... DFSORT/ICETOOL 12
No new posts JCL sort card - get first day and las... JCL & VSAM 9
Search our Forums:

Back to Top