Wednesday, June 4, 2008

ABAP Logical Database Program Comparison

ABAP Logical Database Program Comparison

Find below 2 programs performing the same task. The following program does not use a logical database.

REPORT ZEX_LOGICALDAT .

DATA: WA_SPFLI TYPE SPFLI,
      WA_SFLIGHT TYPE SFLIGHT.

SELECT-OPTIONS: SEL_CARR FOR WA_SPFLI-CARRID.

SELECT CARRID CONNID CITYFROM CITYTO
            FROM SPFLI
            INTO CORRESPONDING FIELDS OF WA_SPFLI
            WHERE CARRID IN SEL_CARR.

           WRITE: / WA_SPFLI-CARRID,
                         WA_SPFLI-CONNID,
                         WA_SPFLI-CITYFROM,
                         WA_SPFLI-CITYTO.

SELECT FLDATE
            FROM SFLIGHT
            INTO CORRESPONDING FIELDS OF WA_SFLIGHT
            WHERE CARRID = WA_SPFLI-CARRID and
            CONNID = WA_SPFLI-CONNID.

            WRITE: / WA_SFLIGHT-FLDATE.

ENDSELECT.
ENDSELECT.

The following program uses a Logical Database F1S.


REPORT ZEX_LOGICALDAT1 .

NODES: SPFLI, SFLIGHT.

GET SPFLI FIELDS CARRID CONNID CITYFROM CITYTO.

WRITE:/ SPFLI-CARRID,
        SPFLI-CONNID,
        SPFLI-CITYFROM,
        SPFLI-CITYTO.

GET SFLIGHT FIELDS FLDATE.

WRITE:/ SFLIGHT-FLDATE.

SAP ABAP Logical Database Structure

SAP ABAP Logical Database Structure

Please find below Tasks of a Logical Database.

  • Basically a Logical Database can be used to read the same data for several programs.
  • A Logical Database provides a consistent user interface.
  • In Logical Database Authorizations are carried out centrally
  • Performance is improved
The structure of a typical Logical Database is as Follows for example the structure of KDF is shown below.

Structure of the Logical Database KDF

Advantages of SAP Logical Databases

Advantages of SAP Logical Databases

SAP Logical Databases offer the following Advantages:

  • Saves Time: This is because a Logical Database comes along with a pre-defined Selection Screen and Data Retrieval Logic.
  • A Logical Database can be used in Multiple Programs. Hence if you you create a Logical Database once it can be used along with several of your programs where similar logic is required.
  • It offers a easy to use and a Standard User Interface
  • Central Authorization Checks for Database Access.
  • Flexibility: This is because even though a Logical Database has its own selection screen and data retrieval logic still you can complement this with your selection screens and SELECT statements. This makes the program more powerful
  • Checks for the User Input, if it is complete, correct and plausible.
Note: One executable program can have only one Logical Database.



SAP Logical Databases

SAP Logical Databases

A Logical Database is a special ABAP program. Basically what a Logical Database does is it combines the contents of certain database tables. A Logical Database needs to be mentioned in the Program attributes, this is done while creating a new program. A program that has a Logical Database linked to it basically has another program working along with it, but this program works like a single program. It makes use of the additional functionality provided by the Logical Database. The processing blocks of the Logical Database are called by the runtime environment in a particular order.

Basically a Logical Database has two functions one is to

Call the Selection Screen and the
Retrieve the data.
__________________________________________________

A program that uses Logical Database is Event Driven. The most important Event associated with a Logical Database is the GET EVENT. This EVENT is responsible for retrieving the Data.

Example of a Logical Database: F1S

If you are using a Logical Database, even though the Selection screen and the Data Retrieval is carried out by the Logical Database still you can control the selection screen and the depth of the data retrieval process. This can be achieved with the help of the NODE statement.

Once the Logical database is mentioned in the Program Attributes you can then use the GET EVENT in the main program to determine the depth of the data retrieval. Also the NODES statement in your program interacts with the Selection Screen of the Logical Database. You can use the EXIT or CHECK statements to determine the depth of the GET EVENT.


SAP ABAP Program Syntax Checks

SAP ABAP Program Syntax Checks

Before activating a program you need to check if the program is syntactically correct. This can easily be done in the ABAP editor with the following tools

Syntax Check
Extended Program Check
_________________________________________

The menu pat is as follows

Program >>>>>> Check >>>>>> Syntax
Program >>>>>> Check >>>>>> Extended Program Check
_________________________________________________________________

Syntax Check (Standard Syntax Check)

Here the syntax is checked by the system and if an error occurs the check stops and immediately an error message is displayed. Also the system suggests error correction. Any SAP ABAP program before execution needs to be Activated and before activation a Syntax check is necessary. If the program has not been checked for Syntax, and directly activated then during the activation process you have an option to ignore the errors and activate anyway. If you choose this option, the syntax errors are displayed while executing the program.

In case you are running a Syntax check on an Include program then automatically the system combines it with the TOP INCLUDE. In case the systems generates WARNINGS in the syntax check, then you can still run the program as some of the WARNINGS can be ignored. But its a good practice to correct all the warnings as they could lead to unforeseen errors and can give trouble in future SAP releases.

Extended Program Check

The extended program check does a more complete check of the program. It actually does a Syntax check on all the interfaces called from your program. All these check are excluded from the Standard Syntax check explained above. Basically there are 2 types of errors in any program

Static Errors and
Runtime Errors

The Runtime errors are not checked by the Standard Syntax Check explained above. Even the Extended Program Check is a Syntax Check for Static Errors. Sometimes in extended program check you may get warnings that cannot be corrected, the code that produces such warnings should be commented for extended check or you can put
pseudo comments ("#EC). All other Warnings should be corrected before activating the program. Technically the development is not considered to be complete if the Extended Program Check shows errors/warnings.