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

How to avoid Move Corresponding

Former Member
0 Likes
3,761

Hi All,

I have used Move-Corresponding in my code,which I want to avoid. Logic I have used is as follow:

I have 2  tables, table A and Table B.Now if there are 10 fields in table A ,then in table B there are those same 10 and 4 more fields.

After populating table A,I pass the values of those 10 fields to table B and update the value of the rest 4.

Code:

loop at <table A> into <wa_A>

     MOVE-CORRESPONDING <wa_A> to <wa_B>

    

        <WA_B>-field1 = <>.

         <WA_B>-field2 = <>.

         <WA_B>-field3 = <>.

         <WA_B>-field4 = <>.

          APPEND <wa_B> to <Table B>

ENDLOOP.

Please tell me a more efficient way of doing this.I want to avoid using Move Corresponding

Regards

12 REPLIES 12
Read only

roberto_forti
Contributor
0 Likes
2,350

Hi Tanushree,

That sample not is a problem.

Following the link about move-corresponding.


http://help.sap.com/saphelp_46c/helpdata/en/34/8e732a6df74873e10000009b38f9b8/frameset.htm

Regards

Read only

Former Member
0 Likes
2,350

What is the issue with "MOVE-CORRESPONDING"?

Or if you know the sequence of the fields will also be same you can ASSIGN COMPONENT

Or you can individually get the NAMES of the internal table A and B and use ASSIGN (V_NAME) to <f1> and <f2> respectively and then <f2> = <f1> or just simply pass field by field without field symbols. But this would require more effort and the difference may not be that "efficient" also.

R

Read only

Former Member
0 Likes
2,350

Does all the fields in table A are character type? And the 10 fields in table B are in the same sequence as table A? If yes, then you could do the following.

loop at table_A into wa_A.

   wa_B = wa_A.

  wa_B-field1 = ...

  wa_B-field2 = ...

  wa_B-field3 = ...

  wa_B-field4 = ...

append wa_B to table_B.

endloop.

-Chandra

Read only

Former Member
0 Likes
2,350

Thanks everyone for the reply.

Actually one of my structure is of standard type pa0002 and other is a z type with 4 custome fields.

The 4 custom fields are also the primary key,so the order is different.

for eg:

struc A:

1

2

3

4

STRUC B:

1

2

a

b

c

3

4

d

Therefore I am using Move corresponding which is not that good performance wise.

Regards

Read only

0 Likes
2,350

if it is just 4 fields why can't you just move them one by one?

Read only

0 Likes
2,350

I have  just give an example.I have more than 100 fields in my table

Read only

0 Likes
2,350

Ok fair enough.

I don't know why people say MOVE-CORRESPONDING is inefficient. As per me it is quite efficient in certain cases wher you just change the structures and it starts working. If MOVE-CORRESPONDING is inefficient then most of the middleware framework mainly CRM/ SRM middleware is inefficient as SAP uses it in lot of places .

If you still don't like it, did try for some logic using field symbols as I explained in my first post?

R

Read only

0 Likes
2,350

There is no problem with MOVE-CORRESPONDING.

Remember: computer time is cheap. Programmer time is expensive.

Rob

Read only

former_member184158
Active Contributor
0 Likes
2,350

Hi

I can not understand what is the problem of MOVE-CORRESPONDING

we can not live without MOVE-CORRESPONDING,

but suppose that if you have table1 ---> 30 fields

and table 2 has ---> 50  fields

intersection 5 fields, then you have to use field symobi for these 5 fields.

give me only one reason that you don't want to use MOVE-CORRESPONDING??

Regards

Ebrahim

Read only

0 Likes
2,350

I have been told its not an efficient coding way,so I have been asked to avoid it in my project

Read only

0 Likes
2,350

Hi tanushree,

this is your opinion, any how, just try to use field symbol, I am really curious if there is a nother alternative for Move Corresponding.

Read only

0 Likes
2,350

There is no alternative. There is no performance issue with move-corresponding. The OP has been wrongly informed. I can't see the point in this discussion continuing, so I am locking the thread.