How to Use Text Editor in Module pool?
Solution
Please use the code for below:
PERFORM display_text_editor.
PERFORM add_test_editor.
*&---------------------------------------------------------------------*
*& Form display_text_editor
*&---------------------------------------------------------------------*
FORM display_text_editor.
IF g_editor IS INITIAL.
repid = sy-repid.
CREATE OBJECT g_cust_cont
EXPORTING
container_name = 'SNR_CONT'
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5.
CREATE OBJECT g_editor
EXPORTING
parent = g_cust_cont
wordwrap_mode = cl_gui_textedit=>wordwrap_at_fixed_position
wordwrap_position = line_length
wordwrap_to_linebreak_mode = cl_gui_textedit=>true.
CALL METHOD g_editor->set_statusbar_mode
EXPORTING
statusbar_mode = 0.
CALL METHOD g_editor->set_toolbar_mode
EXPORTING
toolbar_mode = 0.
ENDIF. "editor is initial
ENDFORM. " display_text_editor
*&---------------------------------------------------------------------*
*& Form add_test_editor
*&---------------------------------------------------------------------*
FORM add_test_editor.
CALL METHOD g_editor->set_text_as_r3table
EXPORTING table = it_pi_text
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
MESSAGE i015 WITH
repid 'Error in set_text_as_r3table'.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
MESSAGE i015 WITH
repid 'set_text_as_r3table: Error in FLUSH'.
ENDIF.
ENDFORM. " add_test_editor
*** " This section is called from the PAI routine of the screen
*&---------------------------------------------------------------------*
*& Module text_editor_exec INPUT
*&---------------------------------------------------------------------*
MODULE text_editor_exec INPUT.
PERFORM text_editor_exec.
ENDMODULE. " text_editor_exec INPUT
*---------------------------------------------------------------------*
* FORM text_editor_exec *
*---------------------------------------------------------------------*
FORM text_editor_exec.
CHECK NOT g_editor4 IS INITIAL.
CALL METHOD g_editor4->get_text_as_r3table
IMPORTING table = it_pi_text
EXCEPTIONS
OTHERS = 1.
IF sy-subrc NE 0.
MESSAGE i015 WITH
repid 'Error in get_text_as_r3table'.
ENDIF.
CALL METHOD cl_gui_cfw=>flush.
IF sy-subrc NE 0.
MESSAGE i015 WITH
repid 'get_text_as_r3table: Error in FLUSH'.
ENDIF.
ENDFORM.