Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

cl_gui_textedit control is ignoring empty lines

Hi,

I am using cl_gui_textedit this class to have text editor in my application,

when i enter some text like:

this is first line

this is second line

this is last line.

editor is automatically taking this as

this is first line

this is second line

this is last line.

it is not considering the empty lines or line breaks, for setting the texts i am using method set_text_asstream method.

please suggest what to be done inorder to have lines in editor.

Former Member
replied

Hello Kranthi,

The method SET_TEXT_AS_STREAM( ) expects the caller to provide the "\r" & "\n" i.e., Carriage Return(CR) & Line Feed(LF) respectively.

So the idea is to add an additional CRLF for the blank lines.

Check the code snippet below:

DATA: lt_text_stream TYPE STANDARD TABLE OF char32,
        lv_string      TYPE string.

* Populate the text stream
  APPEND 'this is first line' TO lt_text_stream. "Text Line
  APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed

  APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Blank Line

  APPEND 'this is second line' TO lt_text_stream. "Text Line
  APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed

  APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Blank Line

  APPEND 'this is last line' TO lt_text_stream. "Text Line
  APPEND cl_abap_char_utilities=>cr_lf TO lt_text_stream. "Line Feed

* Concatenate the text lines into a string
  CONCATENATE LINES OF lt_text_stream INTO lv_string.

* Send the text stream to the Text Editor
  text_view->set_textstream(
    EXPORTING
      text                    = lv_string
    EXCEPTIONS
      error_cntl_call_method  = 1
      not_supported_by_gui    = 2
      OTHERS                  = 3
         ).
  IF sy-subrc <> 0.
    "Error handling
  ENDIF.

I was having indentation issues with SET_TEXT_AS_STREAM( ) so i've used the SET_TEXTSTREAM( ). In both the cases you've to add an extra CRLF to get the blank lines.

Hope i'm clear.

BR,

Suhas

PS: Internally the method SET_TEXT_AS_STREAM( ) calls SET_TEXTSTREAM( ) based on some condition!

0 View this answer in context

Helpful Answer

by
Not what you were looking for? View more on this topic or Ask a question