Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Forum Index
 
Register
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Search an array inside an array

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Thu Jan 24, 2019 4:19 pm    Post subject: Search an array inside an array
Reply with quote

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

Garry Carroll

Senior Member


Joined: 08 May 2006
Posts: 1074
Location: Dublin, Ireland

PostPosted: Thu Jan 24, 2019 5:36 pm    Post subject:
Reply with quote

Shouldn't you have
Code:
03 FILLER OCCURS 25 TIMES.
indexed by something?

Garry
Back to top
View user's profile Send private message
amitc23

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Thu Jan 24, 2019 5:45 pm    Post subject:
Reply with quote

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

Senior Member


Joined: 31 Oct 2006
Posts: 1004
Location: Richmond, Virginia

PostPosted: Fri Jan 25, 2019 2:15 am    Post subject:
Reply with quote

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

New User


Joined: 05 Nov 2014
Posts: 95
Location: India

PostPosted: Fri Jan 25, 2019 11:18 am    Post subject:
Reply with quote

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

Global Moderator


Joined: 06 Jun 2008
Posts: 8551
Location: Dubuque, Iowa, USA

PostPosted: Fri Jan 25, 2019 7:59 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Fetch the Dataset names from inside m... kalyan94 TSO/ISPF 18 Wed Jun 17, 2020 2:06 pm
No new posts RegEX search in ISPF editor jzhardy TSO/ISPF 4 Mon Apr 20, 2020 10:46 am
No new posts COBOL batch program using large size ... Akriti Mishra COBOL Programming 3 Thu Mar 26, 2020 11:37 pm
No new posts COBOL - Array result in single variab... vinu78 COBOL Programming 3 Thu Feb 20, 2020 5:29 pm
No new posts ISPF search - capturing result jzhardy TSO/ISPF 15 Sat Dec 07, 2019 5:20 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us