Converting Numeric data to Hex



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Converting Numeric data to Hex

Postby Mann_B » Thu Aug 30, 2012 10:42 am

Hi All

I have to convert NUmeric data to Hex value.
ex:14974 to '3A7E'
I searched and got t know that if we move 9(5) to 9(04) COMP field we will get o/p as
37
AE

Later then convert those bytes into "displayable" hex.
When I tried like above , I am not getting expected o/p.
I got out put as..
9(5) fld - 14974..When i moved it to 9(4) COMP field..the o/p is 4974.

Can you please let me know how to convert the numeric data to Hex.
Thank you
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

Re: Converting Numeric data to Hex

 

Re: Converting Numeric data to Hex

Postby BillyBoyo » Thu Aug 30, 2012 11:39 am

Try a search for BBHEXD.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Converting Numeric data to Hex

Postby Mann_B » Thu Aug 30, 2012 12:03 pm

I did serach for BHEXD.But I couldnot find related to Numeric to Hex conversion.Please tell me what is BHEXD
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

Re: Converting Numeric data to Hex

Postby BillyBoyo » Thu Aug 30, 2012 12:07 pm

BBHEXD is a callable program with which you can display chunks of storage in hex.

Even if you don't want to use the program, the code might give you some ideas. Also if you search for "Bill O'Boyle" and HEX, "Dick Scherrer" and same, "Ronald Burr" and same, you'll find some other methods.

Basically, there's a lot of stuff out there. Google could have got you to something, always with the caveat that a certain amount of the "stuff out there" is rubbish :-)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Converting Numeric data to Hex

Postby dick scherrer » Thu Aug 30, 2012 7:29 pm

Hello,

I did serach for BHEXD.But I couldnot find

If you searched for BHEXD, that would be a problem . . .

BBHEXD can be found on the internet as well as in our forum.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: Converting Numeric data to Hex

Postby Mann_B » Thu Sep 13, 2012 4:36 pm

HI...

I have defined fld like this.
05 WS-FLD PIC 9(4) BINARY.
05 WS-FLD-X REDEFINES
WS-FLD PIC X(2).

If we move Numeric to WS-FLD then WS-FLD-X will have the Hex value of that numeric field.

Thank you.
Mann_B
 
Posts: 79
Joined: Wed Mar 31, 2010 11:48 am
Has thanked: 0 time
Been thanked: 0 time

Re: Converting Numeric data to Hex

Postby dick scherrer » Thu Sep 13, 2012 11:32 pm

Hello,

Yes, the "hex value" will be in the x(2) field. Unless we misunderstand what you said you wanted to do, the value will not be "readable" to the eye (i.e. it will not be displayable) . . .
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post