SAP LINE FEED
Get Example source ABAP code based on a different SAP table
Line Feeds in Character String Processing
A line feed (
ITOC
Control Characters in ABAP
In ABAP, some control characters, especially the line feed character, can easily obtained by using the respective
There are also constants for control characters in
ASSERT cl_abap_char_utilities=>horizontal_tab = | t|.
ASSERT cl_abap_char_utilities=>cr_lf = | r n|.>
ABAP_EXAMPLE_VX5
The actual code of a control character can be determined (as for all characters) as follows:
ABEXA 01762
In an Unicode system this gives
ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5
In another way around, any control character of any code page can be included in a character string, here again the Unicode line feed:
ABEXA 01763
ABAP_EXAMPLE_END
Using the Line Feed Character in ABAP
The line feed character and other control characters are needed when sending character strings to frameworks that can handle them. Examples are different output media or writing to files.
Line Feed in Outputs
The following are examples for line feeds in common output media.
ABAP_EXAMPLE_VX5
The text control of the
ABEXA 01764
The first output is:
The second output is:
<(> <)>
<(> Hello!<)>
<(> <)>
<(><)>>
ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5
The first output of
ABEXA 01765
ABAP_EXAMPLE_END
BEGIN_SECTION VERSION 5 OUT
Line Feed in Files
The following is an example for line feeds written to a file.
ABAP_EXAMPLE_VX
Writing text to a text file of the frontend computer.
DATA(text) = VALUE text( (
<(> | r n| <)>
<(> | r n| <)>
<(> | Hello! r n| <)>
<(> | r n| <)>
<(> | r n| ) ).<)>
cl_gui_frontend_services=>gui_download(
EXPORTING filename = 'c: temp text.htm'
CHANGING data_tab = text ).>
Opening the file with a notepad editor shows that the line feeds are handled there. Here,
ABAP_EXAMPLE_END
Line Feed in Classic Lists
The line feed character and other control characters cannot be used in
END_SECTION VERSION 5 OUT
Replacing Line Feeds
It is a common task to remove line feeds and other control characters from character strings that are received from outside of ABAP.
This can be easily done as follows:
Another pattern is
For doing so, it must be checked If the code pages match. If the code page of the AS ABAP does not match the code page of the control characters in the text, field symbols must be used as shown above to represent the control characters of the code page of the text.