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 & Move corresponding

Former Member
0 Likes
609

Hi,

Difference between Move & Move-corresponding .

Vighnesh .

4 REPLIES 4
Read only

Former Member
0 Likes
586

hi,

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

Example.

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.

Example.

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

Regards

Read only

Former Member
0 Likes
586

Hi,

1. Move assigns the value to the specified field.

It is just like a = b.

2. Whereas

3. MOVE-CORRESPONDING STRUCT1 TO STRUCT2

means,

ALL FIELDS HAVING THE SAME NAME,

WILL BECOME EQUAL.

(Rest fields, which do not have same name,

will be ignored)

4. Suppose have a struct1 has 5 fields,

struct 2 has 9 fields,

so instead of giving 5 different lines,

STRUCT2-FIEDL1 = STRUCT1-FIELD1

STRUCT2-FIEDL2 = STRUCT1-FIELD2

STRUCT2-FIEDL3 = STRUCT1-FIELD3

STRUCT2-FIEDL4 = STRUCT1-FIELD4

STRUCT2-FIEDL5 = STRUCT1-FIELD5

We just use MOVE-CORRESPONDING STRUCT1 TO STRUCT2.

Regards,

Priyanka.

Read only

Former Member
0 Likes
586

Hi,

Move Statement is used to move a variable or a record from one work area to another. it moves data in a order i.e. field by field the order of fields in in both tables should be same otherwise we will get an error.

Example.

DATA: var1 TYPE c VAULE 'A',

var2 TYPE c.

MOVE var1 to var2.

Move Corresponding moves data from one table to another with respect to names of fields. i.e no sequence is maintained . it automatically searches for field names and moves data acoordingly.

Example.

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.

Generally, Move works faster than Move Corresponding.

If u move the order in both tables i.e sequence in both tables r same go for move otherwise use move-corresponding.

Regards,

Padmam.

Read only

Former Member
0 Likes
586

<b>MOVE</b>

Assigns values.

Syntax

MOVE <f1> TO <f2>.

<b>Assigns the contents of the data object <f1> to the variable <f2>, with automatic type conversion if necessary. Equivalent to <f2> = <f1>.</b>

<b>MOVE-CORRESPONDING</b>

Assigns values between identically-named components of structures.

Syntax

MOVE-CORRESPONDING <struc1> TO <struc2>.

<b>Moves the contents of the components of structure <struc1> to the components of <struc2> that have identical names.</b>

reward points if it is usefull ..

Girish