View previous topic :: View next topic
|
Author |
Message |
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
Prajesh_v_p
Active User
Joined: 24 May 2006 Posts: 133 Location: India
|
|
|
|
Hi Enrico,
Thanks a lot. It worked out well.
Sorry that, it did nt ring any bell in my head first time
Thanks,
Prajesh V P |
|
Back to top |
|
|
jctgf Currently Banned Active User
Joined: 04 Nov 2006 Posts: 109
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
I know of no built-in function to do this. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
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 |
|
|
|