EVALUATE statement is used for conditional processing which helps in eliminating a series of nested IF statements to test several conditions. The EVALUATE statement is very similar to the CASE construct common in many other programming languages. If none of the EVALUATE satisfies, by default the statements coded under WHEN OTHER will be executed and control transfers to the next executable statement after ending of EVALUATE.
EVALUATE {subject} [ ALSO {subject} ] ... {TRUE } {TRUE } {FALSE } {FALSE } { { WHEN obj-phrase [ ALSO obj-phrase ] ... } ... statement-1 } ... [ WHEN OTHER statement-2 ] [ END-EVALUATE ] Subject has the following format { IDENTIFIER } { LITERAL } { COND EXPRESSION } { ARITH EXPRESSION } Obj-phrase has the following format { ANY } { TRUE } { FALSE } { cond-obj } { [NOT] obj-item [ {THRU } obj-item ]} { {THROUGH} }
EVALAUTE can be divided into below types based on its usage in the program.
Example 1: Simple EVALUATE EVALUATE WS-RENT-APTNO WHEN 1 PERFORM 100-RENT-REPORT WHEN 2 PERFORM 200-RENT-REPORT WHEN OTHER PERFORM 999-ERROR-REPORT END-EVALUATE.
Example 2: EVALUATE TRUE EVALUATE TRUE WHEN WS-RENT-APTNO = 1 AND WS-RENT-BUILDING = A PERFORM 100-RENT-REPORT WHEN WS-RENT-APTNO = 2 AND WS-RENT-BUILDING = A PERFORM 200-RENT-REPORT WHEN OTHER PERFORM 999-ERROR-REPORT END-EVALUATE.
Example 3: EVALUATE with THRU EVALUATE WS-RENT-APTNO WHEN 1 THRU 99 PERFORM 100-RENT-REPORT WHEN 101 THRU 999 PERFORM 200-RENT-REPORT WHEN OTHER PERFORM 999-ERROR-REPORT END-EVALUATE.
Example 4: EVALUATE with multiple WHEN conditions EVALUATE WS-RENT-APTNO WHEN 1 WHEN 2 WHEN 3 PERFORM 100-RENT-REPORT WHEN 4 WHEN 5 WHEN 6 PERFORM 200-RENT-REPORT WHEN OTHER PERFORM 999-ERROR-REPORT END-EVALUATE.
Example 5: EVALUATE with MULTIPLE conditions EVALUATE WS-RENT-APTNO ALSO TRUE WHEN 1 THRU 99 ALSO WS-RENT-BUILDING = "A" PERFORM 100-RENT-REPORT WHEN 101 THRU 999 ALSO WS-RENT-BUILDING = "A" PERFORM 200-RENT-REPORT WHEN OTHER PERFORM 999-ERROR-REPORT END-EVALUATE.
Example 6: EVALUATE with MULTIPLE conditions EVALUATE TRUE ALSO TRUE WHEN WS-RENT-APTNO <= 99 ALSO WS-RENT-BUILDING = "A" PERFORM 100-RENT-REPORT WHEN WS-RENT-APTNO > 99 ALSO WS-RENT-BUILDING = "A" PERFORM 200-RENT-REPORT WHEN OTHER PERFORM 999-ERROR-REPORT END-EVALUATE.
COBOL Blog: Click Here IBM Reference: Click Here
Effective User interviews play a crucial role in Scrum methodology, helping Product Owners and Scrum…
Product Owners should be well-versed in various user research tools and techniques to effectively understand…
Effective Product Owner plays a crucial role in Agile development, acting as the bridge between…
A well-maintained product backlog is crucial for successful product development. It serves as a single…
Incremental value to the customer refers to the gradual delivery of small, functional parts of…
A Product Market refers to the group of potential customers who might be interested in…