Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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: 1243
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 Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
This topic is locked: you cannot edit posts or make replies. Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us