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: 

REGARDING WRITE

Former Member
0 Kudos

WRITE : FIELD1 TO FIELD2,FIELD3,FIELD4.

WHAT HAPPENS EXACTLY ,

IF IT IS OF SAME DATA TYPE.

WHAT HAPPENS IF IT IS OF DIFFERENT DATA-TYPE.

EXPLAIN IN SCENARIOS

6 REPLIES 6

Former Member
0 Kudos

Hi

The result will be FIELD1'll be written in FIELD2, FIELD3 and FLIED4'll be written on video (so Abap list).

Max

0 Kudos

what is the use of move.

using move also we can do the same-thing,

then what is the use of this "" write"" statment.

Former Member
0 Kudos

if the both the data types are compatible filed1 will be transfered to field2 otherwise you will get a syntax error.

example you can write an integer to char but not a char to integer.

data: int type i value 5,

char type c.

write int to char. will work

write char to int. syntax error

Thanks.

Message was edited by:

mg s

Former Member
0 Kudos

w_field(4) type c value 'BOSS',

w_field1(10) type c,

w_field2(8) type c,

w_field3(6) type c.

write w_field to : w_field1, w_field2, w_field3.

write : w_field, w_field1, w_field2, w_field3.

In this case all the values are moved. But if the size of the target is less the additional data is truncated.

Here are the rules....

<b>Conversion table for source type C</b>

Target

Conversion

C

The target field is filled from left to right. If it is too long, it is filled with blanks from the right. If it is too short, the contents are truncated from the right.

D

The character field must contain an 8-character date in the format YYYYMMDD .

F

The contents of the source field must be a valid representation of a type F field as described in Literals.

N

Only the digits in the source field are copied. The field is right-justified and filled with trailing zeros.

I, P

The source field must contain the representation of a decimal number, that is, a sequence of digits with an optional sign and no more than one decimal point. The source field can contain blanks. If the target field is too short, an overflow may occur. This may cause the system to terminate the program.

STRING

The occupied length of the source field is copied. All trailing spaces are truncated.

T

The character field must contain a six-character time in HHMMSS format.

X

Since the character field must contain a hexadecimal string, the only valid characters are 0,1,2,3,4,5,6,7,8,9,A,B,C,D,E,F. This string is packed as a hexadecimal number, transported left-justified, and filled with zeros or truncated on the right.

XSTRING

As for fields of type X, except that the target field is not filled with zeros.

Regards,

Pavan P.

varma_narayana
Active Contributor
0 Kudos

Hi...

We can use the WRITE statement is 2 ways.

<b>WRITE VAR. </b> This is to display the field in the list.

DATA: var1 type sy-datum.

var2(10) .

var1 = sy-datum.

<b>WRITE VAR1 TO VAR2.</b>

in this case WRITE statement acts as assignment operator. but it will copy the data to the field using the OUTPUT format (DD.MM.YYYY) instead of INTERNAL format (YYYYMMDD)

incase of

MOVE var1 to var2.

it will copy using INTERNAL format only.

<b>Reward if helpful.</b>

Former Member
0 Kudos

hi,

writes the value of field1 to remaining fields.

In case of different data types system performs internal type conversions if they are also not possible then it displays an error regarding type incompatible.

ex: system can internally converts a char value to integer,

integer to float

..............

if helpful reward some points.

with regards,

Suresh.A