Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  ABAP RESTful Programming Model →  Derived Types 

Variables with Derived Types

Other versions: 7.31 | 7.40 | 7.54

Syntax


TYPES dtype TYPE TABLE FOR 
        CREATE|UPDATE|DELETE|LOCK|READ IMPORT|
        MAPPED [LATE]| REPORTED [LATE]|FAILED [LATE]|
        ACTION
      entity_name.

DATA dtype TYPE TABLE FOR
        CREATE|UPDATE|DELETE|LOCK|READ IMPORT|
        MAPPED [LATE]| REPORTED [LATE]|FAILED [LATE]|
        ACTION
     entity_name.

CREATE DATA dref TYPE TABLE FOR
              CREATE|UPDATE|DELETE|LOCK|READ IMPORT|
              MAPPED [LATE]| REPORTED [LATE]|FAILED [LATE]|
              ACTION
            entity_name.

Effect

In the case of modularization, it may be necessary to declare variables with derived types outside the reserved handler methods too. For this purpose, a special syntax in the form TYPE TABLE FOR is provided, which is supported in the statements TYPES, DATA and CREATE DATA.

It is not possible to use an alias to reference the entity here, only the entity_name. This is because, unlike in handler methods, no reference to a specific behavior definition is given.

Data objects with derived type can also be created dynamically, preferably using the method CL_ABAP_BEHVDESCR=>CREATE_DATA( ). The way the objects are created is based on absolute types. If preferred, these types can be constructed manually and instantiated using CREATE DATA dref TYPE (name).

The absolute name starts with \BDEF=, followed by bdef_name (the name of the behavior definition). This is usually followed by \ENTITY=entity_name and a specified operation. The schema for all derived types is as follows:

\BDEF=bdef_name\ENTITY=entity_name\TYPE=CREATE
\BDEF=bdef_name\ENTITY=entity_name\TYPE=UPDATE
\BDEF=bdef_name\ENTITY=entity_name\TYPE=DELETE
\BDEF=bdef_name\ENTITY=entity_name\TYPE=LOCK
\BDEF=bdef_name\ENTITY=entity_name\TYPE=FAILED
\BDEF=bdef_name\ENTITY=entity_name\TYPE=MAPPED
\BDEF=bdef_name\ENTITY=entity_name\TYPE=REPORTED
\BDEF=bdef_name\ENTITY=entity_name\TYPE=FAILED_LATE
\BDEF=bdef_name\ENTITY=entity_name\TYPE=MAPPED_LATE
\BDEF=bdef_name\ENTITY=entity_name\TYPE=REPORTED_LATE

For the operation READ IMPORT:
\BDEF=bdef_name\ENTITY=entity_name\TYPE=READ_I

For the operation READ RESULT:
\BDEF=bdef_name\ENTITY=entity_name\TYPE=READ_R

For the operation ACTION IMPORT:
\BDEF=bdef_name\ENTITY=entity_name\ACTION=action_name\TYPE=IMPORTING

For the operation ACTION RESULT:
\BDEF=bdef_name\ENTITY=entity_name\ACTION=action_name\TYPE=RETURNING

For the operation read-by-association IMPORT:
\BDEF=bdef_name\ENTITY=entity_name\ASSOC=assoc_name\TYPE=READ_I

For the operation read-by-association RESULT:
\BDEF=bdef_name\ENTITY=entity_name\ASSOC=assoc_name\TYPE=READ_R

For the operation read-by-association LINK:
\BDEF=bdef_name\ENTITY=entity_name\ASSOC=assoc_name\TYPE=LINK

For the operation create-by-association:
\BDEF=bdef_name\ENTITY=entity_name\ASSOC=assoc_name\TYPE=CREATE

For response structures:
\BDEF=bdef_name\TYPE=FAILED
\BDEF=bdef_name\TYPE=FAILED_LATE
\BDEF=bdef_name\TYPE=MAPPED
\BDEF=bdef_name\TYPE=MAPPED_LATE
\BDEF=bdef_name\TYPE=REPORTED
\BDEF=bdef_name\TYPE=REPORTED_LATE


Example

CLASS lcl_handler DEFINITION
        INHERITING FROM cl_abap_behavior_handler.
  PRIVATE SECTION.

    TYPES it_item_c         TYPE TABLE FOR CREATE sales_order_item.
    DATA  it_root_u         TYPE TABLE FOR UPDATE sales_order.
    CREATE DATA rt_item_ri  TYPE TABLE FOR READ IMPORT
                sales_order_item.
    DATA et_item_rr    TYPE TABLE FOR READ RESULT sales_order_item
    TYPES et_root_f    TYPE TABLE FOR FAILED sales_order.
    TYPES it_root_l    TYPE TABLE FOR LOCK sales_order.
    TYPES it_item_a_in     TYPE TABLE FOR ACTION IMPORT
          sales_order_item~add_supplement.
    DATA et_root_a_out     TYPE TABLE FOR ACTION RESULT
         sales_order~set_final_status.
    CREATE DATA rt_ri_items TYPE TABLE FOR READ IMPORT
           sales_order_items.
    DATA lt_rr_items        TYPE TABLE FOR READ RESULT
         sales_order_items.
    DATA lt_rl_items    TYPE TABLE FOR READ LINK sales_order_items.
    ...
ENDCLASS.