Get Example source ABAP code based on a different SAP table
Declaration of Variables with BDEF Derived Types For modularization purposes, BDEF derived types> can be used outside of the reserved handler methods by declaring variables, for example, in ABAP programs. The statements TYPES>, DATA> and CREATE DATA> are supported. For example, an internal table can be declared with the type TYPE TABLE FOR >>: DATA itab TYPE TABLE FOR CREATE entity_name.> entity_name> must be the full name of the entity, not the alias defined in the BDEF> since there is no clear reference to a specific BDEF outside of handler methods in behavior pools>. The following type declarations are supported in the context of BDEF derived types:
TYPE TABLE FOR>>
TYPE STRUCTURE FOR>>
TYPE REQUEST FOR>>
TYPE RESPONSE FOR>>
Creation of Data Objects Data objects with BDEF derived types can be created dynamically. It can be done, most conveniently, using the method create_data> of class CL_ABAP_BEHVDESCR>>: cl_abap_behvdescr=>create_data( ).> The following parameters can be used for the method: Parameter>Details> p_name>Name of the entity p_root>Name of the root p_op>Operation, lbr for example, if_abap_behv=>op-m-create > or the predefined constant (e. g. just 'C'> for create). p_sub_name>Association or action name p_kind> Type category p_structure>'X'> lbr For the creation of a row type (and not a table type) The data object creation is based on absolute types>. These types can be constructed manually and instantiated using the following syntax. CREATE DATA dref TYPE (der_type)>. The variable der_type> represents a string that follows a certain pattern that looks, for example, as follows. Note that the entries for the placeholders must be capitalized and that the string requires additional parts depending on the context, for example, when referring to associations or in case of actions. BDEF=bdef_name ENTITY=entity_name TYPE=operation> The name of the behavior definition (bdef_name>) comes in first position, followed by the entity name (entity_name>; it cannot be the alias) and the specification for the type (operation>). The following table provides an overview on strings that can be used for der_type> in the respective contexts: Context>String for der_type>> Standard operations BDEF=bdef_name ENTITY=entity_name TYPE=CREATE > lbr BDEF=bdef_name ENTITY=entity_name TYPE=UPDATE> lbr BDEF=bdef_name ENTITY=entity_name TYPE=DELETE> lbr lbr For create-by-association operations: BDEF=bdef_name ENTITY=entity_name ASSOC=assoc_name TYPE=CREATE> Read operations For READ IMPORT>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=READ_I> lbr For READ RESULT>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=READ_R> lbr lbr For read-by-association operations: lbr IMPORT>: lbr BDEF=bdef_name ENTITY=entity_name ASSOC=assoc_name TYPE=READ_I> lbr RESULT>: lbr BDEF=bdef_name ENTITY=entity_name ASSOC=assoc_name TYPE=READ_R> lbr LINK>: lbr BDEF=bdef_name ENTITY=entity_name ASSOC=assoc_name TYPE=LINK> Responses TYPE TABLE FOR ...>/TYPE STRUCTURE FOR ...> (the variants without _LATE> refer to those types with the addition EARLY>): lbr BDEF=bdef_name ENTITY=entity_name TYPE=FAILED> lbr BDEF=bdef_name ENTITY=entity_name TYPE=FAILED_LATE> lbr BDEF=bdef_name ENTITY=entity_name TYPE=MAPPED> lbr BDEF=bdef_name ENTITY=entity_name TYPE=MAPPED_LATE> lbr BDEF=bdef_name ENTITY=entity_name TYPE=REPORTED> BDEF=bdef_name ENTITY=entity_name TYPE=REPORTED_LATE> lbr lbr TYPE RESPONSE FOR ...> lbr BDEF=bdef_name TYPE=FAILED> lbr BDEF=bdef_name TYPE=FAILED_LATE> lbr BDEF=bdef_name TYPE=MAPPED> lbr BDEF=bdef_name TYPE=MAPPED_LATE> lbr BDEF=bdef_name TYPE=REPORTED> lbr BDEF=bdef_name TYPE=REPORTED_LATE> Actions and functions For ACTION IMPORT>/FUNCTION IMPORT> : lbr BDEF=bdef_name ENTITY=entity_name ACTION=action_or_function_ name TYPE=IMPORTING > lbr For ACTION RESULT>/FUNCTION RESULT>: lbr BDEF=bdef_name ENTITY=entity_name ACTION=action_or_function_name TYPE=RETURNING> lbr For ACTION REQUEST>/FUNCTION REQUEST>: lbr BDEF=bdef_name ENTITY=entity_name ACTION=action_or_function_name TYPE=REQUEST> Locks BDEF=bdef_name ENTITY=entity_name TYPE=KEY> lbr lbr ABAP_NOTE ... TYPE=LOCK> is obsolete. Permissions For INSTANCE FEATURES KEY>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=I_CONTROL_K> lbr lbr For INSTANCE FEATURES REQUEST>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=I_CONTROL_F> (optionally with GROUP>) lbr lbr For INSTANCE FEATURES RESULT>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=I_CONTROL_R> (optionally with GROUP>) lbr lbr For FEATURES REQUEST>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=G_CONTROL_F> (optionally with GROUP>) lbr lbr For FEATURES RESULT>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=G_CONTROL_R> (optionally with GROUP>) lbr lbr For INSTANCE AUTHORIZATION KEY>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=I_AUTH_K> lbr lbr For INSTANCE AUTHORIZATION REQUEST>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=I_AUTH_Q> (optionally with GROUP>) lbr lbr For INSTANCE AUTHORIZATION RESULT>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=I_AUTH_R> (optionally with GROUP>) lbr lbr For GLOBAL AUTHORIZATION REQUEST>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=G_AUTH_Q> (optionally with GROUP>) lbr lbr For GLOBAL AUTHORIZATION RESULT>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=G_AUTH_R> (optionally with GROUP>) lbr lbr For PERMISSIONS REQUEST>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=PERM_Q> lbr lbr For PERMISSIONS KEY>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=PERM_K> lbr lbr For PERMISSIONS RESULT>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=PERM_R> ... FOR CHANGE...>/ lbr ... FOR DELETE...> For TYPE TABLE FOR CHANGE>/TYPE STRUCTURE FOR CHANGE>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=CHANGE> lbr lbr For TYPE RESPONSE FOR CHANGE>: lbr BDEF=bdef_name TYPE=CHANGE> lbr lbr For TYPE TABLE FOR DELETE>/TYPE STRUCTURE FOR DELETE>: lbr BDEF=bdef_name ENTITY=entity_name TYPE=DELETE> lbr lbr For TYPE RESPONSE FOR DELETE>: lbr BDEF=bdef_name TYPE=DELETE> TYPE TABLE FOR HIERARCHY>/ lbr TYPE STRUCTURE FOR HIERARCHY > BDEF=bdef_name ENTITY=entity_name TYPE=HIERARCHY>
ABAP_EXAMPLE_VX5 Declaration of variables: ABEXA 01628 ABAP_EXAMPLE_END
ABAP_EXAMPLE_VX5 Creation of data objects: ABEXA 01629 ABAP_EXAMPLE_END
ABAP_EXAMPLE_ABEXA The class CL_DEMO_RAP_EML_EXPLICIT_DECL>> demonstrates the explicit declaration of variables with BDEF derived types with a simple EML READ> statement. ABAP_EXAMPLE_END