Skip to content

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 wa TYPE demo_blob_table LOCATOR FOR ALL COLUMNS.

    SELECT SINGLE picture
           FROM demo_blob_table
           INTO wa-picture
           WHERE name = source.

    IF sy-subrc <> 0.
      MESSAGE 'Nothing found, run DEMO_DB_WRITER first!'
              TYPE 'S' DISPLAY LIKE 'E'.
      RETURN.
    ENDIF.

    wa-name = target.
    INSERT demo_blob_table FROM wa.

    IF sy-subrc = 0.
      MESSAGE 'You can run DEMO_DB_READER with new name now' TYPE 'S'.
    ELSE.
      MESSAGE 'Target already exists' TYPE 'S' DISPLAY LIKE 'E'.
    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.