Skip to Content
author's profile photo Former Member
Former Member

Text Area in Screen Painter

Hi,

I would like to have an Text Area in Screen painter. I didn't find any control for Text Area so i used custom control and used the following code to bring up the Text Editor control.

DATA : editor_itxt TYPE REF TO cl_gui_textedit,

textedit_container_itxt TYPE REF TO cl_gui_custom_container,

NPATT_TXT_MESSAGE(1000).

IF editor_itxt IS INITIAL.

  • create control container for item long text

CREATE OBJECT textedit_container_itxt

EXPORTING

container_name = 'NPATT_TXT_MESSAGE'

EXCEPTIONS

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5.

  • create calls constructor, which initializes, creates and links

  • a TextEdit Control

CREATE OBJECT editor_itxt

EXPORTING

parent = textedit_container_itxt

wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position

wordwrap_to_linebreak_mode = cl_gui_textedit=>true

EXCEPTIONS

OTHERS = 1.

CALL METHOD editor_itxt->set_toolbar_mode

EXPORTING

toolbar_mode = 0. "Do not show toolbar.

  • toolbar_mode = 1. "Show toolbar.

CALL METHOD editor_itxt->set_statusbar_mode

EXPORTING

statusbar_mode = 0. "Do not show statusbar.

ENDIF.

I couldn't get the data entered with NPATT_TXT_MESSAGE.

Can someone help me?

Thanks in advance

arun

Add a comment
10|10000 characters needed characters exceeded

Related questions

3 Answers

  • Best Answer
    Posted on Nov 29, 2004 at 09:33 PM

    Hi Arun

    You should call the relevant method of "<b>cl_gui_textedit</b>" to get its content.

    OR

    You can simply use FMs wrapping that textedit control. These are "<b>RH_EDITOR_SET</b>" which you should use at PBO of your screen and "<b>RH_EDITOR_GET</b>" at PAI of your screen to get its content.

    *--Serdar

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Arun

      You can get the content of "cl_gui_textedit" object using various method of it.

      <b>1. GET_LINE_TEXT</b>:

      <i>e.g.</i>

      CALL METHOD gr_textedit->get_line_text
        EXPORTING
          line_number = line_number
        IMPORTING
          text = text
        EXCEPTIONS
          invalid_parameter = 1
          error_cntl_call_method = 2.

      <b>2. GET_TEXT_AS_R3TABLE

      3. GET_TEXT_AS_STREAM</b>

      You can refer to demo programs "<b>SAPTEXTEDIT_TEST*</b>".

      *--Serdar

  • author's profile photo Former Member
    Former Member
    Posted on Nov 30, 2004 at 11:28 PM

    Hi Serder,

    Sorry for such a delay. Regarding this,

    I don't unserstand how to use this,

    You can simply use FMs wrapping that textedit control. These are "RH_EDITOR_SET" which you should use at PBO of your screen and "RH_EDITOR_GET" at PAI of your screen to get its content.

    Can you post a code with sample custom control name to show an Textedit control.

    Also, i want to know how can i wrap the text to next line, When i type it keeps on going to the right and it doesn't go to the new line.

    How can i handle this?

    Thank you

    arun

    Add a comment
    10|10000 characters needed characters exceeded

    • Hi Arun

      I have no connection to an SAP system right now. But as I remember you place a custom container on the screen as usual. Then at PBO of your screen you call "RH_EDITOR_SET" to set the editor. At the interface of the FM, there are parameters to pass the name of the custom control you placed on your screen, maximum number of characters per line, program name and dynpro number.

      At PAI of your screen you call "RH_EDITOR_GET" to take the content of the editor through its tables parameter into your internal table.

      Technically, this FMs use cl_gui_textedit" class. But I think easier to use.

      Hope this helps...

      *--Serdar

  • Posted on Dec 03, 2004 at 11:54 AM

    Hi Arun

    Here is code snippets for both functions:

    <u>To set your editor, i.e calling at PBO</u>

    CALL FUNCTION 'RH_EDITOR_SET'
      EXPORTING
        repid = sy-cprog
        dynnr = <screen_number>
        controlname = <custom_control_name>
        max_cols = <maximum_line_length>
        max_lines = <maximum_no_of_lines> "has no effect"
        show_tool = 'X'
        show_status = 'X'
        display_mode = space
      TABLES
        lines = gt_lines
      EXCEPTIONS
        create_error = 1
        internal_error = 2
        OTHERS = 3. 

    This will link a text editor to the custom control <i><custom_control_name></i> at the screen <i><screen_number></i> of your program with the data at the table <b>"gt_lines"</b> and it is editable since I pass space to the parameter <b>"display_mode"</b>.

    <u>At PAI, to get the content;</u>

    REFRESH gt_lines .
    CALL FUNCTION 'RH_EDITOR_GET'
      EXPORTING
        controlname = <custom_control_name>
      TABLES
        lines = gt_lines
      EXCEPTIONS
        internal_error = 1
        OTHERS = 2 .
    

    And this will get the content of the text editor linked to the same custom control into the table gt_lines.

    If you want to store the data, then you must store all the editor content in a flat form. That is you need placeholder for line break. What I do is using "#" for line breaks. I use <b>"SPLIT"</b> statement to form the internal table with lines from the flat line where lines are separated by "#". And I use <b>"CONCATENATE"</b> statement to concatenate them to form the flat line from the internal table.

    Hope this also helps...

    *--Serdar

    Add a comment
    10|10000 characters needed characters exceeded

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.