Ansicht
Dokumentation

ABENLDB_EXAMPLE - LDB EXAMPLE

ABENLDB_EXAMPLE - LDB EXAMPLE

Fill RESBD Structure from EBP Component Structure   General Material Data  
This documentation is copyright by SAP AG.
SAP E-Book

- Example of a Logical Database

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

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 link 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 are not database tables, they must be declared using NODES. The interface work areas are shared by the database program and a linked executable program or the function module LDB_PROCESS and therefore 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 corresponding field can be initialized again.

The database tables are read in accordance with the selection criteria of the user and the associated GET events are raised in the subroutines put_....

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






Fill RESBD Structure from EBP Component Structure   rdisp/max_wprun_time - Maximum work process run time  
This documentation is copyright by SAP AG.

Length: 6843 Date: 20240419 Time: 093418     sap01-206 ( 53 ms )