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

Conversion from Binary to Hex


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Sep 24, 2009 11:08 am
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Thu Sep 24, 2009 11:48 am
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
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
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

Moderator Emeritus


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

PostPosted: Mon Sep 28, 2009 8:17 pm
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: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon Sep 28, 2009 8:58 pm
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 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 SMF Record Date conversion failing CLIST & REXX 1
No new posts Assembler class assignment: stuck on ... PL/I & Assembler 12
Search our Forums:

Back to Top