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: 

about the move corresponding

Former Member
0 Kudos

hi,

can anyone say about the diff... between the move corresponding and move statment..

wat is the diff.. move corresponding and append stmt.. in which situation we need to use this....

8 REPLIES 8

former_member530652
Participant
0 Kudos

Hi,

move statement is used when u'hv to transfer data frm one variable to another......

and move corresponding is used when u'hv to transfer data from one structure variable to anothe structure variable....

append statement appends ur data at the end of respective structure or table.........

Former Member
0 Kudos

move will move from one field to another.

move corresponding will move from one structure to another but it will first look for identical type then it will move only, so it is generally avoided,because it takes more time in checking same type.

append statement will simply append one record at the bottom of your internal table,it is used to populate internal table.

generally we append work area to the internal table.

dont forget to reward point,

kush

Former Member
0 Kudos

Hi

Reward if help.

MOVE-CORRESPONDING wa_tab1 to wa_tab2.************ End

MOVE: wa_tab1-fld1 to wa_tab2-fld1, wa_tab1-fld2 to wa_tab2-fld2, wa_tab1-fld3 to wa_tab2-fld3,

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.

In the MOVE statement (or when you assign one value to another with the equal sign), it is not possible to specify the field names dynamically as the contents of other fields. If you need to do this, you must use field symbols .

The source and target fields can be of different data types. The result of the value assignment depends on whether these data types are compatible and whether a type conversion can be performed. If there is no conversion rule between the data types in question, no assignment can be made.

DATA: t(10) TYPE c,

number TYPE p DECIMALS 2,

count TYPE i.

t = 1111.

MOVE '5.75' TO number.

count = number.

Following these assignments, the fields t, number and count have the values ‘1111 ’, 5.75, and 6 respectively. When you assign the number literal 1111 to T, it is converted into a character field with length 10. When you assign number to count , the decimal number is rounded to an integer (as long as the program attribute Fixed pt. arithmetic has been set).

Assigning Values Between Components of Structures

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.

...

Any necessary type conversions are performed individually.

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.

In this example, the values of name-surname, name-firstname and name-initials are set to 'Flintstone’, ‘Fred’, and 'FF'. name-title always has the value ‘Mister’.

Append Structure->Append structures are used for enhancements that are not included in the standard. This includes special developments, country versions and adding customer fields to any tables or structures.

An append structure is a structure that is assigned to exactly one table or structure. There can be more than one append structure for a table or structure.

The following enhancements can be made to a table or structure TAB with an append structure:

· Insert new fields in TAB,

· Define foreign keys for fields of TAB that already exist,

· Attach search helps to fields of TAB that already exist,

These enhancements are part of the append structure, i.e. they must always be changed and transported with the append structure.

Pls Reward if help.

Former Member
0 Kudos

MOVE-CORRESPONDING struc1 TO struc2.

struc1 and struc2 must be structures.

Searches for all names of subfields that occur both in struc1 and struc2. Generates for all relevant field pairs which correspond to the subfields ni, statements of the form

MOVE struc1-ni TO struc2-ni.

The other fields remain unchanged.

MOVE f TO g.

Moves the contents of field f to field g. Field f remains unchanged.

This statement is equivalent to:

g = f.

Reward if useful

Former Member
0 Kudos

Hi,

Move- move statement it will simply map the first field of the source table

with the first field of the target table.....second field to second field and likewise. It does not really checks whether the fields are of similar datatypes or even they are compatible or not..thats the reason u r getting the error.

Move corresponding - it checks for the particular field in the target table and then assigns...but again it consumes a lot of runtime and becomes a performance issue.

Regards,

Suganya.

Former Member
0 Kudos

Hi,

Move-Corresponding is used to move field values from one work area to another by comparing the field names.

By using move-corresponding over simple move - you do not have to ensure that the source and target fields are in the same order in source and target work areas respectively.

Hence, basically, use it for transferring values from one work area to another, and ensure the source and target fields have the same name in the two work areas (irrespective of position in the work area).

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:

MOVE <f1> TO <f2> Equals <f2> = <f1>

Instead of using the move-corresponding clause it is advisable to use the move statement instead. Attempt should be made to move entire internal table headers in a single shot, rather than moving the fields one by one.

Move is used to transfer data from one variable to other like

data: lv_f1 type char10,

lv_f2 type char2.

move lv_f1 to lv_f2.

Appendstatement:

The append statement is part of a facility in Basis which assists in the process of collecting lists of values, such as time histories, in an efficient manner. The components of the facility are:

setlast, a routine for imposing a limit on the last subscript.

The := ``append'' operator.

rtadddim, a routine for ``adding'' a dimension to a variable.

The routine setlast(name, n) limits the LAST dimension (only) of the variable name to length of n. If n is greater than the current length (unlimited) of last subscript of name, then an attempt is made to expand storage so that the length will be at least n.

If n is greater than the current maximum value, then the maximum is set to 1.5 times the existing value or at least 16. This exponential growth is used to help reduce memory fragmentation while preserving constant time operation cost. setlast can be used on static arrays as long as no attempt is made to exceed the actual storage available.

regards.

vasavi.

kindly reward if helpful.

Former Member
0 Kudos

Hi

Move Corresponding :

If your work area structure not similar to work area where you want to move data but they have some field names and their types similar

You can use Move-Corresponding warea1 to warea2 .

Whereas MOVE stmt moves the data from one field to another .

Append statement:

Creates a record entry into the table whereas Move Corresponding only moves data , which can be handled as per the requirement but doesnt appends/Creates entry into table .

Hope it helps.

Praveen.

Former Member
0 Kudos

Hi,

You will get the diffrence from:

http://help.sap.com/saphelp_nw70/helpdata/en/fc/eb3260358411d1829f0000e829fbfe/frameset.htm

Regards,

Renjith Michael.