2008 Oct 09 12:01 PM
Hi Friends,
I would like to understand the usage of assignment operators in OO ABAP such as:
lit_table_desc ?= cl_abap_typedescr=>describe_by_name( p_source ).
ASSIGN wa_source_->_* TO <source_wa>.
Kindly let me know what is the significance and usage of these and any link where I can find documentation for these.
Thanks-
Harmeet Singh,
2008 Oct 09 12:04 PM
?= is Wide casting or down cast
Please check this document which would give your more clear idea...
2008 Oct 09 12:04 PM
?= is Wide casting or down cast
Please check this document which would give your more clear idea...
2008 Oct 09 12:12 PM
Hello Harmeet
P_SOURCE is an itab.
Method cl_abap_typedescr=>describe_by_name returns a reference variable of TYPE REF TO cl_abap_typedescr of which CL_ABAP_TABLEDESCR (lit_table_desc) is a subclass:
CL_ABAP_TYPEDESCR
CL_ABAP_DATADESCR
CL_ABAP_TABLEDESCR
Thus, we have a narrowing casting (down casting):
lit_table_desc ?= cl_abap_typedescr=>describe_by_name( p_source ).
WA_SOURCE contains a DATA reference presumably to a line of the itab which can be de-referenced to dynamically create the structure:
DATA: wa_source TYPE REF TO data.
FIELD-SYMBOS: <wa_source> TYPE any.
GET REFERENCE OF p_source INTO wa_source.
ASSIGN wa_source->* TO <wa_source>.
Regards
Uwe
2008 Oct 13 9:33 AM
Method cl_abap_typedescr=>describe_by_name returns a reference variable of TYPE REF TO cl_abap_typedescr of which CL_ABAP_TABLEDESCR (lit_table_desc) is a subclass:
CL_ABAP_TYPEDESCR
o CL_ABAP_DATADESCR
+ CL_ABAP_TABLEDESCR
Thus, we have a narrowing casting (down casting):
lit_table_desc ?= cl_abap_typedescr=>describe_by_name( p_source ).
Uwe, isn't it a widenning cast? We change from more general view to more specialized, thus it is a widdening, although called down cast:)
2008 Oct 13 8:47 AM