split long sentence into two lines
how to split long sentence into two lines?this is a problem i faced in previous days, and i don’t know if SAP already have a special function to do this. That’s why i made one function module to handle this. I hope it can help you
function zfmpm_split_string.
*”———————————————————————-
*”*”Local Interface:
*” IMPORTING
*” REFERENCE(STRING) TYPE ANY
*” REFERENCE(LENGTH) TYPE INT1
*” TABLES
*” IT_SPLITTED STRUCTURE TLINE
*”———————————————————————-data: begin of itab1 occurs 0,
words(255) type c,
end of itab1.data: wa1 like line of itab1,
ld_totalchar type i,
ld_length type i.split string at space into table itab1.
loop at itab1 into wa1.
ld_totalchar = strlen( wa1-words ) + strlen( it_splitted-tdline ) + 1.
if ld_totalchar <= length.
if it_splitted is not initial.
concatenate it_splitted-tdline wa1-words into it_splitted-tdline separated by space.
else.
it_splitted-tdline = wa1-words.
endif.
else.
append it_splitted.
clear it_splitted.
free ld_totalchar.
it_splitted-tdline = wa1-words.
endif.
endloop.
append it_splitted.
clear it_splitted.
free ld_totalchar.
endfunction.

Leave a Reply