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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

occurs if statement

Status
Not open for further replies.

ptrj

Programmer
Feb 22, 2006
10
BE
hellow
I have a question about the if statement if you have a table:
so i have this:

01 WoordTemp occurs 10 pic x(30).
01 WoordReal occurs 10 pic x(30).

move "testing" to WoordTemp(1)
move "testing" to WoordReal(2)

if WoordTemp(1) = WoordReal(2)
display "hellow world!"
end-if

why can't i do this?? I don't understand it
How can I fix this?
thx

 
An 01 level cannot have an OCCCURS clause. It is a standard COBOL rule.
 
You can correct your code as follows:
Code:
01.
  05 WoordTemp occurs 10 pic x(30).
01.
  05 WoordReal occurs 10 pic x(30).

As webrabbit mentions, it's just a restriction of the language. I should note that you could also have made both tables subordinate to the same group item (01 level).

I've not named the "records" (01 levels) above. Most folks would consider that bad practice as names there may be useful documentation of the contents of the group item.

Regards,

Glenn
 
With some versions of COBOL (i.e., RM/COBOL version 9), you can have an OCCURS for 01 levels.
 
Althugh I am aware that some vendors do have extensions allowing OCCURS at the 01 (and some at the 77) level, there are some reasons - not just historical for NOT allowing this. The most obvious (to me) reason has to do with questions of what happens if you allow it for 01-levels under and FD (or SD or RD). Similarly, allowing it for an 01-level in Linkage Section can cause logistic problems.

Again, implementors with this extension do provide rules for it, but they can seem (almost?) as arbitrary as the univeral STANDARD rule to disallow it.

Bill Klein
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top