The site was offered a task.
Start with this line of code as the first line in your application. Requirement: make sure to cut and paste this line of code and NOT type it.
DATA(sentence) = `ABАP is excellent `.
Using the value in the variable sentence, programmatically determine the number of words in this variable and then count the number of UNIQUE letters in each word.
Your output should look like this:
My result 6 rows.
data lc_text0 type string value 'Number of words:'.
data lc_text1 type string value 'Number of unique characters in the word:'.
data lt_split type table of string with default key.
data(lv_sentence) = `ABSP is excellent `.
split condense( lv_sentence ) at space into table lt_split.
write: lc_text0, condense( conv string( lines( lt_split ) ) ), /.
loop at lt_split assigning field-symbol(<lv_split>).
write: lc_text1, <lv_split>, '-', condense(
reduce i( init x = 0 for n = 0
while n <= strlen( <lv_split> ) - 1 let lv_symbol = <lv_split>+n(1)
lv_all_sumb = strlen( <lv_split> ) - 1
in next x = x + strlen( condense( val = boolc( reduce i( init x2 = 0 for j = 0 while j <= lv_all_sumb next x2 = x2 + ( cond i( when lv_symbol = <lv_split>+j(1) then 1 else 0 ) ) ) = 1 )