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

HEX to ASCII conversion


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
pravinj

New User


Joined: 10 Jun 2008
Posts: 24
Location: india

PostPosted: Mon May 07, 2012 4:47 pm
Reply with quote

We have a requirement to convert serial number stored in HEX format to displayable format. Input field will be in fact be an alphanumeric field storing the hex characters in it.

Code:
For example,
Input serial number: 17B46
Expected output    : 97094


Input is the HEX equivalent of the output stored in string format.

Please let me know on how we could approach it.
Back to top
View user's profile Send private message
Bill Woodger

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Mon May 07, 2012 4:52 pm
Reply with quote

What's with the ASCII? You'll need to find out what ASCII is, 'cos generally you won't find it on the mainframe.

If you have a fullword binary number and you want to display it, you define it and DISPLAY it.

Code:
05  A-FULLWORD-NUMBER COMP PIC 9(9) or PIC S9(9).

DISPLAY A-FULLWORD-NUMBER

Or even better, move it to a numeric-edited field.
Back to top
View user's profile Send private message
enrico-sorichetti

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Mon May 07, 2012 4:56 pm
Reply with quote

every byte is usually represented in it' s HEX form
so Your definition of hex is WRONG!

since this is a COBOL forum why not talk about the proper PIC' s

also the term ASCII has no place in the MAINFRAME !

wiser to review Your understanding of data and number representation

the POP ( Principles of OPerations ) will tell all You might want to know on the subject!
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: Mon May 07, 2012 9:04 pm
Reply with quote

Hello,

Suggest you read about how numeric data is stored/used in COBOL. The COBOL Language Reference is available via the link to "IBM Manuals" at the top of the page.

If you find something in the manual that is not clear, post what you found and your doubt. Someone will be able to clarify.
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 -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts 10 byte RBA conversion DB2 2
No new posts 10 byte RBA conversion -non applicati... JCL & VSAM 1
No new posts file manager is doing string conversion IBM Tools 3
No new posts Converting ASCII values to COMP-3 (ZD... JCL & VSAM 2
No new posts SMF Record Date conversion failing CLIST & REXX 1
Search our Forums:

Back to Top