Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Formatting text in an internal table with carriage returns and word wrap

Former Member
0 Kudos

Hello,

I have an internal table of characters that contains text with the "##" carriage return and the text is not word wrapped. Each line of this input table can contain multiple carriage returns or none at all. I am trying to reformat this text into another internal table with word wrapping and put the lines that end with a carriage return on it's on line in the output internal table.

I know how to use the split command and put the lines with carriage returns onto separate lines in an internal table. But each line is not word wrapped.

After searching this forum, I have found function modules that will word wrap (ex: RKD_WORD_WRAP, SOTR_SERV_STRING_TO_TABLE). But, these do not take into account the carriage returns.

Does anyone have any suggestions?

Thanks!

Paul

2 REPLIES 2

Former Member
0 Kudos

Hi you can have a look at the following code.This might help you :

&----


*& Report ZTEST_STRING

*&

&----


*&

*&

&----


REPORT ztest_string.

PARAMETERS :

offset TYPE i.

DATA: lv_string TYPE string,

max_post1_len TYPE i,

lv_offset TYPE int4,

loc_ktext TYPE string,

rem_text TYPE string,

str TYPE i,

str1 TYPE i.

START-OF-SELECTION.

lv_string = '*** ONE HUNDRED TWENTY-THREE MILLION FOUR HUNDRED FIFTY-SIX THOUSAND SEVEN HUNDRED EIGHTY-NINE DOLLARS AND'.

str = STRLEN( lv_string ).

max_post1_len = offset.

CALL METHOD cl_scp_linebreak_util=>string_split_at_position

EXPORTING

im_string = lv_string

im_pos_vis = max_post1_len

im_pos_tech = max_post1_len

im_boundary_kind = 'W'

IMPORTING

ex_pos_tech = lv_offset.

loc_ktext = lv_string(lv_offset).

CLEAR str1.

str1 = str - lv_offset.

rem_text = lv_string+lv_offset(str1).

WRITE : / 'The original string is ',lv_string.

SKIP 1.

WRITE : / 'The offset string till',lv_offset,'is ', loc_ktext.

SKIP 1.

WRITE : / 'The remaining string is ',rem_text.

0 Kudos

Ravi,

Thanks for your quick reply. As far as I can tell, this doesn't help me too much as I already can word wrap OR split the text in the internal table on the carriage returns independent of each other. But, I just can't figure out how to do both together. If I split the lines on the carriage returns into an internal table, is there a function module or something that will take the whole table as input and wrap it?

Thanks again.

Paul