Entering content frameLinking a Logical DB to an Executable Program Locate the document in its SAP Library structure

When you link an executable program to a logical database by entering the name of the logical database in the program attributes, the subroutines of the logical database program and the event blocks of the executable program form a modularized program for reading and processing data. The individual processing blocks are called in a predefined sequence by the runtime environment (see the diagram in the section Logical Databases and Contexts). The runtime sequence is controlled by the structure, selections, and PUT statements in the logical database, and by the GET statements in the executable program.

Selection Screen

If you specify a logical database in the attributes of an executable program, this affects the standard selection screen of the program. It contains both the selection fields from the logical database and those from the program itself. You can specify which of the logical database selections are relevant for your program, and should therefore appear on the screen, by declaring interface work areas for the relevant nodes.

Runtime Behavior

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.

  1. Initialization before the selection screen is processed.
  2. 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.

  3. 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).
  4. 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).

  5. The selection screen is displayed at the presentation server, and the user can enter data in the input fields.
  6. Input help (F4) or field help (F1) requests.
  7. 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.

  8. 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.
  9. 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.

  10. Processing before reading data.
  11. 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.

  12. Reading data in the logical database and processing in the executable program.
  13. 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.

  14. Processing after reading data.
  15. 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).

  16. 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.

Example

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.

Authorization Checks in Logical Databases

It makes sense to use authorization checks using the AUTHORITY-CHECK statement in the following subroutines in the database program or event blocks of the executable program:

- PAI

- AUTHORITY_CHECK_<table>

- AT SELECTION-SCREEN

- AT SELECTION-SCREEN ON <fname>

- AT SELECTION-SCREEN ON END OF <fname>

- GET <table>

Whether you place the authorization checks in the database program or in the executable program depends on the following:

For example, you should only check authorizations for company code if you actually read lines containing the company code at runtime.

Avoid repetitive checks (for example, within a SELECT loop).

The separation of database access and application logic allows you to program all of your authorization checks centrally in the logical database program. This makes it easier to maintain large programming systems.

 

 

Leaving content frame