View previous topic :: View next topic |
Author |
Message |
Narsimha Beginner
Joined: 03 Dec 2002 Posts: 27 Topics: 14
|
Posted: Mon Dec 23, 2002 7:16 am Post subject: Occurs depending in Table element |
|
|
Hi,
I am having a table which occurs six times. For each entry I can enter one or two phone numbers.
So, I want to put the phone numbers in occurs depending clause. Please find the following structure.
--------------------------------------------------------
Code: |
05 CI-MULTIPLE-ENTRIES-INFO OCCURS 6 TIMES.
10 CI-EMPLOYEE-CODE.
15 CI-EMP-BRKR-DLR PIC X(01).
15 CI-RLTD-EMP-BRKR-DLR PIC X(01).
10 CI-TAX-STATUS-CODE PIC X(04).
10 CI-NET-WORTH-U PIC 9(15).
10 CI-ADDRESS.
15 CI-ATTN-LINE.
20 CI-ATTN-LINE-PREFIX PIC X(04).
20 CI-ATTN-LINE-DETAIL PIC X(28).
15 CI-ADDR-LINE-1 PIC X(32).
15 CI-COUNTRY-CDE PIC X(02).
15 CI-TELEPHONE-COUNT PIC 9(01).
15 CI-TELEPHONE OCCURS 1 TO 2 TIMES
DEPENDING ON CI-TELEPHONE-COUNT.
20 CI-TELEPHONE-NMBR PIC X(60).
10 CI-AGREEMENT-COUNT PIC 9(02).
10 CI-AGREEMENTS OCCURS 1 TO 25 TIMES
DEPENDING ON CI-AGREEMENT-COUNT.
15 CI-DOC-CODE PIC X(04).
15 CI-AGREEMENT-FURNISHED-DATE.
20 CI-FURNISHED-DATE-MM PIC 9(02).
20 CI-FURNISHED-DATE-DD PIC 9(02).
20 CI-FURNISHED-DATE-CCYY PIC 9(04).
15 CI-EXECUTED-AGREEMENT-COPY-DATE.
20 CI-EXECUTED-COPY-DATE-MM PIC 9(02).
20 CI-EXECUTED-COPY-DATE-DD PIC 9(02).
20 CI-EXECUTED-COPY-DATE-CCYY PIC 9(04).
|
--------------------------------------------------------------------
While compiling I am getting the following error.
************************************
IGYGR1263-S "OCCURS DEPENDING ON" object "CI-TELEPHONE-COUNT" was defined as a table-element. The "DEPENDING ON" phrase was discarded.
*************************
Can't we put the occurs depending clause in a static table? Then how can I incorporate the above mentioned functionality?
Thanks,
Narsimha |
|
Back to top |
|
|
Abhi Beginner
Joined: 03 Dec 2002 Posts: 21 Topics: 4 Location: India, Pune
|
Posted: Mon Dec 23, 2002 8:40 am Post subject: |
|
|
Narsimha,
I have never tried this before but I think the compile error makes sense doesn't it? If u were to define a table which depends on a variable which itself is an item of another table how is the program supposed to know at run time what should be the limit of the first table. I mean which subscript of the "DEPENDING ON" variable should it consider in particular.
I can't put much thought right now for an alternative but I suppose u will have to use seperate tables. |
|
Back to top |
|
|
kolusu Site Admin
Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
Posted: Mon Dec 23, 2002 9:33 am Post subject: |
|
|
Narsimha,
The depending variable can be defined as a seperate entry.You cannot define it in the table layout.
So define the depending variable in the working-storage section like this
Code: |
01 CI-TELEPHONE-COUNT PIC 9(01).
01 CI-AGREEMENT-COUNT PIC 9(02).
|
In the procedure divison you can move the respective counts to these variables.
Code: |
MOVE 1 TO CI-TELEPHONE-COUNT
MOVE 25 TO CI-AGREEMENT-COUNT
|
Also I see that your variable CI-EXECUTED-AGREEMENT-COPY-DATE exceeds the max allowable length of 30 characters. So you need to change that also.
Hope this helps...
cheers
kolusu
Last edited by kolusu on Thu Dec 26, 2002 10:11 am; edited 1 time in total |
|
Back to top |
|
|
CaptBill Beginner
Joined: 02 Dec 2002 Posts: 100 Topics: 2 Location: Pasadena, California, USA
|
Posted: Mon Dec 23, 2002 1:08 pm Post subject: |
|
|
What you are describing is a VARIABLE OCCURS within a VARIABLE OCCURS. This sort of data structure is NOT supported by COBOL. Since the inner occurs is only 2 times, why not just declare it as FIXED then you would have a supported structure? You can have the occurrances initialized to some value, SPACE, HIGH or LOW VALUES then test it to see if it has data. |
|
Back to top |
|
|
Narsimha Beginner
Joined: 03 Dec 2002 Posts: 27 Topics: 14
|
Posted: Thu Dec 26, 2002 7:31 am Post subject: |
|
|
Hi,
Solution given by kolusu worked for me. Thanks you all for your replies.
Thanks,
Narsimha |
|
Back to top |
|
|
|
|