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: 

Move Corresponding and move statement

koushikking
Explorer
0 Kudos

Hi Experts,

As per i have analysed,  move corresponding is working faster than move statement but in sap forum it is mentioned move statement is faster, so please any one help on this performance wise, as am using move corresponding inside the loop of 600000 records.

23 REPLIES 23

Former Member
0 Kudos

What's your question in detail? If MOVE is faster or MOVE-CORRESPONDING?

0 Kudos

Move corresponding is faster

0 Kudos

In your case, I guess. In general MOVE should be faster because it does not need to find the corresponding fields.

former_member194965
Active Participant
0 Kudos

Hi Koushik,

MOVE: means from move one field to other , and the field names may be different

MOVE-CORRESPONDING means both the field names in both sides are to be same.then only we use this.

      MOve-Corresponding is more convinient than moving fileds individually. but this command takes more CPU time this result in poor performance.




Regards,

E.Ananthachari.

pranay570708
Active Contributor
0 Kudos

Don't use Move-corresponding inside the loop, move each fields separately.

As above mentioned move-corresponding checks field name between two structures to move contents to respective fields. This hampers performance. Using Move will directly transfers the value without bothering about field names.

0 Kudos

But what if you have 20 fields. Then that would be 20 times a move statement. Wouldn't move corresponding be faster (only one statement to do by abap).

I don't know the answer, just a question that pops up reading this discussion.

By the way I almost always use move-corresponding and never had any performance issues . If I have a perfomance issue it is because of other statements. Maybe I am just lucky ?

0 Kudos

Well, I can imagine that 20 single moves are not as good as one move corresponding, because I guess the kernal can execute the single statement quicker than the 20 statements (depending on the huge of the structure). But if there is one move statement against one move corresponding statement, the first should win the race in general.

But to improve the performance the first question should be: Can I avoid the moving (copying)?

0 Kudos

when you need to move maximum fields from one structure to another, then you can go for Move-Corresponding. But only for couple of fields, Move is preferable.

0 Kudos

Pranay Patel wrote:

when you need to move maximum fields from one structure to another, then you can go for Move-Corresponding. But only for couple of fields, Move is preferable.

Where exactly do you get this information from? Can you please enlighten us with the source?

matt
Active Contributor
0 Kudos

Pranay Patel wrote:

...

As above mentioned move-corresponding checks field name between two structures to move contents to respective fields. This hampers performance. Using Move will directly transfers the value without bothering about field names.

Does it? Can you prove it? If it's true for old versions, is it true for newer ones? Really, this is just a subjective opinion. See my post below for how the internals could be optimised.

The OP finds move-corresponding is faster. So long as he's tested correctly, why should we doubt that with unsubstantiated theory?

prad_k
Explorer
0 Kudos

As per i have analysed ??


Could you please tell us how you analysed the statements move and move-corresponding ?



Refer below links


https://help.sap.com/abapdocu_70/en/ABAPMOVE-CORRESPONDING.htm




0 Kudos

Hi Pradeep,

i have used move-corresponding inside the loop and work area contains 16 fields and structure of both work area is same.... it takes less time compare to individual 16 move statements.

Former Member
0 Kudos

Why do you use 16 individual moves, if the structure is the same and you can do it with one move? So, if you want a real comparison between MOVE (or 😃 and MOVE-CORRESPONDING use in both cases one statement.

Former Member
0 Kudos

Move corresponding may be faster but this is risky. This can be used if you are sure that every field name and corresponding data type is correct. Move for me is the safest way.

matt
Active Contributor
0 Kudos

It is safer, but there's a trade-off perhaps of readability. However, in 7.4 onwards you can have the best of both worlds using CORRESPONDING operator with MAPPING.

raphael_almeida
Active Contributor
0 Kudos

But folks... The MOVE is considered obsolete (on SAP_ABA 7.4), instead it should use the equal sign. Of course the user who opened the issue not said component version SAP_ABA he is using, yet I think much better to use the = sign of what to do the MOVE command.


About MOVE-CORRESPONDING (still talking about 7.4), we have other ways of doing, and not think it's bad performance.

Former Member
0 Kudos

Both are pretty efficient memory operations, so I wouldn't worry about performance. If that's your only concern, you're a mighty good troop of ABAPers.

However, from a maintenance perspective I prefer move-corresponding. You can add a field to the structure or table and it is automatically transported in memory (if you design your code well).

Wolfgang

jay_kumar8
Active Participant
0 Kudos

Hi,

Move corresponding is better when you had more fields inside the loop.

Regards

Raj

Former Member
0 Kudos

I'm a little surprised that this is still being asked. Many years ago, we were taught not to use MOVE-CORRESPONDING because it was less efficient for the kernel to analyze and perform. In the intervening time, hardware became much quicker but programming costs increased, so MOVE-CORRESPONDING became much more widely accepted. I don't know if newer releases handle this statement more efficiently or not.

Rob

matt
Active Contributor
0 Kudos

The internals may well be more efficient with all kinds of optimisation. For example, perhaps the interpreter is smart enough to buffer the mapping so it's done only once between two object structures, and the actual moves are done in a single operation, then move-corresponding now may be faster than a bunch of moves.

If the OP has run his tests several times and got the same result that move-correspdoning is faster than move alone, then that's what he's got.

Certainly not something I'd worry about.

0 Kudos

You're right (again) Matt

I ran a small test of a table with 10 fields. MOVE-CORRESPONDING ran in about 56% of the time as 10 MOVEs.

Rob

matt
Active Contributor
0 Kudos

If you find that one particular way is faster than another, then that's what you've found and to heck with theory!

But you need to know you've tested it properly. Run the program five times with move-corresponding and take the average timing of the last four runs. Do the same witih move. Compare results.

If the results are less than 10% difference, then nothing has been demonstrated, and you should do whichever you consider the best programming.

former_member185124
Participant
0 Kudos

This message was moderated.