Get Example source ABAP code based on a different SAP table
Assignments Between Data Reference Variables Data reference variables are either completely typed or typed with the generic type data>. ITOC
Upcasts in Data References An upcast> in data references is possible in the following cases:
The static types of the source variable and the target variable match according to the following rules:
Both are elementary data types with identical technical type properties>, namely the built-in ABAP type, length, and number of decimal places. It is not important how the static types were defined.
Both have an identical structured type. In the case of structured types, identical technical type properties are not sufficient, but the same structured type must have been used to define the static types.
Both are table types with matching technical type properties, that is, line types, table category, and table key. In the case of non-structured line types, identical technical properties of the line type are sufficient. In the case of structured line types, both definitions must have been made with reference to the same structured type.
The static type of the source variable is completely typed, and the static type of the target variable is generic.
Latest notes: With respect to checks on static types, structured types behave like classes. Two differently structured types do not match, even if they consist of identical components. NON_V5_HINTS ABAP_HINT_END
Downcasts in Data References A downcast> in data references is only possible if the static type of the source variable is generic and that of the target variable is completely typed. The syntax check makes it impossible for static types of the source variable and the target variable to be completely typed, but not identical at the same time.
ABAP_EXAMPLE_VX5 The assignment from dref1> to dref2> is an upcast. The assignment from dref2> to dref1> is a downcast, which in the example below raises an exception. If the statement CREATE DATA>> had the addition TYPE i >, the downcast would also have been successful. ABEXA 00917 ABAP_EXAMPLE_END