Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how much is the size of this record.....? 1

Status
Not open for further replies.

kurup

Programmer
Jun 1, 2001
32
IN
hi friends,

just get me this out....

01 ENTIRE-MESSAGE.
05 FILLER PIC X(4) VALUE "For ".
05 VALUE1 PIC ZZ9 VALUE 1.
05 PARTIAL-MESSAGE.
10 FILLER PIC X(14) VALUE " the total is ".
10 VALUE2 PIC ZZZ,ZZZ,ZZ9.99.

In memory, what is the length of the variable ENTIRE-MESSAGE and the length of the variable PARTIAL-MESSAGE(i.e.how many characters)

Regards
kurup

 
Did some research in my trusty IBM VS COBOL manual in our TSO Bookmanager system.

It said that all of the Z's (which means supress zeroes) still retain a byte of data storage space, because the supressed zero is replaced with a space.

All of the commas, whether present or supressed, also would count as a byte of storage. And the decimal point character takes up 1 byte of storage.

So therefore counting all the bytes in the following:

01 ENTIRE-MESSAGE.
05 FILLER PIC X(4) VALUE "For ".
05 VALUE1 PIC ZZ9 VALUE 1.
05 PARTIAL-MESSAGE.
10 FILLER PIC X(14) VALUE " the total is ".
10 VALUE2 PIC ZZZ,ZZZ,ZZ9.99.

The variable PARTIAL-MESSAGE should have 14 (FILLER) + 14 (VALUE2) = 28 bytes.

Adding to that, the first FILLER (4 bytes) + VALUE1 (2 bytes -- even though, if the value is 1, the supressed zero is replaced by a space) = 6 bytes. And then the entire value of PARTIAL-MESSAGE (28 bytes) for a grand total of 34 bytes for ENTIRE-MESSAGE.

Hope this helps, and hope I'm accurate! :)

Nina Too
 
Hi,

let COBOL tell it yourself by using LENTH OF.

Some IBM examples:

MOVE LENGTH OF A TO B
DISPLAY LENGTH OF A, A
ADD LENGTH OF A TO B
CALL "PROGX" USING BY REFERENCE A BY CONTENT LENGTH OF A

Also if you compile something, some compilers like IBM's can give the length of the variables in the listing.

I hope this is helpful.

Regards,

Crox
 
hi friends,
thank u all for ur help in helping me out.I used the technique suggested by Crox to find it out.The output matched our reasoning i.e. the answer was 35,28.

The program i used is as below

IDENTIFICATION DIVISION.
PROGRAM-ID. TEST.
ENVIRONMENT DIVISION.
DATA DIVISION.
WORKING STORAGE SECTION.
01 ENTIRE-MESSAGE.
05 FILLER PIC X(4) VALUE "For ".
05 VALUE1 PIC ZZ9 VALUE 1.
05 PARTIAL-MESSAGE.
10 FILLER PIC X(14) VALUE " the total is ".
10 VALUE2 PIC ZZZ,ZZZ,ZZ9.99.
01 VARLEN PIC 99.
01 VARSUBLEN PIC 99.

PROCEDURE DIVISION.

MOVE LENGTH OF ENTIRE-MESSAGE TO VARLEN.
MOVE LENGTH OF PARTIAL-MESSAGE TO VARSUBLEN.
DISPLAY VARLEN.
DISPLAY VARSUBLEN.
STOP RUN.

OUTPUT:: 35 28


Regards,
Kurup

 
Also thanks for the corrections that people made to my attempts at calculatiing. When I saw "ZZ9," I counted the "Z's" and forgot to count the "9". So my grand total was off by 1, should have been 35 rather than 34.

But my calculations for PARTIAL-MESSAGE was correct. Length = 28. :-D

But using the LENGTH parameter was a great idea. So I gave Crox a vote. :)

Nina Too
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top