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
 

 

why we shouldn't use occur clause in 01 group level item ?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
pkmurali
Warnings : 1

Active User


Joined: 15 Dec 2005
Posts: 237

PostPosted: Sat May 05, 2007 11:36 am    Post subject: why we shouldn't use occur clause in 01 group level item ?
Reply with quote

why we shouldn't use occur clause in 01 group level item ?
Back to top
View user's profile Send private message

William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat May 05, 2007 12:30 pm    Post subject:
Reply with quote

You're kidding, right?
It's not "shouldn't", it's "can't".
That's the Rules.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat May 05, 2007 9:02 pm    Post subject:
Reply with quote

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
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sat May 05, 2007 9:28 pm    Post subject:
Reply with quote

Actually it is because of the guarantee provided by COBOL that 01 levels in working storage are doubleword aligned.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat May 05, 2007 9:41 pm    Post subject:
Reply with quote

Hi Will,

I used to think that but now I'm not so sure. What makes you think so?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sun May 06, 2007 1:09 am    Post subject:
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun May 06, 2007 7:02 am    Post subject:
Reply with quote

I know all that, but how does it prevent the compiler from generating the appropriate code to process the table?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Sun May 06, 2007 11:37 am    Post subject:
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun May 06, 2007 10:22 pm    Post subject:
Reply with quote

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
View user's profile Send private message
rz061m

New User


Joined: 03 Mar 2006
Posts: 48
Location: Chennai

PostPosted: Mon May 07, 2007 3:18 pm    Post subject:
Reply with quote

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
View user's profile Send private message
amiya_mf

New User


Joined: 01 Mar 2005
Posts: 19

PostPosted: Mon May 07, 2007 4:08 pm    Post subject:
Reply with quote

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
View user's profile Send private message
Phrzby Phil

Active Member


Joined: 31 Oct 2006
Posts: 964
Location: Richmond, Virginia

PostPosted: Mon May 07, 2007 5:43 pm    Post subject:
Reply with quote

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
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Mon May 07, 2007 10:15 pm    Post subject:
Reply with quote

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
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 find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts Group Data based on a key Arun Raj DFSORT/ICETOOL 7 Thu Apr 27, 2017 11:29 pm
No new posts Need Help with : IFTHEN(WHEN=GROUP) Sumanta_89 DFSORT/ICETOOL 1 Wed Apr 19, 2017 5:23 pm
No new posts Group elements using ICETOOL Learncoholic DFSORT/ICETOOL 2 Fri Apr 14, 2017 11:01 am
No new posts Why TS/OP would Not contact site supp... RahulG31 All Other Mainframe Topics 4 Wed Mar 22, 2017 7:46 am


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