View previous topic :: View next topic
|
Author |
Message |
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
Hi All,
I want to convert a PIC 9(7) field to PIC X(6) (HEX) field and want to display it in the file.
e.g if I have inpput 9999999 then I want to display 98967F (hex value of 9999999) in my output file.
I know one way is to convert 7 digit number to hex by multiplying by 16 to the power 5 and all.............I was wondering if theres any function in cobol or if neone know any other way.
Thanks
Neelesh |
|
Back to top |
|
|
gcicchet
Senior Member
Joined: 28 Jul 2006 Posts: 1702 Location: Australia
|
|
|
|
Hi,
as as I know the HEX representation of 9999999 is F9F9F9F9F9F9F9 so I don't know where 98967F comes from.
Gerry |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
Is that a pic 9(7) comp-3, comp, or display field? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
The "hex" value of 9999999 is 98967F. The F is not a sign but is part of the value.
Try moving the 9(7) field to a 9(8) COMP field. It will create the value you want, but will be 4 bytes long and should look like
in the file.
Hopefully, the X(6) is not actually a requirement. |
|
Back to top |
|
|
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
Thans Dick......I want to display 98967F itself in the file.........to be more precise I want to display HEX value as normal Alphabetic value.....
It should be in the DISPLAY format.
Hope I am clear enuff :-), sorry for not being very clear in my first post.
Thanks Everyone
Neelesh |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello Neelesh,
Quote: |
sorry for not being very clear in my first post. |
You were clear enough, i was only hoping "real" hex would be enough
You will need to first move the field to the comp field like i mentioned earlier and then convert those bytes into "displayable" hex.
If you look in the COBOL forum, there is at least one topic that has code that will convert a single byte to displayable hex. |
|
Back to top |
|
|
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
Hi Dick,
I tried to search in the previous posts and cudn't get any satisfying answer.
I will keep searching from my end, however if neone knows of ne soln please let me know.
Thanks |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
Back to top |
|
|
neelesht
New User
Joined: 24 Jul 2006 Posts: 99 Location: Los Angeles
|
|
|
|
Thnx everyone, I did that nt xactly the same way as suggested.
Thanks alot |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Good to hear that it is working.
Thank you for letting us know
d |
|
Back to top |
|
|
|