Skip to content

ABAP Keyword Documentation →  ABAP − Reference →  Obsolete Language Elements →  Obsolete Processing of External Data →  Logical Databases (Obsolete) →  Logical Databases - Examples 

Example of a Logical Database

This example demonstrates all significant components of the imaginary logical database TEST_LDB.

Other versions: 7.31 | 7.40 | 7.54

Structure

LFA1
  |
  |----LFB1
         |
         |----LFC1
         |
         |----BKPF

Selections in the Selection Include

SELECT-OPTIONS: slifnr   FOR lfa1-lifnr,
                sbukrs   FOR lfb1-bukrs,
                sgjahr   FOR lfc1-gjahr,
                sbelnr   FOR bkpf-belnr.

Database Program

-------------------------------------------------------
* DATABASE PROGRAM OF LOGICAL DATABASE TEST_LDB
-------------------------------------------------------
PROGRAM sapdbtest_ldb DEFINING DATABASE test_ldb.
NODES: lfa1,
       lfb1,
       lfc1,
       bkpf.
-------------------------------------------------------
* Initialize selection screen (processed before PBO)
-------------------------------------------------------
FORM init.
....
ENDFORM.
-------------------------------------------------------
* PBO of selection screen
-------------------------------------------------------
FORM pbo.
....
ENDFORM.
-------------------------------------------------------
* PAI of selection screen
-------------------------------------------------------
FORM pai USING fname mark.
  CASE fname.
    WHEN 'SLIFNR'.
     ....
    WHEN 'SBUKRS'.
     ....
    WHEN 'SGJAHR'.
     ....
    WHEN 'SBELNR'.
     ....
  ENDCASE.
ENDFORM.
-------------------------------------------------------
* Raise event GET lfa1
-------------------------------------------------------
FORM put_lfa1.
  SELECT * FROM lfa1
           WHERE lifnr IN @slifnr INTO @lfa1.
    PUT lfa1.
  ENDSELECT.
ENDFORM.
-------------------------------------------------------
* Raise event GET lfb1
-------------------------------------------------------
FORM put_lfb1.
  SELECT * FROM lfb1
           WHERE lifnr = @lfa1-lifnr
             AND bukrs IN @sbulrs
           INTO @lfb1.
    PUT lfb1.
  ENDSELECT.
ENDFORM.
-------------------------------------------------------
* Raise event GET lfc1
-------------------------------------------------------
FORM put_lfc1.
  SELECT * FROM lfc1
           WHERE lifnr = @lfa1-lifnr
             AND bukrs      =  @lfb1-bukrs
             AND gjahr      IN @sgjahr
           INTO lfc1.
    PUT lfc1.
  ENDSELECT.
ENDFORM.
-------------------------------------------------------
* Raise event GET bkpf
-------------------------------------------------------
FORM put_bkpf.
  SELECT * FROM bkpf
           WHERE bukrs      =  @lfb1-bukrs
             AND belnr      IN @sbelnr
             AND gjahr      IN @sgjahr
           INTO @bkpf.
    PUT bkpf.
  ENDSELECT.
ENDFORM.

The PROGRAM statement has the addition DEFINING DATABASE test_ldb. This defines the association of the database program with the logical database TEST_LDB.

The nodes of the structure are declared using the NODES statement. This creates the required interface work areas as table work areas. The statement TABLES can be used, as a node, in the same way for database tables If the nodes do not have any database tables, they need to be declared using NODES. The interface work areas are shared by the database program and an associated executable program or the function module LDB_PROCESS and become the interface used for passing data.

The selection screen can be initialized in the subroutines init and pbo.

The user input on the selection screen can be, for example, checked for authorizations in the subroutine pai. Other checks, such as plausibility or value range checks, are also possible here. If a check is negative, an error dialog can be programmed and the field in question can be initialized again.

The database tables are read in accordance with the user's selection criteria and the associated GET events are triggered in the subroutines put_....

This program is only designed to demonstrates the principles of the structure of a logical database. It does not contain any methods for optimizing response times. The chronology of the subroutine calls is determined by the structure of the logical database.