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

Converting decimal value into hexdecimal


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

New User


Joined: 23 Feb 2007
Posts: 7
Location: USA

PostPosted: Fri Jun 01, 2007 3:38 am
Reply with quote

i have a requirement need to convert number value into hex decimal in
COBOL

example numeric 10 equivalent in hexadecimal 'A'

one more numeric 4190186 = 3FEFEA

i tried using DB2 scalar function . did not work?


01 WS-MISC.
05 WS-HEX-COV PIC X(6).
05 WS-HEX-C PIC S9(7)V USAGE COMP-3
VALUE 4190186.

EXEC SQL
SELECT HEX(:WS-HEX-C) INTO :WS-HEX-COV
FROM SYSIBM.SYSDUMMY1
END-EXEC.

DISPLAY ' ' WS-HEX-COV


your help is appreciated

Regards
RDK
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3156
Location: Tucson AZ

PostPosted: Fri Jun 01, 2007 5:33 am
Reply with quote

rlnraju1979 wrote:
i have a requirement need to convert number value into hex decimal in COBOL
example numeric 10 equivalent in hexadecimal 'A'
So far, so good, I understand....
Quote:
one more numeric 4190186 = 3FEFEA
HUH????
You have to (make more sense/be more specific) for me to understand....
Back to top
View user's profile Send private message
rlnraju1979

New User


Joined: 23 Feb 2007
Posts: 7
Location: USA

PostPosted: Fri Jun 01, 2007 6:49 am
Reply with quote

i am working on cobol/db2/mq interface program. i am sending data to other system. they want messange lenght in hexadecimal

interfance 1 data lenght field x(7)
2 date upto 4 megabytes
example : if i send 110 length data they need data length field(length here 110) in hexadecimal that is 6E -

if i send 4190186 length data they need in hexa 3FEFEA


i hope you understand my requirement.

Thanks in advance.

RDK
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: Fri Jun 01, 2007 6:58 am
Reply with quote

Hello,

Please explain how this "hex" will be used after it is created.

Do you want to be able to "see" the hex (as in a DISPLAY statement? If so, that would not be converting to hex, but a series of characters to display the hex.

If you move the "comp-3" field to a "comp" field, you will have the hex value, but you will not be able to display it as you've described. If you wrote it into a file and then viewed the file with HEX ON, you would see it. If your goal is to print the "hex" on a report or on a screen, other work is needed.

Once you explain what you need to do with the value, we can offer better suggestions. Do keep in mind that while you completely understand your question, others may not.
Back to top
View user's profile Send private message
rlnraju1979

New User


Joined: 23 Feb 2007
Posts: 7
Location: USA

PostPosted: Fri Jun 01, 2007 8:18 am
Reply with quote

SORRY GUY'S
I DID NOT EXPLAIN properly WHAT I NEED.
HEX VALUE WILL BE USED IN X(6)... THE OTHER SYSTEM PEOPLE USE THIS VALUE TO FIND OUT THE ACTUAL LENGTH OF THE MESSAGE IN MQ.
THEY WANT IN IN HEXADECIMAL CHARACTER. THE OTHER SYSTEM IS ON C LANGUAGE.

I TRIED AT HOME AFTER I CAME FROM OFFICE. IT WORKED...HERE IS THE SOLUTION

01 WS-MISC.
05 WS-HEX-COV PIC X(8).
05 WS-HEX-COV-R REDEFINES WS-HEX-COV.
15 WS-HEX-COV-R-2 PIC X(2).
15 WS-HEX-COV-R-6 PIC X(6).
05 WS-HEX-C PIC S9(7) COMP-5
VALUE 4190.

EXEC SQL
SELECT HEX(:WS-HEX-C) INTO :WS-HEX-COV
FROM SYSIBM.SYSDUMMY1
END-EXEC.

DISPLAY 'HEX:' WS-HEX-COV
DISPLAY 'HEX:' WS-HEX-COV-R-2
DISPLAY 'HEX:' WS-HEX-COV-R-6

GOBACK.

OUTPUT
HEX:0000105E
HEX:00
HEX:00105E

sorry for inconvenience.

REGARDS,
RDK
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: Fri Jun 01, 2007 8:26 am
Reply with quote

No inconvenience icon_smile.gif

Good to hear that you have a solution that gets the desired result.

We're here for any other "opportunities" icon_smile.gif
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Need Help with Packed Decimal Signs DFSORT/ICETOOL 4
No new posts Converting fixed length file to excel... IBM Tools 7
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
Search our Forums:

Back to Top