Skip to content

ABAP Keyword Documentation →  ABAP - Reference →  Creating Objects and Values →  CREATE OBJECT 

CREATE OBJECT - parameter_tables

Short Reference

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 dynamically to the instance constructor or assign return values 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 values to the non-class-based exceptions.

The syntax and semantics are the same as those that apply to dynamic method calls using the statement CALL METHOD. 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

Creates a Control Framework (CFW) dialog box dynamically and passes input parameters 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.