SAP Function STRING_CENTER - (Obsolete) Centered a string

Parameter Reference Type Length Default Optional Text
STRING 0 Input string

Parameter Reference Type Length Text
CSTRING 0 Output a centered string

Exception Text
TOO_SMALL Output field too short


Functionality
This function modules transports a string to the target field incentered format. The rest of the target field is padded with blanks.
All exceptions are generated with RAISE and must be handled in thecalling program.
Examples
The string 'abcd' appears in a
6-character target field as ' abcd ' (one blank at thebeginning and at the end
7-character field as ' abcd ' (two blanks at thebeginning, one at the end)
Sample call:
DATA: CSTR(10).
CALL FUNCTION 'STRING_CENTER'
EXPORTING STRING = 'abcdef'
IMPORTING CSTRING = CSTR
EXCEPTIONS TOO_SMALL = 1.
IF SY-SUBRC = 0.
* Der übergebene String steht zentriert in CSTR
ELSE.
* CSTR zu kurz
ENDIF.
Note
The ABAP/4 language element WRITE ... CENTERED TO ... provides almostthe same functionality as the function module. Also refer to theABAP/4 documentation WRITE.
The ABAP/4 language element provides better performance than thefunction module call.
The function module has been retained to ensure compatibility withfuture releases.
Difference: With WRITE 'abcd' CENTERED TO FIELD with a 7-charactertarget field FIELD, the target field has one blank at the beginning andtwo blanks at the end: ' abcd '.