aniket Beginner
Joined: 27 May 2005 Posts: 14 Topics: 8
|
Posted: Sat Oct 18, 2008 9:00 pm Post subject: How to replace a byte in packed decimal using outrec |
|
|
Hi,
Here is my requirement: I have a packed decimal number from positions 2 to 9 in a file (picture cluase PIC S9(15) comp-3.) . I want to replace a particular byte using sort. e.g. I have a number 1059861611, I want to replace '8' with 0. This is to be done for all the records in the file. Can you please help me out?
Thanks!
Aniket. _________________ Thanks,
Aniket. |
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Sun Oct 19, 2008 11:43 am Post subject: |
|
|
aniket,
If I understand correctly all you need to do is change the last nibble in byte 6 to 0 if it is 8. To do that you simply divide the 6th byte by 10(x'16') and get the remainder and check if it is 8 then multiply the 6th byte with 10(x'16') again so that it will be zero. I assumed that your input is FB recfm and 80 bytes in length.
Code: |
//SYSIN DD *
SORT FIELDS=COPY
INREC IFOUTLEN=80,
IFTHEN=(WHEN=INIT,OVERLAY=(81:6,1,BI,MOD,+16,EDIT=(T))),
IFTHEN=(WHEN=(81,1,ZD,EQ,8),
OVERLAY=(6:(6,1,BI,DIV,+16),MUL,+16,TO=BI,LENGTH=1))
/* |
_________________ Kolusu
www.linkedin.com/in/kolusu |
|