Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Cobol PIC query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
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    Post subject: Cobol PIC query
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    Post subject: Reply to: Cobol PIC query
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: 1228
Location: Israel

PostPosted: Tue Jan 06, 2009 3:14 pm    Post subject: Reply to: Cobol PIC query
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    Post subject:
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    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
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm
No new posts IMS T-Pipe queue counts in a COBOL Pr... Siva NKK Kothamasu IMS DB/DC 0 Tue May 09, 2017 6:31 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am
No new posts Cobol upgrade - source code missing f... gthmrj IBM Tools 1 Wed Apr 26, 2017 6:04 pm
No new posts COBOL Programming Sandpit? jodrisco COBOL Programming 6 Wed Apr 12, 2017 3:47 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us