‎2006 Nov 23 1:27 PM
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.
‎2006 Nov 23 1:31 PM
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.
‎2006 Nov 23 1:30 PM
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
‎2006 Nov 23 1:50 PM
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
‎2006 Nov 23 1:31 PM
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
‎2006 Nov 23 1:31 PM
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.
‎2006 Nov 23 1:32 PM
hi,
the only difference is for WRITE TO the target field should be of character type.
Cheers,
Abdul Hakim
Mark all useful answers..
‎2006 Nov 23 1:46 PM
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.