2-Enumeration in ABAP 7.51

lightEnumeration -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.


1


OUTPUT:

2


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.

3


 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s