‎2008 Mar 03 8:27 AM
Hi,
can you tell me what are the defferences b/w move and move corresponding
‎2008 Mar 03 8:33 AM
Hi,
I think move will transfer the values byte by byte and move-corresponding will transfer values of the field with same name.
Hope this helps.
Harikrishna.
‎2008 Mar 03 8:34 AM
Move workarea-a to workarea-b
- The above statement will move field 1 of workarea-a to field 1 of workarea-b. That is, it will move position wise.
Move-Corresponding workarea-a to workarea-b
- The above statement will compare the fields of workarea-a and workarea-b by name. That is, if we have invoice no in workarea-a and invoice no in workarea-b, and we say move-corresponding, it will move invoice no from workarea-a to invoice no of workarea-b
‎2008 Mar 03 8:34 AM
hi,
Move: If u r using 2 field strings with same structure only then move stmt is possible.
Move corresponding: if u use diff. field strings with some common fields then u can use move corresponding to transfer the value. it 'll check field wise and then it 'll move.
Thanks.
Arunprasad.P
‎2008 Mar 03 8:35 AM
Hi
This statement should be used with care and should rarely be used because if its impact on performance. Use MOVE-CORRESPONDING with like structures only. If moving a data structure to an equivalent structure, move the entire data structure in one statement using <IT_LFA1> = *<LFA1>.
Move corresponding statement moves value from one structure to another structure
MOVE-CORRESPONDING struc1 TO struc2.
Structures must be specified for struc1 and struc2. All components with the same name are searched for in struc1 und struc2 and the content of components in struc1 is assigned to the components with the same name in struc2. All other components are not affected.
Nested structures are fully expanded. The names of the components are compared to the lowest common level. For each comp component pair with the same name, the
MOVE struc1-comp TO struc2-comp.
Example
DATA: BEGIN OF struc1,
comp TYPE c LENGTH 1 VALUE 'U',
BEGIN OF struci,
comp1 TYPE c LENGTH 1 VALUE 'V',
BEGIN OF comp2,
col1 TYPE c LENGTH 1 VALUE 'X',
col2 TYPE c LENGTH 1 VALUE 'Y',
END OF comp2,
END OF struci,
END OF struc1.
DATA: BEGIN OF struc2,
BEGIN OF struci,
comp1 TYPE string,
comp2 TYPE string,
comp3 TYPE string,
END OF struci,
END OF struc2.
MOVE-CORRESPONDING struc1 TO struc2.
If you want to pass the data from one internal table to another internal table, then if the structure of both the table will be same then you can assign directly like that
it_tab1 = it_tab2.
or
it_tab1[] = it_tab2.
MOVE struc1-comp TO struc2-comp.
statement is executed, and - if necessary - the corresponding conversions are performed.
Before Release 6.10, specified field symbols or formal parameters had to be structured and typed for struc1 and struc2. Since Release 6.10 untyped field symbols, field symbols with the generic type ANY, or formal parameters can be used for struc1 and struc2. These must be structures when the statement is executed, otherwise an untreatable exception is triggered.
Note
If structures are specified for struc1 and struc2, the name is compared once when the program is generated by the ABAP Compiler. If untyped field symbols or formal parameters are used, the names must be compared each time the statement is executed.
Example
The structure struc1 contains the components:
struc1-comp1
struc1-struci-comp1
struc1-struci-comp2-col1
struc1-struci-comp2-col2
The structure struc2 contains the components:
struc2-struci-comp1
struc2-struci-comp2
struc2-struci-comp3
‎2008 Mar 03 8:36 AM
Hi,
Move:- To move a vale from one field to another, use the move statement.
Move-corresponding:- To perform a move from one field string to another where the data type and/or lenths do not match, use the move-corresponding.
Regards,
Sreedhar.
‎2008 Mar 03 8:39 AM
hi,
refer to the link.
http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3260358411d1829f0000e829fbfe/content.htm
4) COPYING INTERNAL TABLES :
a. To copy the entire contents of one internal table into another, use the MOVE statement.
Syntax:
MOVE <itab1> to <itab2>
Eg: DATA: BEGIN OF line,
col1(1) TYPE c,
col2(1) TYPE c,
END OF line.
DATA: etab LIKE TABLE OF line WITH HEADER LINE,
ftab LIKE TABLE OF line with header line .
etab-col1 = 'A'. etab-col2 = 'B'.
Append etab.
etab-col1 = 'B'. etab-col2 = 'C'.
Append etab.
MOVE etab[] TO ftab[].
LOOP AT etab.
WRITE: / etab-col1, etab-col2.
ENDLOOP.
loop at ftab.
write: / ftab-col1,ftab-col2.
endloop.
move-corresponding
DATA: BEGIN OF address,
firstname(20) TYPE c VALUE 'Fred',
surname(20) TYPE c VALUE 'Flintstone',
initials(4) TYPE c VALUE 'FF',
street(20) TYPE c VALUE 'Cave Avenue',
number TYPE i VALUE '11',
postcode(5) TYPE n VALUE '98765',
city(20) TYPE c VALUE 'Bedrock',
END OF address.
DATA: BEGIN OF name,
surname(20) TYPE c,
firstname(20) TYPE c,
initials(4) TYPE c,
title(10) TYPE c VALUE 'Mister',
END OF name.
MOVE-CORRESPONDING address TO name.
SKIP.
WRITE: / 'MOVE CORRESPONDING'.
ULINE.
WRITE: / 'FIRSTNAME', address-firstname,
/ 'SURNAME ', address-surname,
/ 'INITIALS ', address-initials,
/ 'STREET ', address-street,
/ 'NUMBER ', address-number,
/ 'POSTCODE ', address-postcode,
/ 'CITY ', address-city.
SKIP.
WRITE: / 'SURNAME ', name-surname,
/ 'FIRSTNAME', name-firstname,
/ 'INITIALS ', name-initials,
/ 'TITLE ', name-title.
Output :
MOVE CORRESPONDING
____________________________
FIRSTNAME Fred
SURNAME Flintstone
INITIALS FF
STREET Cave Avenue
NUMBER 11
POSTCODE 98765
CITY Bedrock
SURNAME Flintstone
FIRSTNAME Fred
INITIALS FF
TITLE Mister
regards,
sreelakshmi
‎2008 Mar 03 8:41 AM
Hi
move : this will move the data from one feild to other.
i.e MOVE source to destination.
Both these statements assign the content of the operand source to the data object destination. The variants with the language element TO or the assignment operator = are valid for all assignments between operands that are not reference variables, and for assignments between reference variables for which the static type of source is more specific than or the same as the static type of destination(narrowing cast).
Variants with the language element ?TO or the assignment operator ?= (casting operator ) must be used if the source and destination are reference variables and the static type of source is more general than the static type of destination (widening cast). For assignments between operands that are not reference variables, use of the question mark ? is not permitted.
The data object destination can be any data object that can be listed at a write position, and the data object source can be a data object, a predefined function or a functional method (as of release 6.10). The data type of the data object destination must either be compatible with the data type of source, or it must be possible to convert the content of source into the data type of destination according to one of the conversion rules.
MOVE-CORRESPONDING struc1 TO struc2.
Effect
Structures have to be specified for struc1 and struc2. All components with the same name are searched for in struc1 und struc2 and the content of components in struc1 is assigned to the components with the same name in struc2M. All other components are not affected.
Nested structures are fully expanded. The names of the components are compared to the lowest common level. For each comp component pair with the same name, the
MOVE struc1-comp TO struc2-comp.
statement is executed, and - if necessary - the corresponding conversions are performed.
Before Release 6.10, specified field symbols or formal parameters had to be structured and typed for struc1 and struc2. Since Release 6.10, untyped field symbols or formal parameters can be used for struc1 and struc2. These have to be structures when the statement is executed, otherwise this triggers an untreatable exception.
Note
If structures are specified for struc1 and struc2, the name is compared once when the program is generated by the ABAP Compiler. If untyped field symbols or formal parameters are used, the names must be compared each time the statement is executed.
Example
In the struc1 and struc2 structures there are the components struci-comp1 and struci-comp2. These are asssigned from struc1 to struc2. In struc1, struci-comp2 is self-structured, in struc2, struci-comp is elementary. For the assignment of struc1-struci-comp1 to struc2-struci-comp1 , the source field is interpreted as an elementary field of type c according to the conversion rules for structures. The struc1-comp1 and struc2-struci-comp3 components do not have any equivalents with the same name and are not considered for the assignment.
DATA: BEGIN OF struc1,
comp(1) TYPE c VALUE 'X',
BEGIN OF struci,
comp1(1) TYPE c VALUE 'Y',
BEGIN OF comp2,
comp(1) TYPE c VALUE 'Z',
END OF comp2,
END OF struci,
END OF struc1.
DATA: BEGIN OF struc2,
BEGIN OF struci,
comp1(1) TYPE c,
comp2(1) TYPE c,
comp3(1) TYPE c,
END OF struci,
END OF struc2.
MOVE-CORRESPONDING struc1 TO struc2.
‎2008 Mar 03 8:45 AM
Hi,
MOVE- Moves the contents of field 1 to field 2. Field 1 remains unchanged.
MOVE-CORRESPONDING -
Ex: MOVE-CORRESPONDING struc1 TO struc2.Effect struc1 and struc2 must be structures. Searches for all names of subfields that occur both in struc1 and struc2.
Reward if it is useful.
Regards,
Ramya
‎2008 Apr 02 7:40 AM
but how to say,simply speaking,'move' just can be regarded as copy whole,
as for 'move-corresponding', i think,sometimes, you mabye only need to assign certain components of a structure to be certain components of another structure.
hope it helpful to u.
best!
liam.
‎2008 Apr 02 9:05 AM
very lucky, i found one practice i had ever made. which maybe show u simply and directly the deference between 'move' and 'move-correponding'.
as the following:
&----
*& Test for the deference between 'move' and 'move-corresponding'
&----
DATA: BEGIN OF address,
firstname(20) TYPE c VALUE 'Fred',
surname(20) TYPE c VALUE 'Flintstone',
initials(4) TYPE c VALUE 'FF',
street(20) TYPE c VALUE 'Cave Avenue',
number TYPE i VALUE '11',
postcode(5) TYPE n VALUE '98765',
city(20) TYPE c VALUE 'Bedrock',
END OF address.
DATA: BEGIN OF name,
surname(20) TYPE c,
firstname(20) TYPE c,
initials(4) TYPE c,
title(10) TYPE c VALUE 'Mister',
END OF name.
DATA: num TYPE i.
DO 2 TIMES.
IF num IS INITIAL.
MOVE-CORRESPONDING address TO name.
WRITE: / name-surname, name-firstname, name-initials,name-title.
ELSE.
MOVE address TO name.
WRITE: / name-surname, name-firstname, name-initials,name-title.
ENDIF.
num = num + 1.
ENDDO.
&----
& -
&----
just let me know if it works.
regards!
liam.
‎2008 Apr 02 10:25 AM
Both can be used for transfering data from structure to structure.
When u use move str1 to str2, it serially transfers the data from str1 to str2. So if str1 & str2 are not similar, data will get transfered in the way u dont want.
But when u use move-corresponding str1 to str2, system will search for the fields similar from str1 & str2. So even though str1 & str2 are not similar, data will get transfered in the way u want.
Second & important difference is , move statement takes time to transfer the data than move-corresponding statement.
Hope this helps.
Reward if useful
JK