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: 90
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: 1054
Location: Dublin, Ireland / Edinburgh, Scotland

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: 90
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

Active Member


Joined: 31 Oct 2006
Posts: 982
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: 90
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: 8500
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 Search the strings present in ps file... Bhuvana Narasimhan All Other Mainframe Topics 8 Thu Aug 22, 2019 8:20 pm
No new posts Verify WITH UR present inside program... priyankakir CLIST & REXX 23 Wed Jun 12, 2019 3:37 pm
No new posts Search string from concatenated input... srini24 JCL & VSAM 8 Sat Mar 30, 2019 9:51 pm
No new posts How to delete a VSAM dataset from ins... Mike.Fulton JCL & VSAM 6 Fri Feb 15, 2019 5:58 am
No new posts Array in Cobol Db2 Stored Procedure Ashishpanpaliya DB2 4 Wed Jan 09, 2019 3:06 pm

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