View previous topic :: View next topic
|
Author |
Message |
gigish.thomas
New User
Joined: 27 Mar 2008 Posts: 4 Location: pune
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello and welcome to the forum,
What happens when you compile this program? |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Kjeld
Active User
Joined: 15 Dec 2009 Posts: 365 Location: Denmark
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
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 |
|
|
|