Create multiline text area in ModulPool

Posted on March 6, 2015
Tweet

Sometimes we need to addd a Text Area in our ModulPool. Here is how it can be done:

PROCESS BEFORE OUTPUT.
* MODULE STATUS_0100.
  MODULE show_multiline.
*&---------------------------------------------------------------------*
*&      Module  show_multiline  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE show_multiline OUTPUT.

ENDMODULE.                 " show_multiline  OUTPUT
*&---------------------------------------------------------------------*
*& Include ZTEST_MPTOP                                                 *
*&                                                                     *
*&---------------------------------------------------------------------*

PROGRAM  ZTEST_MP.

DATA: v_text  TYPE REF TO cl_gui_textedit,
      cc_text TYPE REF TO cl_gui_custom_container.

*&---------------------------------------------------------------------*
*&      Module  show_multiline  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE show_multiline OUTPUT.

CREATE OBJECT CC_TEXT
  EXPORTING
    CONTAINER_NAME              = 'CC_TEXT'
  EXCEPTIONS
    CNTL_ERROR                  = 1
    CNTL_SYSTEM_ERROR           = 2
    CREATE_ERROR                = 3
    LIFETIME_ERROR              = 4
    LIFETIME_DYNPRO_DYNPRO_LINK = 5
    others                      = 6.

CREATE OBJECT V_TEXT
  EXPORTING
    PARENT                 = CC_TEXT
  EXCEPTIONS
    ERROR_CNTL_CREATE      = 1
    ERROR_CNTL_INIT        = 2
    ERROR_CNTL_LINK        = 3
    ERROR_DP_CREATE        = 4
    GUI_TYPE_NOT_SUPPORTED = 5
    others                 = 6.
    .

This class contains many methods, which can be called using the object we just created, we call a class method using the following syntaxis:

CALL METHOD object->method.

Here are some methods that can be used:

set_toolbar_mode   " You can remove the toolbar
set_statusbar_mode " You can remove statusbar
set_readonly_mode  " This method have a parameter readonly_mode, if we set
                   " the number 1 to that parameter, then the textbox will be
                   " read-only 

Examples:

CALL METHOD text-> set_toolbar_mode.
CALL METHOD text-> set_statusbar_mode.

CALL METHOD text->set_readonly_mode
    EXPORTING
        readonly_mode = '1'.