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: 7989
Location: Bellevue, IA

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: 7989
Location: Bellevue, IA

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 Writing on to GSAM variable length rohanthengal JCL & VSAM 6 Fri Mar 03, 2017 7:46 pm
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Execute TSO ACF commands from COBOL-I... supreethi.srid TSO/ISPF 0 Tue Feb 21, 2017 5:19 pm
No new posts Mainframe Interview Questions CICS,CO... akshathan Mainframe Interview Questions 6 Thu Feb 09, 2017 6:38 pm
No new posts Count Trailing Spaces in variable str... Virendra Shambharkar SYNCSORT 10 Thu Feb 02, 2017 12:23 pm


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