Search Table using PERFORM
PERFORM statement you can use when you defined an array with a subscript.
Method-1
PERFORM P200-READ-SALES-FILE.
MOVE '*** NO PART DESCRIPTION' TO RPT-DTL-PART-DESC.
PERFORM VARYING WS-SUB FROM 1 BY 1 UNTIL (WS-SUB > WS-TBL-MAX)
OR (IN-PRT-NBR = PART-NBR (WS-SUB))
IF IN-PRT-NBR = PART-NBR (WS-SUB)
MOVE PART-DESC TO RPT-DTL-PART-DESC
END-IF
END-PERFORM.
Search Table using SEARCH statement
Method-2
You can use SEARCH logic when your Table defined with an index.
PERFORM P200-READ-SALES-FILE.
SET WS-INDX TO 1.
SEARCH PART-TABLE
AT END MOVE '*** NO PART DESCRIPTION' TO RPT-DTL-PART-DESC
WHEN IN-PRT-NBR = PART-NBR (WS-INDX)
MOVE PART-DESC TO RPT-DTL-PART-DESC END-SEARCH.
Related Posts
-
Why DELETE with Subqueries Fails in PySpark SQL (And How to Fix It)
Learn why PySpark SQL DELETE with WHERE IN subquery fails and how to fix it using DELETE USING, Delta tables, and join-based deletes.






