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: 

cl_gui_textedit control is ignoring empty lines

former_member450736
Active Participant
0 Kudos

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.

1 ACCEPTED SOLUTION

SuhaSaha
Advisor
Advisor
0 Kudos

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!

3 REPLIES 3

SuhaSaha
Advisor
Advisor
0 Kudos

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 Kudos

Hi Suhas,

it is working now, thank you very much.

Thanks,

Kranthi.

Former Member
0 Kudos

Hello Kranthi Kumar,

It should work fine. It is working fine for me.

You have tp make sure to use the below attributes(cl_gui_textedit=>wordwrap_at_fixed_position for wordwrap_mode ) while calling the create object:-

  • create calls constructor, which initializes, creats and links

  • TextEdit Control

CREATE OBJECT g_editor

EXPORTING

parent = g_editor_container

wordwrap_mode =

  • cl_gui_textedit=>wordwrap_off

cl_gui_textedit=>wordwrap_at_fixed_position

  • cl_gui_textedit=>WORDWRAP_AT_WINDOWBORDER

wordwrap_position = line_length

wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

Also make sure to use the below method (get_text_as_r3table) to get the data back from the text editor:-

  • retrieve table from control

CALL METHOD g_editor->get_text_as_r3table

IMPORTING

table = g_inputtable[].

Hope this answers your question.

Thanks,

Greetson