Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Convert numeric to HEX and display the HEX value

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Convert numeric to HEX and display the HEX value
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: 1703
Location: Australia

PostPosted: Tue Sep 09, 2008 6:22 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Sep 09, 2008 6:35 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Tue Sep 09, 2008 8:34 am    Post subject:
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    Post subject:
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

Site Director


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

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

Hello,

Try here:
http://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    Post subject:
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

Site Director


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

PostPosted: Wed Sep 10, 2008 7:17 pm    Post subject: Reply to: Convert numeric to HEX and display the HEX value
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    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts display the sign only if the value is... useit DFSORT/ICETOOL 3 Wed Oct 04, 2017 5:53 pm
No new posts File Aid tool to compare numeric data balaji81_k Compuware & Other Tools 2 Tue Sep 26, 2017 3:35 am
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts DB2 NULL Values display V S Amarendra Reddy DB2 3 Thu Sep 07, 2017 6:59 pm
No new posts Remove leading spaces from numeric field rexx77 SYNCSORT 6 Wed Sep 06, 2017 2:15 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us