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

diff bt move to and write to

Former Member
0 Likes
1,251

hai friends..

can you tell me ..

what is difference bt "move to" and "write to"..

hai friends..

can you tell me ..

what is difference bt "move to" and "write to"..

10 REPLIES 10
Read only

Former Member
0 Likes
1,177

Hi,

MOVE is used to move the fields of the same type

WRITE TO is used to move the fields other than other data types also.

Generally first field is forcibly written to second field data type in WRITE TO.

reward if useful

regards,

ANJI

Read only

andreas_mann3
Active Contributor
0 Likes
1,177

hi,

with write to you can format a variable (see F1 -> options)

e.g. "currency EUR"

A.

Read only

Former Member
0 Likes
1,177

Hello Selva,

In move to : ur target field must be of the same type as the source field.

and In write to : ur target field must always be a character type field.

PS: Reward each helpful answer.

Regards,

Deepu.K

Read only

Laxmana_Appana_
Active Contributor
0 Likes
1,177

Hi,

Check this :

WRITE f TO g

Assigns the contents of the source field f to the target field g as a new value.

The field type C is always used, regardless of the actual data type.

But MOVE, the format of the target field g is the same as f .

Regards

L Appana

Read only

Former Member
0 Likes
1,177

Hi..,

When u use WRITE TO it considers the user master settings !!

but MOVE does not !!

As well as the MOVE statement, which converts the value of the source field into the data type of the target field, there is also a statement WRITE TO, which converts the contents of the source field into a field with type C.

WRITE <f1> TO <f2> [<option>].

This statement converts the contents of a data object <f1> to type C, and places the string in the variable <f2>. The data type of <f1> must be convertible into a character field; if it is not, a syntax or runtime error occurs. The contents of <f1> remain unchanged. The variable <f2> is always interpreted as a character string, regardless of its actual line type. The conversion does not take other data types into account. Therefore, you should not use a target field with a numeric data type (F, I , or P). If you do use a numeric data type, the syntax check displays a warning if the target field is statically defined. However, this warning may be upgraded to a real syntax or runtime error in future releases.

The WRITE TO statement always checks the settings in the user’s master record. These specify, for example, whether the decimal point appears as a period (.) or a comma (,). You can also use all of the formatting options available with the WRITE statement, apart from UNDER and NO-GAP.

<b>In the WRITE TO statement, you can specify the name of the source field dynamically as the contents of another field, which is not possible with MOVE.</b> To do this, specify the name of the field containing the name of the source field in parentheses:

WRITE (<f>) TO <g>.

The difference comes when you are working with date and quantity (type p) fields..

check the difference !!

<b>data d type d value '20070416'.

data d1 type d.

write d to d1.

write /: d, d1.</b>

regards,

sai ramesh

Read only

Former Member
0 Likes
1,177

MOVE TO:

used to update update field, variable etc.

does not support formatting option

WRITE TO:

used to update update field, variable etc.

support formatting like date: ddmmyyyy

Read only

Former Member
0 Likes
1,177

MOVE TO --> this just moves the field to the target field

WRITE TO --> this changes the format of the field and moves to target field

Read only

Former Member
0 Likes
1,177

Hi,

<b>WRITE TO:</b>

WRITE <f1> TO <f2> [<options>].

Does NOT follow the Conversion Rules. The target field is interpreted as a type C field.

Option - all Formatting Options except UNDER and NO-GAP.

Always checks the settings in the user's master record, e.g. whether the decimal point appears as a period (.) or a comma (,).

Specifying the Source field at Runtime with WRITE TO:

WRITE (<f1>) TO <f2>.

The system places the value of the data object assigned to <f1> in <f2>.

Example:

DATA: NAME(10) VALUE 'SOURCE',

SOURCE(10) VALUE 'Antony',

TARGET(10).

...

WRITE (NAME) TO TARGET.

WRITE: TARGET.

This produces the output:

Antony

<b>

MOVE TO:</b>

MOVE <f1> TO <f2>.

Follows the Conversion Rules.

Regards

Sudheer

Read only

Former Member
0 Likes
1,177

Hi,

<b>Move..to..</b>

Moves the contents of field X to field Y. Field f remains unchanged.

This statement is equivalent to: Y=X.

<b>Write..to..</b>

WRITE f TO g[+off][(len)].

Effect

Assigns the contents of the source field f to the target field g as a new value.

In contrast to MOVE, the format of the target field g is the same as when outputting to a list with WRITE. The field type C is always used, regardless of the actual data type.

As with list output, the settings in the user's master record for decimal point (period or comma) and date format are taken into account.

Instead of specifying a static source field f, you can also specify a source field (name) dynamically. In this case, the content of the field name is interpreted as the source field name at runtime. The content of this named field is then formatted accordingly.

You can identify the target field g more precisely by specifying the offset and/or length in the form g+off(len). Both the offset and the length specifications off and len can also be dynamic.

In the WRITE name TO g variant, the return code is set as follows:

SY-SUBRC = 0:

Contents of name are valid, statement executed.

SY-SUBRC = 4:

Example

WRITE ... TO with dynamic source field specification and dynamic offset and length specification for the target field:

DATA: NAME(5) VALUE 'FIELD',

FIELD(5) VALUE 'Harry',

DEST(18) VALUE 'Robert James Smith',

OFF TYPE I,

LEN TYPE I.

OFF = 7.

LEN = 8.

WRITE (NAME) TO DEST+OFF(LEN).

The field DEST now contains the value "Robert Harry ith".

****reward points if helpful.

All the best

Read only

Former Member
0 Likes
1,177

Hi selva,

1.

Move D1 : <b>20070416</b>

Write D2 : <b>16.04.2007</b>

2. This simple program will make it clear.

3. Just copy paste.

4.

report abc.

data : d0 type sy-datum.

data : d1(10) type c.

data : d2(10) type c.

*----


d0 = sy-datum.

move d0 to d1.

write d0 to d2.

*----


write 😕 'Move D1 : ' , d1.

write 😕 'Write D2 : ' , d2.

regards,

amit m.