Validating numeric fields in cobol
You can use a construct such as EVALUATE LIFE WHEN TRUE ... END-EVALUATE Of course, this simple example would be better simply done as an IF.However, in more complex evaluations, it can be of use.004430 004310 004320 EVALUATE TRUE 004330 WHEN PLANET-NAME = "Mercury" MOVE 1 TO PLANET-NUMBER 004340 WHEN PLANET-NAME = "Venus " MOVE 2 TO PLANET-NUMBER 004350 WHEN PLANET-NAME = "Earth " MOVE 3 TO PLANET-NUMBER 004360 WHEN PLANET-NAME = "Mars " MOVE 4 TO PLANET-NUMBER 004370 WHEN PLANET-NAME = "Jupiter" MOVE 5 TO PLANET-NUMBER 004380 WHEN PLANET-NAME = "Saturn " MOVE 6 TO PLANET-NUMBER 004390 WHEN PLANET-NAME = "Uranus " MOVE 7 TO PLANET-NUMBER 004400 WHEN PLANET-NAME = "Neptune" MOVE 8 TO PLANET-NUMBER 004410 WHEN PLANET-NAME = "Pluto " MOVE 9 TO PLANET-NUMBER 004420 WHEN OTHER MOVE 0 TO PLANET-NUMBER 004420 END-EVALUATE. WHEN OTHER PERFORM UNKNOWN-CLAIM-TYPE END-EVALUATE As far as indentation, etc are concerned, I would actually write it as above if it were a fairly simple case-structure like this with a single action to be taken in each case.004430 I would have to disagree with the poster regarding 88-levels in an EVALUATE. For anything more complex, indentation similar to that described already is the way to go.
The base-10 (decimal) numbers 0 to 9 are defined for zoned-decimal fields in hex as F0-F9, respectively. For this byte only, the zone portion can be either a C or F for positive values and a D for negative.If the number 123 is stored in a “5p 0” field, the hex value is 00123F or 00123C.Valid values for all zones and digits must be in the range 0-9, except for the last digit which must be F or C for positive values or D for negative.This puts the statement(s) to be performed in the same column in which they would have been if the old IF-construct had been used. You can't use 88-levels in a WHEN statement unless you're saying something like EVALUATE TRUE WHEN LIFE. The EVALUATE VALUE(1:6) worked fine for me, except I added single quotes around the 1 and the 2.
For example, a “7p 2” field is stored in (7 1) / 2 = 4 bytes.