SPLIT dobj AT sep INTO
{ {result1 result2 ...} | {TABLE result_tab} }
[IN {BYTE|CHARACTER} MODE].
The content of the data object dobj is separated according to the sequence of separators contained in sep. The results are either stored in individual variables result1 result2 ... or in the lines of an internal table result_tab. Before the separation, the data objects result1 result2 ... and the table result_tab are initialized. The internal table must be a standard table.
The system searches the data object dobj from right to left for all occurrences of the content of the data object sep. The search is case-sensitive. All content from the start of the data object to the first found location, between the found locations, and from the last found location to the end of the data object are assigned consecutively to the individual data objects result1 result2 ..., or appended to the internal table result_tab. If there are not enough data objects result1 result2 ... to record all the intermediate results, dobj is only separated until all the data objects result1 result2 ... except for the last one have been assigned values. The rest of the content of dobj is then not separated and assigned to the last individual data object in one piece, or appended to the internal table.
If the content of the data object sep is found immediately at the start of dobj, or occurs in direct succession in dobj, the result of the separation is an empty string. If the content of sep is at the end of dobj, the search is terminated and no further separation takes place to the right of this point.
If the content of the data object sep is not found or is an empty string, the result of the separation is a single field that contains the whole content of dobj, and which is assigned to the first individual data object or the first line of the internal table.
If a data object result1 result2 ... or the lines of the
internal table result_tab have a fixed length that is
not sufficient for an intermediate result, this is cut off on the right, and
sy-subrc is set to 4. If the data object or table field is longer than the intermediate result,
it is filled to the right with blank characters or hexadecimal 0s. If the data objects
result1 result2 ... or the lines of the internal table result_tab
are strings, their length is adapted to match the length of the corresponding intermediate result.
In character string processing, the trailing blanks are taken into account for separators
sep of fixed length, but not in the data object dobj or in the intermediate results arising from the separation.
System fields
sy-subrc | Meaning |
0 | The intermediate results were copied to the target fields or the internal table without being cut off. |
4 | During transfer to the target fields or the internal table, at least one of the intermediate results was cut off on the right. |
... IN {BYTE|CHARACTER} MODE
The optional addition IN {BYTE|CHARACTER} MODE> determines whether
character string or byte sequence processing is carried out.
If the addition is not specified, character string processing is executed. Depending on the type of
processing, the data objects dobj,
sep, and the target fields result1 result2 ...
or the lines of the internal table result_tab must be byte-type or character-type.
The text field text is separated at its blank characters, into the three strings str1, str2, and str3, and then into an internal table with the line type string. As the three strings are not sufficient for all seven parts, after the separation, str3 contains "drag it is getting old", while the internal table contains seven lines; one for each word in text.
DATA: str1 TYPE string,
str2 TYPE string,
str3 TYPE string,
itab TYPE TABLE OF string,
text TYPE string.
text = `What a drag it is getting old`.
SPLIT text AT space INTO: str1 str2 str3,
TABLE itab.