IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Problem in Search


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed Jul 08, 2009 3:52 pm
Reply with quote

Hi,

I am reading two files and moving data of one file to internal table and then giving search on table for values which are present in first file. I am facing follwoign errors:

Code:

Not enough subscripts or indices were specified for "WS-NUM-TBL".A subscript or index value of 1 was assumed for each missing subscript or index.

Not enough subscripts or indices were specified for "WS-NAME-TBL".
 A subscript or index value of 1 was assumed for each missing subscript or index.


my code for search is :

Code:

C200-READ-SRCH-FILE SECTION.

PERFORM VARYING INDX1 FROM 1 BY 1 UNTIL WS-EOF-SRCH-FILE           
  READ SRCH INTO SRCH-RECD AT END                                 
    MOVE 'YES' TO WS-SRCH-FILE-SW                                 
    GO TO C200-EXIT                                               
  NOT AT END                                                       
      ADD +1 TO WS-SRCH-READ-CNTR                                 
      ADD +1 TO INDX1                                             
  END-READ                   

C200-EXIT.EXIT.

C300-READ-MASTER-FILE SECTION.                                   
                                                                 
    READ MASTER INTO MASTER-RECD AT END                           
      MOVE 'YES' TO WS-MASTER-FILE-SW                             
      GO TO C300-EXIT                                             
    NOT AT END                                                   
      ADD +1 TO WS-MASTER-READ-CNTR                               
      PERFORM VARYING INDX2 FROM 1 BY 1 UNTIL WS-EOF-MASTER-FILE 
        MOVE WS-NUM-TWO(INDX2)  TO WS-NUM-TBL                     
        MOVE WS-NAME-TWO(INDX2) TO WS-NAME-TBL                   
        ADD +1 TO INDX2                                           
      END-PERFORM                                                 
    END-READ.                                                     
                                                                 
C300-EXIT.EXIT.                                                   

 D100-MAIN-PROCESS SECTION.                                   
                                                               
     SEARCH MASTER-TBL-RECD AT END                             
       GO TO D100-EXIT                                         
      WHEN WS-NUM-TBL(IDX) = WS-NUM-ONE                       
        MOVE WS-NUM-TBL(IDX)  TO WS-NUM                       
        MOVE WS-NAME-TBL(IDX) TO WS-NAME                       
        WRITE MATCH FROM MATCH-RECD                           
        SET IDX UP BY 1                                       
     END-SEARCH.                                               
                                                               
 D100-EXIT.EXIT.                                                                                   
END-PERFORM.                                                       


I have given code for reading of files and search code.

Please help me .

regards,
rupesh gupta
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Wed Jul 08, 2009 3:55 pm
Reply with quote

Please post the table declaration part.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed Jul 08, 2009 3:58 pm
Reply with quote

Hi,

File and table layout are as
Code:

01 SRCH-RECD.                                                   
   05 WS-NUM-ONE                   PIC X(03) VALUE SPACES.       
   05 WS-NAME-ONE                  PIC X(09) VALUE SPACES.       
01 MASTER-RECD.                                                 
   05 WS-NUM-TWO                   PIC X(03) VALUE SPACES.       
   05 WS-NAME-TWO                  PIC X(09) VALUE SPACES.       
01 MATCH-RECD.                                                   
   05 WS-NUM                       PIC X(03) VALUE SPACES.       
   05 WS-NOF-MASTER-FILE           PIC X(09) VALUE SPACES.       
                                                                 
01 MASTER-TBL.                                                   
   05 MASTER-TBL-RECD OCCURS 500 TIMES INDEXED BY IDX.           
     07 MASTER-TBL-RECD-GRP.                                     
       10 WS-NUM-TBL                PIC X(03) VALUE SPACES.     
       10 WS-NAME-TBL               PIC X(09) VALUE SPACES.     
                                                                 


regards,
rupesh gupta
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Wed Jul 08, 2009 4:09 pm
Reply with quote

Change the below statement

Quote:
SET IDX UP BY 1


to :

