FUNCTION ZSTRING_TO_INITIALCAPS.
*"----------------------------------------------------------------------
*"*"Local interface:
*" IMPORTING
*" VALUE(INSTRING) TYPE C
*" EXPORTING
*" VALUE(OUTSTRING) TYPE C
*"----------------------------------------------------------------------
constants: c_delimiter(21) value ' .()-{}[]/#1234567890'.
data: v_instring(80) type c,
v_len type i,
v_char type c,
i type i,
j type i.
v_instring = instring.
check not v_instring is initial.
translate v_instring to lower case.
condense v_instring.
* Translate first character to upper case
v_char = v_instring+0(1).
translate v_char to upper case.
v_instring+0(1) = v_char.
v_len = strlen( v_instring ).
v_len = v_len - 1. " Translate next char
i = 1. " Start from 2nd char
while i < v_len.
if v_instring+i(1) CA c_delimiter.
j = i + 1. " Translate next char
v_char = v_instring+j(1).
translate v_char to upper case.
v_instring+j(1) = v_char.
endif.
i = i + 1.
endwhile.
outstring = v_instring.
ENDFUNCTION.