Formatting Options

You can use various formatting options with the WRITE statement.

Syntax

WRITE .... f option.

Option

Function

LEFT-JUSTIFIED

Output is left-justified.

CENTERED

Output is centered.

RIGHT-JUSTIFIED

Output is right-justified.

UNDERg

Output starts directly under field g.

NO-GAP

The blank after field f is omitted.

USING EDIT MASKm

Specifies format template m.

USING NO EDIT MASK

Deactivates a format template specified in the ABAP Dictionary.

NO-ZERO

If a field contains only zeros, these are replaced by blanks. For type c and n fields, leading zeros are replaced automatically.

Option

Function

NO-SIGN

The leading sign is not displayed on the screen.

DECIMALSd

d defines the number of digits after the decimal point.

EXPONENTe

In type f fields, the exponent is defined in e.

ROUNDr

Type p fields are multiplied by 10**(-r) and then rounded.

CURRENCYc

Format according to currency c in table TCURX.

UNITu

The number of decimal places is fixed according to unit u specified in table T006 for type p fields.

Option

Function

DD/MM/YY

Separators as defined in user's master record.

MM/DD/YY

Separators as defined in user's master record.

DD/MM/YYYY

Separators as defined in user's master record.

MM/DD/YYYY

Separators as defined in user's master record.

DDMMYY

No separators.

MMDDYY

No separators.

YYMMDD

No separators.

For more information on formatting options and the exclusion principles for some of these options, see the keyword documentation for the WRITE statement.

Below are some examples of formatting options. For more examples, see Creating Complex Lists. The decimal character and thousands separators (period or comma) of numeric fields are defined in the user's master record

ABAP Coding

Screen Output

DATA: g(5) TYPE c VALUE 'Hello',
  f(5) TYPE c VALUE 'Dolly'.
WRITE: g, f.
WRITE: /10 g,
   /  f UNDER g.
WRITE: / g NO-GAP, f.

Hello Dolly

Hello

Dolly

HelloDolly

DATA time TYPE t VALUE '154633'.
WRITE: time,
  /(8) time USING EDIT MASK '__:__:__'.

154633

3:46:33 PM

WRITE: '000123',
   / '000123' NO-ZERO.

000123

123

DATA float TYPE f VALUE '123456789.0'.
WRITE float EXPONENT 3.

123456,789E+03

DATA pack TYPE p VALUE '123.456'
  DECIMALS 3.
WRITE pack DECIMALS 2.
WRITE: / pack ROUND -2,
   / pack ROUND -1,
   / pack ROUND 1,
   / pack ROUND 2.

123.46

12,345.600

1,234.560

12.346

1.235

WRITE: sydatum,
   / sydatum yymmdd.

6/27/1995

950627

Apart from the formatting options shown in the above tables, you can also use the formatting options of the FORMAT statement. These options allow you to specify the intensity and color of your output. For more information, see The FORMAT Statement.