Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
souji

New User

Joined: 28 Aug 2008
Posts: 9
Location: Bangalore

 Posted: Mon Nov 10, 2008 5:42 pm    Post subject: Conversion from a varchar holding hexadecimal to decimal Hi, I have encountered the following situation and need your help regarding the following. I have a varchar variable which at some position is holding '.....&..' If I retrieve this value in a char variable I get '.....&..'. But actually this is the hexadecimal for 500.11. My requirement is to pull this as a decimal. A decimal variable declared as fixed decimal(15,2) should hold 500.11. can this be done though the built in functions or/and the implicit assignments. Please help !

dick scherrer

Site Director

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

Posted: Mon Nov 10, 2008 9:10 pm    Post subject:

Hello Soujanya and welcome to the forum,

First - are you working with pl/i or assembler (or)?

Next - please post the "hex" content for the '.....&..' value.

 Quote: A decimal variable declared as fixed decimal(15,2) should hold 500.11.
A field of 15,2 should hold a value much greater than 500.11. . .

If you post the bit of problem code (not the entire program) someone shouold be able to offer a suggestion.
souji

New User

Joined: 28 Aug 2008
Posts: 9
Location: Bangalore

 Posted: Tue Nov 11, 2008 11:16 am    Post subject: Conversion from a varchar holding hexadecimal to decimal Hi Dick... I am working on PL/I.. the hex content for the value is .....&.. 00000501 0000001C Thanks & Regards, Soujanya[/img]
dick scherrer

Site Director

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

 Posted: Tue Nov 11, 2008 11:25 am    Post subject: Hello, The value you posted is a valid packed decimal number with a value of 50011. The "C" indicates the number is positive. Are you familiar with the packed-decimal data format?
Srihari Gonugunta

Active User

Joined: 14 Sep 2007
Posts: 295
Location: Singapore

 Posted: Tue Nov 11, 2008 12:06 pm    Post subject: Souji, You can redefine the same char field with a dec(15,2).
Garry Carroll

Senior Member

Joined: 08 May 2006
Posts: 1005
Location: Dublin, Ireland / Edinburgh, Scotland

Posted: Tue Nov 11, 2008 9:09 pm    Post subject:

 Quote: You can redefine the same char field with a dec(15,2).

In the case described by the O/P, the varchar has length 8. A dec fixed(15,n) field could be overlaid on this. However, if the varchar is a different length, DEC FIXED(15,n) will be incorrect. Multiple overlays of dec fixed fields could be used, selecting which overlay to use on the basis of the length of the varchar?

Garry.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics How to group and sum the decimal value sakrat DFSORT/ICETOOL 2 Tue Mar 06, 2018 9:13 pm Conversion of DLI update Jobs as BMP ... Gopinath Shanmugam IMS DB/DC 3 Wed Dec 20, 2017 12:02 pm Conversion of UTF-8 to EBCDIC muralikrishnan_new COBOL Programming 1 Tue Nov 21, 2017 5:33 pm Mainframe Blocks to Tracks conversion upendrasri JCL & VSAM 1 Sat Nov 18, 2017 10:52 am Extend the decimal values in DIVISION Balaryan DFSORT/ICETOOL 3 Thu Oct 05, 2017 4:05 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us