Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Converting decimal value into hexdecimal

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Converting decimal value into hexdecimal
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: 3158
Location: Tucson AZ

PostPosted: Fri Jun 01, 2007 5:33 am    Post subject: Re: pls help convert decimal value into hexdecimal
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    Post subject:
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

Site Director


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

PostPosted: Fri Jun 01, 2007 6:58 am    Post subject:
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    Post subject:
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

Site Director


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

PostPosted: Fri Jun 01, 2007 8:26 am    Post subject:
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    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 Joinkeys with decimal scdinesh DFSORT/ICETOOL 3 Fri Feb 10, 2017 4:46 am
No new posts Converting decimal to numeric using I... Balaryan DFSORT/ICETOOL 4 Thu Feb 02, 2017 11:27 pm
This topic is locked: you cannot edit posts or make replies. DB2 query Using Recursion, Converting... smilewithashu2 DB2 3 Tue Jan 03, 2017 12:50 pm
No new posts Comparing Decimal and CHAR columns rakesh17684 DB2 7 Thu Oct 20, 2016 2:33 am
No new posts Converting multiple VB files to FB fi... Viswanath Reddy JCL & VSAM 6 Mon Aug 08, 2016 11:49 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us