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

Cobol PIC query


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

New User


Joined: 20 Feb 2007
Posts: 1
Location: Pune

PostPosted: Tue Jan 06, 2009 12:04 pm
Reply with quote

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
View user's profile Send private message
hikaps14

Active User


Joined: 02 Sep 2005
Posts: 189
Location: Noida

PostPosted: Tue Jan 06, 2009 2:43 pm
Reply with quote

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
View user's profile Send private message
Marso

REXX Moderator


Joined: 13 Mar 2006
Posts: 1353
Location: Israel

PostPosted: Tue Jan 06, 2009 3:14 pm
Reply with quote

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
View user's profile Send private message
Terry Heinze

JCL Moderator


Joined: 14 Jul 2008
Posts: 1249
Location: Richfield, MN, USA

PostPosted: Wed Jan 07, 2009 12:50 pm
Reply with quote

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. icon_smile.gif
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 Replace each space in cobol string wi... COBOL Programming 3
No new posts COBOL -Linkage Section-Case Sensitive COBOL Programming 1
No new posts COBOL ZOS Web Enablement Toolkit HTTP... COBOL Programming 0
No new posts Calling DFSORT from Cobol, using OUTF... DFSORT/ICETOOL 5
No new posts Generate random number from range of ... COBOL Programming 3
Search our Forums:

Back to Top