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
 

 

How to convert hex to character format

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
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    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

vasanthkumarhb

Active User


Joined: 06 Sep 2007
Posts: 276
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

Site Director


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

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: 2150
Location: At my coffee table

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
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Extra character appears in file when ... Balu5491 All Other Mainframe Topics 1 Wed Jul 26, 2017 2:39 pm
No new posts Convert CLIST to REXX cvnlynn CLIST & REXX 12 Tue Jun 27, 2017 2:06 am
No new posts Need to write record of PS File in ex... Chandan1993 JCL & VSAM 1 Wed Jun 07, 2017 1:35 am
No new posts Format record to remove Leading zeroes Learncoholic DFSORT/ICETOOL 14 Wed Apr 05, 2017 2:43 pm
No new posts How to pick only YYMMDD from DATE1P (... atulbaviskar SYNCSORT 7 Wed Mar 22, 2017 11:39 am


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