ABAP Keyword Documentation → ABAP - Reference → Processing External Data → ABAP Database Accesses → Open SQL → Open SQL - Streaming and Locators → Open SQL - Examples forLOB Handles
Locator, Copy Column
The example demonstrates how column content can be copied using locators.
Other versions: 7.31 | 7.40 | 7.54
Source Code
DATA:
source TYPE c LENGTH 255
VALUE '/SAP/PUBLIC/BC/ABAP/mime_demo/ABAP_Docu_Logo.gif',
target TYPE c LENGTH 255
VALUE 'picture_copy'.
DATA wa TYPE demo_blob_table LOCATOR FOR ALL COLUMNS.
cl_demo_input=>add_field( CHANGING field = source ).
cl_demo_input=>request( CHANGING field = target ).
SELECT SINGLE picture
FROM demo_blob_table
WHERE name = @source
INTO @wa-picture.
IF sy-subrc <> 0.
cl_demo_output=>display(
'Nothing found, run DEMO_DB_WRITER first!' ).
RETURN.
ENDIF.
wa-name = target.
INSERT demo_blob_table FROM @wa.
IF sy-subrc = 0.
cl_demo_output=>display(
'You can run DEMO_DB_READER with new name now' ).
ELSE.
cl_demo_output=>display(
'Target already exists' ).
ENDIF.
wa-picture->close( ).
Description
In the main
method, an
LOB handle structure is derived from the structure of the DEMO_BLOB_TABLE database table
, whereby the PICTURE component is declared as an
LOB handle component for a locator. This locator is then created in a SELECT
statement
.
A new value is then assigned to the key field of the LOB handle structure and the LOB handle structure
is used as a work area in an INSERT
statement. In this way, the content of the column to which the locator is connected is copied to the corresponding column of the new row
without the content having to be transported to the ABAP program.
If you are accessing data which was previously written in the example for write streams, this is the data of a figure in the GIF format. By specifying the new name, the copied figure can be displayed using the example for read streams.