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 and Assign Statement

Former Member
0 Likes
4,048

What is the difference between Move & assign statement?

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
1,811

Move :- To assign the value of a data object <fl> 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 > .

Assign :- ASSIGN < f > TO < FS >.

When you assign the data object, the system checks whether the technical attributes of the

data object < f > correspond to any type specifications for the field symbol < FS >. The field

symbol adopts any generic attributes of < f > that are not contained in its own type

specification. Following the assignment, it points to < f > in memory.

Move :- To assign the value of a data object <fl> 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 > .

Assign :- ASSIGN < f > TO < FS >.

When you assign the data object, the system checks whether the technical attributes of the

data object < f > correspond to any type specifications for the field symbol < FS >. The field

symbol adopts any generic attributes of < f > that are not contained in its own type

specification. Following the assignment, it points to < f > in memory.

8 REPLIES 8
Read only

Former Member
0 Likes
1,811

Hi,

Assign is used with field symbols to move data, whereas MOVE is used for variables.

Regards,

Pankaj

Read only

Former Member
0 Likes
1,811

Hi,

Move c to w_var.

we r moving c into w_var.

Assign is used for field symbols

ASSIGN mem_area TO <fs> casting_spec range_spec.

Effect

This statement assigns the memory area specified using mem_area to the field symbol <fs>. You can assign a data object or a memory area calculated from the address of a data object. After the assignment, the field symbol refers to the assigned memory area and can be used in operand positions. When used in a statement, it behaves like a dereferenced data reference, meaning that the statement works with the content of the memory area.

The data type with which the assgigned memory area is treated, depends on the specifications in casting_spec . You can either execute an explicit casting or the field symbol takes on the data type of the data object specified in the assignment. A field symbol to which a memory area is assigned, has this data type after the assignment and behaves like a data object of this type.

The assigned memory area mem_area must be at least as long as the data type specified in casting_spec and must have the same alignment. If the data type determined in casting_spec is deep, the deep components with their type and position must appear in the assigned memory area exactly like this.

Use the specifications in range_spec to restrict the memory area that can be assigned to the field symbol.

Plzz reward points if it helps

Read only

Former Member
0 Likes
1,811

In MOVE actually copies data into another data field.

while ASSIGN is used in field-symbols. and field symbols is used to reference another variable dynamically. So this field symbol will simply point to some other variable and this pointer can be changed at runtime.

(Assign is like Pointer in C)

Read only

Former Member
0 Likes
1,811

Hi,

If f is source field and g is target field, then

MOVE f TO g.

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

This statement is equivalent to:

g = f.

Assign deals with field-symbols. Field-symbols are nothing but like pointers in C.

if you give ASSIGN f TO <fs>.

Then if u change the value of <fs> it will reflect in f also.

suppose lets say f = 5.

then give ASSIGN f TO <fs>.

then give <fs> = 10.

you can see the value of f changes to 10.

This is the difference between MOVE and ASSIGN.

Hope this helps you,

by-

Srinath S

Read only

Former Member
0 Likes
1,812

Move :- To assign the value of a data object <fl> 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 > .

Assign :- ASSIGN < f > TO < FS >.

When you assign the data object, the system checks whether the technical attributes of the

data object < f > correspond to any type specifications for the field symbol < FS >. The field

symbol adopts any generic attributes of < f > that are not contained in its own type

specification. Following the assignment, it points to < f > in memory.

Read only

Former Member
0 Likes
1,811

.

Edited by: Rajesh Soman on Jan 17, 2008 1:29 PM

Read only

Former Member
0 Likes
1,811

Hi,

MOVE:

For eg,

I_MARA is the internal table which has 1 record,

TYPES: BEGIN OF STRUCT_MARA,

MATNR TYPE MATNR,

MTART TYPE MTART,

MEINS TYPE MEINS,

END OF STRUCT_MARA.

DATA: I_MARA TYPE STANDARD TABLE OF STRUCT_MARA WITH HEADER LINE.

data: v_matnr type matnr.

(if V_MATNR is a variable of type matnr (V_MATNR TYPE MATNR)).

Then,

The data has to be moved into V_MATNR,

ie,

MOVE: I_MARA-MATNR TO V_MATNR.

Note: MOVE can be used for tranfering data between two variables of same type also.

ASSIGN:

I_MARA is the internal table which has 1 record,

TYPES: BEGIN OF STRUCT_MARA,

MATNR TYPE MATNR,

MTART TYPE MTART,

MEINS TYPE MEINS,

END OF STRUCT_MARA.

DATA: I_MARA TYPE STANDARD TABLE OF STRUCT_MARA WITH HEADER LINE.

data: <f1> type any.

(if <f1>is a field-symbol of type any (<f1> type any)).

Then,

ASSIGN I_MARA-MATNR TO <f1>.

The field-symbol <f1> will point the address of the I_MARA-MATNR

Note: ASSIGN i s only used for field-symbols and it is used by the field-symbols to point the address of a field used in ASSIGN syntax.

hope this helps.

Read only

Former Member
0 Likes
1,811

Hi Sneha,

Move :- To assign the value of a data object <fl> 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 > .

Assign :- ASSIGN < f > TO < FS >.

When you assign the data object, the system checks whether the technical attributes of the

data object < f > correspond to any type specifications for the field symbol < FS >. The field

symbol adopts any generic attributes of < f > that are not contained in its own type

specification. Following the assignment, it points to < f > in memory.

Hope this helps ...

Reward if useful

Cheers

Kripa Rangachari..