Exercise 4: Using Multiple Controls
Usage
You can create multiple controls of the same type or of a different type in your program. In this exercise, you create a second editor window that is designed to be used as a clipboard for short texts.

For a detailed description on creating controls, see
Procedure
DATA: scratch TYPE REF TO cl_gui_textedit,
custom_container2 TYPE REF TO cl_gui_custom_container.
CREATE OBJECT custom_container2
EXPORTING
CONTAINER_NAME = 'MYCONTAINER2'
EXCEPTIONS
CNTL_ERROR = 1
CNTL_SYSTEM_ERROR = 2
CREATE_ERROR = 3
LIFETIME_ERROR = 4
LIFETIME_DYNPRO_DYNPRO_LINK = 5.
CREATE OBJECT SCRATCH
EXPORTING
parent = custom_container2
WORDWRAP_MODE = CL_GUI_TEXTEDIT=>WORDWRAP_AT_WINDOWBORDER
WORDWRAP_TO_LINEBREAK_MODE = CL_GUI_TEXTEDIT=>TRUE.
CALL METHOD SCRATCH->SET_STATUSBAR_MODE
exporting
STATUSBAR_MODE = CL_GUI_TEXTEDIT=>FALSE.
Check Your Work
In the second container, the system displays a text editor without a status bar. Using the Copy function of the first editor and the Paste function of the second editor, you can copy text into the second window.
Discussion
In the PBO module, you create multiple controls and call additional control methods. Transferring methods to the frontend only requires synchronization at PBO end. This means the methods of two different instances use the same Automation Queue.

Basically, there is one Automation Queue for each internal mode. In this queue, the system buffers method calls of all control instances that were created in the same internal mode.
Theoretically, you can buffer as many method calls in the queue as you like. However, the system limits the runtime for RFC calls. If this limit is exceeded, you must introduce additional points of synchronization, since otherwise the backend terminates the connection. Generally, this is not due to the number of RFC calls, but to the data volume to be transferred in such a call (long texts, for example).
Strategy
Especially if you use multiple controls, you can apply a certain strategy to reduce the number of flush calls. In many cases, you must retrieve the control properties with
GET methods before you can determine control behavior with SET methods. Since you need the current values in your ABAP program after a GET method, a flush is indispensable (see also Exercise 1: Using Imported Values). In case of several GET calls independent of each other, you best proceed as follows:Grouping calls thus allows you to optimize performance.