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

cl_gui_textedit

Former Member
0 Likes
1,487

Hello folks,

I tried to read the text from an custom container, but the text the text won't appear (gs_stamm-text ist empty).

Definition

data: g_editor type REF TO cl_gui_textedit,
       g_editor_container type REF TO cl_gui_custom_container.

PBO


if g_editor is initial.

     g_repid = sy-repid.

     CREATE OBJECT g_editor_container
       EXPORTING
         container_name              = 'TEXTFELD'
       EXCEPTIONS
         cntl_error                  = 1
         cntl_system_error           = 2
         create_error                = 3
         lifetime_error              = 4
         lifetime_dynpro_dynpro_link = 5.
     if sy-subrc ne 0.
       leave program.
     endif.

     CREATE OBJECT g_editor
       EXPORTING
         parent                     = g_editor_container
         wordwrap_mode              = cl_gui_textedit=>wordwrap_at_fixed_position
         wordwrap_to_linebreak_mode = cl_gui_textedit=>true.

     CALL METHOD G_EDITOR->SET_TOOLBAR_MODE
       EXPORTING
         TOOLBAR_MODE           = 0
       EXCEPTIONS
         ERROR_CNTL_CALL_METHOD = 1
         INVALID_PARAMETER      = 2
         others                 = 3
             .

     if sy-subrc ne 0.
       CALL FUNCTION 'popup_to_inform'
         EXPORTING
           titel = g_repid
           txt2  = space
           txt1  = text-001.
     ENDIF.

   ENDIF.

PAI:

CALL METHOD G_EDITOR->GET_TEXTSTREAM
         importing
           text                   = gs_stamm-text "gs_stamm-text is type string
         EXCEPTIONS
           ERROR_CNTL_CALL_METHOD = 1
           not_supported_by_gui   = 2
           others                 = 3.
       if sy-subrc ne 0.
         CALL FUNCTION 'popup_to_inform'
           EXPORTING
             title = g_repid
             txt2  = space
             txt1  = text-004.
       endif.

Thank you in advance for your help.

Thorsten

3 REPLIES 3
Read only

Former Member
0 Likes
819

check sap technical demos,

this will give you the whole detail.

sap technical dot com->Tutorials->ABAP->TextControl->Demo.htm

regards,


Read only

Former Member
0 Likes
819

Add this to your PBO

CALL METHOD g_editor->set_textstream

   EXPORTING

       text                   = gs_stamm-text

   EXCEPTIONS

     error_cntl_call_method = 1

     not_supported_by_gui   = 2

others                 = 3

Cheers!

Abhinab

Read only

venkat_aileni
Contributor
0 Likes
819

Hi-

Check below sample code:

PBO:

*--for Item Note Text object

   CREATE OBJECT note_text

     EXPORTING

       parent            = note_container

       wordwrap_mode     = cl_gui_textedit=>wordwrap_at_fixed_position

       wordwrap_position = 80"132

       max_number_chars  = 10000.

*--to append text object notes to custom text editor

     CALL METHOD note_text->set_text_as_r3table

       EXPORTING

         table           = tbl_note_text[]

       EXCEPTIONS

         error_dp        = 1

         error_dp_create = 2

         OTHERS          = 3.

*--to disable toolbar for Iten Note text editor

   CALL METHOD note_text->set_toolbar_mode

     EXPORTING

       toolbar_mode           = 0

     EXCEPTIONS

       error_cntl_call_method = 1

       invalid_parameter      = 2

       OTHERS                 = 3.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

*--to set cursor position for Item Note text editor

   CALL METHOD cl_gui_textedit=>set_focus

     EXPORTING

       control           = note_text

     EXCEPTIONS

       cntl_error        = 1

       cntl_system_error = 2

       OTHERS            = 3.

   IF sy-subrc <> 0.

     MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

   ENDIF.

PAI:

*--to check whether there are any changes made in the comments

       CALL METHOD note_text->get_textmodified_status

         IMPORTING

           status                 = lv_txt_status

         EXCEPTIONS

           error_cntl_call_method = 1

           OTHERS                 = 2.

       IF sy-subrc <> 0.

         MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                    WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

       ENDIF.

*--if status = 1 then new comments were added

       IF lv_txt_status = 1.

         CLEAR: lv_txt_status.

*--to read new text

         CALL METHOD note_text->get_text_as_r3table

           IMPORTING

             table = tbl_note_text[].

         IF sy-subrc <> 0.

           MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

                      WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

         ENDIF.

       ENDIF.


Thanks.

-Venkat