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

Copy Objects in OO ABAP.

Former Member
0 Likes
537

Hi,

data: o_pricecond type zpricecond_struct.

data: o_pricemat type zpricematerial_struct.

..some code for filling objects.

I now have 2 different objects .

I want to copy all fields from one object to another.

The field names are the same...

This gives me an error!

o_pricemat = o_pricecond.

If this isn't supported I will have to do like this:

o_pricemat-f1 = o_pricecond-f1.

o_pricemat-f2 = o_pricecond-f2.

o_pricemat-f3 = o_pricecond-f3.

...

o_pricemat-f18 = 'MARTIN'

append o_pricemat to i_price_tab.

That's lots of coding...

//Martin

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
376

Hi Martin,

<b>o_pricecond</b> and <b>o_pricemat</b> seem to be structured variables. Since they are declared with different types, a direct assignment is not possible. You can try using

move-corresponding o_pricecond to o_pricemat.

Regards,

Anand Mandalika.

Hi,

data: o_pricecond type zpricecond_struct.

data: o_pricemat type zpricematerial_struct.

..some code for filling objects.

I now have 2 different objects .

I want to copy all fields from one object to another.

The field names are the same...

This gives me an error!

o_pricemat = o_pricecond.

If this isn't supported I will have to do like this:

o_pricemat-f1 = o_pricecond-f1.

o_pricemat-f2 = o_pricecond-f2.

o_pricemat-f3 = o_pricecond-f3.

...

o_pricemat-f18 = 'MARTIN'

append o_pricemat to i_price_tab.

That's lots of coding...

//Martin

1 REPLY 1
Read only

Former Member
0 Likes
377

Hi Martin,

<b>o_pricecond</b> and <b>o_pricemat</b> seem to be structured variables. Since they are declared with different types, a direct assignment is not possible. You can try using

move-corresponding o_pricecond to o_pricemat.

Regards,

Anand Mandalika.