Skip to Content

Text Editor

I am displaying text editor on the screen.

    create object gt_textbox  "cc_container
             exporting
                   container_name    = 'GT_TEXTBOX'.

    create object text_editor
    exporting
    parent = gt_textbox.  "cc_container.

i want to limit the number of lines in the text editor to 3.

How can i do that.

Thank you.

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

4 Answers

  • author's profile photo Former Member
    Former Member
    Posted on Nov 15, 2007 at 05:27 PM

    Hi Karthik,

    Use SET_HEIGHT Method to limit the number of lines in editor.

    Reward points if it helps,

    Satish

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 15, 2007 at 05:35 PM

    Try like this.

    data: i_height type i value 3.
    
    call method text_editor->SET_HEIGHT
    exporting HEIGHT = i_height.  " <

    Regards,

    Naimesh Patel

    Add a comment
    10|10000 characters needed characters exceeded

    • Even if i use the code...

      I notice that user is able to enter more than three lines.

      call method text_editor->SET_HEIGHT
      exporting HEIGHT = i_height.  " 

      Here is my code for the Text Editor.

      DATA: GT_TEXTBOX   TYPE REF TO CL_GUI_CUSTOM_CONTAINER.
      DATA: C_CONTROL1 TYPE SCRFNAME VALUE 'GT_TEXTBOX'.
      DATA: TEXT_EDITOR TYPE REF TO CL_GUI_TEXTEDIT.
      
       CREATE OBJECT GT_TEXTBOX  "cc_container
                   EXPORTING
                         CONTAINER_NAME    = 'GT_TEXTBOX'.
      
          CREATE OBJECT TEXT_EDITOR
          EXPORTING
          PARENT = GT_TEXTBOX
          WORDWRAP_MODE    = 2
          MAX_NUMBER_CHARS = 374
          WORDWRAP_POSITION = 128.      "cc_container.

      My Objective is to lock the Text editor with 3 lines.

      How can i do that

      Message was edited by:

      Karthik

  • Posted on Nov 15, 2007 at 05:36 PM

    Hi Karthik,

    Pls check the following theread. Here some sample codes are there. Hope it will be useful.

    CL_GUI_TEXTEDIT limit lines

    it will solve your problem..

    <b>Reward points if useful....</b>

    Thanks & Regards

    ilesh 24x7

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Nov 19, 2007 at 08:06 PM

    Hi Karthik,

    one way to get ur solution is to give error message when user tries to enter 4th line..

    Look at the bold part of code in below example... use OOPS it will help u...

    report zrep1 .
     
    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 > 3.

    message e001(00) with 'The line limit is two'.

    endif.</b>

    start-of-selection.
     
      loop at textlines into wa_text.
        write:/ wa_text.
      endloop.
    
    

    Hope it will solve ur problem

    <b>Reward points if useful..</b>

    Thanks & Regards

    ilesh 24x7

    Add a comment
    10|10000 characters needed characters exceeded

    • As suggested earlier, you can check the number of entries in the text table after user action eg. PAI.

      call method text_editor->get_text_as_r3table
      importing
      table = textlines
      exceptions
      others = 1.
      
      describe table textlines lines lines.
      if lines > 4.
      message e001(00) with 'The line limit is three'.
      endif.

      Regards,

      Naimesh Patel

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.