ABAP Keyword Documentation → ABAP - Reference → Creating Objects → CREATE OBJECT
CREATE OBJECT - parameter_tables
Other versions: 7.31 | 7.40 | 7.54
Syntax
... [PARAMETER-TABLE ptab]
[EXCEPTION-TABLE etab].
Effect
The additions PARAMETER-TABLE
and EXCEPTION-TABLE
pass actual parameters to the instance constructor dynamically or assign return codes to the non-class-based exceptions.
You can use these additions only if the instantiated class is specified dynamically in name
.
You use the special internal tables ptab
and etab
to assign actual parameters to the input parameters of the instance constructor or return codes to the non-class-based exceptions.
The syntax and meaning are the same as for the dynamic form of the statement
CALL METHOD
. In particular, the internal tables ptab
and etab
must be defined with reference to the tables ABAP_PARMBIND_TAB and ABAP_EXCPBIND_TAB from the
type group ABAP.
Example
Dynamic creation of a dialog box from
Control Frameworks (CFW) and dynamic passing of the input parameters to the instance constructor
of the global class CL_GUI_DIALOGBOX_CONTAINER. The class is defined explicitly by the addition TYPE
.
DATA: container TYPE REF TO cl_gui_container,
exc_ref TYPE REF TO cx_root,
exc_text TYPE string.
DATA: class TYPE string VALUE `CL_GUI_DIALOGBOX_CONTAINER`,
ptab TYPE abap_parmbind_tab,
ptab_line TYPE abap_parmbind.
ptab_line-name = 'PARENT'.
ptab_line-kind = cl_abap_objectdescr=>exporting.
GET REFERENCE OF CL_GUI_CONTAINER=>DESKTOP
INTO ptab_line-value.
INSERT ptab_line INTO TABLE ptab.
ptab_line-name = 'WIDTH'.
ptab_line-kind = cl_abap_objectdescr=>exporting.
GET REFERENCE OF 1000 INTO ptab_line-value.
INSERT ptab_line INTO TABLE ptab.
ptab_line-name = 'HEIGHT'.
ptab_line-kind = cl_abap_objectdescr=>exporting.
GET REFERENCE OF 300 INTO ptab_line-value.
INSERT ptab_line INTO TABLE ptab.
TRY.
CREATE OBJECT container TYPE (class)
PARAMETER-TABLE ptab.
CATCH cx_sy_create_object_error INTO exc_ref.
exc_text = exc_ref->get_text( ).
MESSAGE exc_text TYPE 'I'.
ENDTRY.