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
 
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: 8188
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: 8188
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: 967
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
This topic is locked: you cannot edit posts or make replies. Cobol to fetch the content by using s... arunc55 COBOL Programming 4 Fri Nov 17, 2017 1:25 pm
No new posts VBS and VB, COBOL syntax is the same ... natt.sut COBOL Programming 3 Sun Nov 12, 2017 6:36 am
No new posts Move from Comp3 variable to Edited Va... Revathy.nair0485 COBOL Programming 7 Fri Nov 03, 2017 3:30 pm
This topic is locked: you cannot edit posts or make replies. Can a alphanumeric data be moved to a... nico_neoz COBOL Programming 10 Mon Oct 30, 2017 8:28 am
No new posts COBOL - EXIT statement weird behavior anthony.pangestu COBOL Programming 0 Fri Oct 27, 2017 9:57 am

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