Enumeration -Part2
It is possible to define data objects by referring to the enumeration types and also making the assignment. The post shows the declaration of enumeration data object and its possible assignment.
CODE:
* Enumeration- Available from 7.51 release .Its a combination of types & constants
TYPES: BEGIN OF ENUM t_vowels,
letter_a, ” enumeration constant
letter_e, ” enumeration constant
letter_i, ” enumeration constant
letter_o, ” enumeration constant
letter_u, ” enumeration constant
END OF ENUM t_vowels.
WRITE:/ letter_a,
/ letter_e,
/ letter_i,
/ letter_o,
/ letter_u.
ULINE.
DATA: lv_vowel TYPE t_vowels. ” enumerated data object
lv_vowel = letter_i. ” Make assignment
WRITE:/ lv_vowel.
lv_vowel = letter_u. ” Make assignment
WRITE:/ lv_vowel.
OUTPUT:
An enumerated data object can’t be assigned to any other value except the set of values defined in the enumerated types. When assigned a compile time error occurs.