View previous topic :: View next topic
|
Author |
Message |
fandoo
New User
Joined: 20 Feb 2007 Posts: 1 Location: Pune
|
|
|
|
I have a Flat file which has a 1-byte field. We are interested in the decimal equivalent of the hex data in this field. eg. say the 1-bye field contains X'5E', the decimal is 94. We want to see 94.
I want to map this 1-byte field via a Cobol picture clause? What can I use? I cannot use PIC s9(04) COMP as it used 2 bytes. I need a Cobol Binary definition for a 1-Byte field, does anything exist?
Is there any way out...I do not want to transform the data...I want to view the data as it is in the file via a Cobol copybook? |
|
Back to top |
|
|
hikaps14
Active User
Joined: 02 Sep 2005 Posts: 189 Location: Noida
|
|
|
|
Hi,
I doubt if you can get any direct transformantion into 1 byte binary, as Binary format occupies 2, 4, or 8 bytes of storage.
Please read the link below for further clarification on binary storage :
Binary (USAGE BINARY or COMP-4) Items
Thanks,
-Kapil. |
|
Back to top |
|
|
Marso
REXX Moderator
Joined: 13 Mar 2006 Posts: 1353 Location: Israel
|
|
|
|
That's easy with todays COBOL:
Code: |
03 CONV-SUB PIC 9(04) COMP VALUE 0.
03 CONV-SUB-X REDEFINES CONV-SUB
PIC X(02).
MOVE X'5C' TO CONV-SUB-X (2:1)
DISPLAY 'CONV-SUB = ' CONV-SUB |
The result displayed is: CONV-SUB = 0092 which is what you want. |
|
Back to top |
|
|
Terry Heinze
JCL Moderator
Joined: 14 Jul 2008 Posts: 1249 Location: Richfield, MN, USA
|
|
|
|
or
Code: |
03 CONV-SUB-X.
05 CONV-SUB PIC 9(04) COMP-5.
MOVE X'005C' TO CONV-SUB-X
DISPLAY 'CONV-SUB = ' CONV-SUB |
if you like to save a few keystrokes. |
|
Back to top |
|
|
|