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: bw. WRITE TO & MOVE TO

Former Member
0 Likes
664

Hi,

I am a beginner of ABAP. Does anyone tell me the differences between the WRITE TO stm and MOVE TO stm?

Thanks in advance,

Kalai.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
611

Hullo,

basically both commands will do the same, however with "WRITE TO" conversion routines are used and it's possible to use edit masks:

See the following example:

REPORT ztestak.

data: test1(10) type c,
test2(10) type c.

START-OF-SELECTION.

move sy-datum to test1.
write sy-datum to test2.

write :/ 'With MOVE :', test1.
write :/ 'With WRITE:', test2.

Output:

With MOVE : 20050726 
With WRITE: 07/26/2005

Hope this helps.

6 REPLIES 6
Read only

anversha_s
Active Contributor
0 Likes
611

hi,

1. Todays date is 23.nov.2006. (sy-datum)

Move :---> 20061122

Write :----> 23.11.2006

2. just copy paste to get a taste of it.

3.

report abc.

DATA : STR(15) TYPE C.

MOVE SY-DATUM TO STR.

WRITE:/ STR.

WRITE SY-DATUM TO STR.

WRITE:/ STR.

regards,

anver

Read only

0 Likes
611

hi,

again adding to above.

While using the MOVE statement the source field & the target field should be of the same type or should be type convertible & compatible.

example ;

data : source type i value 100, 
target type i.
move source to target.

In the case of WRIE TO the source field can be of any type but the target field should always be a character type.

example ;

data : source type i value 200,
target(10) type c.
write source to target.

rgds

Anver

Read only

michael-john_turner
Active Participant
0 Likes
611

Hi,

At the simplest level:

MOVE: does type conversion based upon the type of the target field (ie the data type of the source field is converted to the data type of the target field)

WRITE: assumes the target field is of type C (ie character data)

See the ABAP online help for more information (go to transaction SE38, click on the Documentation icon and search for the MOVE and WRITE statements).

MJ

Read only

Former Member
0 Likes
612

Hullo,

basically both commands will do the same, however with "WRITE TO" conversion routines are used and it's possible to use edit masks:

See the following example:

REPORT ztestak.

data: test1(10) type c,
test2(10) type c.

START-OF-SELECTION.

move sy-datum to test1.
write sy-datum to test2.

write :/ 'With MOVE :', test1.
write :/ 'With WRITE:', test2.

Output:

With MOVE : 20050726 
With WRITE: 07/26/2005

Hope this helps.

Read only

abdul_hakim
Active Contributor
0 Likes
611

hi,

the only difference is for WRITE TO the target field should be of character type.

Cheers,

Abdul Hakim

Mark all useful answers..

Read only

Former Member
0 Likes
611

Hi,

Move is a simple data transfer statement to move content of a variable to another.

Write statements are associated with formatting options. some happen automatically and some can be forced by programmer.

like when you write a date field, even though it is internally stored as YYYYMMDD.

these will be done when you do a write to.

So if the source is a date field and the target is a string. imagine..

1. write lv_date1 to lv_date_string dd/mm/yyyy.

lv_date type sy-datum.

lv_date_string type string.

lv_date_string will now have the date as 23/11/2006

2. for the same data declation, if u say

move lv_date1 to lv_date_string...

lv_date_string will have 20061123.

Hope this clarifies ur doubt.

Pls reward suitable points.