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: 

Convert text string to table and include wordwrap

Is there an abap class that will convert a string field into a table that will include wordwrap ?

1 ACCEPTED SOLUTION

aaron_morden2
Contributor
0 Kudos

Try below code:


    CALL FUNCTION 'RKD_WORD_WRAP'
      EXPORTING
        textline            = input_string
        delimiter           = ' '
        outputlen           = 100
      TABLES
        out_lines           = output_itab
      EXCEPTIONS
        outputlen_too_large = 1
        OTHERS              = 2.

8 REPLIES 8

aaron_morden2
Contributor
0 Kudos

Try below code:


    CALL FUNCTION 'RKD_WORD_WRAP'
      EXPORTING
        textline            = input_string
        delimiter           = ' '
        outputlen           = 100
      TABLES
        out_lines           = output_itab
      EXCEPTIONS
        outputlen_too_large = 1
        OTHERS              = 2.

Former Member
0 Kudos

Hi

You can use class CL_GUI_TEXTEDIT method TRANSFORM_STRING_TO_TABLE.

Nat

0 Kudos

CL_GUI_TEXTEDIT=>TRANSFORM_STRING_TO_TABLE is a protected method, so can't be used outside of a class inherited from CL_GUI_TEXTEDIT. Did you actually try the code out before suggesting it, or are you just fishing for forum points?

0 Kudos

If he did, then he stopped more than two years ago

Nevertheless, thanks for the clarification, and keep challenging the more recent points chasers.

Thomas

Dorian
Participant

Dale:

Try class CL_SWF_UTL_CONVERT_XSTRING. The methods in it are named with XSTRING, but also work with type STRING as well.

Regards,

D.

0 Kudos

Try class CL_SWF_UTL_CONVERT_XSTRING method TABLE_TO_XSTRING.

CALL METHOD cl_swf_utl_convert_xstring=>table_to_xstring

EXPORTING

i_table = my_internal_table

i_size = size_of_my_internal_table

RECEIVING

r_stream = revceiving_string

EXCEPTIONS

invalid_input = 1

OTHERS = 2.

Hope this will help you.

Click answered if your purpose is solved

Former Member
0 Kudos

You can use method '/SAPSLL/TEXT_TABLE_TO_STRING' to convert text lines to string

*convert text lines to string

data: lv_string type string.

clear lv_string.

CALL FUNCTION '/SAPSLL/TEXT_TABLE_TO_STRING'

EXPORTING

IT_TLINES = lt_lines

IMPORTING

EV_TXTSTRING = lv_string

To Covnert String to Text Lines, use - '/SAPSLL/TEXT_STRING_TO_TABLE'

    • Convert text lines to string

CALL FUNCTION '/SAPSLL/TEXT_STRING_TO_TABLE'

EXPORTING

IV_TXTSTRING = ls_extension-value

IMPORTING

ET_TLINES = lt_lines

.

ray_mannion
Participant

Just thought I would share this since my google search landed me here.

I was trying to pass a string from a UI5 app through the Gateway server into an RFC to result in being header text on a sales order and needed to go from string -> bapisdtext_t table

This method converts a string to the ITF format of TLINE which is the TDFORMAT and TLINE segment. The TDFORMAT contains an '*' when a new line exists but leaves it blank when the wordwrap happens.

Hope it helps...

After reading the above, I found cl_cnv_mbt_utils=>convert_string_to_table

FORM %string_to_bapisdtext USING text_id      TYPE tdid
input_string TYPE string
CHANGING bapi_text TYPE bapisdtext_t.

DATA(tline_table) = cl_cnv_mbt_utils=>convert_string_to_table( iv_string = input_string ).

LOOP AT tline_table ASSIGNING FIELD-SYMBOL(<tline>).
APPEND INITIAL LINE TO bapi_text ASSIGNING FIELD-SYMBOL(<bapi>).
<bapi>-text_id = text_id.
<bapi>-langu = sy-langu.
<bapi>-format_col = <tline>-tdformat.
<bapi>-text_line = <tline>-tdline.
ENDLOOP.
ENDFORM.