SAP STRINGS - Guide
Get Example source ABAP code based on a different SAP table
GUIDELINE 6.9
Strings
ABAP_BACKGROUND
Strings are
In contrast to text and byte fields of a fixed length (
In the case of assignments between strings, sharing takes effect. This means that only the internal reference is copied first. Sharing is canceled if the source or target object is accessed for modification.
ABAP_RULE
Use strings rather than fixed length fields for the internal storage and processing of character and byte strings.
ABAP_DETAILS
Strings are more flexible than fields of a fixed length and usually help you save memory space, because no unnecessary space is occupied by blanks or zeros, and because sharing is implemented for assignments. Furthermore, closing blanks are always significant in text strings. Text fields simply ignore closing blanks in many operand positions (but not in all), which may be quite confusing at times.
Exception
In the following cases, fields of a fixed length should be used instead of strings:
Bad example
The following source code shows an internal table for storing an
DATA html_table TYPE TABLE OF html_line.
APPEND '<(><<)>HTML>' TO html_table.
...
APPEND '<(><<)>BODY>' TO html_table.
...
APPEND '<(><<)>/BODY>' TO html_table.
APPEND '<(><<)>/HTML>' TO html_table.
Good example
The following source code shows the above example but uses text strings. The memory space gained should outweigh the additional administration effort considerably. As an alternative to using an internal table, you can also concatenate the
APPEND `<(><<)>HTML>` TO html_table.
...
APPEND `<(><<)>BODY>` TO html_table.
...
APPEND `<(><<)>/BODY>` TO html_table.
APPEND `<(><<)>/HTML>` TO html_table.