View previous topic :: View next topic
|
Author |
Message |
raja_nathan90
New User
Joined: 26 Jul 2022 Posts: 2 Location: India
|
|
|
|
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 |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1329 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
raja_nathan90
New User
Joined: 26 Jul 2022 Posts: 2 Location: India
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1329 Location: Bamberg, Germany
|
|
|
|
If you can name the columns from and to, FINDREP still offers some options. Have a look at the manual. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
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 |
|
|
Joerg.Findeisen
Senior Member
Joined: 15 Aug 2015 Posts: 1329 Location: Bamberg, Germany
|
|
|
|
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 |
|
|
|