Quote:
SET IDX to 1


and move before search statement.

This will work i think.
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Wed Jul 08, 2009 4:10 pm
Reply with quote

Apologize.

I used quote instead of code.
Back to top
View user's profile Send private message
Binop B

Active User


Joined: 18 Jun 2009
Posts: 407
Location: Nashville, TN

PostPosted: Wed Jul 08, 2009 4:25 pm
Reply with quote

Hi Rupesh,

I am not sure whether this is the cause for ur problem, but whereever you have given PERFORM VARYING BY statement with an index, you are explicitly incrementing the index which is not required.
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Wed Jul 08, 2009 4:38 pm
Reply with quote

Rupesh,

Please post your result.
Back to top
View user's profile Send private message
Mathiv Anan

Active User


Joined: 23 Jul 2008
Posts: 106
Location: USA

PostPosted: Wed Jul 08, 2009 4:43 pm
Reply with quote

Adding to Binop's

Code:
      PERFORM VARYING INDX2 FROM 1 BY 1 UNTIL WS-EOF-MASTER-FILE 
        MOVE WS-NUM-TWO(INDX2)  TO WS-NUM-TBL                     
        MOVE WS-NAME-TWO(INDX2) TO WS-NAME-TBL                   
        ADD +1 TO INDX2                                           
      END-PERFORM   


WS-NUM-TBL and WS-NAME-TBL have no subscripts/indices mentioned.

change it to
Code:
WS-NUM-TBL(INDX2)
WS-NAME-TBL(INDX2)
       
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 4:46 pm
Reply with quote

wtf??????? am i in the wrong forum????????????????????????

within C300-READ-MASTER-FILE
this is your problem:

MOVE WS-NUM-TWO(INDX2) TO WS-NUM-TBL
MOVE WS-NAME-TWO(INDX2) TO WS-NAME-TBL

to the left side of the errors (which you did not bother to provide)
is the line number of the code in error

you have the index on WS-NUM-TWO and NAME instead of WS-NUM-TBL and NAME.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Wed Jul 08, 2009 4:50 pm
Reply with quote

Anan/dbzTHEdinosauer,

I have changed code as
Code:

PERFORM VARYING INDX2 FROM 1 BY 1 UNTIL WS-EOF-MASTER-FILE 
  MOVE WS-NUM-TWO         TO WS-NUM-TBL(INDX2)             
  MOVE WS-NAME-TWO        TO WS-NAME-TBL(INDX2)             
END-PERFORM                                                 


but it still giving the error.

regards,
rupesh gupta
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Jul 08, 2009 4:55 pm
Reply with quote

I've got to echo Dick -- wtf?????????

The error messages are quite sufficient and explanatory to resolve your problem without involving the forum. The variables named in the error messages are arrays, you did not provide a subscript or index value for them, so COBOL assumed you meant the first element. If you have trouble understanding these error messages, perhaps you should reconsider your career choice -- COBOL is telling you everything you need to resolve this one on your own; I shudder to think of you attempting to resolve an issue that requires looking at a dump, or looking at hexadecimal data, or ....
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Jul 08, 2009 4:59 pm
Reply with quote

or just plain looking and thinking:

MASTER-TBL-RECD OCCURS 500 TIMES INDEXED BY IDX.


MOVE WS-NUM-TWO TO WS-NUM-TBL(INDX2)


use the correct index....................

you are lucky that you don't have a second table defined with INDX2.
I can imagine the problem you would have had trying to debug that mess..
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu Jul 23, 2009 12:11 pm
Reply with quote

Hi,

I have removed all hte error and has got the o/p. But my o/p is not coming correct .It is taking only one ocurance of each record.
e.g my input file has following records:
A101
B203
C304

2nd i/p file has:
A101
A101
B203
B203
B203
A101
A101
C304
C304
B203
C304
C304

my o/p
A101
B203
C304

i should get all the records from 2nd file.

2nd file is loaded into interna; table and i am using follwoing code:



Code:

