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

Updating a 1 byte thats in occurs multiple times in a row


IBM Mainframe Forums -> DFSORT/ICETOOL
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
raja_nathan90

New User


Joined: 26 Jul 2022
Posts: 2
Location: India

PostPosted: Tue Jul 26, 2022 12:19 pm
Reply with quote

HI,

I ran in to a case where I need to update a 1 byte value on a file which occurs multiples times in a single row. Below give is a sample input.

In Below input file, I need to update the value 'N' to 'Y' that occurs multiple places and row 1 , row2 & Row N lengths are different. row 1 might have 2 occurences and row 2 might have 5 and row might have 9 occurences.

I thought of few options but couldn't get anywhere. I dont want to create a cobol program for this.

Any insights or ideas on this would be great !

Input:
Row 1 : key1.....................ABCXYZ....N...ABCZXZ....N...
Row 2 : key2.....................ABCDAE....N...ABCRES....N...ABCFER....N...
Row N : keyN.....................ABCUHD....N...ABCIJK....



Expected output:

Row 1 : key1.....................ABCXYZ....Y...ABCZXZ....Y...
Row 2 : key2.....................ABCDAE....Y...ABCRES....Y...ABCFER....Y...
Row N : keyN.....................ABCUHD....Y...ABCIJK....
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Tue Jul 26, 2022 12:27 pm
Reply with quote

Are the instances that might be 'N' always at the same offsets? If they are, it should be straightforward to change.

See Frank Yaeger's 2009 explanation @ ibmmainframes.com/about42538.html

Garry.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1329
Location: Bamberg, Germany

PostPosted: Tue Jul 26, 2022 12:45 pm
Reply with quote

Sample that will change ANY occurrences of 'N' to 'Y'
Code:
OPTION COPY                   
INREC IFTHEN=(WHEN=INIT,       
  FINDREP=(INOUT=(C'N',C'Y')))
END
Back to top
View user's profile Send private message
raja_nathan90

New User


Joined: 26 Jul 2022
Posts: 2
Location: India

PostPosted: Tue Jul 26, 2022 1:05 pm
Reply with quote

The data is occurs and the number of 'N' might be 10 in a row and just 2 in another row.

and for @Joerg.Findeisen , that would change other values in row too like below.

input:
ABCXnZ....N...ABCZXN....N..


output would become

ABCXYZ....Y...ABCZXY....Y..
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1329
Location: Bamberg, Germany

PostPosted: Tue Jul 26, 2022 1:19 pm
Reply with quote

If you can name the columns from and to, FINDREP still offers some options. Have a look at the manual.
Back to top
View user's profile Send private message
Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1205
Location: Dublin, Ireland

PostPosted: Tue Jul 26, 2022 1:24 pm
Reply with quote

Quote:
The data is occurs and the number of 'N' might be 10 in a row and just 2 in another row.


So, there might be 10 or there might be 2 occurrences of 'N' in a record (not row, it's a dataset not a database)?

Here's changing up to three occurrences where the 'N' is at offsets 10, 15 and 20. Adjust for your offsets and maximum:

Code:
  INREC IFTHEN=(WHEN=(10,1,CH,EQ,C'N'),OVERLAY=(10:C'Y'), 
           HIT=NEXT),                                     
        IFTHEN=(WHEN=(15,1,CH,EQ,C'N'),OVERLAY=(15:C'Y'), 
           HIT=NEXT),                                     
        IFTHEN=(WHEN=(20,1,CH,EQ,C'N'),OVERLAY=(20:C'Y')) 


Garry.
Back to top
View user's profile Send private message
Joerg.Findeisen

Senior Member


Joined: 15 Aug 2015
Posts: 1329
Location: Bamberg, Germany

PostPosted: Tue Jul 26, 2022 10:41 pm
Reply with quote

Might be a bit more effective in this case. Just a suggestion.
Code:
  OPTION COPY                         
  ALTSEQ CODE=(D5E8)                 
  INREC IFTHEN=(WHEN=INIT,           
    OVERLAY=(44:44,1,TRAN=ALTSEQ,     
             58:58,1,TRAN=ALTSEQ,
             .. ))   
  END
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 combine multiple unique records into ... DFSORT/ICETOOL 2
No new posts Repeat n times by substuting SEQNUM i... DFSORT/ICETOOL 2
No new posts SORT JCL to merge multiple tow into s... DFSORT/ICETOOL 6
No new posts Using Multiple IFTHEN and WHEN condit... SYNCSORT 12
No new posts INCLUDE OMIT COND for Multiple values... DFSORT/ICETOOL 5
Search our Forums:

Back to Top