ABAP Keyword Documentation → ABAP - Reference → Declarative statemnts → Data Types and Data Objects → Declaring Data Types → TYPES → TYPES - LOB HANDLE
Deriving LOB Handle Structures
The example demonstrates the derivation of
LOB handle structures using the TYPES
statement.
Other versions: 7.31 | 7.40 | 7.54
Source Code
REPORT demo_types_lob_handle.
CLASS demo_lob_handles DEFINITION.
PUBLIC SECTION.
CLASS-METHODS main.
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.
PRIVATE SECTION.
CLASS-METHODS type_output IMPORTING struct TYPE string.
ENDCLASS.
CLASS demo_lob_handles IMPLEMENTATION.
METHOD main.
type_output( 'LOB_HANDLE_STRUCTURE_1' ).
type_output( 'LOB_HANDLE_STRUCTURE_2' ).
type_output( 'LOB_HANDLE_STRUCTURE_3' ).
type_output( 'LOB_HANDLE_STRUCTURE_4' ).
type_output( 'LOB_HANDLE_STRUCTURE_5' ).
type_output( 'LOB_HANDLE_STRUCTURE_6' ).
ENDMETHOD.
METHOD type_output.
DATA structdescr TYPE REF TO cl_abap_structdescr.
DATA components TYPE abap_compdescr_tab.
DATA component LIKE LINE OF components.
DATA typedescr TYPE REF TO cl_abap_typedescr.
DATA refdescr TYPE REF TO cl_abap_refdescr.
DATA name TYPE string.
structdescr ?= cl_abap_structdescr=>describe_by_name( struct ).
components = structdescr->components.
WRITE (47) struct COLOR 1 INTENSIFIED OFF.
LOOP AT components INTO component.
TRY.
name = struct && '-' && component-name.
refdescr ?= cl_abap_typedescr=>describe_by_name( name ).
typedescr = refdescr->get_referenced_type( ).
WRITE: /(6) component-name
COLOR 1 INTENSIFIED OFF,
(40) typedescr->absolute_name
COLOR 2 INTENSIFIED OFF.
CATCH cx_sy_move_cast_error.
ENDTRY.
ENDLOOP.
SKIP.
ENDMETHOD.
ENDCLASS.
START-OF-SELECTION.
demo_lob_handles=>main( ).
Description
The package-visible area of the demo_lob_handles
class contains various derivations
of LOB handle structures from the DEMO_LOB_TABLE database table. The methods of the 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
andblob1
become LOB handle components using direct column specification afterREADER
. The componentclob1
contains the static type CL_ABAP_DB_C_READER andblob1
contains the static type CL_ABAP_DB_X_READER. All other components are displayed according to the normal rules for their predefined types.
- In the structured type
lob_handle_structure_2
, all components are turned intoLOB
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 converted into CL_ABAP_DB_C_WRITER by specifyingWRITER FOR ALL CLOB COLUMNS
and the static type for the components of type RAWSTRING is converted into CL_ABAP_DB_X_LOCATOR by specifyingLOCATOR 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 componentsclob1
andclob2
is converted into CL_ABAP_DB_C_READER by directly specifying READER. All components of the type RAWSTRING are converted into reference types for IF_ABAP_DB_BLOB_HANDLE by specifyingLOB HANDLE FOR ALL BLOB COLUMNS
. The other components of the type STRING are converted into reference types for CL_ABAP_DB_C_LOCATOR by specifyingLOCATOR 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 forclob1
,clob2
, and clob3 and CL_ABAP_DB_X_READER forblob1
,blob2
, andblob3
. TheLOB HANDLE FOR ALL OTHER COLUMNS
specification has no direct effect, but instead works on possible enhancements to the database table of further LOBs, which then maintain their appropriate 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. The specification ofFOR ALL CLOB COLUMNS
is only possible since no components of type STRING were recorded by the previous specifications.