cancel
Showing results for 
Search instead for 
Did you mean: 

Overwrite Object Instance or all Attributes of it

michael_koch9
Active Participant
0 Kudos

Hello,

i have an question regarding ABAP OO,

i like to do following:

1) i like to give the reference me into a attribute of an local object.

2) edit attributes of this object

3) overwrite attributes of me with changed on of the atrribute of the local attribute

Step 1 and 2 is no problem,

but when i tried it like this.

me = lo_test->test.

i get the message that "me" is not overwriteable,

sure i can make it by every attribute of my class:

me->test1 = lo_test->test->test1.

me->test2 = lo_test->test->test2.

...

but i want a dynamic why to overwrite all attributes.

Thank you for any idea!

Regards

Marcus

View Entire Topic
christian_wohlfahrt
Active Contributor
0 Kudos

Hi Marcus!

'me' (or 'lo_test') are pointer to an object. In case of attributes handling looks similar to a structure with their fields, but you discover the main difference: the structure name is just the head for all components - but 'me' is not a pointer to a (structured) field string.

You have to handle the attribute level (or make your assignments in a method). Maybe you can get a more dynamic access by using one structure with all values as single attribute.

Regards,

Christian

michael_koch9
Active Participant
0 Kudos

Hi Christian,

thank you for your answer.

My Problem is i have an existing object with ~ 80 Attributes which are already implemented - so it would by a lot of effort and testing for me to rewrite all attributes to a structure.

But it is the right way, is there maybe a generic structure of the me instance to do right this lik me->all_attributes. I´ve even neaver heared about, but maybe???

Regards Marcus

michael_koch9
Active Participant
0 Kudos

Hello,

i found an answer for my problem!:

there is no problem, because it is not necessary to overwrite the me reference. while i transfer the sam instance of the object only in a new reference both object variables refer to same object instance and therefor changes have not to be transfered between them.

Thanks anyway for our assistance in this case.

regards marcus