SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Structure of Logical Databases (LDB)



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> List Generation, LDB, Spool Process, SAP Query, Report Painter
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1640

PostPosted: Sun Nov 04, 2007 2:13 pm    Post subject: Structure of Logical Databases (LDB) Reply with quote

Structure of Logical Databases
The following diagram shows the structure of a logical database, which can be divided into three sections:


Other components such as documentation, language-specific texts, and user-defined selection screens extend the functions further.

Structure
The structure defines the data view of the logical database. It adopts the hierarchy of the database tables defined by their foreign key relationships. This also controls the sequence in which the tables are accessed. It determines the structure of the other components and the behavior of the logical database at runtime.

Selections
The selections define a selection screen, which forms the user interface of the executable programs that use the logical database. Its layout is usually determined by the structure. You can adapt the selections to your own requirements and also add new ones. When you link a logical database to an executable program, the selections of the logical database become part of the standard selection screen of the program (screen number 1000). If you call a logical database using the function module LDB_PROCESS, the selections are filled using interface parameters.

Database Program
The database program contains the ABAP statements used to read the data and pass it to the user of the logical database. There is a container for special subroutines into which, amongst other things, the data from the database tables is read. These subroutines are called by the reporting processor in the runtime environment in a sequence that has been predefined by the structure. The database program is determined by the structure and selections and can be adapted or expanded to meet your requirements.

Structure
The structure of a logical database is usually based on the foreign key relationships between hierarchical tables in the SAP System. Logical databases have a tree-like structure, which can be defined as follows:

· There is a single node at the highest level. This is known as the root node.

· Each node can have one or several branches.

· Each node is derived from one other node.

The nodes must be structures defined in the ABAP Dictionary or data types from a type group. Normally, these are the structures of database tables which the logical database reads and passes to the user for further evaluation. However, it is also possible, and sometimes useful, to use ABAP Dictionary structures without an underlying database. For technical reasons, the maximum number of nodes allowed in the structure of a logical database is 300.

Any executable ABAP program that has a logical database linked to it can contain a GET statement for each node of the structure. When you run the program, the corresponding event blocks are processed in the sequence prescribed by the hierarchical structure of the logical database. If a program does not contain a GET statement for every node of a logical database, the processing passes through all the nodes that lie in the path from the root to the nodes specified by GET statements.

If you call a logical database using the function module LDB_PROCESS, the depth to which the system reads is controlled by an interface parameter.

Suppose LFA1 is the root node, LFBK and LFB1 are branches of LFA1, and LFC1 is a branch of LFB1.


If the executable program contains GET statements for all nodes, the GET events are executed in the order LFA1, LFBK, LFB1, LFC1. If the program only contains a single GET statement for LFB1, the processing only passes through LFA1 and LFB1.

Selections

The selections in a logical database are defined using the normal statements for defining selection screens, that is, PARAMETERS, SELECT-OPTIONS and SELECTION-SCREEN. In a logical database, you can also use the additions VALUE-REQUEST and HELP-REQUEST to define specific input and value help. You define the selection screen in a special include program known as the selection include.

When you write programs using a logical database, you can also add your own program specific selections. The standard selection screen then contains the database-specific selections, followed by the program-specific selections that you have defined.

When the system generates the selection screen for an executable program, database-specific selection criteria and parameters are only displayed if you have declared an interface work area for them in your program using the NODES or TABLES statement.

Suppose you have a selection include containing the following lines:

SELECT-OPTIONS slifnr FOR lfa1-lifnr.
PARAMETERS pbukrs LIKE lfb1-bukrs FOR TABLE lfb1.

The selection criterion SLIFNR is linked to table LFA1, the parameter PBUKRS to table LFB1. If the TABLES statement in an executable program (report) declares LFA1 but not LFB1, SLIFNR is displayed on the selection screen, but PBUKRS does not appear.

The selection screen of a logical database can contain dynamic selections as well as static ones. Dynamic selections are extra, user-defined selections that the user can make as well as using the static selections defined in the selection include. To improve performance, you should always use this option instead of reading more data than you need and then sorting it out in the application program.

