Ansicht
Dokumentation

ABENWRITE_FORMATS - WRITE FORMATS

ABENWRITE_FORMATS - WRITE FORMATS

BAL Application Log Documentation   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book

WRITE, Predefined Formats

The predefined output format of the statements WRITE ... TO and WRITE depends on the data type and user-specific default settings. It is partly dependent on the length available. In the case of WRITE ... TO, this is the length of the target variable; in the case of WRITE, this is the output length. If the length is not sufficient, the variables are truncated as specified in the predefined truncation behavior.

Alignment

The following table shows the predefined alignment for the built-in ABAP types.

Data Type Alignment
Numeric data types Right-aligned
Character-like data types Left-aligned
Byte-like data types Left-aligned
Date types/time types Left-aligned

Example

The text field text is padded with blanks on the left by WRITE.

General Format

Numeric Data Types

  • In the numeric data types (b, s), i, int8, and p, the last place on the right is reserved for the sign (this also applies to b, even though these numbers are always positive). Here, negative values are given a minus "-" in the result and positive values a blank. The thousands separators defined in the user master record are inserted if the available length is sufficient. If data type p is used, decimal places are respected regardless of the program property fixed point arithmetic and a decimal separator is inserted if necessary (see below).
  • If the available length is sufficient, decimal floating point numbers with the data types decfloat16 and decfloat34 are displayed in mathematical notation and with the thousands separators defined in the user master record. If the available length is not sufficient for the decimal places of the number, it is rounded commercially to the number of positions available. If the available length is not sufficient for the places in front of the decimal separator, the value is formatted in scientific notation without thousands separators. Negative numbers are prefixed with a minus sign in both cases. An exponent is always displayed with a plus/minus sign, but without leading zeros. Trailing zeros in the decimal places are not shown.
  • A binary floating point number with the type f is formatted in scientific notation with a preceding plus/minus sign (empty if the number is positive), a place before the decimal separator, a maximum of 16 decimal places, the character "E", and a three-figure exponent, including a plus/minus sign.

For, information about the number format with respect to decimal and thousands separators, see.

Notes

  • If there is not enough space available to display a number using these rules, an exception is raised for decimal floating point numbers only. Other numeric types are truncated and flagged with "*".
  • For the data types b and s, it should be noted that the predefined output lengths for lists ignore the place that is reserved for the plus/minus sign, which can lead to unexpected results.

Example

If nothing else is defined in the formatting settings, the example produces the output shown below. It should be noted that the place on the far right is reserved for the sign for type i.

\nbsp           123,456

\nbsp            123,456

\nbsp1.2345600000000E+05

Character-Like Data Types

Data objects of character-like data types are passed without formatting. In the case of character-like data types with a fixed length (c, n), trailing blanks are cut off. The content of text strings with the type string is passed completely.

Example

After the assignment, the variable text contains the left-aligned character string Hello World!.

Byte-Like Data Types

Byte-like data objects are formatted in hexadecimal format, where one byte is represented by two characters.

Example

After the assignment, the variable text contains the left-aligned character string 48656C6C6F20576F726C.

Date Types and Time Types

The content of a date field or time field of type d or t or the content of a time stamp field of type utclong is formatted in accordance with the rules for date and time formats listed below. Here, the content is not checked for the character-like types d and t.

Example

If nothing else is defined in the formatting settings, the example produces the output shown below.

XX/XX/XXXX

XX:XX:XX

Number, Date, and Time Formats

Apart from one exception, numbers, date formats, and time formats are determined by the current formatting setting of the language environment, which can be set using SET COUNTRY.

Number Output

The predefined number format for the output of numeric fields, that is, decimal and thousands separators, depends on the current formatting setting. The possible formats correspond to the country-specific number formats. Thousands separators are inserted only if the length is sufficient.

Example

If nothing else is defined in the formatting settings, the example produces the output shown below.

1,000,000

1,000,000

Date Output

The predefined date format for the output of date fields of type d depends on the current formatting setting. The possible formats correspond to the country-specific date formats. The respective separators are inserted only if the length is sufficient. A date field is formatted regardless of its content.

Example

If nothing else is defined in the formatting settings, the example produces the format shown below.

04/04/2019

04.04.2019

Time Output

Time fields of type t are by default always displayed in 24-hour format with colons as separators. Separators are inserted only if the length is sufficient. To use a 12-hour format defined in the current formatting settings, the addition ENVIRONMENT TIME FORMAT must be used. A time field is formatted regardless of its content.

Example

The example produces the format shown below.

13:07:35

130.735

Time Stamp Output

The output of time stamp fields with the time stamp type utclong and time stamps in packed numbers where the addition TIME ZONE is specified is constructed from a date and time output in their current formats, separated by a blank.

  • The date format is taken from the current formatting setting for time stamp fields with the type utclong and for time stamps in packed numbers.
  • The time format is determined as follows:
  • The time format is taken from the current formatting settings for time stamp fields with the type utclong. In the case of initial time stamp fields, the target area is padded with blanks. A time stamp field whose value is greater than or equal to the last second or between "9999-12-31 23:59:59.0000000" and "9999-12-31 23:59:59.9999999" is represented as "9999-12-31 23:59:59.9999999".

  • In the case of time stamps in packed numbers, the time format is always the 24 hour format with colons as separators. The 12 hour time format is not possible. In front of second fractions, the decimal separator is always a comma (,). An initial packed number is considered invalid by the addition TIME ZONE and its output is "*00.00.0000 00:00:00.000000.

Notes

  • The addition TIME ZONE must be specified for time stamp fields with the type TIME ZONE.
  • Time stamps in packed numbers for which the addition TIME ZONE is not specified are handled as data type p.

Example

If nothing else is defined in the formatting settings, the example creates the format shown below.

04.04.2019 12:42:48.2006610

04.04.2019 12:42:48.2006610

04/04/2019 12:42:48.2006610

04/04/2019 12:42:48.2006610






CPI1466 during Backup   General Data in Customer Master  
This documentation is copyright by SAP AG.

Length: 12822 Date: 20240425 Time: 231005     sap01-206 ( 169 ms )