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: 

Move statement

Former Member
0 Kudos

Hi Experts,

I want to know about

1) move

move corresponding

2) steps to observe to improve the performance

Thanks in advance

Nagaraju

1 ACCEPTED SOLUTION

former_member583013
Active Contributor
0 Kudos

MOVE

Move the content of an internal table/variable to another internal table/variable


MOVE T_TEST-FIELD1 TO T_TEST2-FIELD1.

MOVE-CORRESPONDING

Move all fields that applied.


MOVE-CORRESPONDING T_TABLE1 TO T_TABLE2.

IMPROVE PERFORMANCE

Use Field-Symbols.

Avoid Select-Endselect.

Specify full keys or indices.

Avoid unnecessary selects.

Greetings,

Blag.

6 REPLIES 6

former_member583013
Active Contributor
0 Kudos

MOVE

Move the content of an internal table/variable to another internal table/variable


MOVE T_TEST-FIELD1 TO T_TEST2-FIELD1.

MOVE-CORRESPONDING

Move all fields that applied.


MOVE-CORRESPONDING T_TABLE1 TO T_TABLE2.

IMPROVE PERFORMANCE

Use Field-Symbols.

Avoid Select-Endselect.

Specify full keys or indices.

Avoid unnecessary selects.

Greetings,

Blag.

Former Member
0 Kudos

MOVE field by field gives better performance than MOVE-CORRESPONDING as in move-corresponding it checks every field in both ends.

Thanks,

Srinivas

Former Member
0 Kudos

move-corresponding should have same field names with same structure

Use select up to <n> rows instead of select single if you are not using full key.

Avoid using select queries inside the loop endloop instead fetch data into internal table before processing and use read statement.

Sort internal table before reading. Use binary search if you are using full key.

Avoid cluttered if elseifs instead use case endcase.

Use available index for the tables.

Modularize the code

Avoid multiple joins instead use for all entries.

While fetching data from huge tables like bseg into internal tables, use package size.

There are many other tips to improve performance. You can get abundant stuff by searching.

It depends on how you handle the performance based on the situation you come across.

Hope this helps!

Thanks,

SKJ

Thanks,

SKJ

Former Member
0 Kudos

Hi,

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’

In SUMMARY , move is for moving variables or structures of same type whereas move-corrresponding is for assigning same fields in different structures.

Performance Issues

some of the performance improvement tips

1) Dont use hardcoding i.e variable = 'HELLO', instead create some constants and then assign that constant to the variable.

2) Dont use LOOP in LOOP

3) Dont use SELECT in LOOP

4) Use Sub routines in case of repititive code

5) Use changing,using with the subroutines

6) before using the read statement sort the table.

7) dont use select-endselect.

😎 dont use move-corresponding fields.

9) dont use joins instead go for 'for all entries'

10) use hash tables when large volumes of data is there instead of sorted .

11) dont use select *

12) select * into corresponding fields

13) use the indices available for the table.

14) use types instead of occurs.

Reward points if helpful.

Thanks and Regards.

abapdeveloper20
Contributor
0 Kudos

Hi,

One tip:

Make sure while writing SELECT statement , the order of fields in the "WHERE" should follow the order of fiels in the DDIC table.

use ABAPDOCU transaction code and choose ABAP Program Execution

Reward points if my reply is useful

~Lakshmiraj~

Former Member
0 Kudos

Hi,

Take one example structures

1.structure1:

field1,

field2,

field3,

field4.

2.Structure2:

field1,

field2,

field3,

field4.

3.Structure3:

field2,

field4,

field3,

field1.

MOVE is used to store the values from one structure/variable

to another structure/variable,WHEN both structures are of same type.

Ex:- MOVE structure1 TO structure2.

MOVE-CORRESPONDING is used to store the values, WHEN both structures are different.

Ex:- MOVE-CORRESPONDING structure1 TO structure3.

Reward,if it is useful.

Thanks,

Chandu