Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Conversion from Binary to Hex

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Thu Sep 24, 2009 10:58 am    Post subject: Conversion from Binary to Hex
Reply with quote

For one of our requirment, we need to convert the Binary value we recieve from user to Hex as illustrated below:

When a user enters 0051, we need to convert that to 0033. We cannot try the SQLs for this as this is a heavily used program.

Thanks in advance.

Hope it is clear.

Thanks,
Prajesh V P
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10327
Location: italy

PostPosted: Thu Sep 24, 2009 11:08 am    Post subject: Reply to: Conversion from Binary to Hex
Reply with quote

Quote:
For one of our requirment, we need to convert the Binary value we recieve from user to Hex as illustrated below:


I suggest to review Your terminology....

You receive a character string 0051 which represents a number in zoned format PIC 9(4) (0051) x'F0F0F5F1'
and You need to convert it to its binary equivalent pic 9(4) COMP<somethin> (0051) x'0033'

now that the issue has ben properly reworded it should be easy to realize that a simple ...
MOVE <zoned> TO <comp_binary> should solve Your problem

check the COBOLmanuals for the proper syntax
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Thu Sep 24, 2009 11:22 am    Post subject:
Reply with quote

Hi Enrico,

This how I get.

9(02) - 51

This how I wanted

X(02) - X'0033'

Here 33 is the binary equivalent of 51. I am looking whether this conversion is possible from 9(02) to X(02) and vice versa.

Thanks,
Prajesh V P
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10327
Location: italy

PostPosted: Thu Sep 24, 2009 11:48 am    Post subject: Reply to: Conversion from Binary to Hex
Reply with quote

use a bit of imagination ...
You got what You asked for the COMP field will contain exactly that x'0033'

my previous post was edited for clarity adding the human readable representation and the hex storage content
Back to top
View user's profile Send private message
Prajesh_v_p

Active User


Joined: 24 May 2006
Posts: 133
Location: India

PostPosted: Thu Sep 24, 2009 5:29 pm    Post subject:
Reply with quote

Hi Enrico,

Thanks a lot. It worked out well.

Sorry that, it did nt ring any bell in my head first time icon_wink.gif
Thanks,
Prajesh V P
Back to top
View user's profile Send private message
jctgf
Currently Banned

Active User


Joined: 04 Nov 2006
Posts: 109

PostPosted: Mon Sep 28, 2009 7:11 pm    Post subject:
Reply with quote

I have a similar need, but not that simple.
I'd like to see the binary representation of the content of a decimal zoned field.
For example, if the decimal value is 21, I'd like to get it's binary EBCDIC representation, 00010101, in a 8-digit decimal field so that I can handle each digit (0 or 1) separately.
I made a little program to do it but I wonder if there's a Cobol function for it.
Thanks.
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: Mon Sep 28, 2009 8:17 pm    Post subject:
Reply with quote

Hello,

I know of no built-in function to do this.
Back to top
View user's profile Send private message
Bill O'Boyle

CICS Moderator


Joined: 14 Jan 2008
Posts: 2504
Location: Atlanta, Georgia, USA

PostPosted: Mon Sep 28, 2009 8:58 pm    Post subject:
Reply with quote

jctgf wrote:
I have a similar need, but not that simple.
I'd like to see the binary representation of the content of a decimal zoned field.
For example, if the decimal value is 21, I'd like to get it's binary EBCDIC representation, 00010101, in a 8-digit decimal field so that I can handle each digit (0 or 1) separately.
I made a little program to do it but I wonder if there's a Cobol function for it.
Thanks.

There isn't any function for this, although LE offers a callable service routine to test bits, which is named CEESITST.

Bill
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 -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Binary to display characters Roy Ware SYNCSORT 3 Tue Sep 19, 2017 8:46 pm
No new posts Check Binary Values for symbols gandikk CA Products 3 Tue Mar 21, 2017 5:11 am
No new posts resume binary ftp in z/os meykh2014 All Other Mainframe Topics 6 Sun Jan 22, 2017 10:01 am
No new posts File Aid to File Manager conversion murali3955 IBM Tools 4 Thu Nov 24, 2016 3:41 pm
No new posts Conversion of a VB file to FB. isssal DFSORT/ICETOOL 1 Mon Oct 31, 2016 10:23 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us