Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

help required for assignment operators in OO ABAP context

Former Member
0 Kudos

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,

1 ACCEPTED SOLUTION

Former Member
0 Kudos

?= is Wide casting or down cast

Please check this document which would give your more clear idea...

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f2dac69e-0e01-0010-e2b6-81c1e8e5...

4 REPLIES 4

Former Member
0 Kudos

?= is Wide casting or down cast

Please check this document which would give your more clear idea...

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f2dac69e-0e01-0010-e2b6-81c1e8e5...

uwe_schieferstein
Active Contributor
0 Kudos

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

0 Kudos

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:)

narin_nandivada3
Active Contributor
0 Kudos

Hi Harmeet,

The operators are Widening CAST and Narrowing Cast.

Please check this thread related to casting with example and also with explanation

And check these threads too

Hope this would help you.

Good luck

Narin