Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Declarations →  Declaration Statements →  Data Types and Data Objects →  Declaring Data Types →  TYPES →  TYPES - LOB HANDLE 

Deriving LOB Handle Structures

This example demonstrates how LOB handle structures are derived using the statement TYPES.

Other versions: 7.31 | 7.40 | 7.54

Source Code

REPORT kellerh_test.

CLASS demo_lob_handles DEFINITION.
  PUBLIC SECTION.
    TYPES:

      lob_handle_structure_1 TYPE demo_lob_table
                             READER FOR COLUMNS clob1 blob1,


      lob_handle_structure_2 TYPE demo_lob_table
                             LOB HANDLE FOR ALL COLUMNS,

      lob_handle_structure_3 TYPE demo_lob_table
                             LOCATOR FOR ALL BLOB COLUMNS
                             WRITER FOR ALL CLOB COLUMNS,

      lob_handle_structure_4 TYPE demo_lob_table
                             READER FOR COLUMNS clob1 clob2
                             LOB HANDLE FOR ALL BLOB COLUMNS
                             LOCATOR FOR ALL OTHER CLOB COLUMNS,

      lob_handle_structure_5 TYPE demo_lob_table
                             READER FOR COLUMNS blob1 blob2 blob3
                             LOCATOR FOR COLUMNS clob1 clob2 clob3
                             LOB HANDLE FOR ALL OTHER COLUMNS,

      lob_handle_structure_6 TYPE demo_lob_table
                             READER FOR COLUMNS blob1
                             LOCATOR FOR COLUMNS blob2
                             LOB HANDLE FOR COLUMNS blob3
                             LOB HANDLE FOR ALL CLOB COLUMNS.

    CLASS-METHODS main.

  PRIVATE SECTION.
    CLASS-DATA out TYPE REF TO if_demo_output.
    CLASS-METHODS output_type IMPORTING struct TYPE string.
ENDCLASS.

CLASS demo_lob_handles IMPLEMENTATION.
  METHOD main.
    out = cl_demo_output=>new( ).
    DO 6 TIMES.
      output_type( |LOB_HANDLE_STRUCTURE_{ sy-index }| ).
    ENDDO.
    out->display( ).
  ENDMETHOD.
  METHOD output_type.
    TYPES: BEGIN OF result,
             component_name TYPE string,
             absolute_name  TYPE string,
           END OF result,
           results TYPE TABLE OF result WITH EMPTY KEY.

    out->next_section( struct
      )->write_data(
           VALUE results(
             FOR component IN CAST cl_abap_structdescr(
               cl_abap_structdescr=>describe_by_name( struct )
                 )->components
             WHERE ( type_kind = cl_abap_typedescr=>typekind_oref )
             ( VALUE #(
                 component_name = component-name
                 absolute_name  = CAST cl_abap_refdescr(
                   cl_abap_typedescr=>describe_by_name(
                     struct && `-` && component-name )
                       )->get_referenced_type(
                       )->absolute_name ) ) ) ).
  ENDMETHOD.
ENDCLASS.

START-OF-SELECTION.
  demo_lob_handles=>main( ).

Description

The package-visible area of the class demo_lob_handles contains various derivations of LOB handle structures from the database table DEMO_LOB_TABLE. The methods of this class are used for the output of the static type of the derived LOB handle components.

The DEMO_LOB_TABLE database table contains a key field of type INT4, as well as three columns CLOB1, CLOB2, CLOB3 of type STRING and three columns BLOB1, BLOB2, BLOB3 of type RAWSTRING.

The derivations listed here function as follows:

  • In the structured type lob_handle_structure_1, clob1 and blob1 become LOB handle components using columns specified directly after READER. The component clob1 contains the static type CL_ABAP_DB_C_READER and blob1 contains the static type CL_ABAP_DB_X_READER. All other components are displayed in accordance with the regular rules for their built-in types.
  • In the structured type lob_handle_structure_2, all components are turned into LOB components by specifying FOR ALL COLUMNS for LOB handle components. The static type of the components of type STRING is IF_ABAP_DB_CLOB_HANDLE and the static type for the components of type RAWSTRING is IF_ABAP_DB_BLOB_HANDLE.
  • In the structured type lob_handle_structure_3, all components are converted into LOB components for LOB handle components. The static type of the component of type STRING is changed to CL_ABAP_DB_C_WRITER by specifying WRITER FOR ALL CLOB COLUMNS and the static type for the components of type RAWSTRING is changed to CL_ABAP_DB_X_LOCATOR by specifying LOCATOR FOR ALL BLOB COLUMNS.
  • In the structured type lob_handle_structure_4, all components are converted into LOB components for LOB handle components. The static type of the components clob1 and clob2 is changed to CL_ABAP_DB_C_READER by specifying READER directly. All components of the type RAWSTRING are changed to reference types for IF_ABAP_DB_BLOB_HANDLE by specifying LOB HANDLE FOR ALL BLOB COLUMNS. The other components of the type STRING are changed to reference types for CL_ABAP_DB_C_LOCATOR by specifying LOCATOR FOR ALL OTHER CLOB COLUMNS.
  • In the structured type lob_handle_structure_5, all LOB components are listed directly and thereby converted into the corresponding LOB handle components with the static types CL_ABAP_DB_C_LOCATOR for clob1, clob2, and clob3 and CL_ABAP_DB_X_READER for blob1, blob2, and blob3. Specifying LOB HANDLE FOR ALL OTHER COLUMNS has no direct effect, but instead is applied to any enhancements to the database table of further LOBs, which then preserve their type-friendly interface reference type.
  • In the structured type lob_handle_structure_6, all components are converted into LOB components for LOB handle components, whereby here the maximum number of column specifications is demonstrated. FOR ALL CLOB COLUMNS can only be specified since no components of type STRING were covered by previous statements.