SAP DERIVED TYPES COMP ABAP Statements



Get Example source ABAP code based on a different SAP table
  



Components of BDEF Derived Types
BDEF derived types are derived by the ABAP runtime framework from CDS entities and their behavior definition in the BDEF . Internal tables and structures that are typed with BDEF derived types contain components of CDS entities, i. e. persisted key and data field values, that retain their original line type. Yet, BDEF derived types also contain additional RAP components that do not derive their line type from the entity. They have special, tailor-made line types that provide additional information required in the context of transactional processing. The names of those RAP components begin with % to avoid naming conflicts with components of the CDS entities.
The use of the components depends on the RAP operation and/or context, for example, %pid is only available for late numbering scenarios. All of the % components are generated by the ABAP compiler and are either typed with data types from the ABAP Dictionary or contain % components themselves. Among the components, there are also component groups available. They begin with %, too, and serve the purpose of summarizing groups of table columns under a single name. For example, %key summarizes all primary keys of persisted instances.
See the details on the components following the links:
Components related to keys and RAP BO instance identification
Using Keys and Identifying RAP BO Instances in a Nutshell
%cid
%cid_ref
%is_draft
%key
%pid
%pre
%tky
%tmp
Components related to information processing
%element
%fail
%global
%msg
%other
%path
%state_area
Miscellaneous components
%action
%assoc
%control
%create
%data
%delete
%features
%field
%op
%own
%param
%perm
%target
%update



Latest notes:

The components of BDEF derived types can be checked via the element information in ADT by choosing F2 for the typed variable. Note that %key and %data are component groups. The field names of the key and data fields are both displayed without the % component and as part of the % component.
IMAGE ABDOC_DERIVED_TYPES_ADT_F2.png 334 235 For a convenient handling and specification of the % components, the ADT code completion shows possible entries and simplifies inserting them without the need to remember the respective field names from the underlying CDS view.
IMAGE ABDOC_DERIVED_TYPES_ADT_F2_2.png 470 54
If the full entity type of a data element is available in a BDEF derived type in the context of component groups, the components can be accessed directly without using the % component, that is, for example, %data-field_name. The specification of field_name alone is the same as using it together with the %data component (%data-field ). Note that the value assignment for the keys in BDEF derived types should be done with care. For example, in types in which %data and %key are available, %data additionally includes %key as a component. In such types, a value assignment for the keys might be done in multiple ways. A value filled for %key-key_field_name is the same as key_field_name (without the % component), %data-key_field_name and %data-%key-key_field_name. However, if values are specified for a primary key field more than once, the value that is last specified is respected. The compiler does not show an error message for multiple specification.
NON_V5_HINTS
ABAP_HINT_END
VX_EXA_ONLY

ABAP_EXAMPLE_VX
The two programs DEMO_RAP_DERIVED_TYPES_TABLE and DEMO_RAP_DERIVED_TYPES_STRUC allow the selection of a particular BDEF derived type, TYPE TABLE FOR or TYPE STRUCTURE FOR respectively, and visualize the availability of the components of the individual BDEF derived type in an internal table that is displayed in an output window. The program makes use of a managed RAP BO. The dummy BDEF DEMO_MANAGED_ROOT_TEST contains various elements in the behavior body to show many of the components in the output. The dummy behavior pool DEMO_MANAGED_ROOT_TEST does not contain any method implementations in the BP_DEMO_MANAGED_ROOT_TEST=====CCIMP. Since variables cannot be declared with many of the BDEF derived types outside of the implementation class (for example, in a program), the global class BP_DEMO_MANAGED_ROOT_TEST contains variables that are typed with the various BDEF derived types and methods (get_comp and get_comp_table) that get the components.
ABAP_NOTE The availability of components varies depending on the specification in the BDEF:
%is_draft is only available for draft scenarios.
%pid is only available for late numbering scenarios.
For example, in the case of TYPE STRUCTURE FOR GLOBAL FEATURES RESULTS, which is similar for several other types that require a certain specification in the BDEF, only those elements that are specified with features : global are available as components.
Wherever %key is available, %tky can be specified, too. %pky can also be specified (except in CREATE operations).
Wherever %key and %data are available, the actual key and data fields can be specified as well without the % component. Hence, the field names are also available as components.