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
 

 

What is the size of this cobol variable? 01 var pic -8(9).

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
gigish.thomas

New User


Joined: 27 Mar 2008
Posts: 4
Location: pune

PostPosted: Thu Feb 03, 2011 9:21 am    Post subject: What is the size of this cobol variable? 01 var pic -8(9).
Reply with quote

What is the size of this cobol variable? 01 var pic -8(9).
Also can anyone tell me why we are declaring like 8(9) and how it differ from 9(8)? Thanks!!!
Back to top
View user's profile Send private message

dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Thu Feb 03, 2011 10:03 am    Post subject:
Reply with quote

Hello and welcome to the forum,

What happens when you compile this program?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Thu Feb 03, 2011 5:42 pm    Post subject:
Reply with quote

Nobody can tell you the size of the variable because it is not valid:
Code:
               01  WS-VAR.
                   05  WS-A                    PIC -8(9).

=> IGYDS1160-S Character(s) "8" were found as "PICTURE" string character(s).  A
               "PICTURE" string of "S9(1)" was assumed.
Who told you about the picture? You need to go back to that person and find out why you were told something that is not allowed in COBOL -- at least z/OS COBOL.
Back to top
View user's profile Send private message
Kjeld

Active User


Joined: 15 Dec 2009
Posts: 365
Location: Denmark

PostPosted: Thu Feb 03, 2011 6:18 pm    Post subject: Re: What is the size of this cobol variable? 01 var pic -8(9
Reply with quote

gigish.thomas wrote:
What is the size of this cobol variable? 01 var pic -8(9).
Also can anyone tell me why we are declaring like 8(9) and how it differ from 9(8)? Thanks!!!

If you ask the size of a cobol variable you should generally also assess if a numeric item is in display format, packed decimal, or binary. Everything about size is documented in the cobol reference manual obtainable from the top menu 'IBM Manuals' in this forum.
The difference between pic -9(8) and pic -8(9) is that the first will compile successfully, and the latter won't.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 8057
Location: East Dubuque, Illinois, USA

PostPosted: Thu Feb 03, 2011 6:24 pm    Post subject:
Reply with quote

Also, why bother asking the size, anyway? If you compile a program with a variable having the PICTURE (and the PICTURE is valid), the compiler option MAP will tell you exactly how long the variable is.
Back to top
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 962
Location: Richmond, Virginia

PostPosted: Thu Feb 03, 2011 6:47 pm    Post subject:
Reply with quote

Once you do finally get the valid PIC, then you'll need to determine whether the sign is included in the rightmost byte or is separate (leading or trailing).

The PIC line won't tell you - it will be stated elsewhere - so you need to research that also.
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 Converting Variable block file to Fix... bhavana yalavarthi DFSORT/ICETOOL 10 Tue May 16, 2017 2:20 pm
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 Getting error while opening a variabl... apandey1 COBOL Programming 5 Fri May 05, 2017 12:22 pm
No new posts COBOL Code Parsers and Lineage Establ... balimanja COBOL Programming 2 Tue May 02, 2017 3:30 am


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