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 & assign

Former Member
0 Likes
758

Hi,

What is the difference between Move & assign statement?

Thanks,

Manjula.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
718

hi,

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

To assign the value of a data object to a variable , use the following statement: MOVE TO . or the equivalent statement = . The contents of remain unchanged. 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 = = = .

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.

ASSIGN TO . When you assign the data object, the system checks whether the technical attributes of the data object correspond to any type specifications for the field symbol . The field symbol adopts any generic attributes of that are not contained in its own type specification. Following the assignment, it points to in memory.

move---

To move a value from one field to another, use the move statement. The entire contents or a portion thereof can be moved. Instead of move, you can use the assignment operator =, as shown below. They are both referred to as a move statement.

The following is the syntax for the move statement. Operators and operands must be separated by spaces. Multiple assignment occurs from right to left.

move v1 to v2.

or

v2 = v1.

or

v2 = v1 = vm = vn . . ..

or

move v1[N(L)] to v2[N(L)].

or

v2[N(L)] = v1[N(L)].

where:

v1 is the sending variable or field string.

v2 is the receiving variable or field string.

N is an offset from the beginning of the variable or field string.

L is the number of bytes to move.

Static ASSIGN

If you already know the name of the field that you want to assign to the field symbol when you write a program, use the static ASSIGN statement:

ASSIGN dobj TO <fs>.

When you assign the data object, the system checks whether the technical attributes of the data object dobj correspond to the type specifications for the field symbol <fs>. The field symbol adopts any generic attributes of dobj that are not contained in its own type specification. After the assignment, it points to this field in the memory.

REPORT demo_field_symbols_stat_ASSIGN .

FIELD-SYMBOLS: <f1> TYPE ANY, <f2> TYPE i.

DATA: text(20) TYPE c VALUE 'Hello, how are you?',

num TYPE i VALUE 5,

BEGIN OF line1,

col1 TYPE f VALUE '1.1e+10',

col2 TYPE i VALUE '1234',

END OF line1,

line2 LIKE line1.

ASSIGN text TO <f1>.

ASSIGN num TO <f2>.

DESCRIBE FIELD <f1> LENGTH <f2>.

WRITE: / <f1>, 'has length', num.

ASSIGN line1 TO <f1>.

ASSIGN line2-col2 TO <f2>.

MOVE <f1> TO line2.

ASSIGN 'LINE2-COL2 =' TO <f1>.

WRITE: / <f1>, <f2>.

The list output is:

Hello, how are you? has length 20

LINE-COL2 = 1,234

The example declares two field symbols <f1> and <f2>. <f2> may only have fields of type I since it has been typed accordingly. <f1> and <f2> both point to different fields during the program.

http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb38d5358411d1829f0000e829fbfe/content.htm

please reward points if helpful,

shylaja

6 REPLIES 6
Read only

former_member156446
Active Contributor
0 Likes
718

Hi Manjula

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.

Assign will be generally used with field-symbols.

>field-symbols:<fs> type char10.

>data: lv_f1 type char10.

> assign lv_f1 to <fs>. initially the <fs> will be initial and we need to >assign a value to it.

Read only

Former Member
0 Likes
718

No diffrerence between both. Both will assign value from one variable to another

MOVE w_data1 to w_data2.

Or

w_data2 = w_data1.

Second statements we generally use for numeric values where as first we can use for any type of data.

Rewards if useful.

Minal

Read only

Former Member
0 Likes
718

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.

Assign

Assign Works only with Field Symbol

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. After the assignment, it points to <f> in memory.

Vinodh Balakrishnan

Read only

Former Member
0 Likes
718

Hi Manjula,

Use the following statement :

assign (x) to <datain>.

This will assign the value which is contained in x.

If you use assign x to <datain>, then x would be assigned to <datain>.

Hope this clarifies your doubt.

MOVE statement :

sample.

CLEAR w_faxtn.

MOVE 'OGGETTO: pagamento fatture diverse'(f21) TO w_faxtn-fax_line(34)

.

APPEND w_faxtn.

CLEAR w_faxtn.

MOVE

'A fronte delle fatture sotto elencate, abbiamo provvveduto a (f22)

bonificarVi' TO w_faxtn-fax_line+9(60).

APPEND w_faxtn.

CLEAR w_faxtn.

cheers,

Hema.

Read only

Former Member
0 Likes
719

hi,

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

To assign the value of a data object to a variable , use the following statement: MOVE TO . or the equivalent statement = . The contents of remain unchanged. 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 = = = .

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.

ASSIGN TO . When you assign the data object, the system checks whether the technical attributes of the data object correspond to any type specifications for the field symbol . The field symbol adopts any generic attributes of that are not contained in its own type specification. Following the assignment, it points to in memory.

move---

To move a value from one field to another, use the move statement. The entire contents or a portion thereof can be moved. Instead of move, you can use the assignment operator =, as shown below. They are both referred to as a move statement.

The following is the syntax for the move statement. Operators and operands must be separated by spaces. Multiple assignment occurs from right to left.

move v1 to v2.

or

v2 = v1.

or

v2 = v1 = vm = vn . . ..

or

move v1[N(L)] to v2[N(L)].

or

v2[N(L)] = v1[N(L)].

where:

v1 is the sending variable or field string.

v2 is the receiving variable or field string.

N is an offset from the beginning of the variable or field string.

L is the number of bytes to move.

Static ASSIGN

If you already know the name of the field that you want to assign to the field symbol when you write a program, use the static ASSIGN statement:

ASSIGN dobj TO <fs>.

When you assign the data object, the system checks whether the technical attributes of the data object dobj correspond to the type specifications for the field symbol <fs>. The field symbol adopts any generic attributes of dobj that are not contained in its own type specification. After the assignment, it points to this field in the memory.

REPORT demo_field_symbols_stat_ASSIGN .

FIELD-SYMBOLS: <f1> TYPE ANY, <f2> TYPE i.

DATA: text(20) TYPE c VALUE 'Hello, how are you?',

num TYPE i VALUE 5,

BEGIN OF line1,

col1 TYPE f VALUE '1.1e+10',

col2 TYPE i VALUE '1234',

END OF line1,

line2 LIKE line1.

ASSIGN text TO <f1>.

ASSIGN num TO <f2>.

DESCRIBE FIELD <f1> LENGTH <f2>.

WRITE: / <f1>, 'has length', num.

ASSIGN line1 TO <f1>.

ASSIGN line2-col2 TO <f2>.

MOVE <f1> TO line2.

ASSIGN 'LINE2-COL2 =' TO <f1>.

WRITE: / <f1>, <f2>.

The list output is:

Hello, how are you? has length 20

LINE-COL2 = 1,234

The example declares two field symbols <f1> and <f2>. <f2> may only have fields of type I since it has been typed accordingly. <f1> and <f2> both point to different fields during the program.

http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb38d5358411d1829f0000e829fbfe/content.htm

please reward points if helpful,

shylaja

Read only

Former Member
0 Likes
718

Hi,

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.

Reward points if found helpfull...

Cheers,

siva.