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

Logical Data base

Former Member
0 Likes
997

Hi ,

What is logical data base ? Use it ?

1 ACCEPTED SOLUTION
Read only

SantoshKallem
Active Contributor
0 Likes
923

In logical database u have dynamic selections called FREE SELECTION.

it is allowed at runtime.

i feel this is major advantage for LDB

rewrd if useful.

santhosh

5 REPLIES 5
Read only

Former Member
0 Likes
923

Hi Kumar,

Check this info.

A logical database is a special ABAP/4 program which combines the contents of certain database tables. You can link a logical database to an ABAP/4 report program as an attribute. The logical database then supplies the report program with a set of hierarchically structured table lines which can be taken from different database tables.

GET will fetch the table data immediately

GET LATE

In the LDB when you define the table structure in hierarchy, first it will fetch the higher node data and then all the below node tables data and comes to a second record in the top node table. for this GET Late is used.

You can create any number of primary keys in a table

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

/people/srivijaya.gutala/blog/2007/03/05/why-not-logical-databases

www.sapbrain.com/FAQs/TECHNICAL/SAP_ABAP_Logical_Database_FAQ.html

www.sap-img.com/abap/abap-interview-question.htm

www.sap-img.com/abap/quick-note-on-design-of-secondary-database-indexes-and-logical-databases.htm

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

http://help.sap.com/saphelp_nw2004s/helpdata/en/9f/db9bb935c111d1829f0000e829fbfe/content.htm

Hope this resolves your query.

Reward all the helpful answers.

Regards

Read only

SantoshKallem
Active Contributor
0 Likes
924

In logical database u have dynamic selections called FREE SELECTION.

it is allowed at runtime.

i feel this is major advantage for LDB

rewrd if useful.

santhosh

Read only

Former Member
0 Likes
923

This is from SAP Help:

<b>Logical Databases</b>

Logical databases are special ABAP programs that read data from database tables. They are used by executable (type 1) programs. At runtime, you can regard the logical database and the executable program (reports) as a single ABAP program, whose processing blocks are called by the runtime environment in a particular, pre-defined sequence.

You edit logical databases using a tool within the ABAP Workbench, and link them to executable programs (reports) when you enter the program attributes. You can use a logical database with any number of executable programs (reports). From Release 4.5A, it is also possible to call logical databases on their own.

<b>Structure of a Logical Database</b>

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

Structure

The structure of a logical database determines the database tables which it can access. 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.

Selection Part

The selection part of the logical database defines input fields for selecting data. The runtime environment displays these on the selection screen when you run an executable program linked to the logical database. The corresponding fields are also available in the ABAP program, allowing you, for example, to change their values to insert default values on the selection screen.

Database Program

The database program of a logical database is a container for special subroutines, in which the data is read from the database tables. These subroutines are called by the reporting processor in the runtime environment in a predefined sequence.

<b>To access the LDB in ur program you have to use the GET Event</b>

This is the most important event for executable programs that use a logical database. It occurs when the logical database has read a line from the node <table> and made it available to the program in the work area declared using the statement NODES <table>.

When you define the corresponding event block in the program, you can specify a field list if the logical database supports field selection for this node:

GET <table> [FIELDS <f1> <f 2>...].

For more info check the SAP Standard program

<b>

EVENT_DEMO.</b>

Message was edited by:

divya rajendiran

Read only

Former Member
0 Likes
923

A logical database can read the lines of these tables one after the other into an executable program in a sequence which is normally defined by the hierarchical structure. The term logical database is sometimes used to mean not only the program itself, but also the data that it can procure.

Tasks of Logical Databases

Logical databases serve mainly to reuse predefined functionality for reading data from database tables, but they can also be programmed for other tasks. To keep the application logic of application programs free from technical details, logical databases can perform the following tasks:

· Reading the same data for several programs.

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.

· Defining the same user interface for several programs.

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

· Central authorization checks

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

· Improving Performance

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.

Read only

Former Member
0 Likes
923

<b>Logical Databases</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 and linking them to executable ABAP programs while setting the program contents. You edit logical databases using the Logical Database Builder in the ABAP Workbench.

However, since Release 4.5A, it has also been possible to call logical databases independently of this tool 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 executable programs, allowing them to use more than one logical database and process a database more than once.

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>example</b>

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.

You declare the node of the structure using the TABLESstatement. This creates the necessary interface work areas as 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 NODESstatement. 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 GET events. 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.

hope it will clear ur doubts

regards

ravish

<b>plz reward if helpful</b>