Hello,
I am fairly new to COBOL programming and I am running into a bit of a coding block.
Currently I am coding a program that searches fields in a large array. The problem I am running into is the array I am searching has multiple records that need to be reported out. Currently the only way I can figure out how to code the application is it will find only first record, report the field, and that’s it. I need to fix this search so it will search the array entirely and report all the correct fields. I have tried coding this program with a SEARCH ALL statement and that didn’t work. Please let me know if you can help me out. Thank you!
Here is the current code. Please let me know if you need more
PERFORM 4100-HLQ-CNTL
UNTIL SEARCH-SUB > ARRAY-STOP.
4100-HLQ-CNTL.
ADD 1 TO SEARCH-SUB.
MOVE ABM-HLQ(SEARCH-SUB) TO HLQ-SEARCH.
PERFORM 4200-JOB-COST-TABLE-SEARCH.
4200-JOB-COST-TABLE-SEARCH.
* SEARCH JOB ARRAY WITH HLQ8 SEARCH
SET COSTS-INDEX TO 1.
SEARCH REGDB-COSTS
AT END PERFORM 4300-JOB-COST-TABLE-SRCH-HLQ4
WHEN JOB-NAME(COSTS-INDEX)(1:8) =
HLQ-SEARCH(1:8)
PERFORM 5000-MATCH-FOUND
END-SEARCH.
4300-JOB-COST-TABLE-SRCH-HLQ4.
HLQ-SEARCH (variable for this example)
HLQ
ABCDEFGH
JOB-NAME (variables in the array to be searched)
000100 ABCDEFGH|
000200 ABCDEFGH|
000300 ABCDEFGH|
000400 ABCDEFGH|
000500 ABCDEFGH|
Current output (note that only the first and only field is being reported)
HLQ
--------
ABCDEFGH
Desired Output (note that all 5 Job names are reported)
HLQ
--------
ABCDEFGH
ABCDEFGH
ABCDEFGH
ABCDEFGH
ABCDEFGH
I am fairly new to COBOL programming and I am running into a bit of a coding block.
Currently I am coding a program that searches fields in a large array. The problem I am running into is the array I am searching has multiple records that need to be reported out. Currently the only way I can figure out how to code the application is it will find only first record, report the field, and that’s it. I need to fix this search so it will search the array entirely and report all the correct fields. I have tried coding this program with a SEARCH ALL statement and that didn’t work. Please let me know if you can help me out. Thank you!
Here is the current code. Please let me know if you need more
PERFORM 4100-HLQ-CNTL
UNTIL SEARCH-SUB > ARRAY-STOP.
4100-HLQ-CNTL.
ADD 1 TO SEARCH-SUB.
MOVE ABM-HLQ(SEARCH-SUB) TO HLQ-SEARCH.
PERFORM 4200-JOB-COST-TABLE-SEARCH.
4200-JOB-COST-TABLE-SEARCH.
* SEARCH JOB ARRAY WITH HLQ8 SEARCH
SET COSTS-INDEX TO 1.
SEARCH REGDB-COSTS
AT END PERFORM 4300-JOB-COST-TABLE-SRCH-HLQ4
WHEN JOB-NAME(COSTS-INDEX)(1:8) =
HLQ-SEARCH(1:8)
PERFORM 5000-MATCH-FOUND
END-SEARCH.
4300-JOB-COST-TABLE-SRCH-HLQ4.
HLQ-SEARCH (variable for this example)
HLQ
ABCDEFGH
JOB-NAME (variables in the array to be searched)
000100 ABCDEFGH|
000200 ABCDEFGH|
000300 ABCDEFGH|
000400 ABCDEFGH|
000500 ABCDEFGH|
Current output (note that only the first and only field is being reported)
HLQ
--------
ABCDEFGH
Desired Output (note that all 5 Job names are reported)
HLQ
--------
ABCDEFGH
ABCDEFGH
ABCDEFGH
ABCDEFGH
ABCDEFGH