SAP USING TYPES - Guide
Get Example source ABAP code based on a different SAP table
GUIDELINE 6.5
Using Types
ABAP_BACKGROUND
You can use the data types declared according to the rules on
ABAP_RULE
Use existing types only if they match the semantics of the typed object. You must not select an existing type based only on the technical properties.
ABAP_DETAILS
As long as it extends beyond an elemental ABAP type, the type of a data object or an interface parameter provides the source code reader with information on the semantics of these variables. This makes it easier to recognize the meaning of individual variables.
For this reason, you must use only data types whose semantics match the usage. The technical properties of a type alone do not justify its use in a specific context, as this impedes the readability of the program.
In particular, this applies to the reuse or multiple use of existing types. If you require a data type with specific technical properties for an application, you should not simply use any type with these properties from the ABAP Dictionary. In the past, this has frequently been the chosen procedure. Consequently applying package encapsulation may help prevent the unwanted use of own data types.
Latest notes:
This rule applies especially for the use of structures from the ABAP Dictionary. For example, you should never use a structure defining a database table as a template for input or output fields of classical dynpros or in Web Dynpro. This would violate the
Bad example
In the following source code a variable is declared, whose name and use clearly indicate that it is used for a truth value. The variable is declared with a technically correct, but semantically incorrect, data type.
...
IF is_empty IS INITIAL.
...
ENDIF.
Good example
The following source code shows an improved example compared to the source code above. In this case, the
...
IF is_empty EQ abap_false.
...
ENDIF.