ABAP Keyword Documentation → ABAP - Reference → Processing Internal Data → Character String and Byte String Processing → Statements for Character String and Byte String Processing → WRITE - TO
WRITE - format_options
Other versions: 7.31 | 7.40 | 7.54
Syntax
... [LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED]
{ { [EXPONENT exp]
[NO-GROUPING]
[NO-SIGN]
[NO-ZERO]
[CURRENCY cur]
{ { [DECIMALS dec]
[ROUND scale] }
| [UNIT unit] } }
| { [ENVIRONMENT TIME FORMAT]
[TIME ZONE tz] }
[STYLE stl] }
[USING { {NO EDIT MASK}|{EDIT MASK mask} }]
[ DD/MM/YY | MM/DD/YY
| DD/MM/YYYY | MM/DD/YYYY
| DDMMYY | MMDDYY
| YYMMDD ] ...
Extras
1. ... LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED
2. ... EXPONENT exp
3. ... NO-GROUPING
4. ... NO-SIGN
5. ... NO-ZERO
6. ... CURRENCY cur
7. ... DECIMALS dec
8. ... ROUND scale
9. ... UNIT unit
10. ... ENVIRONMENT TIME FORMAT
11. ... TIME ZONE tz
12. ... STYLE stl
13. ... USING { {NO EDIT MASK}|{EDIT MASK mask} }
14. ... DD/MM/YY | MM/DD/YY
| DD/MM/YYYY | MM/DD/YYYY | DDMMYY | MMDDYY
| YYMMDD
Effect
These formatting options override the predefined formats
of the statements WRITE ... TO
and WRITE. Without these additions, the content of the source field is formatted only according to its data type.
The result of the formatting is adapted to the available length. In the case of WRITE ... TO, this is the length of the target variable; in the case of WRITE, this is the
output length. In some cases, the behavior of
the additions used in combination with WRITE can differ from the general behavior in the case of WRITE ... TO.
If a conversion routine is executed when formatting, the other formatting options are ignored.
The additions can be used together, with the following restrictions:
-
The additions
ENVIRONMENT TIME FORMATandTIME ZONEare mutually exclusive and cannot be used with the additionsCURRENCY, DECIMALS,EXPONENT,NO-GROUPING, NO-SIGN,NO-ZERO,ROUND,STYLE, orUNIT. -
The addition
STYLEcannot be used together with the additionsCURRENCY,DD/MM/YY, ... ,YYMMDD,ROUND,ENVIRONMENT TIME FORMAT,TIME ZONE, andUNIT. -
The addition
UNITcannot be used together with the additionsDECIMALS,ROUND,STYLE,ENVIRONMENT TIME FORMAT, andTIME ZONE.
Note
The definition of a decimal floating point
number in ABAP Dictionary always defines an output style. This means that, when data objects declared
with a reference to this type in ABAP Dictionary and are part of the output, the same exclusions apply as when using the addition STYLE.
Addition 1
... LEFT-JUSTIFIED|CENTERED|RIGHT-JUSTIFIED
Effect
This addition determines whether the content of the source field that is formatted according to the
other options is adjusted within the available length to the right, the center, or to the left. Trailing
blanks are ignored for fields of type c and are handled like all other characters for fields of type string.
The adjustment is done by filling surplus positions in the result either from the right or from the
left or alternately from the left and right with blanks. If the available length is too short, source
fields of the types c and string are truncated on the left (if right-justified), unlike the usual
cutoff behavior.
Example
Left-justified, centered, and right-justified assignment of three text field literals to a text field of 50 characters length.
DATA formatted_text TYPE c LENGTH 50.
WRITE 'Left' TO formatted_text LEFT-JUSTIFIED.
cl_demo_output=>write( formatted_text ).
WRITE 'Center' TO formatted_text CENTERED.
cl_demo_output=>write( formatted_text ).
WRITE 'Right' TO formatted_text RIGHT-JUSTIFIED.
cl_demo_output=>write( formatted_text ).
cl_demo_output=>display( ).
Addition 2
... EXPONENT exp
This addition cannot be used together with additions ENVIRONMENT TIME FORMAT and TIME ZONE.
Effect
This addition determines the exponent when formatting
floating point
numbers. The addition EXPONENT affects source fields of the type f or when the addition STYLE is specified. Otherwise it is ignored.
exp expects a data object of the type i that contains the required exponent.
-
In data type
f, the mantissa is adjusted to this exponent by moving the decimal point and padding with zeroes. Ifexpcontains 0, no exponent is created. If the value ofexpis greater than the exponent of the source field plus 16, only zeroes are allocated to the mantissa. If the value ofexpis less than the exponent of the source field, and there is not enough space for the places required before the decimal point, the addition is ignored. If the value inexpis positive and has more than three digits, only the first three digits of the exponent are used. -
The addition
STYLEconverts source fields of all numeric types (b,s),i,p,f,decfloat16, anddecfloat34before formatting todecfloat34. Only the scientific notation O_SCIENTIFIC can be declared together withEXPONENTafterSTYLE. The additionEXPONENTdefines the exponent here.
Example
The formatted result of the statement WRITE TO is "1,414". The standard formatting for a length of 6 would be "1E+00".
DATA: float TYPE f,
formatted_text TYPE c LENGTH 6.
float = SQRT( 2 ).
WRITE float TO formatted_text EXPONENT 0.
cl_demo_output=>display( formatted_text ).
Addition 3
... NO-GROUPING
This addition cannot be used together with additions ENVIRONMENT TIME FORMAT and TIME ZONE.
Effect
When formatting data objects of the data types (s), i,
p, decfloat16, or decfloat34, this addition suppresses the thousands separators. Otherwise, the addition is ignored.
Addition 4
... NO-SIGN
This addition cannot be used together with additions ENVIRONMENT TIME FORMAT and TIME ZONE.
Effect
When formatting data objects of the data types (s), i,
p, decfloat16, decfloat34, or f, this addition suppresses the sign. Otherwise, the addition is ignored.
Example
Output of numbers with explanatory text instead of with +/-sign.
DATA: number TYPE i,
formatted_text TYPE c LENGTH 10.
DO 10 TIMES.
number = sy-index - 5.
IF number >= 0.
WRITE number TO formatted_text.
cl_demo_output=>write_text( formatted_text && ` (positive)` ).
ELSE.
WRITE number TO formatted_text NO-SIGN.
cl_demo_output=>write_text( formatted_text && ` (negative)` ).
ENDIF.
ENDDO.
cl_demo_output=>display( ).
Addition 5
... NO-ZERO
This addition cannot be used together with additions ENVIRONMENT TIME FORMAT and TIME ZONE.
Effect
If the source field has a numeric data type and contains the value 0, the available length is padded
with blanks. If the source field has the data type c, n,
or string, leading zeroes are formatted as blanks. Otherwise, the addition is ignored.
Example
Formats the content of a numeric text field as "123" instead of "0000000123".
DATA: num TYPE n LENGTH 10 VALUE '123',
formatted_text TYPE c LENGTH 10.
WRITE num TO formatted_text.
cl_demo_output=>write_text( formatted_text ).
WRITE num TO formatted_text NO-ZERO.
cl_demo_output=>display_text( formatted_text ).
Addition 6
... CURRENCY cur
This addition cannot be used together with the additions ENVIRONMENT TIME FORMAT
and TIME ZONE and not for the numeric data types decfloat16
and decfloat34. This means it also cannot be used together with the addition STYLE.
Effect
This addition determines the currency-dependent fractional portion when formatting data objects of the numeric data types
(b, s), i, p,
and f. The numeric data types decfloat16 and
decfloat34 produce a syntax error or raise an exception. For all other data types the addition is ignored.
For all permitted numeric data types, cur expects a character-like field containing a
currency code from the
column WAERS of the database table TCURC in uppercase. Usually two decimal
places are used for every value entered in cur, unless the currency code
specified is in the column CURRKEY of the database table TCURX. In this case, the number of decimal places is determined using the CURRDEC column of this table.
For the individual numeric data types, the following applies:
-
For data objects of the types (
b,s) and i , a decimal separator is inserted into the result at the position determined bycurand the thousands separators are moved accordingly. -
For data objects of type
p, the decimal places determined by the definition of the data type are ignored completely. Independent of the actual value and without rounding, decimal separators and thousands separators are inserted between the digits at the positions determined bycur. -
For data objects of type
f, additionCURRENCYhas the same effect as additionDECIMALS(see below), where the number of decimal places is determined bycur.
Note
The addition CURRENCY is useful with currencies from the database tables TCURC or TCURX for displaying data objects of types
(b, s), i , or
p without decimal places, whose contents are currency amounts in the smallest unit of the currency.
Example
The formatted result of "12345678" is "123456,78". The currency code "EUR" is contained in the database table TCURC, but not in TCURX. For this reason two decimal places are used by default.
DATA: int TYPE i VALUE 12345678,
formatted_text TYPE c LENGTH 10.
WRITE int TO formatted_text NO-GROUPING CURRENCY 'EUR'.
cl_demo_output=>display_text( formatted_text ).
Addition 7
... DECIMALS dec
This addition cannot be used together with additions ENVIRONMENT TIME FORMAT, TIME ZONE, and UNIT.
Effect
This addition determines the number of decimal places when formatting data objects of the data types
(b, s),i, p,
decfloat16, decfloat34, or f. Otherwise, the addition is ignored.
dec expects a data object of type i that contains
the number of desired decimal places. If the content of dec is less than 0, it is handled like 0. The content of data objects of data types
(b, s), i, or
p is multiplied by 10 to the power of dec beforehand. For the individual numeric data types, the following applies:
-
For data objects of types (
b,s) andi, a decimal separator and as many zeroes as specified indecare appended. The content ofdecmust not exceed 14, otherwise an unhandleable exception is raised. If the content ofdecis 0, the output remains unaffected. -
For data objects of type
p, independently of the number of decimal places determined in the data type, as many decimal places are used as are specified indec. The content ofdecmust not exceed 14, otherwise an unhandleable exception is raised. If the source field has more decimal places, they are rounded to the decimal places indec. If the source field has fewer decimal places, zeroes are appended accordingly. -
For data objects of types
decfloat16anddecfloat34, the content ofdecdecides the number of decimal places in mathematical notation and the number of decimal places in the mantissa in scientific notation. -
For data objects of type
f, the content ofdecdetermines the number of decimal places in the scientific notation. If the content ofdecis greater than 16, it is handled like 16. If the content ofdecis greater than the number of decimal places of the source field, zeroes are appended accordingly. If the content ofdecis less than the number of decimal places of the source field, they are rounded to the decimal places indec.
If the addition CURRENCY is also specified, it is first executed for the data types
(b, s), i , and
p before the addition DECIMALS is applied. For data type f,
the addition CURRENCY is ignored if it is specified together with DECIMALS.
Example
The formatted result of "1234.5678" is "1234,57".
DATA: pack TYPE p LENGTH 8 DECIMALS 4
VALUE '1234.5678',
formatted_text TYPE c LENGTH 10.
WRITE pack TO formatted_text NO-GROUPING DECIMALS 2.
cl_demo_output=>display_text( formatted_text ).
Addition 8
... ROUND scale
This addition cannot be used together with additions STYLE, ENVIRONMENT
TIME FORMAT, TIME ZONE, and UNIT. Also, ROUND cannot be used for
decimal floating point numbers defined in ABAP Dictionary, because these always have an output style assigned to them.
Effect
For source fields of data type p, this addition multiplies the value of the data object by 10 to the power of
-scale before it is formatted. Otherwise, the addition is ignored.
scale expects a data object of type i that contains the value of the desired scaling.
If the value of scale is greater than 0 and the addition DECIMALS is not specified, the intermediate result is rounded to the
fractional portion
defined in the data type. If the addition DECIMALS is specified, it is rounded to the number of decimal places specified in dec and these places are output.
If the addition CURRENCY is specified, it is applied to the content of the
source field before the multiplication is executed. If the addition DECIMALS
is not specified, the number of decimal places determined by cur is used
for rounding and formatting. If the addition DECIMALS is specified, the value in dec is used.
Example
The formatted result of "12345678" is "123456.7800".
DATA: pack TYPE p LENGTH 8 DECIMALS 0
VALUE '12345678',
formatted_text TYPE c LENGTH 12.
WRITE pack TO formatted_text NO-GROUPING ROUND 2 DECIMALS 4.
cl_demo_output=>display_text( formatted_text ).
Addition 9
... UNIT unit
This addition cannot be used together
with additions DECIMALS, ROUND, STYLE,
ENVIRONMENT TIME FORMAT, and TIME ZONE. Also, UNIT cannot be used for
decimal floating point numbers defined in ABAP Dictionary, because these always have an output style assigned to them.
Effect
This addition truncates the
decimal places that have a value of 0 and that lie outside of the accuracy of a measurement unit
when formatting data objects of data type p. Otherwise the addition is ignored (except for type f).
unit expects a character-like field that contains a
unit code from column MSEHI
of database table T006 in uppercase letters. The system uses column DECAN
of the related row in database table T006 to determine the number of decimal places. If the content of unit is not found in T006, the addition is ignored.
-
If the data type of source field is
pand has at least as many decimal places as specified byunit, and if no other places that are not equal to 0 are cut off by this action, the content of the source field is formatted with this number of decimal places. -
For data objects of type
f, the additionUNIThas the same effect as the additionDECIMALS(see above), where the number of decimal places is determined byunit.
If, at the same time, the addition CURRENCY is used, this addition is executed
first for data type p, before addition UNIT. In this case the addition is ignored for data type f as well.
Example
The first unit ID of the database table T006 is read for which no decimal places are specified in the
column DECAN and this ID is used after the addition UNIT. This formats "1234.0000" as "1234".
DATA: pack TYPE p LENGTH 8 DECIMALS 4
VALUE '1234.0000',
formatted_text TYPE c LENGTH 12,
unit TYPE t006-msehi.
SELECT SINGLE msehi
FROM t006
WHERE decan = 0
INTO (@unit).
IF sy-subrc = 0.
WRITE pack TO formatted_text NO-GROUPING UNIT unit.
cl_demo_output=>display_text( formatted_text ).
ENDIF.
Addition 10
... ENVIRONMENT TIME FORMAT
This addition cannot be used together with additions CURRENCY, DECIMALS,
EXPONENT, NO-GROUPING, NO-SIGN,
NO-ZERO, ROUND, STYLE,
TIME ZONE, or UNIT. Also, ENVIRONMENT TIME FORMAT cannot be used for
decimal floating point numbers defined in ABAP Dictionary, because these always have an output style assigned to them.
Effect
When this addition is used, the formatting is based on a specified time
according to the current formatting setting of the
language environment
that can be set using SET COUNTRY.
A 24-hour format (default) and four 12-hour formats can be configured. The source field can have the type t. The addition is ignored if other types are specified.
The required output length for the 12-hour formats is 11. If data is specified explicitly and statically
in the statement WRITE for a source field with type t,
an output length of at least 11 must be specified. If a dynamic output length is specified, or if the target field for WRITE TO is shorter than 11, the truncation is performed as described
here.
Note
Unlike times, the format of digits or dates in the statement WRITE is always
variable. The format of times is variable only if addition ENVIRONMENT TIME FORMAT is specified.
Addition 11
... TIME ZONE tz
This addition cannot be used together with additions CURRENCY, DECIMALS,
ENVIRONMENT TIME FORMAT, EXPONENT, NO-GROUPING,
NO-SIGN, NO-ZERO, ROUND, STYLE, or UNIT . Also, TIME ZONE cannot be used for
decimal floating point numbers defined in ABAP Dictionary, because these always have an output style assigned to them.
Effect
This addition converts the date and time information of a time stamp to the local date and the local time of the specified time zone. The formatting is done in accordance with the predefined format for time stamps.
The addition TIME ZONE can be specified only if the source field has one
of the data types TIMESTAMPL or TIMESTAMP
from ABAP Dictionary (as with type p with length 11 and 7 decimal places or p with length 8 and no decimal places) as a
time stamp. Other data types produce a syntax error or runtime error.
tz expects a character-like data object containing a
time zone from the database table TTZZ. If the
rule set for the specified time zone is incomplete,
an exception that cannot be handled is raised. If tz is initial, the time zone is set implicitly to "UTC".
If the addition TIME ZONE is specified for source fields with the types
TIMESTAMPL or TIMESTAMP from ABAP Dictionary, the content of the
source field is handled like a time stamp. The conversion is performed in the same way as with the statement CONVERT TIME STAMP.
If the value of tz is not in the database table TTZZ, if the source field
does not contain a valid time stamp, or if the conversion produces a local time outside the value range
for local dates and times, the content is formatted as a UTC time stamp, regardless of the value. Also, an asterisk ("*") is inserted before the date and the final digit of the time is cut off.
If the addition TIME ZONE is not specified for source fields of the types
TIMESTAMPL or TIMESTAMP, the source field is handled in accordance with its numeric type, p.
Notes
-
The addition
ENVIRONMENT TIME FORMATcannot be specified together withTIME ZONE, which means that the 12-hour format for times cannot be used for time stamps. -
The additions
DD/MM/YY, and so on, can also be specified for time stamps and modify the format of the specified date.
Example
Formats a UTC time stamp in Tasmanian time. During summer time, the result is "2010-06-27 04:00:00".
DATA: time_stamp TYPE timestamp,
tzone TYPE timezone,
formatted_text TYPE c LENGTH 50.
time_stamp = 20100627180000.
tzone = 'AUSTAS'.
WRITE time_stamp TO formatted_text TIME ZONE tzone.
cl_demo_output=>display_text( formatted_text ).
Addition 12
... STYLE stl
This addition cannot be used together with the additions CURRENCY,
DD/MM/YY, ... , YYMMDD, ROUND, ENVIRONMENT
TIME FORMAT, TIME ZONE, and UNIT.
Effect
This addition defines the output format for decimal floating point numbers. Only source fields with a
numeric data type are allowed. Numeric source fields that do not have type decfloat34 are
converted to this type before they are formatted. If other types are specified dynamically, the exception CX_SY_WRITE_INVALID_STYLE is raised.
Only those values can be specified for the stl output format that exist as
constants of type OUTPUTSTYLE in the class CL_ABAP_FORMAT; otherwise the exception CX_SY_WRITE_INVALID_STYLE is also raised. The following table contains all possible output formats:
| Constant CL_ABAP_FORMAT=>... | Output Format |
|---|---|
| O_SIMPLE | Predefined Output Format |
| O_SIGN_AS_POSTFIX | Commercial notationThe sign is appended to the right (minus sign for negative values, blank for positive values). Trailingzeroes in decimal places are cut off. Unlike in O_SIMPLE, where it switches to scientific notation, an exception is raised if not enough space is available. |
| O_SCALE_PRESERVING | Predefined output format that preserves the scale, in which trailing zeroes in decimal places are not cut off. The same format is used as inthe conversion of a source field of type decfloat34 to type string, where thepredefined decimal separator of the statement WRITE is used. If enough space is available, thousands separators are also inserted in the mathematicalnotation. If not enough space is available, an exception is raised. The maximum required length is 24 for decfloat16 and 46 for decfloat34. |
| O_SCIENTIFIC | Scientific notationNo sign is used for a positive number. The output always has at least a two digit exponent with a sign.If the addition EXPONENT is not specified, only one digit (whose value isnot zero) is represented in the mantissa before the decimal place, unless the source field has the value0. Any trailing zeroes in the decimal places of the mantissa are cut off. Using the addition DECIMALS,the number of decimal places of the exponent can be specified with EXPONENT.If neither of the additions DECIMALS and EXPONENTare used, the maximum length needed is 23 for decfloat16 and 42 for decfloat34. If not enough space is available, commercial rounding is used. If insufficient spaceis available for the sign, the minimum number of digits before the decimal place of the mantissa, and the required exponent, an exception of the CX_SY_CONVERSION_OVERFLOW class is raised. |
| O_SCIENTIFIC_WITH_LEADING_ZERO | Scientific withleading zero with leading zero As O_SCIENTIFIC with the following differences: Only one digit withthe value 0 is produced before the decimal place. The addition EXPONENT cannotbe used. If the addition DECIMALS is not used, the maximum length needed is 24 for decfloat16 and 43 for decfloat34. |
| O_SCALE_PRESERVING_SCIENTIFIC | Scientific notation preservingscaling. As O_SCIENTIFIC withthe following differences: The exponent always has three digits for decfloat16and four digits for decfloat34. Trailing zeroes after the decimal point ofthe mantissa are not cut off. The addition EXPONENT cannot be used. If insufficientspace is available, rounding does not take place; instead an exception of the CX_SY_CONVERSION_OVERFLOW class is raised. |
| O_ENGINEERING | Engineering format - as O_SCIENTIFIC with the following differences: The value of the exponent isalways a whole number to the power of 3. The value range of the digits before the decimal place is between1 and 999, unless the source field has the value 0. The addition EXPONENT cannot be used. |
If the addition STYLE is used together with other additions that also influence the format of numbers, the following rules apply:
-
The addition
EXPONENTcan only be specified for the output format O_SCIENTIFIC for scientific notation. -
The addition
DECIMALScannot be specified for output formats that preserve scale. For the output formats O_SIMPLE and O_SIGN_AS_POSTFIX,DECIMALSdetermines the number of decimal places. In some cases commercial rounding may take place or trailing zeroes may be appended. For the scientific output formats,DECIMALSdetermines the number of decimal places in the mantissa. In some cases commercial rounding may take place. -
The addition
USING EDIT MASKcan only be specified if it calls a conversion routine. The additionUSING NO EDIT MASKcan be specified as normal.
Notes
- To a great extent, the output formats match the output styles specified when a domain is created with one of the types DF16_DEC, DF16_RAW, DF16_SCL (obsolete), DF34_DEC, DF34_RAW, or DF34_SCL (obsolete) in ABAP Dictionary.
-
The output of a decimal floating point number
defined in ABAP Dictionary causes the addition
STYLEto override the output style defined in ABAP Dictionary. -
It is best to use the addition
STYLEfor the formatting of all numeric output. This addition then replaces all other additions whose output format can be specified usingstl. -
To specify the scaling of a decimal floating point number before the use of the output format O_SCALE_PRESERVING_SCIENTIFIC,
the predefined function
rescalecan be called by specifying the parameterdec. -
The output format O_SCALE_PRESERVING_SCIENTIFIC is intended to help create output that is vertically
adjusted in relation to the decimal separator and exponent without the addition
DECIMALSbeing used. To make this possible, the predefined functionrescalecan be called before output by specifying the parameterprec.
Addition 13
... USING { {NO EDIT MASK}|{EDIT MASK mask} }
Effect
This addition overrides a conversion
routine assigned using a reference to ABAP Dictionary. The addition NO EDIT
MASK only switches off the execution of an assigned conversion routine. The addition EDIT MASK calls either another conversion routine or defines an
edit mask. mask expects a character-like data object.
To call any conversion routine CNVRT, mask must contain two equals signs
directly followed by the name of the conversion routine: "==CNVRT". During formatting, the content of
the source field is passed to function module CONVERSION_EXIT_CNVRT_OUTPUT, converted there, and the
result is used. If the function module is not found, a handleable exception is raised. The statement
DESCRIBE FIELD contains an addition so that it can fill mask accordingly.
If the first two characters in mask are not equals signs, the content is
interpreted as an edit mask, in which some characters have a particular meaning. The statement
WRITE then does not directly format the content of the source field, but the character string in mask instead, as follows:
-
If the first two characters in
maskare "LL" or "RR", they are not inserted into the result. They specify whether the formatting is executed left-justified or right-justified. If the first two characters are any other characters, the formatting is left-justified. -
All "_" characters are replaced from the left (if "LL") or from the right (if "RR") by the characters for character-like types or numbers for the types
(
b,s),i, or p from the source field. For fields of typec, trailing blanks are ignored. Data objects of typesforxare converted to typecbefore they are formatted. Surplus characters "_" inmaskare replaced by blanks. Characters from the source field for which there are no "_" characters inmaskare not included in the result. -
If the source field is of type (
b,s),i, orp, the character "V" inmaskis inserted from the left for a negative number as "-" and for a positive number as a blank into the result. -
All other characters in the edit mask are taken over unchanged.
The formatting is executed for the available length. If formatting options other than an edit mask have
also been specified, they are applied first and then the special characters in the edit mask are replaced
by the intermediate result. The date formatting mask DD/MM/YY is an exception to this rule. If it is specified, the edit mask is ignored.
Notes
- The sign of a negative number is not included in the result if no formatting character "V" is specified. The decimal separator of a packed number with decimal places must be specified at the desired position in the edit mask.
-
For type
p, note that only the digits are evaluated and the position of the decimal separator is of no consequence. -
A conversion routine must be called for the types
decfloat16anddecfloat34. Edit masks cannot be specified. -
When using
EDIT MASKin the statementWRITEfor lists, a number of special features are applicable.
Example
Formats a duration. The assignment executes the function module CONVERSION_EXIT_DURA_OUTPUT,
which converts the period given in seconds into minutes. In the second mapping, the edit mask is used
according to the rules specified above, where the underscores "_" are replaced with characters from time.
DATA: dura TYPE i,
time TYPE t VALUE '080000',
formatted_text TYPE c LENGTH 30.
dura = sy-uzeit - time.
time = dura.
WRITE dura TO formatted_text USING EDIT MASK '==SDURA'.
cl_demo_output=>write_text( formatted_text ).
WRITE time TO formatted_text USING EDIT MASK
'RRThe duration is __:__:__'.
cl_demo_output=>display_text( formatted_text ).
Addition 14
... DD/MM/YY | MM/DD/YY | DD/MM/YYYY | MM/DD/YYYY
| DDMMYY | MMDDYY | YYMMDD
These additions cannot be used together with the addition STYLE and not for
decimal floating point numbers defined in ABAP Dictionary, which are always assigned an output style.
Effect
These additions affect the formatting of data objects of the data type d or the date specified in
time stamps if they are specified as time stamps by the addition TIME ZONE. Otherwise they are ignored.
The content of a data object of type d, or the date specified in a time stamp,
is interpreted as a valid date in the form "yyyymmdd" and formatted for the individual additions as follows:
-
DD/MM/YYandMM/DD/YY
Both additions have the same effect. The date is formatted with a two-digit year and separators. Separators and order are determined
according to the current formatting setting of the
language
environment that can be set using SET COUNTRY.
-
DD/MM/YYYYandMM/DD/YYYY
Both additions have the same effect. The date is formatted with a four-digit year with separators. Separators and order are determined
according to the current formatting setting of the
language
environment that can be set using SET COUNTRY.
-
DDMMYYandMMDDYY
Both additions have the same effect. The date is formatted with a two-digit year with no separators. The order is determined
according to the current formatting setting of the
language
environment that can be set using SET COUNTRY.
-
YYMMDD
This addition formats the date with a two-digit year without separators in the format "yymmdd".
If the available length is too short, the formatted output is truncated on the right.
Notes
- The truncation on the right differs from the usual cutoff behavior in the date output specified by the formatting setting of the language environment, where first the separators are removed and then any surplus characters are cut off.
-
Some special properties
apply when date masks are used in the statement
WRITEfor lists.
Example
The formatting is, for example, "060131".
DATA formatted_text TYPE c LENGTH 50.
WRITE sy-datlo TO formatted_text YYMMDD.
cl_demo_output=>display_text( formatted_text ).
Continue
Decimal Floating Point Numbers, Formatting with STYLE - Example