Você está na página 1de 5

6/21/2014 Example of a Logical Database - BC - ABAP Programming - SAP Library

http://help.sap.com/saphelp_46c/helpdata/en/9f/db9be035c111d1829f0000e829fbfe/content.htm 1/5
Example of a Logical Database
Let us consider the logical database TEST_LDB.
Structure
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.
The Best-Run Businesses Run SAP
SAP Business Suite SAP ERP SAP R/3 and SAP R/3 Enterprise
6/21/2014 Example of a Logical Database - BC - ABAP Programming - SAP Library
http://help.sap.com/saphelp_46c/helpdata/en/9f/db9be035c111d1829f0000e829fbfe/content.htm 2/5
*-------------------------------------------------------*
* 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.
6/21/2014 Example of a Logical Database - BC - ABAP Programming - SAP Library
http://help.sap.com/saphelp_46c/helpdata/en/9f/db9be035c111d1829f0000e829fbfe/content.htm 3/5
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.
6/21/2014 Example of a Logical Database - BC - ABAP Programming - SAP Library
http://help.sap.com/saphelp_46c/helpdata/en/9f/db9be035c111d1829f0000e829fbfe/content.htm 4/5







6/21/2014 Example of a Logical Database - BC - ABAP Programming - SAP Library
http://help.sap.com/saphelp_46c/helpdata/en/9f/db9be035c111d1829f0000e829fbfe/content.htm 5/5
COPYRI GHT BY SAP AG OR AN SAP AFFI LI ATE COMPANY. ALL RI GHTS RESERVED.
PRI NTED FROM SAP HELP PORTAL. (ht t p: / / hel p. sap. com)

Você também pode gostar