Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

REGARDING LOGICAL DATABASES

Former Member
0 Likes
1,184

HI EXPERTS,

i dont know anything about logical databases..can anyone explain me by giving some simple examples...

regards,

raman.

5 REPLIES 5
Read only

Former Member
0 Likes
698

Hi,

1. A logical database is in fact

a program only.

2. This LDB provides two main things :

a) a pre-defined selection screen

which handles all user inputs and validations

b) pre defined set of data

based upon the user selection.

3. So we dont have to worry about from

which tables to fetch data.

4. Moreover, this LDB Program,

handles all user-authorisations

and is efficient in all respects.

5. tcode is SLDB.

*----


1. To get a taste of it.

2. create a new z program.

3. while creating type PNP

in logical database field.

4. paste this code and execute.

REPORT ABC.

*----


infotypes : 0001.

TABLES : PERNR.

*----


GET PERNR.

WRITE 😕 PERNR-PERNR.

5. The selection screen which u see

is coming from logical database PNP program.

6. Execute

7. U will get a list of pernr.

-


SAPDBPNP

this is the main program of LDB PNP

which does the main work.

SAPDB + ldb name.

Check this for LDB

http://help.sap.com/saphelp_46c/helpdata/EN/c6/8a15381b80436ce10000009b38f8cf/content.htm

http://www.cs.ucc.ie/~abf/CS507-8/l37c.pdf.

Good tutorial to start with.

http://www.thespot4sap.com/Articles/SAP_ABAP_Queries_FunctionalAreas_LogicalDB.asp

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/content.htm

Also check this thread,

Regards,

Priyanka.

Read only

Former Member
0 Likes
698

Hi,

Use tcode SE36 to create a LD.

Logical Databases

Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.

However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for programs with type 1.

Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.

Logical Databases - Views of Data

A logical database provides a particular view of database tables in the R/3 System. It is always worth using logical databases if the structure of the data that you want to read corresponds to a view available through a logical database.

The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.

GO THROUGH LINKS -

http://www.sap-basis-abap.com/saptab.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9bfa35c111d1829f0000e829fbfe/content.htm

http://help.sap.com/saphelp_nw04/helpdata/en/9f/db9b5e35c111d1829f0000e829fbfe/frameset.htm

http://help.sap.com/saphelp_nw04/helpdata/en/c6/8a15381b80436ce10000009b38f8cf/frameset.htm

Reward points if useful,

Regards,

Vinodh.

Read only

Former Member
0 Likes
698

<b>Logical Database</b>

<b>

Creating the LDBs in Transcation code ->SE36</b> .

Logical databases are special ABAP programs that retrieve data and make it available to application programs. The most common use of logical databases is still to read data from database tables by linking them to executable ABAP programs.

However, from Release 4.5A, it has also been possible to call logical databases using the function module LDB_PROCESS. This allows you to call several logical databases from any ABAP program, nested in any way. It is also possible to call a logical database more than once in a program, if it has been programmed to allow this. This is particularly useful for programs with type 1.

Logical databases contain Open SQL statements that read data from the database. You do not therefore need to use SQL in your own programs. The logical database reads the program, stores them in the program if necessary, and then passes them line by line to the application program or the function module LDB_PROCESS using an interface work area.

<b>Logical Databases - Views of Data</b>

A logical database provides a particular view of database tables in the R/3 System. It is always worth using logical databases if the structure of the data that you want to read corresponds to a view available through a logical database.

The data structure in a logical database is hierarchical. Many tables in the R/3 System are linked to each other using foreign key relationships. Some of these dependencies form tree-like hierarchical structures. Logical databases read data from database tables that are part of these structures.

<b>Tasks of Logical Databases</b>

As well as allowing you to read data from the database, logical databases also allow you to program other tasks centrally, making your application programs less complicated. They can be used for the following tasks:

<b>Reading the same data for several programs.</b>

The individual programs do not then need to know the exact structure of the relevant database tables (and especially not their foreign key relationships). Instead, they can rely on the logical database to read the database entries in the right order during the GET event.

<b>Defining the same user interface for several programs.</b>

Logical databases have a built-in selection screen. Therefore, all of the programs that use the logical database have the same user interface.

<b>

Central authorization checks</b>

Authorization checks for central and sensitive data can be programmed centrally in the database to prevent them from being bypassed by simple application programs.

<b>

Improving performance</b>

If you want to improve response times, logical databases permit you to take a number of measures to achieve this (for example, using joins instead of nested SELECT statements). These become immediately effective in all of the application programs concerned and save you from having to modify their source code.

<b>

Linking a Logical DB to an Executable Program</b>

<b> Runtime Behavior.</b>

