View previous topic :: View next topic
|
Author |
Message |
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Friends
I have a data structure as follows
Code: |
01 BATCH-FILE-INFO.
03 FILLER OCCURS 25 TIMES.
05 BATCH-COUNT PIC 9(5).
05 DEP-COUNT PIC 9(5).
05 DEP-NUM-BATCHES PIC 9(5).
05 XXX-SOURCE-CRITERIA OCCURS 50 TIMES
INDEXED BY XXX-IDX.
07 XXX-SOURCE-ENTITY-ID PIC X(15).
07 XXX-SOURCE-ENTITY-TYPE PIC X.
07 XXX-SOURCE-AMOUNTS.
09 XXX-NUM-CR-TRAN PIC 9(6).
09 XXX-CR-AMT-TOT PIC 9(15)V9(3).
09 XXX-NUM-DB-TRAN PIC 9(6).
09 XXX-DB-AMT-TOT PIC 9(15)V9(3).
|
I need to search second array i.e. XXX-SOURCE-CRITERIA but when i do that using index it gives me following COMPILE error
Code: |
"SEARCH" IDENTIFIER "XXX-SOURCE-CRITERIA (GROUP)" WAS SUBORDINATE TO AN ITEM THAT HAS NOT DEFINED WITH
"OCCURS" AND "INDEXED BY" CLAUSES. THE STATEMENT WAS DISCARDED. |
[/code]
Please suggest how can i perform search. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1193 Location: Dublin, Ireland
|
|
|
|
Shouldn't you have
Code: |
03 FILLER OCCURS 25 TIMES. |
indexed by something?
Garry |
|
Back to top |
|
|
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Thanks for response Garry. I was also thinking that as an option, but this is an existing code and I need to change at many places. Second occurs I have added now. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
It's been a long time, so I'll just question:
If an array is indexed, can one also reference elements with subscripts?
If so, then your existing code should be ok if COBOL requires you to index the top level? |
|
Back to top |
|
|
amitc23
New User
Joined: 05 Nov 2014 Posts: 95 Location: India
|
|
|
|
Thanks Phil. I was in doubt about that. But for the meanwhile I have indexed the first occurs as well. That resolves compile issue. Will see at run time now. Thanks for help. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
From the Enterprise COBOL Language Reference manual, V6.2, page 448:
Quote: |
Before using a serial search on a multidimensional table, you must also set the value of the index for each superordinate dimension |
So the compiler is telling you that your syntax is invalid since you cannot set the index value for the FILLER OCCURS.
SEARCH can be tricky when dealing with tables that have more than one dimension. From the same page of the manual:
Quote: |
The SEARCH statement modifies only the value in the search index, and, if the VARYING phrase is specified, the value in index-name-1 or identifier-2. Therefore, to search an entire two-dimensional to seven-dimensional table, you must execute a SEARCH statement for each dimension. In the WHEN phrases, you must specify the indexes for all dimensions. Before the execution of each SEARCH statement, you must initialize the associated indexes with SET statements. |
|
|
Back to top |
|
|
|