‎2007 Apr 18 7:04 AM
‎2007 Apr 18 7:06 AM
MOVE --- > Just moves the field
WRITE ---> changes the format and moves the field
‎2007 Apr 18 7:06 AM
MOVE --- > Just moves the field
WRITE ---> changes the format and moves the field
‎2007 Apr 18 7:09 AM
Hi,
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)
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/2005Hope this helps.
Regards
Sudheer
‎2007 Apr 18 7:17 AM
Hai,
Each are having their own conversion rules when MOVE SOURCE to DESTINATION for WRITE SOURCE TO DESTINATION also have.
For more details see the below:
<b>Syntax:
MOVE source {TO|?TO} destination.</b>
destination {=|?=} source.
Effect
Both these statements assign the content of the operand source to the data object destination. The variants with the language element TO or the assignment operator = are valid for all assignments between operands that are not reference variables, and for assignments between reference variables for which the static type of source is more specific than or the same as the static type of destination(narrowing cast).
Variants with the language element ?TO or the assignment operator ?= (casting operator ) must be used if the source and destination are reference variables and the static type of source is more general than the static type of destination (widening cast). For assignments between operands that are not reference variables, use of the question mark ? is not permitted.
The data object destination can be any data object that can be listed at a write position, and the data object source can be a data object, a predefined function or a functional method (as of release 6.10). The data type of the data object destination must either be compatible with the data type of source, or it must be possible to convert the content of source into the data type of destination according to one of the conversion rules.
Notes
If source and/or destination are field symbols, then, as in all ABAP commands, the system works with the content of the data objects to which the field symbols point. The actual pointer content of a field symbol can only be changed using the statement ASSIGN or the addition ASSIGNING when processing internal tables (value semantics). If source and destination are reference variables, the reference contained in source is assigned to destination (reference semantics).
Strings and internal tables are addressed internally using references. When assignments are made between strings and between internal tables (as of release 6.10), only the reference is transferred, for performance reasons. After the assignment, the actual string or the actual table body of the source as well as the target object are addressed (sharing). When the object is accessed to change it, the sharing is canceled and a copy of the content is made. The sharing is displayed in the memory consumption display of the ABAP debugger and in the Memory Inspector tool (as of release 6.20).
Obsolete Form: MOVE PERCENTAGE
There are three possible outcomes of assigning <f1> to <f2>:
The data objects <f1> and <f2> are fully compatible, that is, their data types, field length, and number of decimal places are identical. The contents of source field <f1> are transferred byte by byte into the target field <f2> without any further manipulation. The MOVE statement is most efficient when this is the case.
The data objects <f1> and <f2> are incompatible. This is the case, for example, if the two fields have the same type, but different lengths. The contents of the source field <f1> are converted so that they are compatible with the data type of <f2>, and are then transferred. This procedure only works if a conversion rule exists between the data types of <f1> and <f2>. Type conversions make the MOVE statement less efficient. How much less efficient depends on the individual conversion.
The data objects <f1> and <f2> are incompatible, and no conversion is possible. The assignment is not possible. If this can be recognized statically, a syntax error occurs. If it is not recognized before the program is run, a runtime error occurs.
The source and target fields can be of different data types. In contrast
<b>Syntax:
WRITE {source|(source_name)} TO destination
[int_format_options].</b>
Effect:
This statement assigns the formatted content of the data object source, or the formatted content of the data object whose name is contained in source_name, to the data object destination. The data objects source_name and destination must be character type and flat. source_name can contain the name of the data object to be assigned in upper or lower case. If the data object specified in source_name does not exist, the assignment is not executed, and sy-subrc is set to 4.
The statement WRITE TO has the same effect as the statement WRITE for lists. This statement formats the content of source or the source field specified in source_name as described in the field. It does not, however, store the result in an output area of a list in the list buffer, but instead stores it in a variable. The output length is determined by the length of the variable.
The same additions int_format_options can be specified for formatting the content as in the statement WRITE for lists, except for NO-GAP and UNDER.
System fields
sy-subrc Meaning
0 The data object specified in source_name was found and the assignment was executed.
4 The data object specified in source_name was not found and the assignment was not executed
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 users 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.
Reward points if it helps you.
Regds,
Rama chary.Pammi