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: 

move to and write to

Former Member
0 Kudos

hi,

when we use write to and move to......

1 ACCEPTED SOLUTION

varma_narayana
Active Contributor
0 Kudos

Hi..

Data : V_date type D value '20071023'.

Data : v_text1(10).

Data : v_text2(10).

<b>Move V_date to V_text1. "It will transfer the data in internal format</b>

Write:/ v_text1. "output will be 20071023

<b>Write V_date to V_text2. "It will transfer the data in Output format</b>

Write:/ v_text2. "output will be 23/10/2007 i.e as per User settings

<b>reward if Helpful.</b>

4 REPLIES 4

hymavathi_oruganti
Active Contributor
0 Kudos

WRITE {source|(source_name)} TO destination

[int_format_options].

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.

For the static specification of source, sy-subrc is not set.

Note:

If destination is specified as an untyped field symbol or an untyped formal parameter, and is not flat and character-type when the statement is executed, this leads to an untreatable exception in a Unicode program. In non-Unicode programs, this only leads to an exception for deep types. Flat types are handled as character-type data types.

Example:

After the assignment, the variables date_short and date_long receive the current date in the order specified in the user master record. The variable date_long also contains the defined separators, as the output length is sufficiently long. The content of the variable date_mask is formatted according to the formatting addition DD/MM/YY.

DATA: date_short(8) TYPE c,

date_long(10) TYPE c,

date_mask(8) TYPE c.

WRITE sy-datum TO: date_short,

date_long,

date_mask DD/MM/YY

MOVE source {TO|?TO} destination.

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.

former_member404244
Active Contributor
0 Kudos

Hi,

check the below thread..

reward if helpful.

Regards,

Nagaraj

Former Member
0 Kudos

hi! Hemanth

Move to - When we are in need to move the data from 1 location to another . i,e to Itab ...

Write to - When we to display OR write in a particular location for view.or listing

Reward me if its useful.

Regards,

Nagulan.

varma_narayana
Active Contributor
0 Kudos

Hi..

Data : V_date type D value '20071023'.

Data : v_text1(10).

Data : v_text2(10).

<b>Move V_date to V_text1. "It will transfer the data in internal format</b>

Write:/ v_text1. "output will be 20071023

<b>Write V_date to V_text2. "It will transfer the data in Output format</b>

Write:/ v_text2. "output will be 23/10/2007 i.e as per User settings

<b>reward if Helpful.</b>