D100-MAIN-PROCESS SECTION.                               
                                                         
    READ SRCH INTO SRCH-RECD AT END                     
      MOVE 'YES' TO WS-SRCH-FILE-SW                     
    NOT AT END                                           
        ADD +1 TO WS-SRCH-READ-CNTR                     
        DISPLAY 'WS-SRCH-READ-CNTR' WS-SRCH-READ-CNTR   
    END-READ.                                           
                                                         
    SET IDX TO 1.                                       
    SEARCH MASTER-TBL-RECD AT END                       
      MOVE 'YES' TO WS-TABLE-SW                         
      GO TO D100-EXIT                                   
     WHEN WS-NUM-ONE  = WS-NUM-TBL(IDX)                 
       MOVE WS-NUM-TBL(IDX)  TO WS-NUM                   
       MOVE WS-NAME-TBL(IDX) TO WS-NAME                 
       SET IDX UP BY 1                                   
       WRITE MATCH-REC FROM MATCH-RECD                   
    END-SEARCH.       
                       
D100-EXIT.EXIT.       

Above para is performed as

PERFORM D100-MAIN-PROCESS UNTIL                 
                                WS-EOF-SRCH-FILE.


please help

regards,
rupesh gupta
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Thu Jul 23, 2009 12:22 pm
Reply with quote

remove this line:
SET IDX UP BY 1
from you search statement, and rtfm.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu Jul 23, 2009 12:48 pm
Reply with quote

Hi Dick,

I tried but its going into onfinite loop.

Regards,
rupesh gupta
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Thu Jul 23, 2009 2:15 pm
Reply with quote

Well this thread is too long to keep the track and 'am late to party, however, please tell me where Do you set WS-EOF-SRCH-FILE?
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu Jul 23, 2009 2:19 pm
Reply with quote

Hi Anuj,

Swich is set at end of file as

Code:

READ SRCH INTO SRCH-RECD AT END                 
  MOVE 'YES' TO WS-SRCH-FILE-SW                 
NOT AT END                                       
    ADD +1 TO WS-SRCH-READ-CNTR                 
    DISPLAY 'WS-SRCH-READ-CNTR' WS-SRCH-READ-CNTR
END-READ.                                       


regards,
rupesh gupta
Back to top
View user's profile Send private message
dick scherrer

Moderator Emeritus


Joined: 23 Nov 2006
Posts: 19244
Location: Inside the Matrix

PostPosted: Thu Jul 23, 2009 8:16 pm
Reply with quote

Hello,

Is there some reason why this problem-ridden approach is being continued after 2 weeks of this wasted effort?

Suggest you make sure both files are in sequence, then use a proper 2-file match/merge. There is a working example of the cobol code to do this in a "Sticky" near the top of the cobol part of the forum.

As has been repeated in several topics, it is almost never a good idea to load an entire file into an array simply to compare it against some other file.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Fri Jul 24, 2009 1:48 pm
Reply with quote

Hi Dick,

Actually there was some other work also in which i was involved so this code took more time.

I have completed the coding today and its working fine.

regards,
rupesh gupta
Back to top
View user's profile Send private message
Anuj Dhawan

Superior Member


Joined: 22 Apr 2006
Posts: 6250
Location: Mumbai, India

PostPosted: Fri Jul 24, 2009 2:47 pm
Reply with quote

Glad to hear -- what's the final code did you implement, please share that for the benefit of others.
Back to top
View user's profile Send private message
rupesh gullu

New User


Joined: 12 Dec 2008
Posts: 96
Location: Gurgaon

PostPosted: Thu Jul 30, 2009 8:21 pm
Reply with quote

Hi all,

Here is code for refernece for which i had raised issue.

Please provide me with any inputs if you have.

Regards,
rupesh gupta
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts Search two or more word with FILEAID Compuware & Other Tools 15
No new posts Sortjoin and Search for a String and ... DFSORT/ICETOOL 1
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts first column truncated in search result IBM Tools 13
No new posts ISRSUPC search utility - using high l... TSO/ISPF 2
Search our Forums:

Back to Top