Skip to Content
0

Convert STRING into SOLI_TAB

Mar 14, 2017 at 09:45 AM

440

avatar image

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! =)

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

2 Answers

Best Answer
Raymond Giuseppi
Mar 14, 2017 at 10:41 AM
2

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

Show 2 Share
10 |10000 characters needed characters left characters exceeded

Oh well.. that worked :D
Thank you so much!

0

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.

2
Horst Keller
Mar 14, 2017 at 05:14 PM
1

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_utilities.htm

Share
10 |10000 characters needed characters left characters exceeded