View previous topic :: View next topic
|
Author |
Message |
rlnraju1979
New User
Joined: 23 Feb 2007 Posts: 7 Location: USA
|
|
|
|
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 |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
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 |
|
|
rlnraju1979
New User
Joined: 23 Feb 2007 Posts: 7 Location: USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
rlnraju1979
New User
Joined: 23 Feb 2007 Posts: 7 Location: USA
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
No inconvenience
Good to hear that you have a solution that gets the desired result.
We're here for any other "opportunities" |
|
Back to top |
|
|
|