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

Regarding Move command

Former Member
0 Likes
718

what is the difference between move it1 to it2

and

it2 = it1.

6 REPLIES 6
Read only

former_member632991
Active Contributor
0 Likes
681

Hi,

Both are same.

diff is that with move u can use move corresponding to move firlds from internal table to other which are compatible in both tables.

Hope it helps.

Regards,

Sonika

Read only

Former Member
0 Likes
681

Hi

In move-corresponding ITAB1 to ITAB2, fields are moved field/record by record/field, if the fields are similar in both itabs and we have to APPEND ITAB2 every time

where as

ITAB2[] = itab1[]

all the data from itab1 is dumped at a time to ITAB2, including complete body.

here also both should have same structures.No need of Append here.

reward points if useful

regards,

ANJI

Read only

Simha_
Product and Topic Expert
Product and Topic Expert
0 Likes
681

Hi,

pls. look into it.Good explanation on you requirement.

********************************************

To assign the value of a data object <f1> to a variable <f2>, use the following statement:

MOVE <f1> TO <f2>.

or the equivalent statement

<f2> = <f1>.

The contents of <f1> remain unchanged. <f1> does not 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 value assignments in the form

<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 .

There are three possible outcomes of assigning <f1> to <f2>:

The data objects <f1> and <f2> are fully compatible, that is, their data types, field length, and number of decimal places are identical. The contents of source field <f1> are transferred byte by byte into the target field <f2> without any further manipulation. The MOVE statement is most efficient when this is the case.

The data objects <f1> and <f2> are incompatible. This is the case, for example, if the two fields have the same type, but different lengths. The contents of the source field <f1> are converted so that they are compatible with the data type of <f2>, and are then transferred. This procedure only works if a conversion rule exists between the data types of <f1> and <f2>. Type conversions make the MOVE statement less efficient. How much less efficient depends on the individual conversion.

The data objects <f1> and <f2> are incompatible, and no conversion is possible. The assignment is not possible. If this can be recognized statically, a syntax error occurs. If it is not recognized before the program is run, a runtime error occurs.

The source and target fields can be of different data types. In contrast to other programming languages, where the assignment between different data types is often restricted to a small number of possible combinations, ABAP provides a wide range of automatic type conversions.

For example, the contents of a source field with an elementary data type can be assigned to a target field with any other data type. The single exception to this rule is that it is not possible to assign values between type D fields and type T fields. ABAP even supports assignments between a structure and an elementary field, or between two structures.

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).

Cheers,

Simha.

Pls. reward if useful

Read only

Former Member
0 Likes
681

Hi Doak,

MOVE IT1 to IT2

This stmt. moves the fields in IT1 to IT2, irrespective of the field length and size of IT2. Only fields matching in both of them are successfully moved and others are not successfully moved.

IT1 = IT2

This stmt. assigns the same fields of IT1 to IT2 and also the structure of both should be same, and wiil be same. If not same, error is raised.

Hope this resolves your query.

<b>Reward all the helpful answers.</b>

Regards

Read only

Former Member
0 Likes
681

Hi Doak,

1) MOVE it1 to it2 and it1=it2. are same statements but...

2) MOVE-CORRESPONDING it1 to it 2 and it1 = it2 are not same.

it1 = it2 simply copies the work area of it1 in to work area of it2.

in the case of move corresponding it will move the values by checking the field names from it1 to it2, but keep in mind that it does not see the data type , though there may b a mismatch in data types but iof field names are same it will copy .

but in the first case it will copy the first field to the first field from it1 to it2 and second to second and so on.....without checking the data type or field name.

Reward points if helpful,

Regards,

Tejas

Read only

Former Member
0 Likes
681

Hi,

ABAP converts '=' Statement into move form. And what ever symbols in ABAP if u write using symbols like +, / , = , it will convert into ADD DIV Move like english statement.

so avoid using symbol it will take time for conversion internally.

Hope this would help you out.

Thanks and Regards,

Varun.