无常笔记ABAP Cheat Sheets中文导读全站搜索

英文原文:SAP-samples · 上游版本 d43eb13c4c7c · 原始 Markdown

ABAP Dictionary (DDIC)

This cheat sheet ...

[!NOTE]

Introduction

[!NOTE]

⬆️ back to top

Data Types in DDIC

DDIC supports the following data types:

Built-in ABAP Dictionary Types

[!NOTE]

⬆️ back to top

DDIC Data Types

They can be ...

DDIC Data Elements

[!NOTE]

⬆️ back to top

DDIC Domains

[!NOTE] In modern ABAP, CDS enumerated types offer a similar functionality for fixed values.

Example: DDIC Data Elements/Domains

"Using data elements for local types and data objects

"Data element based on a built-in dicitionary type
TYPES ty_dtel1 TYPE zdemo_abap_dtel_pr.
DATA char3_dtel TYPE zdemo_abap_dtel_pr.

"Data element based on a domain
TYPES ty_dtel2 TYPE zdemo_abap_dtel_do.
DATA char1_dtel TYPE zdemo_abap_dtel_do.

"Data element based on a reference type
TYPES ty_dtel3 TYPE zdemo_abap_dtel_ref.
DATA char10_dtel_ref TYPE zdemo_abap_dtel_ref.

⬆️ back to top

DDIC Structures

[!NOTE] DDIC database tables and several CDS entities also represent structured types that can be used as such in ABAP programs.

Example: DDIC Structures

The following example creates two DDIC structures exploring several options:

⬆️ back to top

DDIC Table Types

Example: DDIC Table Type

The following example creates three DDIC table types exploring several options:

⬆️ back to top

Predefined Types in DDIC

⬆️ back to top

DDIC Database Tables

Example: DDIC Database Tables

The following example creates two DDIC database tables exploring several options:

⬆️ back to top

ABAP CDS Objects as Global Types

[!NOTE]

CDS Types Usable as Elementary Types

CDS Built-In Types

CDS built-in types...

CDS Simple Types

Example: CDS Simple Types

The following example creates CDS simple types:

"Using CDS simple types in ABAP, for example, to declare local
"types and data objects
"Elementary types/data objects
TYPES ty_cds_simple TYPE zdemo_abap_cds_type.
DATA dobj_w_simple_type TYPE zdemo_abap_cds_type.
"Typing a structure component with a CDS simple type
DATA: BEGIN OF struc_w_st,
        comp1 type string,
        comp2 type i,
        comp3 type zdemo_abap_cds_type,
      END OF struc_w_st.
"Internal table with elementary line type represented by the
"CDS simple type
DATA itab_w_st TYPE TABLE OF zdemo_abap_cds_type WITH EMPTY KEY.

"Retrieving type information using RTTI
DATA(tdo_cds_simple_type) = CAST cl_abap_elemdescr( cl_abap_typedescr=>describe_by_name( `ZDEMO_ABAP_CDS_TYPE` ) ).
DATA(type_category_cds_st) = tdo_cds_simple_type->kind.
DATA(type_kind_cds_st) = tdo_cds_simple_type->type_kind.
DATA(is_ddic_type_cds_st) = tdo_cds_simple_type->is_ddic_type( ).
"If you use abap.char(5) as type in the CDS simple type, the following data object contains X
TYPES c5 TYPE c LENGTH 5.
DATA(applies_to_data_cds_st) = tdo_cds_simple_type->applies_to_data( CONV c5( 'abcde' ) ).

⬆️ back to top

CDS Enumerated Types

[!NOTE]

Example: CDS Enumerated Types

The following example creates a CDS enumerated type:

"Using CDS enumerated types in ABAP, for example, to declare
"local types and data objects
TYPES ty_cds_enum TYPE zdemo_abap_cds_enum.
DATA dobj_w_enum_type TYPE zdemo_abap_cds_enum.

"The technical data type of an enumerated value is the base type
"of the enumerated type. You can use the base type of an enumerated
"type in special conversions using the constructor operator CONV.
DATA dobj_c1 TYPE c LENGTH 1 VALUE 'Y'.

DATA(conv_enum_1) = CONV zdemo_abap_cds_enum( dobj_c1 ).
"An enumerated structure with the CDS enumerated type name is
"automatically declared. Therefore, you can access the constants
"with the component selector preceded by the CDS enumerated type
"name.
ASSERT conv_enum_1 = zdemo_abap_cds_enum-enum_constant_3.

