‎2011 Feb 16 11:30 AM
Hi folks,
I'd like to know, if there is a way to clone any object in ABAP? Using implemented interface method if_os_clone~clone is nice, but doesn't help me, because it works only for classes that have implemented corresponding interface. For example it doesn't help me to clone objects of class 'TYPE REF TO DATA'.
‎2011 Feb 16 9:06 PM
TYPE REF TO DATA isn't a class. So I don't understand what you're trying to achieve.
matt
‎2011 Feb 17 6:21 AM
You're right, 'TYPE REF TO DATA' isn't a class. Forget this point!
DATA:
object1 TYPE REF TO YCLASS,
object2 TYPE REF TO YCLASS.
CREATE OBJECT object1.
object2 = object1.
In this example object1 and object2 reference to the same instance. But I want to create a copy of object1, so that there are two separate instances of class YCLASS.
‎2011 Feb 17 6:27 AM
Unless the class has the clone interface implemented (or contains a method for the same purpose), there is no general way of cloning an object.
This is a common feature of object oriented languages.