You are on page 1of 10

Using MOVE-CORRESPONDING Myth to Meaningful

Applies to:
All versions of SAP ABAP Editor in which keyword MOVE-CORRESPONDING can be used. For more information, visit the ABAP homepage.

Summary
In all the ABAP code review checklists of the companies I worked so far, it was mentioned not use the keyword MOVE-CORRESPONDING in the program. The reason quoted is bad performance. Output of exploration, whether it (bad performance) is Myth or Meaningful is this article. Author: Ashok Kumar Rajagopal

Company: Steria India Limited. Created on: 27 April 2009.

Author Bio
I am Ashok Kumar Rajagopal, One of the Senior SAP ABAP Consultant in our company Steria India Limited. Currently I am playing the role of Team Leader. I have worked in USA for around 4 years and also worked in client place located in Amsterdam, Netherlands.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 1

Using MOVE-CORRESPONDING - Myth to Meaningful

Table of Contents
Introduction .........................................................................................................................................................3 MOVE-CORRESPONDING: to Use OR Not to Use ......................................................................................3 Test Plan.............................................................................................................................................................4 Test Case 1 70% Assignment Using MOVE-CORRESPONDING ..............................................................6
Case A With MOVE-CORRESPONDING. ................................................................................................................6 Case B Without MOVE-CORRESPONDING. ...........................................................................................................7

Test Case 2 80% Assignment Using MOVE-CORRESPONDING ..............................................................7


Case A With MOVE-CORRESPONDING. ................................................................................................................7 Case B Without MOVE-CORRESPONDING. ...........................................................................................................7

Test Case 3 90% assignment using MOVE-CORRESPONDING. ..............................................................8


Case A With MOVE-CORRESPONDING. ................................................................................................................8 Case B Without MOVE-CORRESPONDING. ...........................................................................................................8

Overall Comparison between Case A & Case B: ...........................................................................................8 Conclusion: .........................................................................................................................................................9 Related Content..................................................................................................................................................9 Disclaimer and Liability Notice..........................................................................................................................10

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 2

Using MOVE-CORRESPONDING - Myth to Meaningful

Introduction
MOVE-CORRESPONDING: to Use OR Not to Use In performance related topics, programming tips, code review checklists etc, MOVE-CORRESPONDING will have one small place for sure. Almost in all the companies I have worked for, in the code review check list, it is strongly recommended not use MOVE-CORRESPONDING. The reason quoted is, MOVECORRESPONDING will result in bad performance when compared to assigning the fields directly Example for Assigning fields directly:
work_area_2-gl_sirid = work_area_2-rldnr = work_area_2-rrcty = work_area_1-gl_sirid. work_area_1-rldnr. work_area_1-rrcty.

Example for using MOVE-CORRESPONDING: MOVE-CORRESPONDING work_area_1 TO work_area_2. Let us go through some detail tests I have done and come to conclusion to use or not to use the MOVECORRESPONDING in the ABAP programs.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 3

Using MOVE-CORRESPONDING - Myth to Meaningful

Test Plan
If MOVE-CORRESPONDING is not used, values to the work area fields are passed through assignment as we saw in the example before. So the ideal way to test the performance of MOVE-CORRESPONDING is comparing its performance with the performance of field assignment. Two programs need to be created. 5,00,000 records are selected from database table GLPCA and loaded in to internal table Internal_Table_1. This Internal table is looped into work area work_area_1.Inside the loop,in program one,MOVECORRESPONDING is used to pass the value in to work area work_area_2 which has additional fields than work_area_1.From this work_area_2,values are appended to internal_table_2.Then no of records in the internal_table_2 is displayed. In another program, instead of MOVE-CORRESPONDING, fields are assigned directly. The ABAP time taken for execution of the report is measured through Runtime Analysis (SE30). *Data Declaration: TYPES:BEGIN OF type_1, gl_sirid TYPE gu_recid, rldnr TYPE rldnr, rrcty TYPE rrcty, rvers TYPE rvers_pca, ryear TYPE gjahr, rtcur TYPE rtcur, runit TYPE meins, drcrk TYPE shkzg, poper TYPE poper, docct TYPE docct, docnr TYPE belnr_d, docln TYPE docln, rbukrs TYPE bukrs, rprctr TYPE prctr, rhoart TYPE hoart, rfarea TYPE fkber, kokrs TYPE kokrs, racct TYPE racct, hrkft TYPE hrkft. TYPES END OF type_1. *Purposely additional fields are placed in the middle of database fields to *increase the complexity. TYPES:BEGIN OF type_2, gl_sirid TYPE gu_recid, rldnr TYPE rldnr, extra_field_1, rrcty TYPE rrcty, rvers TYPE rvers_pca, extra_field_2, ryear TYPE gjahr, rtcur TYPE rtcur, extra_field_3, runit TYPE meins, drcrk TYPE shkzg, extra_field_4, poper TYPE poper, docct TYPE docct, extra_field_5,

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 4

Using MOVE-CORRESPONDING - Myth to Meaningful

docnr TYPE belnr_d, docln TYPE docln, extra_field_6, rbukrs TYPE bukrs, rprctr TYPE prctr, extra_field_7, rhoart TYPE hoart, rfarea TYPE fkber, kokrs TYPE kokrs, racct TYPE racct, hrkft TYPE hrkft. extra_field_8. TYPES END OF type_2. DATA: work_area_1 TYPE internal_table_1 work_area_2 TYPE internal_table_2 type_1, TYPE STANDARD TABLE OF type_1, type_2, TYPE STANDARD TABLE OF type_2.

