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 - Cutoff Behavior
This section describes the cutoff behavior of the system, if the target field length for the statement
WRITE TO
or the output length for the statement WRITE
is less than the length required for the
predefined format or the format defined using format_options
.
The following sections explain the steps involved in truncating data. The result is truncated until it is short enough to fit the available space.
If the individual formatting options deviate from the rules shown here, these deviations are described for the relevant option.
Other versions: 7.31 | 7.40 | 7.54
Executable Example
Numeric Data Types
Integers and Packed Numbers
For data objects of numerical data types (b
, s
),
i
, int8
, and p
, the cutoff behavior is as follows:
b
, s
), i
, int8
,
and p
are truncated on the left and an asterisk ("*") is inserted in the first place for identification purposes.
The type int8
produces a syntax check warning (which can be hidden by a pragma), if it is known statically that the output length is less than the predefined length 20.
Decimal Floating Point Numbers
For data objects of type decfloat16
and decfloat34
, the cutoff behavior is as follows:
- if the length is not sufficient for the display of at least one whole number place in the mathematical notation or one position of the mantissa in the scientific notation,
- if the length is not sufficient for the mathematical notation when the output format SIGN_AS_POSTFIX is used for commerical notation,
- if the length is not sufficient for the output format SCALE_PRESERVING or SCALE_PRESERVING_SCIENTIFIC (where the scaling is preserved),
The predefined output lengths of 24 or 46 are sufficient for the mathematical notation of 16 or 34 place numbers with an algebraic sign, a decimal point and a corresponding number of thousand separators.
Binary Floating Point Numbers
For data objects of type f
, the cutoff behavior is as follows:
Character-Like and Byte-Like Data Types
For data types c
, string
, n
,
d
, t
, x
and xtring
, the cutoff behavior is as follows:
t
, first the space is removed and then the format is changed to the 24-hour format.
d
and t
,
all separators are removed, unless an addition such as
DD/MM/YY or MM/DD/YY
is specified for d
.
Time Stamp
- For the time stamp type
utclong
the right side is cut off in the case of the statements WRITE TO andWRITE
without any separators being removed first.
- For time stamps in packed numbers whose output
is produced using the addition TIME
ZONE, the right side is cut off in the case of the statement
WRITE TO
without any separators being removed first.
- For time stamps in packed numbers whose output
is produced using the addition TIME
ZONE, elements are cut off the following order in the case of the statement
WRITE
:
- All separators in date and time are removed. The separators in the date are only not removed if a date formatting mask
DD/MM/YY
or similar is also specified.
- The space between date and time is removed.
- The right-hand side is cut off.
Example
This example shows the different cutoff behavior for time stamps in packed numbers in list output using
the statement WRITE
when compared to all other combinations. The format of the output is shown below the source code.
DATA(ts) = utclong_current( ).
DATA(tspl) = cl_abap_tstmp=>utclong2tstmp( ts ).
DATA text TYPE c LENGTH 24.
SET COUNTRY 'US'.
WRITE ts TO text TIME ZONE 'UTC'.
WRITE AT / text.
WRITE tspl TO text TIME ZONE 'UTC'.
WRITE AT / text.
WRITE: AT /(24) ts TIME ZONE 'UTC',
AT /(24) tspl TIME ZONE 'UTC'.
04/08/2019 08:10:16.1539
04/08/2019 08:10:16,1539
04/08/2019 08:10:16.1539
04082019 081016.1539740