Basic Question



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Basic Question

Postby cooldude14344 » Thu Mar 10, 2011 5:47 pm

Guys

Please let me know how much size the below variable occupy?

PERCENT PIC 9(5)V999.

I would like to declare it as PIC 9(4)V(4). - will that have the same size?
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Basic Question

Postby Robert Sample » Thu Mar 10, 2011 6:08 pm

Your question cannot be asnwered as stated. If PERCENT is USAGE DISPLAY, the variable will use 8 bytes. If PERCENT is USAGE COMP, the variable will use 4 bytes. If PERCENT is USAGE COMP-3, the variable will use 5 bytes.

Moving the implied decimal point will NOT change the length of the variable. It may, however, cause you severe problems unless ALL the data is converted to the new format at one time. Since the decimal point is only implied and not actually present, 12345678 would be interepreted as 12345.678 with one PIC and 1234.5678 with the other PIC. These values are not the same, even though the underlying representation (12345678) did not change.
Robert Sample
Global moderator
 
Posts: 3720
Joined: Sat Dec 19, 2009 8:32 pm
Location: Dubuque, Iowa, USA
Has thanked: 1 time
Been thanked: 279 times

Re: Basic Question

Postby BillyBoyo » Thu Mar 10, 2011 7:34 pm

Easiest way to check is to put both in a program, compile, and look at the DMAP generated - always works.

If it is some sort of training question, check out the diffence between storage allocation for 77 level (stuck next to the previous item) and 01 level where each is "lined up" (double-word boundary, or is it a full-word - help me out someone) where you will have some "slack" bytes (storage which is taken up, but which isn't actually used for anything). Again, try some, look at the DMAP and try to understand the difference in the locations.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 265 times

Re: Basic Question

Postby cooldude14344 » Fri Mar 11, 2011 3:10 am

Thanks guys
cooldude14344
 
Posts: 19
Joined: Sat Mar 05, 2011 1:25 am
Has thanked: 0 time
Been thanked: 0 time

Re: Basic Question

Postby Quasar » Sun Mar 13, 2011 11:15 pm

Cooldude -

Both the PICTURE Specifications occupy the same storage space(8 Bytes) in COBOL. There's difference however, in the position of the Assumed decimal point.

Thank you very much.
Quasar Chunawala,
Software Engineer, Lives at Borivali, Mumbai
User avatar
Quasar
 
Posts: 102
Joined: Wed Nov 10, 2010 7:11 pm
Location: Borivali, Mumbai
Has thanked: 13 times
Been thanked: 2 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post