To make dynamic selections available for the node nodeof a logical database, the selection include must contain the following statement:

SELECTION-SCREEN DYNAMIC SELECTIONS FOR NODE|TABLE node.

If the node node is requested by the user of the logical databases, the dynamic selections are included in the selection screen. A user can then choose Dynamic selections to enter extra selections for the corresponding fields. If you call the logical database using the function module LDB_PROCESS, you can pass a corresponding parameter. You can use these selections in dynamic statements in the logical database program to read data. The values of the program-specific selection criteria that you defined for a node for which dynamic selections were available are also passed to the logical database. The user can also define the fields for dynamic selections as a selection view for the logical database.

The selection screen of a logical database is part of the standard selection screen (number 1000) of the executable program to which the logical database is attached. It has a standardized layout - the selection criteria and parameters appear on separate lines in the order in which they were declared. You can change the layout using the SELECTION-SCREEN statement.

The runtime environment generates the selection screen with number 1000 for every program in which the attributes do not contain a different selection screen version. You can prevent certain input fields from the selection screen of a logical database from appearing on the selection screen by defining selection screen versions with a screen number lower than 1000 in the selection include, and entering this version number in the program attributes. By pressing F4 there, you can get an overview of the selection screen versions defined in the logical database concerned. To define a selection screen version, use the statements SELECTION-SCREEN BEGIN|END OF VERSION. Within these statements you can use SELECTION-SCREEN EXCLUDEto specify fields that you do not want to appear on the selection screen.

If the attributes of an executable program contain the number of a selection screen version, the version is used in the standard selection screen. Although the input fields that you excluded from the selection screen are not displayed, the corresponding selections still exist, and you can still edit them in the program or by calling the function module LDB_PROCESS.

Database Program

The name of the database program of a logical database ldbconforms to the naming convention SAPDBldb. It serves as a container for subroutines, which the ABAP runtime environment calls when a logical database is processed. The sequence of the calls and their interaction with the events in executable programs or the function module LDB_PROCESS depends on the structure of the logical database.

A logical database program usually contains the following subroutines:

· FORM LDB_PROCESS_INIT

Called once only before the logical database is processed. It prepares it to be called more than once by the function module LDB_PROCESS.

· FORM INIT

Called once only before the selection screen is processed.

· FORM PBO

Called before the selection screen is displayed, each time it is displayed. Consequently, it is only called when you use the logical database with an executable program, not with the function module LDB_PROCESS.

· FORM PAI

Called when the user interacts with the selection screen. Consequently, it is only called when you use the logical database with an executable program, not with the function module LDB_PROCESS. The interface parameters FNAME and MARK are passed to the subroutine.

FNAME contains the name of a selection criterion or parameter on the selection screen.

MARK describes the selection made by the user: MARK = space means that the user has entered a simple single value or range selection. MARK = '*' means that the user has also made entries on the Multiple Selection screen.

· FORM LDB_PROCESS_CHECK_SELECTIONS

Called instead of the subroutine PAI if the logical database is called using the function module LDB_PROCESS without a selection screen. This subroutine can check the selections passed in the function module interface.

· FORM PUT_node

Called in the sequence defined in the structure. Reads the data from the node nodeand uses the

PUT node.

statement to trigger a corresponding GETevent in the ABAP runtime environment. The PUT statement is the central statement in this subroutine: It can only be used within a subroutine of a logical database. The logical database must contain the node node, and the subroutine name must begin with PUT_node. The PUT statement directs the program flow according to the structure of the logical database. The depth to which the logical database is read is determined by the GET statements in the application program or the interface parameter CALLBACK of the function module LDB_PROCESS.

First, the subroutine PUT_root is executed for the root node. The PUT statement then directs the program flow as follows:

i. If the database program contains the subroutine AUTHORITY_CHECK_node, the first thing the PUT_node statement does is to call it.

ii. Next, the PUT statement triggers a GET event in the runtime environment. If there is a corresponding GET nodestatement in the executable program to which the logical database is linked, the associated event block is processed. If the CALLBACK parameter of the function module LDB_PROCESS is filled accordingly, the corresponding callback routine is called.

