SAP CASTING IMP EXP ABEXA



Get Example source ABAP code based on a different SAP table
  



Field Symbols, Casting
This example demonstrates how castings are performed when the type is specified implicitly and explicitly.

ABAP_SOURCE_CODE
DEMO CL_DEMO_FLD_SMBLS_CASTING

ABAP_DESCRIPTION
An implicit casting is performed in the first part of the method main. The field symbol < fs1> is completely typed with the local type t_date. The field sy-datum can be handled as a structure using the addition CASTING of the statement ASSIGN. This assignment would not be possible without the CASTING addition, since sy-datum is not compatible with the type of the field symbol.
An explicit casting is performed in the second part of the method main. The field symbol < fs2> is completely generic. A cast is performed to the local type t_date for the field sy-datum using the addition CASTING of the statement ASSIGN. The field symbol < fs2> can now be handled like a structure but does not recognize components. For this reason, it must be assigned to another field symbol < fs3>, component by component.