This post is useful for COBOL developers. When you compare Numeric to Alpha-numeric, both behave differently. This post explains it with examples.
1. Evaluate Logic
01 MONTH_NUM pic 9(01) value 1. Evaluate MONTH_NUM WHEN ‘1’ Perform Jan-section WHEN other Perform None-section.
When you execute the above logic, the flow goes to WHEN OTHER. The reason is it checks for exact values (Numeric). Also, the Evaluate does not convert to Unicode. That means Numeric and Alphanumeric values mismatched.
2. IF Logic
IF month_num = ‘01’ Perform Jan-section Else Perform None-section End-if.
When you execute the above logic. It converts, both numeric and alpha to Unicode, and will Perform Jan-section.
To find the difference between IF and Evaluate and use it in your programs correctly.