View previous topic :: View next topic
|
Author |
Message |
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
Please post the table declaration part. |
|
Back to top |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
Change the below statement
to :
and move before search statement.
This will work i think. |
|
Back to top |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
Apologize.
I used quote instead of code. |
|
Back to top |
|
|
Binop B
Active User
Joined: 18 Jun 2009 Posts: 407 Location: Nashville, TN
|
|
|
|
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 |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
Rupesh,
Please post your result. |
|
Back to top |
|
|
Mathiv Anan
Active User
Joined: 23 Jul 2008 Posts: 106 Location: USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
dbzTHEdinosauer
Global Moderator
Joined: 20 Oct 2006 Posts: 6966 Location: porcelain throne
|
|
|
|
remove this line:
SET IDX UP BY 1
from you search statement, and rtfm. |
|
Back to top |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
Hi Dick,
I tried but its going into onfinite loop.
Regards,
rupesh gupta |
|
Back to top |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
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 |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
Anuj Dhawan
Superior Member
Joined: 22 Apr 2006 Posts: 6250 Location: Mumbai, India
|
|
|
|
Glad to hear -- what's the final code did you implement, please share that for the benefit of others. |
|
Back to top |
|
|
rupesh gullu
New User
Joined: 12 Dec 2008 Posts: 96 Location: Gurgaon
|
|
|
|
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 |
|
|
|