Ansicht
Dokumentation

ABENCONVERSION_ENUMERATED - CONVERSION ENUMERATED

ABENCONVERSION_ENUMERATED - CONVERSION ENUMERATED

Addresses (Business Address Services)   CL_GUI_FRONTEND_SERVICES - Frontend Services  
This documentation is copyright by SAP AG.
SAP E-Book

Conversion Rules for Enumerated Types

An enumerated type is a special elementary data type. Variables of this type are enumerated variables, which can only contain the enumerated values that are defined for the enumerated type. For this reason, source fields and target fields must be fully compatible in assignments between enumerated types, with one exception. The compatibility must apply to the enumerated type itself. The base type of the enumerated type is not relevant.

The only exception to this rule is the assignment of source fields with enumerated types to character-like variables of the types c and string. In this case, the following conversion rule applies:

The name and length of the enumerated constant or the component of the enumerated structure in which the current value of the source field is stored during the definition of the enumerated type, are assigned to the target field in uppercase letters.

This type of conversion to a character-like type can produce unexpected results. This is particularly common in operand positions in which implicit conversions take place. For this reason, a conversion of this type produces a message from the extended program check if it is known statically. This message can be hidden using the pragma ##types.

There is no reverse conversion rule for assignments between character-like source fields and enumerated variables. There is however, a special rule for the conversion operator CONV that enables the actual value of an enumerated object to be read in accordance with its basis type.

Notes

  • The following enumerated objects are possible as operands in assignments between enumerated types:

  • To be compatible, the source field and target field must have exactly the same enumerated type. An enumerated type created using RTTC methods is never identical to a type defined using TYPES. A type description object created for an existing enumerated type using RTTC methods, however, describes this type.
  • Enumerated objects with enumerated types can be listed in all read positions where an implicit conversion to a character-like data type c or string takes place. They cannot be listed in operand positions where the operand must have a character-like data type.
  • When converting to a character-like type, the direct name of the enumerated constant is always used in the context of the declaration with a maximum of 30 characters. It is not prefixed with the name of an enumerated structure with the structure component selector (-), nor with any class name with the class component selector (=>). Therefore, the conversion of enumerated objects of different enumerated types can have the same result if the names of the enumerated constants match.
  • To assign a type-dependent initial value to enumerated variables, the statement CLEAR or a constructor expression VALUE #( ) can be used on the right side of an assignment.

Example

The enumerated values of the enumerated structure p of an enumerated type planet are loaded into an internal table whose line type is the enumerated type. Each line is then converted to the character-like type string and this is added to the internal table planet_names.






ROGBILLS - Synchronize billing plans   Fill RESBD Structure from EBP Component Structure  
This documentation is copyright by SAP AG.

Length: 6153 Date: 20240425 Time: 183639     sap01-206 ( 102 ms )