MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Occurs depending in Table element

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
Narsimha
Beginner


Joined: 03 Dec 2002
Posts: 27
Topics: 14

PostPosted: Mon Dec 23, 2002 7:16 am    Post subject: Occurs depending in Table element Reply with quote

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


Joined: 03 Dec 2002
Posts: 21
Topics: 4
Location: India, Pune

PostPosted: Mon Dec 23, 2002 8:40 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12368
Topics: 75
Location: San Jose

PostPosted: Mon Dec 23, 2002 9:33 am    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
CaptBill
Beginner


Joined: 02 Dec 2002
Posts: 100
Topics: 2
Location: Pasadena, California, USA

PostPosted: Mon Dec 23, 2002 1:08 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website
Narsimha
Beginner


Joined: 03 Dec 2002
Posts: 27
Topics: 14

PostPosted: Thu Dec 26, 2002 7:31 am    Post subject: Reply with quote

Hi,

Solution given by kolusu worked for me. Thanks you all for your replies.


Thanks,
Narsimha
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group