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

Convert numeric to HEX and display the HEX value


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Tue Sep 09, 2008 6:06 am
Reply with quote

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
View user's profile Send private message
gcicchet

Senior Member


Joined: 28 Jul 2006
Posts: 1702
Location: Australia

PostPosted: Tue Sep 09, 2008 6:22 am
Reply with quote

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
View user's profile Send private message
Craq Giegerich

Senior Member


Joined: 19 May 2007
Posts: 1512
Location: Virginia, USA

PostPosted: Tue Sep 09, 2008 6:28 am
Reply with quote

Is that a pic 9(7) comp-3, comp, or display field?
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Sep 09, 2008 6:35 am
Reply with quote

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
Code:

0997
086F
in the file.

Hopefully, the X(6) is not actually a requirement.
Back to top
View user's profile Send private message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Tue Sep 09, 2008 7:35 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Sep 09, 2008 8:34 am
Reply with quote

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 icon_smile.gif

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
View user's profile Send private message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Tue Sep 09, 2008 8:50 am
Reply with quote

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
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Tue Sep 09, 2008 9:00 am
Reply with quote

Hello,

Try here:
ibmmainframes.com/viewtopic.php?t=19237
Back to top
View user's profile Send private message
neelesht

New User


Joined: 24 Jul 2006
Posts: 99
Location: Los Angeles

PostPosted: Wed Sep 10, 2008 9:20 am
Reply with quote

Thnx everyone, I did that nt xactly the same way as suggested.

Thanks alot
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Wed Sep 10, 2008 7:17 pm
Reply with quote

Good to hear that it is working.

Thank you for letting us know icon_smile.gif

d
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Issues Converting From ZD to Signed N... DFSORT/ICETOOL 4
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts Convert single row multi cols to sing... DFSORT/ICETOOL 6
No new posts convert file from VB to FB and use tr... DFSORT/ICETOOL 8
Search our Forums:

Back to Top