Application Development and Automation 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 limit lines

Former Member
0 Kudos
2,536

Hi experts,

Is there any way to limit the quantity of lines, using cl_gui_textedit ?

Thanks

Alexandre Nogueira

4 REPLIES 4

RichHeilman
Developer Advocate
Developer Advocate
714

Sure, check the example program. Notice in the constructor of the text editor control, we are forcing that the line size is 72 and that the character count is 216. This means that you are allow 3 lines of 72 characters per line, no more.



report zrich_0001 .

data:
      dockingleft  type ref to cl_gui_docking_container,
      text_editor    type ref to cl_gui_textedit,
      repid type syrepid.

data: textlines type table of tline-tdline,
      wa_text type tline-tdline.

parameters: p_check.

at selection-screen output.

  repid = sy-repid.

  create object dockingleft
              exporting repid     = repid
                        dynnr     = sy-dynnr
                        side      = dockingleft->dock_at_left
                        extension = 1070.

<b>  create object text_editor
              exporting
                   WORDWRAP_MODE    = 2
                   max_number_chars = 216
                   wordwrap_position = 72
                   parent     = dockingleft.</b>

start-of-selection.

  call method text_editor->get_text_as_r3table
     importing
           table              = textlines
     exceptions
           others             = 1.

  loop at textlines into wa_text.
    write:/ wa_text.
  endloop.


Regards,

RIch Heilman

0 Kudos
714

Ok Rich,

But, as this example, I can have 216 lines with 1 caracter. It's the problem.

Alexandre Nogueira

RichHeilman
Developer Advocate
Developer Advocate
0 Kudos
714

I see. Would it be ok to check the number of lines and give an error message?



report zrich_0001 .

data:
      dockingleft  type ref to cl_gui_docking_container,
      text_editor    type ref to cl_gui_textedit,
      repid type syrepid.

data: textlines type table of tline-tdline,
      wa_text type tline-tdline.

data: lines type i.

parameters: p_check.

at selection-screen output.

  repid = sy-repid.

  create object dockingleft
              exporting repid     = repid
                        dynnr     = sy-dynnr
                        side      = dockingleft->dock_at_left
                        extension = 1070.

  create object text_editor
              exporting
*                   wordwrap_mode    = 2
*                   max_number_chars = 216
*                   wordwrap_position = 72
                   parent     = dockingleft.

<b>at selection-screen.

  check sy-ucomm = 'ONLI'.

  call method text_editor->get_text_as_r3table
     importing
           table              = textlines
     exceptions
           others             = 1.

  describe table textlines lines lines.

  if lines > 2.
    message e001(00) with 'The line limit is two'.
  endif.</b>

start-of-selection.


  loop at textlines into wa_text.
    write:/ wa_text.
  endloop.

Regards,

Rich Heilman

0 Kudos
714

Yeap, it's a good way, thanks!

Alexandre Nogueira