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: 1232
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
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am


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