Instantiation and Linking of ALV Objects
After you have created a screen with the container control, you can connect the GUI control to the container.
The steps to connect the GUI control to the container are as follows:
The container control is responsible for integrating the presentation server controls with normal screen processing (PBO, PAI, and resize behavior).
Every GUI control has a representative instance in the ABAP program, therefore the program communicates with two ABAP instances and a minimum of one dynpro. In all, four instances are generated, two in the ABAP program and two at the presentation server.
There are various options for connecting a container instance to a dynpro.
Creation of a Container Control Instance – Process Flow
The figure displays the process to perform the three specified steps in an ABAP program.
You must generate an instance of a container in your program before the screen with the GUI control is displayed. The PBO event of the screen that contains the reserved area is suitable for this step.
To make your program easier to follow, place all control programming in a separate module, for example, init_control_processing.
To create a container control instance, you also require a reference variable for your instance.
Syntax – Defining a Reference Variable
The figure displays individual parts of the definition of a reference variable.
When you use instances of classes (object-oriented programming) in your program, you require pointers to the objects (instances) generated and administered in the memory area of the program. You use a reference variable to administer these pointers in your ABAP program.
To declare the reference variable in your program, use the DATA statement and assign a name to your reference variable. The TYPE REF TO addition means that the field can contain a pointer to an instance. Specify the name of a class after TYPE REF TO. The reference variable can then contain pointers to instances of this class.
Syntax – Creating Instances
To create an instance of the class for which the <object_name> reference variable has been assigned a type, use the CREATE OBJECT <object_name> ABAP statement.
If the class for which you want to generate an instance has a method with the name CONSTRUCTOR, it is automatically executed when the instance is created. The CONSTRUCTOR method can only have IMPORTING parameters and exceptions (EXCEPTIONS) as a signature. You must pass these parameters in the CREATE OBJECT statement, taking care to assign values to all obligatory IMPORTING parameters.
Creation of a Container Control Instance
Use DATA to define a reference variable (go_container) for your container control instance, using TYPE REF TO cl_gui_custom_container.
Use the CREATE OBJECT statement to create an instance of the CL_GUI_CUSTOM_CONTAINER class as a representative object for the container control instance at the presentation server.
You must use the IMPORTING parameter container_name to transfer the name of the area reserved for the control on the screen (for example, MY_CONTROL_AREA).
Insertion of CREATE OBJECT using Pattern
You can use the ABAP Objects pattern to insert the CREATE OBJECT statement.
The steps to insert the CREATE OBJECT statement are as follows: