Entering content frameExample of a Logical Database Locate the document in its SAP Library structure

Let us consider the logical database TEST_LDB.

Structure

This graphic is explained in the accompanying text

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 THE LOGICAL DATABASE TEST_LDB
*-------------------------------------------------------*
PROGRAM SAPDBTEST_LDB DEFINING DATABASE TEST_LDB.
TABLES: LFA1,
        LFB1,
        LFC1,
        BKPF.

*-------------------------------------------------------*
* Initialize selection screen (process before PBO)
*-------------------------------------------------------*
FORM INIT.
 ....
ENDFORM.                                "INIT

*-------------------------------------------------------*
* PBO of selection screen (always before selection
* screen
*-------------------------------------------------------*
FORM PBO.
 ....
ENDFORM.                                "PBO

*-------------------------------------------------------*
* PAI of selection screen (process always after ENTER)
*-------------------------------------------------------*
FORM PAI USING FNAME MARK.
  CASE FNAME.
    WHEN 'SLIFNR'.
     ....
    WHEN 'SBUKRS'.
     ....
    WHEN 'SGJAHR'.
     ....
    WHEN 'SBELNR'.
     ....
  ENDCASE.
ENDFORM.                                "PAI

*-------------------------------------------------------*
* Call event GET LFA1
*-------------------------------------------------------*
FORM PUT_LFA1.
  SELECT * FROM LFA1
WHERE LIFNR IN SLIFNR.
    PUT LFA1.
  ENDSELECT.
ENDFORM.                                "PUT_LFA1

*-------------------------------------------------------*
* Call event GET LFB1
*-------------------------------------------------------*
FORM PUT_LFB1.
  SELECT * FROM LFB1
WHERE LIFNR = LFA1-LIFNR
AND BUKRS IN SBULRS.
    PUT LFB1.
  ENDSELECT.
ENDFORM.                                "PUT_LFB1

*-------------------------------------------------------*
* Call event GET LFC1
*-------------------------------------------------------*
FORM PUT_LFC1.
  SELECT * FROM LFC1
WHERE LIFNR = LFA1-LIFNR
AND BUKRS = LFB1-BUKRS
AND GJAHR IN SGJAHR.
    PUT LFC1.
  ENDSELECT.
ENDFORM.                                "PUT_LFC1

*-------------------------------------------------------*
* Call event GET BKPF
*-------------------------------------------------------*
FORM PUT_BKPF.
  SELECT * FROM BKPF
WHERE BUKRS = LFB1-BUKRS
AND BELNR IN SBELNR
AND GJAHR IN SGJAHR.
    PUT BKPF.
ENDSELECT.
ENDFORM.                                "PUT_BKPF  

The PROGRAM statement has the addition DEFINING DATABASE TEST_LDB. This defines the database program as belonging to the logical database TEST_LDB.

The nodes of the structure are declared with the TABLES statement which generates the appropriate table work areas. You can also use the NODES statement to define database tables as nodes. If a node of a logical database is not a database table, you must use the NODES statement. The interface work areas are shared by the database program and the user, and so act as an interface for passing data. The term "user" here can mean either an executable program to which the logical database is linked, or the function module LDB_PROCESS.

The subroutines INIT and PBO initialize the selection screen.

In the PAI subroutine, you can include an authorization check for the user input on the selection screen. Plausibility or value range checks are also possible. If a check fails, you can write an error dialog. The corresponding field on the selection screen is then made ready for input again.

The PUT_<node> subroutines read the database tables according to the selection criteria entered by the user and trigger the relevant events in the executable program. This program is intended only to show the essential structure of a logical database. It does not contain any refinements to improve response times. The order in which the subroutines are called is determined by the structure of the logical database.

This graphic is explained in the accompanying text

 

 

 

 

 

 

 

Leaving content frame