View previous topic :: View next topic |
Author |
Message |
prasanav0947 Beginner
Joined: 27 Jul 2019 Posts: 2 Topics: 1
|
Posted: Wed Feb 10, 2021 8:56 pm Post subject: Convert HEX value to DECIMAL |
|
|
Hello,
Tried my best to get an answer from the manual and search engine. I am using DFSORT to do this.
I have a file that contains HEX values but I want to convert to decimal. For example:
Input file:
00000787
000008C8
Output file:
00000787 1927
000008C8 2248
-SS |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Feb 11, 2021 8:15 am Post subject: |
|
|
prasanav0947,
You need to use UNHEX function to convert the hex value to binary. Once you convert to Binary then you can convert to Decimal. Something like this
Code: |
//STEP0100 EXEC PGM=SORT
//SYSOUT DD SYSOUT=*
//SORTIN DD *
00000787
000008C8
//SORTOUT DD SYSOUT=*
//SYSIN DD *
OPTION COPY
INREC OVERLAY=(10:01,08,TRAN=UNHEX,
10:10,04,FI,EDIT=(SIIIIIIIIIIIT),SIGNS=(+,-))
/* |
The output from this job would be
Code: |
00000787 +1927
000008C8 +2248
|
|
|
Back to top |
|
 |
prasanav0947 Beginner
Joined: 27 Jul 2019 Posts: 2 Topics: 1
|
Posted: Thu Feb 11, 2021 9:38 am Post subject: |
|
|
Thanks Kolusu. It worked perfectly.
I sincerely hope this in-place(?) conversion is documented in one of the DFSORT manuals. But, now I know that it can be done as you have stated clearly.
Thanks again. |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12378 Topics: 75 Location: San Jose
|
Posted: Thu Feb 11, 2021 2:09 pm Post subject: |
|
|
prasanav0947 wrote: |
I sincerely hope this in-place(?) conversion is documented in one of the DFSORT manuals. But, now I know that it can be done as you have stated clearly.
|
Prasanav0947,
We do not document destructive overlay of data. In this case I am overlaying the 4 byte content(Unhex) with a 13 byte Display value. So it would always have the right data. You also have to note that we might overlay other contents(if exists) at position 10. Since you just have the hex values in the first 8 bytes, I showed the value right next to hex value. _________________ Kolusu
www.linkedin.com/in/kolusu |
|
Back to top |
|
 |
|
|