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 STRING into SOLI_TAB

former_member569700
Discoverer
0 Kudos

Hello everyone!

I want to read a text (>255) from my TextEdit and convert it into a SOLI_TAB for sending it via mail.

 go_editor->get_textstream(
 IMPORTING
 text = l_text ).

 cl_gui_cfw=>flush( ).

This is how I get the String from my TextEdit. Now I tried some methods/functions to convert the String into SOLI_TAB (SO_STRING_TO_TAB, SCMS_STRING_TO_FTEXT, cl_document_bcs=>string_to_soli). Now the problem is.. there is always a text break because the text is >255 characters.

I decieded to write my own method:

-----------------------------------------------------

l_string = i_string.
l_do_run = abap_true.
l_do_check = abap_true.

WHILE l_do_run = abap_true.

IF l_do_check = abap_true.
IF strlen( l_string ) > 255.
l_string_work = l_string(255).
l_string = l_string+255.
ELSE.
l_string_work = l_string.
clear l_string.
ENDIF.
l_do_check = abap_false.
ENDIF.

FIND FIRST OCCURRENCE OF REGEX '##+' IN l_string_work RESULTS l_result RESPECTING CASE.
IF sy-subrc <> 0.
IF l_string IS INITIAL.
ls_soli-line = l_string_work.
APPEND ls_soli TO rt_soli.
l_do_run = abap_false.
EXIT.
ELSE.
l_string = |{ l_string_work }{ l_string }|.
l_do_check = abap_true.
ENDIF.
ENDIF.
l_length = l_result-offset + l_result-length.
ls_soli-line = l_string_work(l_length).
l_string_work = l_string_work+l_length.
APPEND ls_soli TO rt_soli.
CLEAR: ls_soli, l_result.
ENDWHILE.

--------------------------------------

The problem ist now: this method is working when I test it (even when I put strings > 255), but it doesn't work when I use it with the string that I get from the TextEdit.

I'm always getting sy-subrc = 4, why I try to get the first occourence of regex '##+' (it works with the exactly same text, when I run the method in test-mode).

I don't know why and I can't solve the problme.

Can you guys please help me with this? Either tell me how to avoid the break with the Standard functions/methods, or how to Change my code to make it work with the string from TextEdit.

Please help! 😃

1 ACCEPTED SOLUTION

raymond_giuseppi
Active Contributor

Would it not have been easier to use method GET_TEXT_AS_R3TABLE in the initial step?

4 REPLIES 4

raymond_giuseppi
Active Contributor

Would it not have been easier to use method GET_TEXT_AS_R3TABLE in the initial step?

0 Kudos

Oh well.. that worked 😄
Thank you so much!

You should understand that when you see # in the debugger (or in other output), that is often just the way SAP represents a non-printable character. Therefore REPLACE ... '##' ... won't work, since the string you're actually after (in this case, probably CR and LF) isn't actually ##, although you see it like that. You can represent these characters using the constants found in class cl_abap_char_utilities. E.g.

FIND FIRST OCCURRENCE OF cl_abap_char_utilities=>cr_lf IN l_string_work RESULTS l_result RESPECTING CASE.

horst_keller
Product and Topic Expert
Product and Topic Expert

Instead of ## you must most probably use a string template like |\r\n| which stands for the code of CRLF, see https://help.sap.com/http.svc/rc/abapdocu_751_index_htm/7.51/en-US/index.htm?file=abencl_abap_char_u...