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

move n move corresponding

Former Member
0 Likes
761

frends please provide me the detail document and scenarios where we use with examples about move and move corresponding statements?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
733

DATA: BEGIN OF wa_tab1,

fld1(4) VALUE ’FLD1’,

fld2(4) VALUE ’FLD2’,

fld3(4) VALUE ’FLD3’,

fld4(4) VALUE ’FLD4’,

fld5(4) VALUE ’FLD5’,

END OF wa_tab1,

BEGIN OF wa_tab2,

fld1(4),

fld2(4),

fld3(4),

fld4(4),

END OF wa_tab2.

                          • Move Corresponding *************

MOVE-CORRESPONDING wa_tab1 to wa_tab2.

                        • End Move Corresponding ******************************

                                        • Move*******************

MOVE: wa_tab1-fld1 to wa_tab2-fld1,

wa_tab1-fld2 to wa_tab2-fld2,

wa_tab1-fld3 to wa_tab2-fld3,

wa_tab1-fld4 to wa_tab2-fld4.

                                    • End Move ******************

In above example, the result of MOVE and MOVE-CORRESPONDING is same. MOVE-CORRESPONDING is look like easy to coding but MOVE statement have performance better than MOVE-CORRESPONDING because when you apply MOVE-CORRESPONDING CPU usage of system will be increased.

6 REPLIES 6
Read only

Former Member
0 Likes
733

Hi,

Please check this.

Assigning Values with MOVE:

To assign the value of a data object source to a variable destination, use the following statement:

MOVE source TO destination.

or the equivalent statement

destination = source.

The content of source remains unchanged, source does not therefore have to be a variable - it can also be a literal, a text symbol, or a constant. You must always specify decimal points with a period (.), regardless of the user’s personal settings.

Multiple assignments

f4 = f3 = f2 = f1.

are also possible. ABAP processes them from right to left as follows:

MOVE f1 TO f2.

MOVE f2 TO f3.

MOVE f3 TO f4.

Assigning Values Between Components of Structures (MOVE-CORRESPONDING):

The rules for value assignments between data objects also apply to structures. With the command

DATA: struct1 TYPE structure,

struct2 TYPE structure.

struct1 = struct2.

two structures of the same type can be assigned to one another without difficulty. Here, the entire source structure is seen as a unit and copied to the source structure. It is then possible to access the components individually again. If the structures in question are not compatible, see the conversion rules for structures.

In practice, however, you will often only need to assign certain components of a structure to be certain components of another structure. ABAP has a special statement for this purpose:

MOVE-CORRESPONDING sourcestruct TO destinationstruct.

This statement assigns the contents of the components of structure sourcestruct to the components of the destinationstruct structure that have identical names.

When it is executed, it is broken down into a set of MOVEstatements, one for each pair of fields with identical names, as follows:

MOVE sourcestruct-comp1 TO destinationstruct-comp1.

MOVE sourcestruct-comp2 TO destinationstruct-comp2.

Regards,

Ferry Lianto

Read only

Former Member
0 Likes
733

Hi,

You use move command to assing data from one variable to another.

<b>Example.</b>

DATA: var1 TYPE c VAULE 'A',
      var2 TYPE c.

MOVE var1 to var2.

You use moe-corresponding to move the data from one structure where the definition of both the strucutre are not same.

<b>Example.</b>

DATA: BEGIN OF lst_struct1,
             field1,
             field2,
             field3,
             field4,
           END OF lst_struct1.

DATA: BEGIN OF lst_struct2,
             field2,
             field3,
           END OF lst_struct2.

MOVE-CORRESPONDING lst_struct1 TO lst_struct2.

Here, you want to populate the data in lst_struct2 from lst_struct1. But both contains the fields in different order. You can not just do lst_struct2 = lst_struct1. Since fields are out of order, you use MOVE-CORRESPONDING.

Check this link for your referece.

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

Let me know if you need any other information.

Regards,

RS

Read only

Former Member
0 Likes
734

DATA: BEGIN OF wa_tab1,

fld1(4) VALUE ’FLD1’,

fld2(4) VALUE ’FLD2’,

fld3(4) VALUE ’FLD3’,

fld4(4) VALUE ’FLD4’,

fld5(4) VALUE ’FLD5’,

END OF wa_tab1,

BEGIN OF wa_tab2,

fld1(4),

fld2(4),

fld3(4),

fld4(4),

END OF wa_tab2.

                          • Move Corresponding *************

MOVE-CORRESPONDING wa_tab1 to wa_tab2.

                        • End Move Corresponding ******************************

                                        • Move*******************

MOVE: wa_tab1-fld1 to wa_tab2-fld1,

wa_tab1-fld2 to wa_tab2-fld2,

wa_tab1-fld3 to wa_tab2-fld3,

wa_tab1-fld4 to wa_tab2-fld4.

                                    • End Move ******************

In above example, the result of MOVE and MOVE-CORRESPONDING is same. MOVE-CORRESPONDING is look like easy to coding but MOVE statement have performance better than MOVE-CORRESPONDING because when you apply MOVE-CORRESPONDING CPU usage of system will be increased.

Read only

Former Member
0 Likes
733

Hi,

As everyone gave you detailed technical analysis, let me tell you briefly.

'MOVE' will move all the records from one work area to another work area. If both the structures are different, it would result in an error.

'MOVE-CORRESPONDING' will move data from one work area to other with similar fields. ex: wa_work1 has 3 fields called a,b, and c. wa_work2 has 3 fields called f,b, and c. Then contents from b are copied to wa_work2 when u use a statement like move-corresponding wa_work1 to wa_work2.

Read only

Former Member
0 Likes
733

Hi kudala,

1. The simple scenario is like this.

2. STRUCTURE 1 = STRUCTURE 2

(Both structure are EXACTLY The same)

We use MOVE

3. STRUCTURE 1 ~= STRUCTURE 2

(Only Some Field name are common in both)

then we use Move-Corresponding.

regards,

amit m.

Read only

Former Member
0 Likes
733

hi

<b>move</b> is used to assign the value of 1 varaible to another pr 1 table to another having same structure

eg move a to b.

move cforresponding is used to move the values of 1 internal table to another having different structures.

move correponding fields of itab1 to table itab2.

regards

ravish

<b>plz reward points if helpful</b>