SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Creating Objects and Values → CREATE OBJECT →
CREATE OBJECT - parameter_tables
Syntax
... [PARAMETER-TABLE ptab]
[EXCEPTION-TABLE etab].
Effect
The PARAMETER-TABLE and EXCEPTION-TABLE additions pass actual parameters dynamically to the instance constructor or assign return codes to the non-class-based exceptions.
These additions can be used only if the instantiated class is specified dynamically in name. Using the special internal tables ptab and etab, they assign actual parameters to the input parameters of the instance constructor, or return codes to the non-class-based exceptions.
The syntax and semantics are the same as those that apply to dynamic method calls using the statement
CALLMETHOD. The internal
tables ptab and etab in particular must be defined with reference to the tables ABAP_PARMBIND_TAB and ABAP_EXCPBIND_TAB from the
type group ABAP.
Example
The following example illustrates how a dialog box of Control Framework (CFW) is generated dynamically and how input parameters are passed dynamically to the instance constructor of the global class CL_GUI_DIALOGBOX_CONTAINER. The class is defined explicitly using the TYPE addition.
DATA: container TYPE REF TO cl_gui_container,
exc_ref TYPE REF TO cx_root.
DATA: class TYPE string VALUE `CL_GUI_DIALOGBOX_CONTAINER`,
ptab TYPE abap_parmbind_tab.
ptab = VALUE #( ( name = 'PARENT'
kind = cl_abap_objectdescr=>exporting
value = REF #( cl_gui_container=>desktop ) )
( name = 'WIDTH'
kind = cl_abap_objectdescr=>exporting
value = REF #( 1000 ) )
( name = 'HEIGHT'
kind = cl_abap_objectdescr=>exporting
value = REF #( 300 ) ) ).
TRY.
CREATE OBJECT container TYPE (class)
PARAMETER-TABLE ptab.
CATCH cx_sy_create_object_error INTO exc_ref.
MESSAGE exc_ref->get_text( ) TYPE 'I'.
ENDTRY.