View previous topic :: View next topic
|
Author |
Message |
pkmurali Warnings : 1 Active User
Joined: 15 Dec 2005 Posts: 271
|
|
|
|
why we shouldn't use occur clause in 01 group level item ? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
You're kidding, right?
It's not "shouldn't", it's "can't".
That's the Rules. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
I think the reason is that an 01 is the highest group level allowed and the table itself is treated as a group; that would have to be a higher level than the 01s it contains.
But if the OCCURS appears at some lower level than 01, there's always a higher level to define the table as a whole. |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Actually it is because of the guarantee provided by COBOL that 01 levels in working storage are doubleword aligned. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Will,
I used to think that but now I'm not so sure. What makes you think so? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
Enterprise COBOL Language Reference, SYNCHRONIZED clause, just before "Slack Bytes":
Quote: |
In the file section, the compiler assumes that all level-01 records that contain SYNCHRONIZED items are aligned on doubleword boundaries in the buffer. You must provide the necessary slack bytes between records to ensure alignment when there are multiple records in a block.
In the working-storage section, the compiler aligns all level-01 entries on a doubleword boundary.
For the purposes of aligning binary items in the linkage section, all level-01 items are assumed to begin on doubleword boundaries. Therefore, if you issue a CALL statement, such operands of any USING phrase within it must be aligned correspondingly. |
I'm sure it's there, but I didn't find the reference to 77 levels. |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
I know all that, but how does it prevent the compiler from generating the appropriate code to process the table? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
The FM wrote: |
The OCCURS clause cannot be specified in a data description entry that:
v Has a level number of 01, 66, 77, or 88.
v Describes a redefined data item. |
William Thompson wrote: |
That's the Rules. |
But since the compiler can account for and handle slack bytes caused by syncronized entries within the occuring entries, I haven't come up with a good reason why it shouldn't be able to.... |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
That's why I gave up on it.
On the otherhand, it's nice to have a level above the OCCURS level to do things like move the table; init the table with "MOVE ALL X'FF' TO table-level; pass the table to a subpgm, etc.. |
|
Back to top |
|
|
rz061m
New User
Joined: 03 Mar 2006 Posts: 48 Location: Chennai
|
|
|
|
Hi all,
By declaring OCCURS in 01 level you are actually trying to repeat a record from N number of times. This is not possible or actually does not make sense.
***** Rather you can only try to repeat a field in a record for N times not the record itself. *****
EXAMPLE:
01 STUDENT.
05 SUB1 PIC X(3) 10 TIMES.
Here you can have mulitple subjects for a single student. But not the other way round.
Thanks,
RZ061M |
|
Back to top |
|
|
amiya_mf
New User
Joined: 01 Mar 2005 Posts: 18
|
|
|
|
Hi RZ061M,
Your are absolutely right. Repeatation is only ment for fields not for record.
This is the reason 01 does not allow occurs clause.
rz061m wrote: |
Hi all,
By declaring OCCURS in 01 level you are actually trying to repeat a record from N number of times. This is not possible or actually does not make sense.
***** Rather you can only try to repeat a field in a record for N times not the record itself. *****
EXAMPLE:
01 STUDENT.
05 SUB1 PIC X(3) 10 TIMES.
Here you can have mulitple subjects for a single student. But not the other way round.
Thanks,
RZ061M |
|
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Since the language was defined (by committee nonetheless!) before the various COBOL compilers were written, and without regard to the architecture of the many machines it would run on, I think that answers to questions like this relate more to what inspires good programming practices than technical data storage requirements. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Where did "the record" come in?
Quote: |
Your are absolutely right. Repeatation is only ment for fields not for record. |
The rule applies to all level 01s regardless of whether they are a record definition or not. . . . |
|
Back to top |
|
|
|