"Using a value that is not available in the CDS enumerated type
dobj_c1 = 'A'.
TRY.
    DATA(conv_enum_2) = CONV zdemo_abap_cds_enum( dobj_c1 ).
  CATCH cx_sy_conversion_no_enum_value.
    "This example raises an exception.
ENDTRY.

"Retrieving type information using RTTI
DATA(tdo_cds_enum) = CAST cl_abap_enumdescr( cl_abap_typedescr=>describe_by_name( `ZDEMO_ABAP_CDS_ENUM` ) ).
DATA(type_category_cds_enum) = tdo_cds_enum->kind.
DATA(type_kind_cds_enum) = tdo_cds_enum->type_kind.
DATA(is_ddic_type_cds_enum) = tdo_cds_enum->is_ddic_type( ).
DATA(base_kind_cds_enum) = tdo_cds_enum->base_type_kind.
DATA(members_cds_enum) = tdo_cds_enum->members.

⬆️ back to top

CDS Entities Usable as Structured Types

"Creating structured types and data objects using ABAP cheat sheet
"repository objects
"CDS view entity
TYPES ty_struc_cds_ve TYPE zdemo_abap_fli_ve.
DATA dobj_struc_cds_ve TYPE zdemo_abap_fli_ve.
"CDS abstract entity
TYPES ty_struc_cds_abstr TYPE zdemo_abap_abstract_ent.
DATA dobj_struc_cds_abstr TYPE zdemo_abap_abstract_ent.
"CDS table function
TYPES ty_struc_cds_tabfunc TYPE zdemo_abap_table_function.
DATA dobj_struc_cds_tabfunc TYPE zdemo_abap_table_function.

"Using CDS entities as data souces in ABAP SQL statements
DATA itab_cds_ve TYPE TABLE OF zdemo_abap_fli_ve WITH EMPTY KEY.
DATA itab_cds_tabfunc TYPE TABLE OF zdemo_abap_table_function WITH EMPTY KEY.

SELECT * FROM zdemo_abap_fli_ve INTO TABLE @itab_cds_ve.
SELECT * FROM zdemo_abap_table_function INTO TABLE @itab_cds_tabfunc.

[!NOTE]

⬆️ back to top

CRUD Operations Using CDS Artifacts

⬆️ back to top

Excursions

Built-in Database Functions

⬆️ back to top

Finding Released Repository Objects in the System

In an SAP Business AI Platform, ABAP environment and using ADT, you can find released repository objects in the Project Explorer view under Released Objects:

Released APIs

Programmatically retrieving information about which repository objects are released and available in the system:

SELECT ReleasedObjectType, ReleasedObjectName, ReleaseState
  FROM i_apisforclouddevelopment
  WHERE releasestate = 'RELEASED'
  ORDER BY ReleasedObjectType, ReleasedObjectName
  INTO TABLE @DATA(released_apis).

⬆️ back to top

Retrieving Repository Objects Information and Creating Repository Object Programmatically with XCO

Using the XCO library, you can retrieve ABAP repository objects information and create the objects programmatically. The executable example (zcl_demo_abap_cloud_excursion) of the ABAP for Cloud Development cheat sheet includes demo code snippets. The Released ABAP Classes cheat sheet also includes a small selection of code snippets in that context. For more information, refer to the documentation.

⬆️ back to top

More Information

⬆️ back to top

Executable Example

[!NOTE]

Expand the following collapsible section for example code. To try it out, create a demo class named zcl_demo_abap. If it already exists, reuse it. Otherwise, create a new class with a different name. Paste the code into it. If you choose a different class name, update the class name in the code snippet accordingly. After activation, choose F9 in ADT to execute the class. The example is set up to display output in the console.

🟢 Click to expand for example code
CLASS zcl_demo_abap DEFINITION
      PUBLIC
      FINAL
      CREATE PUBLIC .

  PUBLIC SECTION.
    INTERFACES if_oo_adt_classrun.
ENDCLASS.

