DATA : lr_custom_cont TYPE REF TO cl_gui_custom_container,
lr_text_edit TYPE REF TO cl_gui_textedit,
lt_text TYPE TABLE OF char255.
START-OF-SELECTION.
CALL SCREEN 0001.
*&---------------------------------------------------------------------*
*& Module CREATE_PF_STAUS OUTPUT
*&---------------------------------------------------------------------*
MODULE create_pf_staus OUTPUT.
SET PF-STATUS 'EDITOR_STATUS'.
ENDMODULE. " CREATE_PF_STAUS OUTPUT
*----------------------------------------------------------------------*
* MODULE create_container OUTPUT
*----------------------------------------------------------------------*
MODULE create_container OUTPUT.
IF lr_custom_cont IS NOT BOUND.
CREATE OBJECT lr_custom_cont
EXPORTING
container_name = 'EDITOR' " Name of the Screen CustCtrl
repid = sy-repid
dynnr = sy-dynnr.
ENDIF.
ENDMODULE. "create_container OUTPUT
*----------------------------------------------------------------------*
* MODULE create_text_editor OUTPUT
*----------------------------------------------------------------------*
MODULE create_text_editor OUTPUT.
IF lr_text_edit IS NOT BOUND.
CREATE OBJECT lr_text_edit
EXPORTING
wordwrap_mode = 2 " 0: OFF; 1: wrap a window border; 2: wrap at fixed pos
wordwrap_position = 254 " pos of wordwrap, only makes sense with wordwrap_mode=2
parent = lr_custom_cont. " Parent Container
ENDIF.
ENDMODULE. "create_text_editor OUTPUT
*&---------------------------------------------------------------------*
*& Module READ_EDITOR_TEXT INPUT
*&---------------------------------------------------------------------*
MODULE read_editor_text INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'SAVE'.
CALL METHOD lr_text_edit->get_text_as_r3table
IMPORTING
table = lt_text. " text as R/3 table
BREAK-POINT.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " READ_EDITOR_TEXT INPUT
-------------------------------------------------------------------------------------------------
Instead of above method 'get_text_as_r3table' to read the editor text content as an alternative another method get_text_as_stream can be used
CALL METHOD lr_text_edit->get_text_as_stream
IMPORTING
text = lt_text " text as stream with carrige retruns and linefeeds
* is_modified = " modify status of text
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
OTHERS = 3.
---------------------------------------------------------------------------------------------------------
Here is the flow logic of the screen.
Here is the pf status tool bar button details.
Once the user Clicks on the SAVE button, Then the editor text will be placed on the internal table.
Run the program and enter some text and save.
lr_text_edit TYPE REF TO cl_gui_textedit,
lt_text TYPE TABLE OF char255.
START-OF-SELECTION.
CALL SCREEN 0001.
*&---------------------------------------------------------------------*
*& Module CREATE_PF_STAUS OUTPUT
*&---------------------------------------------------------------------*
MODULE create_pf_staus OUTPUT.
SET PF-STATUS 'EDITOR_STATUS'.
ENDMODULE. " CREATE_PF_STAUS OUTPUT
*----------------------------------------------------------------------*
* MODULE create_container OUTPUT
*----------------------------------------------------------------------*
MODULE create_container OUTPUT.
IF lr_custom_cont IS NOT BOUND.
CREATE OBJECT lr_custom_cont
EXPORTING
container_name = 'EDITOR' " Name of the Screen CustCtrl
repid = sy-repid
dynnr = sy-dynnr.
ENDIF.
ENDMODULE. "create_container OUTPUT
*----------------------------------------------------------------------*
* MODULE create_text_editor OUTPUT
*----------------------------------------------------------------------*
MODULE create_text_editor OUTPUT.
IF lr_text_edit IS NOT BOUND.
CREATE OBJECT lr_text_edit
EXPORTING
wordwrap_mode = 2 " 0: OFF; 1: wrap a window border; 2: wrap at fixed pos
wordwrap_position = 254 " pos of wordwrap, only makes sense with wordwrap_mode=2
parent = lr_custom_cont. " Parent Container
ENDIF.
ENDMODULE. "create_text_editor OUTPUT
*&---------------------------------------------------------------------*
*& Module READ_EDITOR_TEXT INPUT
*&---------------------------------------------------------------------*
MODULE read_editor_text INPUT.
CASE sy-ucomm.
WHEN 'BACK' OR 'EXIT' OR 'CANCEL'.
LEAVE TO SCREEN 0.
WHEN 'SAVE'.
CALL METHOD lr_text_edit->get_text_as_r3table
IMPORTING
table = lt_text. " text as R/3 table
BREAK-POINT.
WHEN OTHERS.
ENDCASE.
ENDMODULE. " READ_EDITOR_TEXT INPUT
-------------------------------------------------------------------------------------------------
Instead of above method 'get_text_as_r3table' to read the editor text content as an alternative another method get_text_as_stream can be used
CALL METHOD lr_text_edit->get_text_as_stream
IMPORTING
text = lt_text " text as stream with carrige retruns and linefeeds
* is_modified = " modify status of text
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
OTHERS = 3.
---------------------------------------------------------------------------------------------------------
Here is the flow logic of the screen.
The editor text now available in the internal table which can be stored DB table.
No comments:
Post a Comment