Portal | IBM Manuals | Downloads | Products | Refer | Info | Programs | JCLs | Forum Rules*| Site Map | Mainframe CD 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index
 
Register
 
IBMMAINFRAMES.com - IBM Mainframe Support Forums Index FAQ Search Memberlist Usergroups Profile Log in to check your private messages Log in
 
How to convert hex to character format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions
Author Message
Radha3

New User


Joined: 17 Apr 2008
Posts: 4
Location: Bangalore

PostPosted: Fri Apr 18, 2008 10:37 am    Post subject: How to convert hex to character format
Reply with quote

Hi can anyone anyone help regarding this query

I have a field ABCD PIC X(1) that stores values in
hexadecimal format eg. X'21'

There is another field AAAA PIC X(2)

I want to move ABCD to AAAA so that value in AAAA
comes out to be 21.
Back to top
View user's profile Send private message
References
PostPosted: Fri Apr 18, 2008 10:37 am    Post subject: Re: How to convert hex to character format Reply with quote

vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 298
Location: Bang,iflex

PostPosted: Fri Apr 18, 2008 1:07 pm    Post subject:
Reply with quote

Hi,

Code:
01 ABCD PIC X(1).



if u force the value 21 to store in to variable ABCD the value get truncated

and i guess hexadecimal of numeric 21 is 2B.

afterwards you can convert hexdecimal to numeric or watever u like to change.

there are functions in COBOL to convert hex to other formatts and vice versa.
Back to top
View user's profile Send private message
Radha3

New User


Joined: 17 Apr 2008
Posts: 4
Location: Bangalore

PostPosted: Fri Apr 18, 2008 2:24 pm    Post subject: Reply to: How to convert hex to character format
Reply with quote

What are those functions which are available in COBOL? Can you please tell me..
Back to top
View user's profile Send private message
dick scherrer

Global Moderator


Joined: 23 Nov 2006
Posts: 7505
Location: 221 B Baker St

PostPosted: Fri Apr 18, 2008 7:39 pm    Post subject:
Reply with quote

Hello,

Quote:
if u force the value 21 to store in to variable ABCD the value get truncated
This is incorrect (or at least mis-understood in terms of the request). The request is how to "move" an x'21' (perfectly valid in one byte) to 2 bytes that contain x'F2F1' or 21.

Quote:
and i guess hexadecimal of numeric 21 is 2B.
Has nothing to do with the request.

One way is to define an array of 2-byte entries of all of the values from x'00' to x'FF' and then use the single byte as the displacement into the array.

If i remember, someone also posted a way to "calculate" this and a search in the forum could find it.
Back to top
View user's profile Send private message
CICS Guy

Senior Member


Joined: 18 Jul 2007
Posts: 1142
Location: At my desk

PostPosted: Fri Apr 18, 2008 7:46 pm    Post subject:
Reply with quote

You might play with one by Bill O'Boyle....
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Interview Questions All times are GMT + 6 Hours
Page 1 of 1