View previous topic :: View next topic |
Author |
Message |
Gary_Fsee Beginner
Joined: 03 Jan 2005 Posts: 3 Topics: 2
|
Posted: Mon Jan 03, 2005 10:55 pm Post subject: Help with Complex ODO |
|
|
Hello
I have created a complex ODO structure as follows:
Code: |
01 WS-FORMAT-DATA.
05 WS-HEADER.
10 A1 PIC X(05) VALUE 'AAAAA'.
.
.
.
05 Table-1 OCCURS 1 TO 5 TIMES
DEPENDING ON WS-COUNTER1
INDEXED BY IDX1.
10 TABLE-ELEMENT-1 PIC X(60).
10 TABLE-ELEMENT-2 PIC X(120).
10 TABLE-ELEMENT-3 OCCURS 1 TO 50 TIMES
DEPENDING ON WS-COUNTER2
INDEXED BY IDX2
PIC X(150).
10 TABLE-ELEMENT-4 PIC X(75).
05 WS-FOOTER :?: PIC X(05).
01 WS-HOLD-DATA PIC X(32767).
|
WS-COUNTER-1 and 2 are defined outside. I got no compilation errors. The objective of the program is to move contents of WS-FORMAT-DATA to WS-HOLD-DATA after formatting data in the 01 LEVEL.
Program logic is performed such that the value of ODO objects WS-COUNTER-2 changes with each increment of IDX1. I've also made sure that the both ODO objects are SET before a value is moved to the subordinate and non-subordinate items. I'm also moving the INDEX value IDX2 to an integer variable before WS-COUNTER-2 is changed and restoring the IDX2 value back after the change. I'm moving values to all the items in the 05 level with WS-FOOTER being the last receiving field.
My problem is that I don't see values in TABLE-ELEMENT-4 and WS-FOOTER from the 2nd occurrence of TABLE-1. All other elements have proper data in them.
What am I missing?
Thanks in advance for all your valuable response
Gary. |
|
Back to top |
|
|
Phantom Data Mgmt Moderator
Joined: 07 Jan 2003 Posts: 1056 Topics: 91 Location: The Blue Planet
|
Posted: Tue Jan 04, 2005 12:37 am Post subject: |
|
|
Gary,
Are you incrementing WS-COUNTER-1 and WS-COUNTER-2 properly. Even though you update the IDX'n variables, the memory allocation for the tables are dependant on the values in WS-COUNTER-1 & WS-COUNTER-2. Make sure your code keeps the counter variables in sync. If possible pls post your piece of code that deals with the table manipulation.
Thanks,
Phantom |
|
Back to top |
|
|
Kathi Beginner
Joined: 14 May 2003 Posts: 25 Topics: 0 Location: Mission Viejo, California
|
Posted: Tue Jan 11, 2005 11:08 pm Post subject: |
|
|
Variable Occurs within a Variable Occurs is not allowed.
This is the data structure you have created. Make one of them fixed and it will work. |
|
Back to top |
|
|
Gary_Fsee Beginner
Joined: 03 Jan 2005 Posts: 3 Topics: 2
|
Posted: Wed Jan 12, 2005 11:53 pm Post subject: |
|
|
Not according to the COBOL Manual for Z/OS:
There are three basic forms of complex ODO permitted by the compiler:
1. A data item described by an OCCURS clause with the DEPENDING ON option is Followed by a nonsubordinate item. The nonsubordinate item is variably located.
2. A data item described by an OCCURS clause with the DEPENDING ON option is followed by a nonsubordinate data item described by an OCCURS clause with the DEPENDING ON option.
3. A data item described by an OCCURS clause with the DEPENDING ON option is nested within another data item described by an OCCURS clause with the DEPENDING ON option.
As I have said earlier I did not get any compile errors.
To answer KOLUSU's question I'm not incrementing the values of the WS-COUNTER-1 and WS-COUNTER-2. The value of WS-COUNTER-1 is determined first in the program logic and then the value of WS-COUNTER-2 is determined for each occurrence of WS-COUNTER-1. I guess it gets complicated here.
After much error and trial I decided to split-up the Group elements into TABLE-1, TABLE-2 , TABLE-3 ... each with OCCURS 0 TO 1 TIMES VERB and this seems to be working for me.
Thanks
Gary |
|
Back to top |
|
|
|
|