Ansicht
Dokumentation

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

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

BAL Application Log Documentation   CPI1466 during Backup  
This documentation is copyright by SAP AG.
SAP E-Book
Function

The input text is split once in the specified line length word-compatibly. Recognized separators are SPACE and hyphen (-). The hyphen remains in the result, space does not. The result is filled with spaces 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 in the first position in the text are ignored) and the position specified in length LENGTH, the text is split at this position, not word-compatibly, if necessary. In this case the remaining text can have a leading separator even if separators only occur singly.

If the actual value assigned to the formal parameter REST is shorter than the remaining text (trailing spaces are ignored), no exception is raised, the text is truncated.

If the actual value of the formal parameter LINE is shorter than LENGTH, no exception is raised, the split first part of length LENGTH is 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 actual value assigned to the formal parameter LINE should be at least as big as LENGTH.
The actual length of the formal parameter REST should be as big as the length 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-character)

* L = 'abc ' , R = '-def'

* For LEN = 3, T = 'abc def' ; L(3), 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 language elements have similar functionality:

  • SPLIT

  • MOVE text TO line(length)

  • MOVE text+length TO rest

See the ABAP doc for SPLIT and MOVE





Parameters

AS_CHARACTER
LENGTH
LINE
REST
TEXT

Exceptions

Function Group

CSTR

Fill RESBD Structure from EBP Component Structure   Addresses (Business Address Services)  
This documentation is copyright by SAP AG.

Length: 3770 Date: 20240523 Time: 045155     sap01-206 ( 53 ms )