iii. The PUT statement directs the program flow

(a) To the next subroutine of a node that follows directly, if a lower-level node (not necessarily the very next) in the same subtree is requested by GET in the executable program or in the function module.

(b) To the subroutine of a node at the same level, if the preceding node branches to such a node and if a GET statement exists for such a node in the executable program or the function module.

The PUT statement in that subroutine starts again at step (i). In the subroutine of the lowest node in a subtree to be processed using GET, the program control does not branch further. Instead, the current subroutine is processed further. When a subroutine PUT_node has been executed in its entirety, the program flow returns to the PUTstatement from which it branched to the subroutine PUT_node.

iv. When control has returned from a lower-level subroutine PUT_node, the PUTstatement triggers the event GET node LATEin the runtime environment.

· FORM AUTHORITY_CHECK_node

Called automatically by the PUT node statement. In this subroutine, you can specify authorization checks for the appropriate node node from the structure of the logical database.

· FORM PUT_ldb_SP

Called when the user makes a selection using a search help to process the key chosen in the search help. ldb is the name of the logical database. From this subroutine, you can use the entries in the search help tables to read the relevant entries from the root node root. The processing in the program can then be triggered using PUT root. The subroutine PUT_root is then not called automatically.

· FORM BEFORE_EVENT

Called before an event, the name of which is passed in the parameter EVENT. Currently, the EVENT field can only contain the value START-OF-SELECTION, to call a subroutine before this event.

· FORM AFTER_EVENT

Called after an event, the name of which is passed in the parameter EVENT. Currently, the EVENT field can only contain the value END-OF-SELECTION, to call a subroutine after this event.

· FORM par_VAL, selop_VAL, selop-LOW_VAL, selop-HIGH_VAL

Called when the user calls possible values help for the parameter par or the selection criterion selop. These must belong to the selections in the logical database.

· FORM par_HLP, selop_HLP, selop-LOW_HLP, selop-HIGH_HLP

Called when the user calls possible values help for the parameter par or the selection criterion selop. These must belong to the selections in the logical database.

Example

Suppose that in the logical database structure, LFB1 is a branch of LFA1.

and that the following selection criteria are defined in the selection include:

SELECT-OPTIONS: slifnr FOR lfa1-lifnr,
sbukrs FOR lfb1-bukrs.

A section of the database program would then read:

FORM put_lfa1.
SELECT * FROM lfa1
WHERE lifnr IN slifnr.
PUT lfa1.
ENDSELECT.
ENDFORM.

FORM put_lfb1.
SELECT * FROM lfb1
WHERE lifnr = lfa1-lifnr.
AND bukrs IN sbukrs.
PUT lfb1.
ENDSELECT.
ENDFORM.

An executable program (report) linked to the logical database could contain the lines:

GET lfa1.
WRITE lfa1-lifnr.

GET lfb1.
WRITE lfb1-bukrs.

In this example, the runtime environment calls the routine put_lfa1 after the event START-OF-SELECTION. The event GET lfa1 is triggered by the statement PUT lfa1.

Once the corresponding event block in the program is complete, PUT lfa1 branches to the subroutine put_lfb1.

From this subroutine, the event GET lfb1 is triggered in the application program. If LFB1 is the last node to be read, processing resumes with the SELECTloop in put_lfb1. Otherwise, the program flow moves to the subroutine put_node of the next node. At the end of the SELECT loop of the last node, processing resumes in the SELECTloop of the node at the next level up. The example of programming using nested SELECT loops is only used to make the program flow clearer. In a real logical database, you would avoid doing this in order to minimize the number of database accesses.

The following diagram shows the program flow:


In this example, the PUT statements do not branch to the authorization check subroutines.

Src: http://help.sap.com/saphelp_nw04s/helpdata/en/9f/db9b8535c111d1829f0000e829fbfe/content.htm
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> List Generation, LDB, Spool Process, SAP Query, Report Painter All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.