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

How to convert hex to character format


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
Radha3

New User


Joined: 17 Apr 2008
Posts: 4
Location: Bangalore

PostPosted: Fri Apr 18, 2008 10:37 am
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
vasanthkumarhb

Active User


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

PostPosted: Fri Apr 18, 2008 1:07 pm
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
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

Moderator Emeritus


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

PostPosted: Fri Apr 18, 2008 7:39 pm
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: 2146
Location: At my coffee table

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

You might play with one by Bill O'Boyle....
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 -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts Populate last day of the Month in MMD... SYNCSORT 2
No new posts Modifying Date Format Using DFSORT DFSORT/ICETOOL 9
No new posts Need to convert date format DFSORT/ICETOOL 20
No new posts Keep leading zero(s) after convert fl... SYNCSORT 7
No new posts InfoSphere OPTIM CSV ouput vs DSNTIUA... IBM Tools 3
Search our Forums:

Back to Top