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: 

Alternative to SYSTEM-CALL OBJMGR CLONE me TO result

ennowulff
Active Contributor
0 Kudos

Hey there!

I use the interface IF_OS_CLONE and this system call to clone object references:

"Returning VALUE(result) TYPE REF TO object
SYSTEM-CALL OBJMGR CLONE me TO result.

Code inspector tells me to use a kernel method instead:

If this is true, what could the kernel method be?

thanks

Enno

4 REPLIES 4

Sandra_Rossi
Active Contributor

What is it for? What is the exact use case? The only official way to clone I know is IF_SERIALIZABLE_OBJECT, i.e. the class must allow it, you shouldn't be allowed otherwise.

ennowulff
Active Contributor
0 Kudos

Hey sandra.rossi The use case is that I have a data object and I clone it to compare data after editing the original object.

What do you mean by IF_SERIALIZABLE_OBJECT? what is the procedure? serialize original object, create a new object and deserialize? like this:

CLASS test DEFINITION.
PUBLIC SECTION.
INTERFACES if_serializable_object.
DATA one TYPE string.
DATA two TYPE string.
ENDCLASS.

START-OF-SELECTION.

data(obj) = new test( ).

obj->one = 'AAAA'.
obj->two = 'BBBBB'.

CALL TRANSFORMATION id
SOURCE model = obj
RESULT XML data(ser).

data(new) = new test( ).

CALL TRANSFORMATION id
SOURCE XML ser
RESULT model = new.

how do you know this is the "official" way?

Sandra_Rossi
Active Contributor
0 Kudos

IF_SERIALIZABLE_OBJECT is in the ABAP documentation, so it's official.

Of course, it's stupid to use it just to know if the object has been changed.

If you have a Z class, you may handle the changes the hard way.

If I'm not wrong, persistence classes have an event CHANGED, but you need to rewrite your Z class.

I don't know anything else...

ennowulff
Active Contributor
0 Kudos

sandra.rossi of course the serializable interface is officially documented. but not for the official purpose of cloning objects.

I didn't say I use the copied reference to see _if_ something has changed, but rather to identify the real changes (-> change documents). So I wouldn't call this stupid.

Nevertheless your hint using serialization is a good one. I'll keep in mind for next use of cloning objects.

Thanks!