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

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


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
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
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

Moderator Emeritus


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

PostPosted: Thu Feb 03, 2011 10:03 am
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Feb 03, 2011 5:42 pm
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
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Thu Feb 03, 2011 6:24 pm
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

Senior Member


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

PostPosted: Thu Feb 03, 2011 6:47 pm
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 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 2
No new posts Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
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
Search our Forums:

Back to Top