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: 
Read only

make long text mandatory using cl_gui_textedit

Former Member
0 Likes
1,617

Hi All ,

Is there any method available in class cl_gui_textedit to make text field is mandatory ?

I have created a long text field using class cl_gui_textedit  and want to make this field as mandatory .

Regards,

Sijin K P

2 REPLIES 2
Read only

Former Member
0 Likes
984

While handling user command, method get_text_as_r3table can be used to get data.

After getting data, initial value validation can be done, and control can be passed to user with/without error message.

Read only

former_member209120
Active Contributor
0 Likes
984

Hi Sijin KP,

See this code

DATA : g_container TYPE REF TO cl_gui_custom_container.
DATA : g_editor    TYPE REF TO cl_gui_textedit.

TYPES: BEGIN OF x_texttable,
   line_length(100) TYPE c,
END OF x_texttable.

DATA : g_t_text TYPE TABLE OF x_texttable.
DATA : g_wa_text TYPE x_texttable.
DATA : ok_code TYPE sy-ucomm.

start-of-selection.
CALL SCREEN 100.
*&---------------------------------------------------------------------*
*&      Module  STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE status_0100 OUTPUT.
   SET PF-STATUS 'ZTEST_STATUS'.
*  SET TITLEBAR 'xxx'.

   IF g_editor IS INITIAL.
     CREATE OBJECT g_container
       EXPORTING
         container_name         = 'G_CUSTOM'. " container name

     CREATE OBJECT g_editor
       EXPORTING
         parent                 = g_container.

* To hide statusbar and toolbar
     CALL METHOD g_editor->set_toolbar_mode
       EXPORTING
         toolbar_mode = cl_gui_textedit=>false.

     CALL METHOD g_editor->set_statusbar_mode
       EXPORTING
         statusbar_mode = cl_gui_textedit=>false.


* To Set disply - 1 or edit - 0 mode
     CALL METHOD g_editor->set_readonly_mode
       EXPORTING
         readonly_mode = 0.

   ENDIF.
ENDMODULE.                 " STATUS_0100  OUTPUT
*&---------------------------------------------------------------------*
*&      Module  USER_COMMAND_0100  INPUT
*&---------------------------------------------------------------------*
*       text
*----------------------------------------------------------------------*
MODULE user_command_0100 INPUT.
   CASE ok_code.
     WHEN 'SAVE'.
*      CALL METHOD g_editor->get_text_as_r3table
*        IMPORTING
*          table           = g_t_text
*        EXCEPTIONS
*          error_dp        = 1
*          error_dp_create = 2
*          OTHERS          = 3.

       CALL METHOD g_editor->get_text_as_stream
         IMPORTING
           text = g_t_text.

     if g_t_text is INITIAL.
     Message : 'Enter Text' type 'E'.
     LEAVE to screen 100.
     endif.

     WHEN 'PRINT'.

       clear g_wa_text.
*      LOOP AT g_t_text INTO  g_wa_text.
       g_wa_text-line_length = 'ABCD'.

       APPEND g_wa_text TO g_t_text.
*      EXIT.
*      ENDLOOP.

       CALL METHOD g_editor->set_text_as_stream
       EXPORTING
         text = g_t_text.

     WHEN 'BACK'.

       LEAVE TO SCREEN 0.
   ENDCASE.


ENDMODULE.                 " USER_COMMAND_0100  INPUT

if you save with out entering data in text box it show error like this, in this way you make the text box as mandatory.