I've got a very simple ABAP program demonstrating how to display a Text Editor field (cl_gui_textedit
), which I want to share via Internet, email, forum, blog post or whatever.
I'd like the people to just copy, paste and run this very simple demonstration in an instant, but this program contains a GUI Status and a Dynpro screen, which are difficult to share because it's not code (see the details after the program code).
I know these ways to share ABAP and non-ABAP objects, but my opinion is that it's too much complex for such a simple demonstration: SAP Transport Request, Git repository and abapGit.
Note that I have other Dynpro SAP Control Framework demonstrations (cl_gui_alv_grid
, cl_gui_html_viewer
, etc.) so I'd like to generalize the question to all types of controls.
Is there a way to easily share, copy, paste and run this demonstration (possibly by refactoring the code), whatever it's cl_gui_textedit
or any other Dynpro Control?
The 3 elements of the demonstration:
REPORT zdemo_cl_gui_textedit.
DATA go_custom_container TYPE REF TO cl_gui_custom_container.
DATA go_textedit TYPE REF TO cl_gui_textedit.
START-OF-SELECTION.
CALL SCREEN 100.
MODULE _0100_pbo OUTPUT.
SET PF-STATUS '0100'.
IF go_textedit IS NOT BOUND.
CREATE OBJECT go_custom_container
EXPORTING
container_name = 'CUSTOM_CONTAINER'.
CREATE OBJECT go_textedit
EXPORTING
parent = go_custom_container.
ENDIF.
ENDMODULE.
MODULE _0100_pai INPUT.
IF sy-ucomm = 'EXIT'.
SET SCREEN 0.
ENDIF.
ENDMODULE.
CUSTOM_CONTAINER
of type "Custom Control".PROCESS BEFORE OUTPUT.
MODULE _0100_PBO.
PROCESS AFTER INPUT.
MODULE _0100_PAI AT EXIT-COMMAND.
EXIT
, of type "E" (Exit command).My preferred way to propose a minimal reproducible example (MRE) is to use cl_gui_container=>screen0
which is a container displayed over a Dynpro screen, and it may contain any kind of Dynpro Control (not limited to cl_gui_textedit
).
So, a Dynpro screen must first be displayed. Instead of a general Dynpro screen, a Selection Screen may be used, which is built by the ABAP statements PARAMETERS
or SELECT-OPTIONS
.
In selection screens, the "Process Before Output" logic corresponds to the event "AT SELECTION-SCREEN OUTPUT", and the exit button is managed by default (if other buttons are needed, the control CL_GUI_TOOLBAR
may be used, several controls may be displayed inside cl_gui_container=>screen0
by using the control CL_GUI_SPLITTER_CONTAINER
).
Warning: the solution of using cl_gui_container=>screen0
is nice for demonstration programs, but I don't recommend using it for productive programs because it's an unofficial trick. Instead, use containers inside normal Dynpro screens (cl_gui_custom_container
), around (cl_gui_docking_container
) or over it as a dialog box screen (cl_gui_dialogbox_container
).
Hence, the whole example can be simplified to these below lines of code, the Dynpro screen and GUI Status objects are not needed.
REPORT zdemo_cl_gui_textedit.
DATA go_textedit TYPE REF TO cl_gui_textedit.
PARAMETERS dummy.
AT SELECTION-SCREEN OUTPUT.
IF go_textedit IS NOT BOUND.
go_textedit = NEW #( parent = cl_gui_container=>screen0 ).
ENDIF.
NB: other MRE in Stack Overflow based on the same concept:
cl_salv_table
cl_gui_alv_grid
cl_gui_html_viewer
cl_gui_toolbar
cl_salv_tree
NB: a User Interface demonstration can be improved if it contains rich and meaningful data, which you can obtain from the database tables SFLIGHT
, SBOOK
, etc. For instance, this data can be used for an ALV grid. These tables should be present in all ABAP systems but may be delivered empty. To generate content, run any of these programs:
SCARR
, SPFLI
, SFLIGHT
, SBOOK
...: run the program SAPBC_DATA_GENERATOR
.ALV_
(e.g. ALV_CHCK
, ALV_T_T2) used by a few SAP demo programs: run the program
BCALV_GENERATE_ALV_T_T2`.NB: instead of cl_gui_container=>screen0
, you may use cl_gui_container=>default_screen
, that's the same behavior. Technically speaking, cl_gui_container=>screen0
is displayed over cl_gui_container=>default_screen
i.e. if both containers contain a control, only the control in cl_gui_container=>screen0
will be shown. If you want to display a control in a popup screen, cl_gui_container=>screen1
up to screen9
have to be used. Each number represents a "modal level": screen2
is for a popup called from the first popup. I don't know what represents cl_gui_container=>desktop
, I can't display anything in it.