The following list shows the sequence in which the ABAP runtime environment calls the subroutines of the logical database and the event blocks in the executable program. The runtime environment executes a series of processors (selection screen processor, reporting processor). The ABAP code listed below shows the processing blocks that belong to the individual steps.

Initialization before the selection screen is processed. 
Subroutine:

FORM INIT 

This subroutine is called once only before the selection screen is first displayed.

Event block:

INITIALIZATION. 

This event occurs once only before the selection screen is first displayed.

PBO of the Selection screen Initialization before each occasion on which the selection screen is displayed (for example, to supply default values for key fields). 
Subroutine:

FORM PBO.

This subroutine is called each time the selection screen is sent (before it is displayed). 

Event block:

AT SELECTION-SCREEN OUTPUT.

This event is called each time the selection screen is sent (before it is displayed). 

The selection screen is displayed at the presentation server, and the user can enter data in the input fields. 
Input help (F4) or field help (F1) requests. 
Subroutines:

FORM <par>_VAL. 
FORM <selop>_VAL. 
FORM <selop>-LOW_VAL. 
FORM <selop>-HIGH_VAL. 

If the user requests a list of possible entries for database-specific parameters <par> or selection criteria <selop>, these subroutines are called as required. 

If the user requests field help for these parameters, the subroutines are called with the ending _HLP instead of _VAL.

Event blocks:

AT SELECTION-SCREEN ON VALUE-REQUEST FOR <par>.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <selop>-LOW. 
AT SELECTION-SCREEN ON VALUE-REQUEST FOR <selop>-HIGH. 

If the user requests a list of possible entries for database-specific parameters <par> or selection criteria <selop>, these events are triggered as required. 

If the user requests field help for these parameters, the events with the addition ON HELP-REQUEST occurs instead of ON VALUE-REQUEST.

PAI of the selection screen. Checks to see whether the user has entered correct, complete, and plausible data. Also contains authorization checks. If an error occurs, you can program a user dialog and make the relevant fields ready for input again. 
Subroutines: 

FORM PAI USING FNAME MARK.

The interface parameters FNAME and MARK are passed by the runtime environment.

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

If MARK = SPACE, the user has entered a simple single value or range selection.

If MARK = '*', the user has also entered selections on the Multiple Selection screen.

Using the combination FNAME = '*' and MARK = 'ANY', you can check all entries at once when the user chooses a function or presses ENTER.

Event blocks:

AT SELECTION-SCREEN ON <fname>.

Event for processing a particular input field. 

AT SELECTION-SCREEN ON END OF <fname>.

Event for processing multiple selections. 

AT SELECTION-SCREEN.

Event for processing all user input. 

Processing before reading data. 
Subroutine:

BEFORE EVENT 'START-OF-SELECTION'.

The logical database can use this subroutine for necessary actions before reading data, for example, initializing internal tables. 

Event block:

START-OF-SELECTION.

First event in an executable program after the selection screen has been processed. You can use this event block to prepare the program for processing data. 

Reading data in the logical database and processing in the executable program. 
Subroutine:

FORM PUT_<node> 

The logical database reads the selected data of the node <node>.

Event block:

GET <table> [LATE].

This event is triggered by the PUT statement in the above subroutine. This event block allows you to process the data read for <node> in the corresponding interface work area. 

Processing after reading data. 
Subroutine:

AFTER EVENT 'END-OF-SELECTION'.

The logical database can use this subroutine for necessary actions after reading data, for example, releasing memory space. 

Event block:

END-OF-SELECTION.

Last reporting event. You can use this event block to process the temporary dataset that you have created (for example, sort it). 

If a list was generated during the above steps, the list processor in the runtime environment takes control of the program and displays the list. 


Suppose TABLE1 is the root node and TABLE2 is its only subordinate node in a logical database. The processing steps for reading and processing data would then have the following hierarchical order: 

START-OF-SELECTION. 

  FORM PUT_TABLE1.

  GET TABLE1.

    FORM PUT_TABLE2.

    GET TABLE2.

  GET TABLE1 LATE.

END-OF-SELECTION.

-Logical database is another tool for ABAP reports. Using LDB we can provide extra features for ABAP reports.

-While using LDB there is no need for us to declare Parameters.

-Selection-screen as they will be generated automatically.

-We have to use the statement NODES in ABAP report.

-If there are many tables the Performance will be slow as all the table data will be read from top node to bottom node .

<b>When to use logical database?</b>

Ans. Advantage of Logical databases:

less coding s required to retrieve data compared to normal internel tables.

Tables used LDB are in hierarchial structure.

reward points if it is usefull .....

Girish

Read only

Former Member
0 Likes
698

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.

Regards,

Pavan P.