Reading logical database using ABAP program

SAP Logical databases are special type of ABAP programs to retrieve (read) database data for reusing in other application programs. it shortly known as ldb. It provides a customized view of the database data.

A Logical database structure is a like a tree structure linked with the foreign key relationship between SAP database tables.

Following things are the purposes of Logical database

  • Reading the same data for multiple programs
  • Defining the same user interface for multiple programs
  • Central authorization checks
  • Improving performance

Logical database has three components. They are

  • Structure (data view specification)
  • Selections (user interface for the program)
  • Database Program (ABAP coding to read the data)

SAP ABAP Logical database components structure

Here is a sample ABAP program to read a ldb.

Requirement:
Read a logical database in SAP ABP (you must have data in those tables, now LFA1), fill up an internal table. Sort the data by a given field and then display the internal table.

ABAP program Source Code:

report zldbread no standard page heading.
tables: lfa1.
data: begin of t occurs 0,
linfr like lfa1-lifnr,
name1 like lfa1-name1,
end of t.

start-of-selection.

get lfa1.
clear t.
move-corresponding lfa1 to t.
append t.
end-of-selection.
sort t by name1.
loop at t.

write: / t-name1, t-lifnr.
endloop.

Some Basic Questions & Answers

What are the components of an ABAP Logical Database
Structure, Selections & ABAP program are the components of a SAP ABAP Ldb.
Which function module used to call a logical database
LDB_PROCESS si the function module to call ldb from another SAP ABAP application program.