Application Development and Automation 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: 
Read only

?=

0 Likes
286

what is functionality of ?= in the below statement....

LOOP AT lt_relations INTO li_relation.

ls_agent-agent ?= cl_obl_interface_factory=>binrel_agent(

ii_relation = li_relation ).

ls_agent-binrel = li_relation.

COLLECT ls_agent INTO lt_agent.

ENDLOOP.

plz help me.

Thanks,

Regards.

2 REPLIES 2
Read only

uwe_schieferstein
Active Contributor
0 Likes
250

Hello

'?=' is the casting from one reference type to another.

Method CL_OBL_INTERFACE_FACTORY=>BINREL_AGENT returns the most generic reference type, i.e. OBJECT.

Using ?= this generic object is casted into the more specific object type of ls_agent-agent (presumably CL_BINARY_RELATION).

Regards

Uwe

Read only

Former Member
0 Likes
250

Hi,

Go through the below sample code to understand about casting...

REPORT Z_ABAPOBJECTS_CAST.

----


  • CLASS C1 DEFINITION

----


*

----


CLASS C1 DEFINITION.

PUBLIC SECTION.

data: var1 type ref to object.

METHODS: METH1.

ENDCLASS. "C1 DEFINITION

----


  • CLASS C1 IMPLEMENTATION

----


*

----


CLASS C1 IMPLEMENTATION.

METHOD METH1.

WRITE: / 'This is a method one'.

ENDMETHOD. "METH1

ENDCLASS. "C1 IMPLEMENTATION

----


  • CLASS C2 DEFINITION

----


*

----


CLASS C2 DEFINITION inheriting from c1.

PUBLIC SECTION.

METHODS: METH2.

ENDCLASS. "C2 DEFINITION

----


  • CLASS C2 IMPLEMENTATION

----


*

----


CLASS C2 IMPLEMENTATION.

METHOD METH2.

WRITE: / 'This is a method two'.

ENDMETHOD. "METH2

ENDCLASS. "C2 IMPLEMENTATION

START-OF-SELECTION.

DATA REF1 TYPE REF TO C1.

DATA REF2 TYPE REF TO C2.

DATA REF3 TYPE REF TO C2.

CREATE OBJECT REF2.

ref1 = ref2.

ref3 ?= ref1.

Regards,

Azaz Ali.