CLASS zcl_demo_abap IMPLEMENTATION.
  METHOD if_oo_adt_classrun~main.

    "Populating demo database tables from the ABAP cheat sheet repository
    zcl_demo_abap_aux=>fill_dbtabs( ).

    "---------------------------------------------------
    "------------ Built-in dictionary types ------------
    "---------------------------------------------------

    "Built-in dictionary types are not directly usable in ABAP,
    "except for types specified in ABAP SQL.
    "The following example shows miscellaneous typed literals in
    "an ABAP SQL statement. Typed literals can be specified in read
    "positions where host variables are possible.
    DATA(tmstamp) = CONV timestamp( '20240808112517' ).
    DATA(str) = `Some string`.
    SELECT SINGLE
      FROM zdemo_abap_fli
      FIELDS
        carrid,
        @str AS host_var,
        char`X` AS flag,
        int8`32984723948723` AS int8,
        raw`11` AS raw,
        numc`1234` AS numc,
        utclong`2024-01-01T10:01:02,2` AS utc,
        tims`101507` AS tims,
        curr`173.95` AS curr,
        "Multiple cast expressions splitting a time stamp into date and time parts
        CAST( CAST( div( @tmstamp, 1000000 ) AS CHAR ) AS DATS ) AS date,
        CAST( substring( CAST( @tmstamp AS CHAR ), 9, 6 ) AS TIMS ) AS time,
        "Untyped literal
        'ABAP' AS txt
      WHERE fldate = datn`20240102`
      INTO @DATA(misc_typed_literals).

    out->write( data = misc_typed_literals name = `misc_typed_literals` ).

    "-----------------------------------------------------------
    "--------------- DDIC data elements/domains ----------------
    "-----------------------------------------------------------

    "Using DDIC data elements for local types and data objects

    "Data element based on a built-in dicitionary type
    TYPES ty_dtel1 TYPE zdemo_abap_dtel_pr.
    DATA char3_dtel TYPE zdemo_abap_dtel_pr.

    "Data element based on a domain
    TYPES ty_dtel2 TYPE zdemo_abap_dtel_do.
    DATA char1_dtel TYPE zdemo_abap_dtel_do.

    "Data element based on a reference type
    TYPES ty_dtel3 TYPE zdemo_abap_dtel_ref.
    DATA char10_dtel_ref TYPE zdemo_abap_dtel_do.

    "Using a data element in an explicit conversion
    DATA(char3_dtel_inl) = CONV zdemo_abap_dtel_pr( '1234567890' ).
    out->write( data = char3_dtel_inl name = `char3_dtel_inl` ).

    "Using RTTI to demonstrate the type mapping of built-in dicitionary
    "types (that serve as the types of the DDIC data elements) to ABAP types
    "The example data element ZDEMO_ABAP_DTEL_PR is typed with numc, length 5.
    DATA(tdo_a) = CAST cl_abap_elemdescr( cl_abap_typedescr=>describe_by_name( 'ZDEMO_ABAP_DTEL_PR' ) ).
    DATA(type_kind_a) = tdo_a->type_kind.
    DATA(output_length_a) = tdo_a->output_length.
    TYPES n5 TYPE n LENGTH 5.
    DATA(applies_a) = tdo_a->applies_to_data( CONV n5( '12345' ) ).

    "The example data element ZDEMO_ABAP_DTEL_PR is based on a domain. The type used is char, length 1.
    DATA(tdo_b) = CAST cl_abap_elemdescr( cl_abap_typedescr=>describe_by_name( 'ZDEMO_ABAP_DTEL_DO' ) ).
    DATA(type_kind_b) = tdo_b->type_kind.
    DATA(output_length_b) = tdo_b->output_length.
    TYPES c1 TYPE c LENGTH 1.
    DATA(applies_b) = tdo_b->applies_to_data( CONV c1( 'A' ) ).

    out->write( data = type_kind_a name = `type_kind_a` ).
    out->write( data = output_length_a name = `output_length_a` ).
    out->write( data = applies_a name = `applies_a` ).
    out->write( data = type_kind_b name = `type_kind_b` ).
    out->write( data = output_length_b name = `output_length_b` ).
    out->write( data = applies_b name = `applies_b` ).

    "-----------------------------------------------------------
    "-------------------- DDIC structures ----------------------
    "-----------------------------------------------------------

    "Using DDIC structures to declare local types and data objects
    TYPES ty_struc_flat TYPE zdemo_abap_struc_flat.
    TYPES ty_struc_deep TYPE zdemo_abap_struc_deep.
    DATA flat_struc1 TYPE ty_struc_flat.
    DATA flat_struc2 TYPE zdemo_abap_struc_flat.
    DATA deep_struc1 TYPE ty_struc_deep.
    DATA deep_struc2 TYPE zdemo_abap_struc_deep.

    "Populating the demo structures
    "Flat structure
    flat_struc1 = VALUE #( chars = 'abc'
                           num = 123
                           cuky = 'EUR'
                           curr = '123.45'
                           id  = '98765'
                           flag = 'X' ).

    "Deep structures including structures
    "Addressing the components of nested structures via the structure name
    "Note struc3: The include structure component in the DDIC structure is specified
    "with a suffix. When addressing the components via the structure name, the suffix
    "is not needed. Check the F2 information, which lists the individual components
    "with suffix.
    deep_struc2 = VALUE #( bt_elem1 = 'abcde'
                           bt_elem2 = 123
                           "...
                           dref1 = NEW #( 'abc' )
                           "...
                           struc2 = VALUE #( carrid = 'XY' carrname = 'XY Airways' )
                           struc3 = VALUE #( carrid = 'YZ' connid = '1234' )
                           "...
                          ).

    "Addressing the components of included structures individually
    DATA(deep_struc3) = VALUE zdemo_abap_struc_deep( bt_elem1 = 'abcde'
                                                     bt_elem2 = 123
                                                     "...
                                                     dref1 = NEW #( 'abc' )
                                                     "...
                                                     "Components referring to struc2
                                                     carrid = 'XY'
                                                     carrname = 'XY Airways'
                                                     "Components referring to struc3 (with suffixes)
                                                     carrid_in = 'YZ'
                                                     connid_in = '1234'
                                                     "...
                                                    ).

    DATA(comp_val1) = deep_struc2-carrid.
    DATA(comp_val2) = deep_struc2-struc2-carrid.
    DATA(comp_val3) = deep_struc2-struc3-carrid.
    ASSERT comp_val1 = comp_val2.
    ASSERT comp_val1 <> comp_val3.

    DATA(comp_val4) = deep_struc3-carrid.
    DATA(comp_val5) = deep_struc3-struc2-carrid.
    DATA(comp_val6) = deep_struc2-struc3-carrid.
    DATA(comp_val7) = deep_struc3-carrid_in.
    ASSERT comp_val4 = comp_val5.
    ASSERT comp_val6 = comp_val7.
    ASSERT comp_val4 <> comp_val6.

    "----------------------------------------------------
    "------------------ DDIC table types ----------------
    "----------------------------------------------------

    "Declaring internal tables and local table types based on
    "DDIC table types
    TYPES ty_tab_elem TYPE zdemo_abap_tt_str.
    TYPES ty_tab_struc TYPE zdemo_abap_tt_so.
    DATA tab_elem1 TYPE ty_tab_elem.
    DATA tab_elem2 TYPE zdemo_abap_tt_str.
    DATA tab_struct1 TYPE ty_tab_struc.
    DATA tab_struct2 TYPE zdemo_abap_tt_so.

    "Using RTTI to check whether the technical properties of the demo table
    "types are identical to those of the released table type string_table
    DATA(applies) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_name( 'ZDEMO_ABAP_TT_STR' ) )->applies_to_data( VALUE string_table( ) ).
    ASSERT applies = 'X'.

    "Using RTTI to retrieve table keys
    "The example table type zdemo_abap_tt_so is specified with a primary table with components
    "and secondary table key
    DATA(tdo_table_type) = CAST cl_abap_tabledescr( cl_abap_typedescr=>describe_by_name( 'ZDEMO_ABAP_TT_SO' ) ).
    DATA(table_keys) = tdo_table_type->get_keys( ).
    out->write( data = table_keys name = `table_keys` ).

    "The example also specifies an alias name
    DATA(table_key_aliases) = tdo_table_type->get_key_aliases( ).
    out->write( data = table_key_aliases name = `table_key_aliases` ).

    "-------------------------------------------------------
    "-------------- Predefined types in DDIC ---------------
    "-------------------------------------------------------

    "Multiple predefined domains and data elements are available in the system
    "The following example demonstrates data elements for built-in dictionary types.
    "In these cases, the data elements have the same names as the built-in dictionary
    "types.
    DATA a TYPE int1.
    DATA b TYPE int2.
    DATA c TYPE int4.
    DATA d TYPE d16n.
    DATA e TYPE d34n.
    DATA f TYPE datn.
    DATA g TYPE timn.
    DATA h TYPE utcl.

    "Respective built-in DDIC types cannot be specified directly
    "in ABAP programs. So, the following data object declaration
    "using a built-in DDIC type is not possible.
    "DATA i type rawstring.

    "Note: The following type definition emphasizes that local
    "types hide global type names.
    TYPES rawstring TYPE xstring.
    DATA j TYPE rawstring.

    "Programmatically retrieving information about which released APIs are available
    "The following statement retrieves released data elements and domains.
    SELECT ReleasedObjectType, ReleasedObjectName, ReleaseState
      FROM i_apisforclouddevelopment
      WHERE releasestate = 'RELEASED'
      AND ( ReleasedObjectType = 'DTEL' OR ReleasedObjectType = 'DOMA' )
      ORDER BY ReleasedObjectType, ReleasedObjectName
      INTO TABLE @DATA(released_dtel_doma).

    "Truth values
    "Using the data element abap_boolean as type in the data object declaration.
    DATA is_true TYPE abap_boolean.

    DATA(some_string) = `Hello#ABAP##World#`.
    IF some_string CS `#`.
      "Using abap_true/abap_false from the released abap type pool as constant values
      is_true = abap_true.
    ELSE.
      is_true = abap_false.
    ENDIF.

    out->write( data = is_true name = `is_true` ).

    "Many predefined data types are used in operand positions of ABAP statements

    "The RESULTS addition to the FIND statement can expect
    "the table type match_result_tab that contains search results.
    DATA findings TYPE match_result_tab.
    FIND ALL OCCURRENCES OF `#` IN some_string RESULTS findings.
    ASSERT lines( findings ) = 4.
    out->write( data = findings name = `findings` ).

    "Dynamic method call and specifying a parameter table of
    "type abap_parmbind_tab.
    DATA(oref) = NEW zcl_demo_abap_objects( ).
    "Creating parameter table
    DATA(ptab) = VALUE abap_parmbind_tab( ( name  = 'I_OP'
                                            kind  = cl_abap_objectdescr=>exporting
                                            value = NEW i( 3 ) )
                                          ( name  = 'R_TRIPLE'
                                            kind  = cl_abap_objectdescr=>returning
                                            value = NEW i( ) ) ).

    "The example method triplse the value specified for i_op.
    CALL METHOD oref->('TRIPLE') PARAMETER-TABLE ptab.
    ASSERT ptab[ name = 'R_TRIPLE' ]-value->* = 9.
    out->write( data = ptab name = `ptab` ).

    "-------------------------------------------------------
    "------------------ DDIC database tables ---------------
    "-------------------------------------------------------

    "Clearing demo database tables
    DELETE FROM zdemo_abap_tabl1.
    DELETE FROM zdemo_abap_tabl2.

    "DDIC database tables represent structued types.
    DATA struc_from_dbtab TYPE zdemo_abap_tabl1.

    struc_from_dbtab = VALUE #( num  = 1
                                chars = 'abcde'
                                id     = '12345'
                                flag  = 'X'
                                str = `ABAP`
                                cuky = 'EUR'
                                curr = '1.2'  ).

    MODIFY zdemo_abap_tabl1 FROM @struc_from_dbtab.

    DATA itab_from_dbtab TYPE TABLE OF zdemo_abap_tabl1 WITH EMPTY KEY.
    SELECT * FROM zdemo_abap_tabl1 INTO TABLE @itab_from_dbtab.
    out->write( data = itab_from_dbtab name = `itab_from_dbtab` ).

    "The following example DDIC database table specifies an included
    "DDIC structure

    DATA itab_from_dbtab2 TYPE TABLE OF zdemo_abap_tabl2 WITH EMPTY KEY.
    itab_from_dbtab2 = VALUE #( ( key_field = 1
                                  chars = 'abcde'
                                  num  = 2
                                  cuky = 'EUR'
                                  curr = '1.2'
                                  id   = '12345'
                                  flag = 'X' )
                                ( key_field = 3
                                  chars = 'fghij'
                                  num  = 4
                                  cuky = 'USD'
                                  curr = '3.4'
                                  id   = '67890'
                                  flag = 'A' )
                                ( key_field = 5
                                  flag = 'Y' ) ).

    MODIFY zdemo_abap_tabl2 FROM TABLE @itab_from_dbtab2.

    CLEAR itab_from_dbtab2.
    SELECT * FROM zdemo_abap_tabl2 INTO TABLE @itab_from_dbtab2.
    out->write( data = itab_from_dbtab2 name = `itab_from_dbtab2` ).

    "----------------------------------------------------
    "------------------ CDS simple types ----------------
    "----------------------------------------------------

    "Using CDS simple types in ABAP, for example, to declarie local
    "types and data objects
    "Elementary types/data objects
    TYPES ty_cds_simple TYPE zdemo_abap_cds_type.
    DATA dobj_w_simple_type TYPE zdemo_abap_cds_type.
    "Typing a structure component with a CDS simple type
    DATA: BEGIN OF struc_w_st,
            comp1 TYPE string,
            comp2 TYPE i,
            comp3 TYPE zdemo_abap_cds_type,
          END OF struc_w_st.
    "Internal table with elementary line type represented by the
    "CDS simple type
    DATA itab_w_st TYPE TABLE OF zdemo_abap_cds_type WITH EMPTY KEY.

    "Retrieving type information using RTTI
    DATA(tdo_cds_simple_type) = CAST cl_abap_elemdescr( cl_abap_typedescr=>describe_by_name( `ZDEMO_ABAP_CDS_TYPE` ) ).
    DATA(type_category_cds_st) = tdo_cds_simple_type->kind.
    DATA(type_kind_cds_st) = tdo_cds_simple_type->type_kind.
    DATA(is_ddic_type_cds_st) = tdo_cds_simple_type->is_ddic_type( ).
    "If you use abap.char(5) as type in the CDS simple type, the following data object contains X.
    TYPES c5 TYPE c LENGTH 5.
    DATA(applies_to_data_cds_st) = tdo_cds_simple_type->applies_to_data( CONV c5( 'abcde' ) ).

    out->write( data = type_category_cds_st name = `type_category_cds_st` ).
    out->write( data = type_kind_cds_st name = `type_kind_cds_st` ).
    out->write( data = is_ddic_type_cds_st name = `is_ddic_type_cds_st` ).
    out->write( data = applies_to_data_cds_st name = `applies_to_data_cds_st` ).

    "----------------------------------------------------
    "------------------ CDS enumerated types ------------
    "----------------------------------------------------

    "Using CDS enumerated types in ABAP, for example, to declare
    "local types and data objects
    "The example CDS enumerated type's base type is specified with abap.char(1).
    TYPES ty_cds_enum TYPE zdemo_abap_cds_enum.
    DATA dobj_w_enum_type TYPE zdemo_abap_cds_enum.

    "The technical data type of an enumerated value is the base type
    "of the enumerated type. You can use the base type of an enumerated
    "type in special conversions using the constructor operator CONV.
    DATA dobj_c1 TYPE c LENGTH 1 VALUE 'Y'.

    DATA(conv_enum_1) = CONV zdemo_abap_cds_enum( dobj_c1 ).
    ASSERT conv_enum_1 = zdemo_abap_cds_enum-enum_constant_3.
    out->write( data = conv_enum_1 name = `conv_enum_1` ).

    "Using a value that is not available in the CDS enumerated type
    dobj_c1 = 'A'.
    TRY.
        DATA(conv_enum_2) = CONV zdemo_abap_cds_enum( dobj_c1 ).
      CATCH cx_sy_conversion_no_enum_value INTO DATA(enum_error).
        out->write( data = enum_error->get_text( ) name = `enum_error->get_text( )` ).
    ENDTRY.

    "Retrieving type information using RTTI
    DATA(tdo_cds_enum) = CAST cl_abap_enumdescr( cl_abap_typedescr=>describe_by_name( `ZDEMO_ABAP_CDS_ENUM` ) ).
    DATA(type_category_cds_enum) = tdo_cds_enum->kind.
    DATA(type_kind_cds_enum) = tdo_cds_enum->type_kind.
    DATA(is_ddic_type_cds_enum) = tdo_cds_enum->is_ddic_type( ).
    DATA(base_kind_cds_enum) = tdo_cds_enum->base_type_kind.
    DATA(members_cds_enum) = tdo_cds_enum->members.

    "Although abap.char(1) is used as base type in the example CDS enumerated type,
    "the following data object is not type compliant.
    DATA(applies_to_data_cds_enum1) = tdo_cds_enum->applies_to_data( abap_true ).
    ASSERT applies_to_data_cds_enum1 IS INITIAL.
    DATA(applies_to_data_cds_enum2) = tdo_cds_enum->applies_to_data( CONV zdemo_abap_cds_enum( 'X' ) ).

    out->write( data = type_category_cds_enum name = `type_category_cds_enum` ).
    out->write( data = type_kind_cds_enum name = `type_kind_cds_enum` ).
    out->write( data = is_ddic_type_cds_enum name = `is_ddic_type_cds_enum` ).
    out->write( data = base_kind_cds_enum name = `base_kind_cds_enum` ).
    out->write( data = members_cds_enum name = `members_cds_enum` ).
    out->write( data = applies_to_data_cds_enum1 name = `applies_to_data_cds_enum1` ).
    out->write( data = applies_to_data_cds_enum2 name = `applies_to_data_cds_enum2` ).

    "Some demo assertions regarding the example CDS enumerated type, which is usable as
    "enumerated structure in ABAP.
    FIELD-SYMBOLS <fs_enum> TYPE data.
    LOOP AT CAST cl_abap_enumdescr( cl_abap_typedescr=>describe_by_name( `ZDEMO_ABAP_CDS_ENUM` ) )->members INTO DATA(enum_comps).
      "Dynamically assigning the enumerated constant to a field symbol
      ASSIGN zdemo_abap_cds_enum-(enum_comps-name) TO <fs_enum>.
      CASE enum_comps-name.
        WHEN 'ENUM_CONSTANT_1'.
          ASSERT <fs_enum> = zdemo_abap_cds_enum-enum_constant_1.
          ASSERT <fs_enum> = CONV zdemo_abap_cds_enum( '' ).
          ASSERT enum_comps-value = ''.
        WHEN 'ENUM_CONSTANT_2'.
          ASSERT <fs_enum> = zdemo_abap_cds_enum-enum_constant_2.
          ASSERT <fs_enum> = CONV zdemo_abap_cds_enum( 'X' ).
          ASSERT enum_comps-value = 'X'.
        WHEN 'ENUM_CONSTANT_3'.
          ASSERT <fs_enum> = zdemo_abap_cds_enum-enum_constant_3.
          ASSERT <fs_enum> = CONV zdemo_abap_cds_enum( 'Y' ).
          ASSERT enum_comps-value = 'Y'.
        WHEN 'ENUM_CONSTANT_4'.
          ASSERT <fs_enum> = zdemo_abap_cds_enum-enum_constant_4.
          ASSERT <fs_enum> = CONV zdemo_abap_cds_enum( 'Z' ).
          ASSERT enum_comps-value = 'Z'.
      ENDCASE.
    ENDLOOP.

    "----------------------------------------------------
    "----- CDS entities usable as structured types ------
    "----------------------------------------------------

    "Several CDS entities represent structured types that can be
    "used in ABAP. The example shows the creation of local data
    "types and objects based on CDS entities. Demo artifacts from
    "the ABAP cheat sheet repository are used.

    "CDS view entity
    TYPES ty_struc_cds_ve TYPE zdemo_abap_fli_ve.
    DATA dobj_struc_cds_ve TYPE zdemo_abap_fli_ve.
    "CDS abstract entity
    TYPES ty_struc_cds_abstr TYPE zdemo_abap_abstract_ent.
    DATA dobj_struc_cds_abstr TYPE zdemo_abap_abstract_ent.
    "CDS table function
    TYPES ty_struc_cds_tabfunc TYPE zdemo_abap_table_function.
    DATA dobj_struc_cds_tabfunc TYPE zdemo_abap_table_function.

    "Using CDS view entities and CDS table functions as data souces
    "in ABAP SQL statements
    DATA itab_cds_ve TYPE TABLE OF zdemo_abap_fli_ve WITH EMPTY KEY.
    DATA itab_cds_tabfunc TYPE TABLE OF zdemo_abap_table_function WITH EMPTY KEY.

    SELECT * FROM zdemo_abap_fli_ve INTO TABLE @itab_cds_ve.
    SELECT * FROM zdemo_abap_table_function INTO TABLE @itab_cds_tabfunc.

    out->write( data = itab_cds_ve name = `itab_cds_ve` ).
    out->write( data = itab_cds_tabfunc name = `itab_cds_tabfunc` ).

  ENDMETHOD.
ENDCLASS.