In ABAP (Advanced Business Application Programming), cl_gui_textedit is a class used for creating and manipulating text editor controls in Object-Oriented ABAP (OOABAP). This class is part of the SAP GUI (Graphical User Interface) framework and is specifically designed for handling text editing within SAP GUI applications.
Here's a brief explanation of how you can use cl_gui_textedit in OOABAP:
cl_gui_custom_container class is used to embed custom controls or UI elements within a container on the SAP GUI screen. This class is part of the Object-Oriented ABAP (OOABAP) programming paradigm. The cl_gui_custom_container class is often used in combination with other classes and methods to create interactive and customized user interfaces.
Creating an Instance:
To use the cl_gui_textedit and cl_gui_custom_container class, you first need to create an instance of the class. You can do this using the create object statement.
Create screen 101 (Modal Screen in this case) by double clicking on “101”.
Create a custom control on the screen with the name “CONTAINER”.
Now, add the logic for displaying the edit control in PBO and PAI Modules of screen 101.
In pbo, create object container go_custom. Then create text editor object by exporting the container go_custom.
if go_custom initial
Create object for go_textedit
The cl_gui_textedit class in ABAP is used for displaying and editing text. The set_text_as_r3table method is used to set the content of the text editor as a table that is typically used in SAP R/3 systems. This method allows you to display tabular data within a cl_gui_textedit control in an Object-Oriented ABAP (OOABAP) program.
The method set_readonly_mode is used to set the read-only mode of the text editor.
read-only mode; eq 0: off; ne 0: on
Database Table
Source Code – The complete coding of the executable program is given below.
*&---------------------------------------------------------------------*
*& Report ZPS_RP_TEXTEDIT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
REPORT zps_rp_textedit.
PARAMETERS : p_textid TYPE zps_t_textedit-id.
DATA : go_custom TYPE REF TO cl_gui_custom_container,
go_textedit TYPE REF TO cl_gui_textedit,
gt_text TYPE TABLE OF char255,
gv_flag(1).
START-OF-SELECTION.
SELECT FROM zps_t_textedit FIELDS text WHERE id = @p_textid INTO TABLE @GT_text.
CALL SCREEN 101.
PROCESS BEFORE OUTPUT
*&---------------------------------------------------------------------*
*& Module STATUS_0101 OUTPUT
*&---------------------------------------------------------------------*
*&
*&---------------------------------------------------------------------*
MODULE STATUS_0101 OUTPUT.
SET PF-STATUS 'PF_STATUS'.
SET TITLEBAR 'Text editor'.
ENDMODULE.
Create one edit button in application toolbar
Create function key for SAVE and BACK
MODULE create_container OUTPUT.
MODULE create_container OUTPUT.
CREATE OBJECT go_custom
EXPORTING
container_name = 'CONTAINER'
repid = sy-repid
dynnr = sy-dynnr
EXCEPTIONS
cntl_error = 1
cntl_system_error = 2
create_error = 3
lifetime_error = 4
lifetime_dynpro_dynpro_link = 5
OTHERS = 6.
ENDMODULE.
MODULE create_text_edit OUTPUT.
IF go_textedit IS NOT BOUND.
CREATE OBJECT go_textedit
EXPORTING
parent = go_custom
EXCEPTIONS
error_cntl_create = 1
error_cntl_init = 2
error_cntl_link = 3
error_dp_create = 4
gui_type_not_supported = 5
OTHERS = 6.
ENDIF.
CALL METHOD go_textedit->set_text_as_r3table
EXPORTING
table = gt_text
EXCEPTIONS
error_dp = 1
error_dp_create = 2
OTHERS = 3.
IF gv_flag IS INITIAL.
CALL METHOD go_textedit->set_readonly_mode
EXPORTING
readonly_mode = 1
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3.
ENDIF.
gv_flag = 1.
ENDMODULE.
PROCESS AFTER INPUT
MODULE user_command_0101 INPUT.
CASE sy-ucomm.
WHEN TEXT-002. " BACK.
LEAVE TO SCREEN 0.
WHEN TEXT-003 OR TEXT-004. "EDIT and SAVE.
IF gv_flag IS NOT INITIAL.
CALL METHOD go_textedit->set_readonly_mode
EXPORTING
readonly_mode = 0
EXCEPTIONS
error_cntl_call_method = 1
invalid_parameter = 2
OTHERS = 3.
ENDIF.
CALL METHOD go_textedit->get_text_as_r3table
IMPORTING
table = gt_text
EXCEPTIONS
error_dp = 1
error_cntl_call_method = 2
error_dp_create = 3
potential_data_loss = 4
OTHERS = 5.
DATA(ls_text) = gt_text[ 1 ]. "Read text from an internal table
UPDATE zps_t_textedit SET text = ls_text .
IF sy-subrc = 0.
MESSAGE s001(zps_msg_text). "Record Updateded Sucessfully
ENDIF.
WHEN OTHERS.
ENDCASE.
ENDMODULE.
Before editing text in database table
Based on text id displaying text details
For Editing text
Click edit button in Application Toolbar
Edit text and click on save button
After editing text in database table
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
7 | |
6 | |
5 | |
4 | |
4 | |
4 | |
4 | |
3 | |
2 | |
2 |