SAP NetWeaver AS ABAP Release 740, ©Copyright 2014 SAP AG. All rights reserved.
ABAP Keyword Documentation → ABAP − Reference → Declarations → Declaration Statements → 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.
Source Code
REPORT demo_types_lob_handle.
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( ).
output_type( 'LOB_HANDLE_STRUCTURE_1' ).
output_type( 'LOB_HANDLE_STRUCTURE_2' ).
output_type( 'LOB_HANDLE_STRUCTURE_3' ).
output_type( 'LOB_HANDLE_STRUCTURE_4' ).
output_type( 'LOB_HANDLE_STRUCTURE_5' ).
output_type( 'LOB_HANDLE_STRUCTURE_6' ).
out->display( ).
ENDMETHOD.
METHOD output_type.
DATA components TYPE abap_compdescr_tab.
DATA component LIKE LINE OF components.
DATA typedescr TYPE REF TO cl_abap_typedescr.
DATA name TYPE string.
DATA: BEGIN OF result,
component_name TYPE string,
absolute_name TYPE string,
END OF result,
results LIKE TABLE OF result.
components =
CAST cl_abap_structdescr(
cl_abap_structdescr=>describe_by_name( struct )
)->components.
out->begin_section( struct ).
LOOP AT components INTO component.
TRY.
name = struct && '-' && component-name.
typedescr =
CAST cl_abap_refdescr(
cl_abap_typedescr=>describe_by_name( name )
)->get_referenced_type( ).
result-component_name = component-name.
result-absolute_name = typedescr->absolute_name.
APPEND result TO results.
CATCH cx_sy_move_cast_error.
ENDTRY.
ENDLOOP.
out->write_data( results ).
out->end_section( ).
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: