Get Example source ABAP code based on a different SAP table
Deriving LOB Handle Structures This example demonstrates how LOB handle structures> are derived using the statement TYPES>>.
ABAP_SOURCE_CODE DEMO CL_DEMO_TYPES_LOB_HANDLE
ABAP_DESCRIPTION The package-visible area of the class demo_lob_handles> contains different derivations of LOB handle structures from the database table DEMO_LOB_TABLE>>. The methods of this class are used to 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 work as follows:
In the structured type lob_handle_structure_1>, clob1> and blob1> become LOB handle components by column specifications 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 represented in accordance with the regular rules> for their built-in types.
In the structured type lob_handle_structure_2>, all LOB components are converted into LOB handle components by specifying FOR ALL COLUMNS>. 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 LOB components are converted into LOB handle components. The static type of the components of type STRING> is converted into CL_ABAP_DB_C_WRITER> by specifying WRITER FOR ALL CLOB COLUMNS > and the static type for the components of type RAWSTRING> is converted into CL_ABAP_DB_X_LOCATOR> by specifying LOCATOR FOR ALL BLOB COLUMNS>.
In the structured type lob_handle_structure_4>, all LOB components are converted into LOB handle components. The static type of the components clob1> and clob2> is converted into CL_ABAP_DB_C_READER> by specifying READER> directly. All components of the type RAWSTRING> are converted into reference types for IF_ABAP_DB_BLOB_HANDLE> by specifying LOB HANDLE FOR ALL BLOB COLUMNS>. The remaining components of the type STRING> are converted into 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 thus 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>. The specification LOB HANDLE FOR ALL OTHER COLUMNS> has no direct effect, but only affects any enhancements to the database table with further LOBs, which then preserve their type-compliant interface reference type.
In the structured type lob_handle_structure_6>, all LOB components are converted into handle LOB 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.