‎2007 Sep 27 8:07 AM
Hi,
I have a part of code:
l_oref_structure ?= cl_abap_typedescr=>describe_by_data(
data_table ).
PERFORM build_field_table TABLES data_fields_table
USING l_oref_structure.
Could someone explain me what this code is responsible for?
What mean " ?= " ?
Regards,
Joanna
‎2007 Sep 27 8:22 AM
Look at <a href="http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCABA/BCABA.pdf">ABAP Programming (BC-ABA)</a>
<b>Assignment Using Interface References - Casting</b>
Like class references, you can assign interface references to different reference variables. You can also make assignments between class reference variables and interface reference variables.
When you use the MOVE statement or the assignment operator (=) to assign reference variables, the system must be able to recognize in the syntax check whether an assignment is possible.
Suppose we have a class reference <cref> and interface references <iref>, <iref1>, and <iref2>.
The following assignments with interface references can be checked statically:
<iref1> = <iref2>
Both interface references must refer to the same interface, or the interface of <iref1>
must contain the interface <iref2> as a component.
<iref> = <cref>
The class of the class reference <cref> must implement the interface of the interface
reference <iref>.
<cref> = <iref>
The class of <cref> must be the predefined empty class OBJECT.
In all other cases, you would have to work with the statement MOVE ...? TO or the casting
operator (?=). The casting operator replaces the assignment operator (=). In the MOVE... ? TO
statement, or when you use the casting operator, there is no static type check. Instead, the
system checks at runtime whether the object reference in the source variable points to an object
to which the object reference in the target variable can also point. If the assignment is possible,
the system makes it, otherwise, the catchable runtime error MOVE_CAST_ERROR occurs.
You must always use casting for assigning an interface reference to a class reference if <cref>
does not refer to the predefined empty class OBJECT:
<cref> ?= <iref>For the casting to be successful, the object to which <iref> points must be an object of the same class as the type of the class variable <cref>.
Regards
‎2007 Sep 27 8:38 AM
It is used when you are assigning the super class object to a sub class object, known as down cast in OO ABAP
‎2007 Sep 27 9:57 AM
This program show data in excel layout in ALV but sometimes there is problem that not all data is shown, do you know what is reason of it?
‎2007 Sep 27 8:44 AM
Hi...
?: is used for Widening Cast as an Operator.
i.e when you are assigning the Super class instance to Subclass reference.
reward if Helpful.