ARTIClE
Determining Elementary Data Types
This example demonstrates how the characteristics of elementary data
types can be determined during runtime.
ABAP_SOURCE_CODE
ABAP_EXEC
ABAP_DESCRIPTION
This example implements a type check that will only allow assignments to
be made if the source and target fields have the same type.
Using the two input fields type1 and type2 , the names of
elementary data types are entered. First an attempt is made, using the
CREATE DATA statement, to dynamically create anonymous data
objects of the types specified. If this does not work, an error message
is displayed.
The generated data objects are assigned to the field symbols
<(><<)>
data1 and data2 .The DESCRIBE FIELD statement
is then used to determine the type of the dynamically created data
object. Only in the case of both data objects having the same type is
data1 assigned to data2 .
The example will not work if you enter complex data types such as
SCARR and SPFLI into the input fields. In this case
DESCRIBE FIELD , ("u" in Unicode or "C" in non-Unicode programs)
declares the same type, which can cause runtime errors, if the
structures are not convertible.
Use the RTTS methods to check complex data types
and object types during runtime.
Documentation extract taken from SAP system, � Copyright SAP AG. All rights reserved