Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Casting Help


i learn OO and maybe someone can explain me

what is the action in bold is doing ?

r_cargo ?= r_plane.


DATA: r_cargo TYPE REF TO lcl_cargo_plane.

DATA: r_plane TYPE REF TO lcl_airplane.

LOOP AT airplane_list INTO r_plane.


r_cargo ?= r_plane.

cargo = r_cargo->get_cargo( ).

IF re_cargo < cargo.

re_cargo = cargo.


CATCH cx_sy_move_cast_error INTO r_exc.


Former Member
Former Member replied


As CL_ABAP_TYPEDESCR is an Abstract class having the static method as DESCRIBE_BY_DATA.

and its RETURNING parameter is typed as a reference to this superclass. since the actual parameter

gx_table is typed on the subclass CL_ABAP_STRUCTDESCR, so the object has to be assigned using

Widening Cast with operator ?= .

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

Hope this would help you.

Good luck


0 View this answer in context

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question