Application Development 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: 

Difference between MOVE and WRITE TO

Former Member
0 Kudos
2,475

What is the difference between MOVE and WRITE TO ?

I have gone thr std help but unable to get it exactly. What is peculiarity about type c ?

The documentation says " 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. "

Regards,

Nitin

1 ACCEPTED SOLUTION

Former Member
0 Kudos
200

hi,

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.

6 REPLIES 6

Former Member
0 Kudos
200

Hi Nitin,

Have you found the answer to this qustion ?

Regards,

Anand Mandalika.

Former Member
0 Kudos
200

Hi Nitin,

I believe the difference is this:

Though both are used to transfer contents of a variable, we should use 'write to' when we need the effect of outputting the variable to list output. (well thats what the documentation says).

U might wonder what the difference is.. suppose we use these methods on a field with conversion exit, it will be clear. Using 'write to', the value is converted using the conversion exit while it is not the case with move.

regards,

Pavan.

Former Member
0 Kudos
200

Hi Nitin,

Try this...

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

Former Member
0 Kudos
200

when you are using 'MOVE' it will try to cast the value according to the target variable.

And also sy-subrc behaves differently

if sy-subrc eq 2 casting done with some adjustments

sy-subrc eq 4

u got some other values u can find them in online documentaion.

Hope This helps

Ismail

0 Kudos
200

Re: Difference between MOVE and WRITE TO

Posted: Jul 27, 2005 4:24 PM Reply E-mail this post

when you are using 'MOVE' it will try to cast the value according to the target variable.

And also sy-subrc behaves differently for move statement

if sy-subrc eq 2 casting done with some adjustments

sy-subrc eq 4

u got some other values u can find them in online documentaion.

Hope This helps

Ismail

Former Member
0 Kudos
201

hi,

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.