SAP Function TEXT_SPLIT - Splits text into specified length plus rest (cf.: SPLIT)

Parameter Reference Type Length Default Optional Text
AS_CHARACTER 0 X Treat as character in Unicode
LENGTH 0 Line length for split
TEXT 0 Input text

Parameter Reference Type Length Text
LINE 0 Results row
REST 0 remaining text


Functionality
The input text is split once in the specified line lengthword-compatibly. Recognized separators are SPACE and hyphen (-). Thehyphen remains in the result, space does not. The result is filled withspaces from the end of the last word until the specified length.
If the separator used (SPACE or '-') is followed by more separators,they are returned as leading separators in REST.
If there is no separator between the second character (separators inthe first position in the text are ignored) and the position specifiedin length LENGTH, the text is split at this position, notword-compatibly, if necessary. In this case the remaining text can havea leading separator even if separators only occur singly.
If the actual value assigned to the formal parameter REST is shorterthan the remaining text (trailing spaces are ignored), no exception israised, the text is truncated.
If the actual value of the formal parameter LINE is shorter thanLENGTH, no exception is raised, the split first part of length LENGTHis truncated at LINE. The characters cut off are not returned in REST,which contains the remaining text from the split position.
The calling program should avoid these special cases, i.e. the actualvalue assigned to the formal parameter LINE should be at least as bigas LENGTH.
The actual length of the formal paramter REST should be as big as thelength of the text passed.
Examples:
DATA: LEN TYPE I, T(50), L(4), R(4).
LEN = 4.
T = 'abc-def'.
CALL FUNCTION 'TEXT_SPLIT'
EXPORTING LENGTH = LEN
TEXT = T
IMPORTING LINE = L
REST = R.
* In this example, L = 'abc-' , R = 'def '
* For LEN = 3, T = 'abc-def' ; L(4), R(4) (i.e. L, R both 4-char.) :
* L = 'abc ' , R = '-def'
* For LEN = 3, T = 'abc def' ; L(4), R(4) :
* L = 'abc ' ; R = ' def'
* For LEN = 3, T = 'abc def' ; L(3), R(4) :
* L = 'abc' , R = ' def'
* For LEN = 4, T = 'abc def' ; L(3), R(4) :
* L = 'abc' , R = 'def '
* For LEN = 4, T = 'abc def' (5 spaces) ; L(3), R(8) :
* L = 'abc' ; R = ' def ' (4 leading spaces)
Note
More efficient ABAP languag elements have similar functionality:
SPLIT
MOVE text TO line(length)
MOVE text+length TO rest
See the ABAP doc for SPLIT and MOVE

The required length of results row
Remaining text which does not fit into the line

Description
This flag is optional and available only in the Unicode environment. Inthe non-Unicode environment, it does not function at all. If this flagis set (in the Unicode environment), the value of the other importingparameter "LENGTH" will be treated as character, not byte.

Value range
space or 'X'.

Default
space.

Description
The position where you want to split the string. The value will betreated as byte, not character even in the Unicode environment. In casethat the value needs to be handled with character basis in the Unicodeenvironment, the other improting parameter "AS_CHARACTER" has to be set.
Input text: This text is broken up once into the specified line

1157153Language dependency of line break