*Select 500000 records from the GLPCA table. SELECT gl_sirid rldnr rrcty rvers ryear rtcur runit drcrk poper docct docnr docln rbukrs rprctr rhoart rfarea kokrs racct hrkft FROM glpca INTO TABLE internal_table_1 UP TO 500000 ROWS. *Testing using MOVE-CORRESPONDING. LOOP AT internal_table_1 INTO work_area_1. MOVE-CORRESPONDING work_area_1 TO work_area_2. work_area_2-extra_field_1 = 'X'. ........ ........ work_area_2-extra_field_8 = 'X'. APPEND work_area_2 TO internal_table_2. CLEAR work_area_2. ENDLOOP. *Testing using Field assignment. LOOP AT internal_table_1 INTO work_area_1.

work_area_2-gl_sirid = work_area_1-gl_sirid. work_area_2-rldnr = work_area_1-rldnr. work_area_2-rrcty = work_area_1-rrcty. ........ ........

work_area_2 = work_area_1.

APPEND work_area_2 TO internal_table_2. CLEAR work_area_2. ENDLOOP. Three test cases are planned as below for detailed testing.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 5

Using MOVE-CORRESPONDING - Myth to Meaningful

Test Case 1 70% Assignment Using MOVE-CORRESPONDING In this case, only 70% of value assignment is done through MOVE-CORRESPONDING. i.e. In Type_1,only 14 fields are taken and rest of the fields are commented. In Type_2, in addition to the fields similar to Type_1, six extra fields are placed in the middle of database fields. Other fields are commented. So inside the loop, 14 field values of work_area_1 is passed to 20 fields of work_area_2.Which is 70% of assignment. Case A With MOVE-CORRESPONDING. Program one, which uses move-corresponding is executed through Transaction Code SE30 and the ABAP time taken for execution is noted. It is done for three times and average is mentioned here.

Select the Evaluate button and get the measured time. Sample Screen shot:

The Average ABAP time taken for execution is .37 Seconds.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 6

Using MOVE-CORRESPONDING - Myth to Meaningful

Case B Without MOVE-CORRESPONDING. Program Two, which uses direct field assignment, is executed through Transaction Code SE30 and the ABAP time taken for execution is noted. It is done for three times and average is mentioned here. The Average ABAP time taken for execution is .56 Seconds. Comparison between Case A & Case B :

Test Case 2 80% Assignment Using MOVE-CORRESPONDING In this case, only 80% of value assignment is done through MOVE-CORRESPONDING. i.e. In Type_1,only 16 fields are taken and rest of the fields are commented. In Type_2, in addition to the fields similar to Type_1, four extra fields are placed in the middle of database fields. Other fields are commented. So inside the loop, 16 field values of work_area_1 is passed to 20 fields of work_area_2.Which is 80% of assignment. Case A With MOVE-CORRESPONDING. Program one, which uses move-corresponding is executed through Transaction Code SE30 and the ABAP time taken for execution is noted. It is done for three times and average is mentioned here. The Average time taken for execution is .35 Seconds. Case B Without MOVE-CORRESPONDING. Program Two, which uses direct field assignment, is executed through Transaction Code SE30 and the ABAP time taken for execution is noted. It is done for three times and average is mentioned here. The Average time taken for execution is .57 Seconds. Comparison between Case A & Case B:

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 7

Using MOVE-CORRESPONDING - Myth to Meaningful

Test Case 3 90% assignment using MOVE-CORRESPONDING. In this case, only 90% of value assignment is done through MOVE-CORRESPONDING. i.e. In Type_1,only 18 fields are taken and rest of the fields are commented. In Type_2, in addition to the fields similar to Type_1, two extra fields are placed in the middle of database fields. Other fields are commented. So inside the loop, 18 field values of work_area_1 is passed to 20 fields of work_area_2.Which is 90% of assignment. Case A With MOVE-CORRESPONDING. Program one, which uses move-corresponding is executed through Transaction Code SE30 and the ABAP time taken for execution is noted. It is done for three times and average is mentioned here. The Average time taken for execution is .38 Seconds. Case B Without MOVE-CORRESPONDING. Program Two, which uses direct field assignment, is executed through Transaction Code SE30 and the ABAP time taken for execution is noted. It is done for three times and average is mentioned here. The Average time taken for execution is .49 Seconds. Comparison between Case A & Case B:

Overall Comparison between Case A & Case B:

Case A = With MOVE-CORRESPONDING. Case B = Without MOVE-CORRESPONDING.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 8

Using MOVE-CORRESPONDING - Myth to Meaningful

Conclusion:
Testing with 500000 records and with different set of assignment of fields, I see only negligible difference of runtime. That too MOVE-CORRESPONDING is quicker than direct field assignment. So at least for 60% 90% of assignment of fields, I can say that using MOVE-CORRESPONDING will affect performance is a Myth and we can use MOVE-CORRESPONDING without any hesitation.

Related Content
SDN Forum Reference For more information, visit the ABAP homepage.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 9

Using MOVE-CORRESPONDING - Myth to Meaningful

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces and therefore is not supported by SAP. Changes made based on this information are not supported and can be overwritten during an upgrade. SAP will not be held liable for any damages caused by using or misusing the information, code or methods suggested in this document, and anyone using these methods does so at his/her own risk. SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of this technical article or code sample, including any liability resulting from incompatibility between the content within this document and the materials and services offered by SAP. You agree that you will not hold, or seek to hold, SAP responsible or liable with respect to the content of this document.

SAP COMMUNITY NETWORK 2009 SAP AG

SDN - sdn.sap.com | BPX - bpx.sap.com | BOC - boc.sap.com 10

You might also like