Evaluate is like a case statement and can be used to replace nested Ifs. The difference between EVALUATE and case is that no 'break' is required for EVALUATE i.e. control comes out of the EVALUATE as soon as one match is made.
General Syntax: EVALUATE subject-1 (ALSO subject2..) WHEN object-1 (ALSO object2..) WHEN object-3 (ALSO object4..) WHEN OTHER imperative statement END-EVALUATE 1.Number of Subjects in EVALUATE clause should be equal to number of objects in every WHEN clause. 2.Subject can be variable, expression or the keyword TRUE/ FLASE and respectively objects can be values, TRUE/FALSE or any condition. 3.If none of the WHEN condition is satisfied, then WHEN OTHER path will be executed.
EVALUATE &n bsp; EVALUATE SQLCODE ALSO FILE-STATUS WHEN A=B AND C=D WHEN 100 ALSO '00' imperative stmt &n bsp; imperative stmt WHEN (D+X)/Y = 4   ; WHEN -305 ALSO '32' imperative stmt &n bsp; imperative stmt WHEN OTHER & nbsp; WHEN OTHER imperative stmt &n bsp; imperative stmt END-EVALUATE &nbs p; END-EVALUATE
EVALUATE SQLCODE ALSO A=B EVALUATE SQLCODE ALSO TRUE WHEN 100 ALSO TRUE WHEN 100 ALSO A=B imperative stmt &n bsp; imperative stmt WHEN -305 ALSO FALSE WHEN -305 ALSO (A/C=4) imperative stmt &n bsp; imperative stmt END-EVALUATE &nbs p; END-EVALUATE