‎2015 Dec 07 3:37 PM
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
‎2015 Dec 07 3:48 PM
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
‎2015 Dec 07 5:20 PM
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
‎2015 Dec 07 10:19 PM
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
‎2015 Dec 08 11:16 AM
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
‎2015 Dec 08 12:00 PM
if it is just 4 fields why can't you just move them one by one?
‎2015 Dec 08 12:19 PM
I have just give an example.I have more than 100 fields in my table
‎2015 Dec 08 1:54 PM
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
‎2015 Dec 08 2:12 PM
There is no problem with MOVE-CORRESPONDING.
Remember: computer time is cheap. Programmer time is expensive.
Rob
‎2015 Dec 08 2:37 PM
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
‎2015 Dec 09 6:41 AM
I have been told its not an efficient coding way,so I have been asked to avoid it in my project
‎2015 Dec 09 7:08 AM
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.
‎2015 Dec 09 9:21 AM
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.