Ansicht
Dokumentation

LDB_PROCESS - Process logical databases

LDB_PROCESS - Process logical databases

CL_GUI_FRONTEND_SERVICES - Frontend Services   SUBST_MERGE_LIST - merge external lists to one complete list with #if... logic for R3up  
This documentation is copyright by SAP AG.
SAP E-Book

Functionality

This function module allows you to call a logical database directly in the same internal mode. Those data records read from the logical database are transfered to the attached callback routines. See also Logical Databases - Calling Using Function Modules.

The events that have been entered in the CALLBACK parameter determine at which depth data is read. At the most two calls can be performed per node, corresponding to the events GET node and GET node LATE at SUBMIT. This means that if the field "GET" is selected, the CALLBACK routine is called immediately after data has been read and before the sub-tree beneath it is processed. If "GET_LATE" is selected, the CALLBACK routine is called after the sub-tree beneath it is processed. See also the documentation for the CALLBACK parameter.

Although various logical databases can be nested arbitrarily, the following restrictions apply when processing these logical databases:

  1. The same logical database cannot be re-called if it is already running (exception LDB_ALREADY_RUNNING).

  2. The same logical database may be called multiple times in succession if it has been so designed. (exception LDB_NOT_REENTRANT). "So designed" means that the database program contains a routine (LDB_PROCESS_INIT) that prepares the logical database for another run.
    CAUTION: In this routine, the logical databaes must initialize its SELECT-OPTIONS and PARAMETERS, because these are global. If it does not, unexpected results could occur if you called it more than once in the same roll area.

There are numerous possibilities for supplying database selections that, for the most part, correspond to parameter transfer at SUBMIT.

  1. SELECTIONS: Structure RSPARAMS. Corresponds to the addition WITH SELECTION TABLE at SUBMIT.

  2. VARIANT: Name of a variant that belongs to the database program of the logical database. Corresponds to the addition USING SELECTION-SET at SUBMIT.

  3. EXPRESSIONS: Dynamic selections in RSDS_TEXPR format. Corresponds to the addition WITH FREE SELECTIONS at SUBMIT.

When conflicts occur, they are regulate just as in SUBMIT: selections stored in the variant VARIANT are overwritten by ones explicitly provided in SELECTIONS. Similarly, dynamic selections stored in the variant are overwritten by ones explicitly provided in EXPRESSIONS.

When a logical database is processed by executing a report, the logical database can check the selections in the PAI routine of the database program and, if necessary, terminate with an error message. If you are using LDB_PROCESS, this is the same as calling the routine LDB_PROCESS_CHECK_SELECTIONS in the database program. This call takes place after all selections have been provided with data. In case of an error, the exception LDB_SELECTIONS_NOT_ACCEPTED is triggered; The caller receives the error message in system fields SY-MSG...

Analogous to the addition FIELDS ... at GET or GET LATE you can use the parameter FIELD_SELECTION at certain nodes for field selection in ordewr to improve performance.

A special kind of node is the "Dynamic Dictionary Type". These nodes can return data with different data types (the possible ABAP Dictionary types must be defined in the logical database). One possible application is, for example, country-specific information in HR. Nodes with this type allow you to use a single logical database to return different structures. The type that the node has in a particular run with the logical database is decided by the caller. When you use an executable program, you specify this using the TYPE addition in the NODES statement, in LDB_PROCESS, you must use the parameter DYN_NODE_TYPES. If a node of this type (defined in a CALLBACK) is not typed in DYN_NODE_TYPES or you specify an invalid type, the exception DYN_NODE_NO_TYPE or DYN_NODE_INVALID_TYPE is triggered.

Example

TYPE-POOLS: RSDS, RSFS

DATA CALLBACK LIKE LDBCB OCCURS 0 WITH HEADER LINE.
DATA SELTAB   LIKE RSPARAMS OCCURS 0 WITH HEADER LINE.
DATA TEXPR    TYPE RSDS_TEXPR.
DATA FSEL     TYPE RSFS_FIELDS.
DATA DYN_NODES TYPE DYN_NODES.
DATA DYN_NODE_TYPES TYPE DYN_NODES_T.

* Structure of CALLBACK table
CALLBACK-LDBNODE     = 'SPFLI'.
CALLBACK-GET         = 'X'.
CALLBACK-GET_LATE    = 'X'.
CALLBACK-CB_PROG     = 'TESTPROG'.
CALLBACK-CB_FORM     = 'CALLBACK_FORM'.
APPEND CALLBACK.

CLEAR CALLBACK.
CALLBACK-LDBNODE     = 'SFLIGHT'.
CALLBACK-GET         = 'X'.
CALLBACK-CB_PROG     = 'TESTPROG'.
CALLBACK-CB_FORM     = 'CALLBACK_FORM'.
APPEND CALLBACK.

CLEAR CALLBACK.
*  Nodes of type "Dynamic Dictionary Type"
CALLBACK-LDBNODE     = 'SBOOK_DYN'.
CALLBACK-GET         = 'X'.
CALLBACK-CB_PROG     = 'TESTPROG'.
CALLBACK-CB_FORM     = 'CALLBACK_FORM'.
APPEND CALLBACK.

* Use US version of node SBOOK_DYN: type SBOOK_US
MOVE: 'SBOOK_DYN' TO DYN_NODES-NODE,
      'SBOOK_US'  TO DYN_NODES-TYPE.
APPEND DYN_NODES TO DYN_NODE_TYPES.

* SELTAB selections
MOVE: 'I'      TO SELTAB-SIGN,
      'CP'     TO SELTAB-OPTION,
      'S'      TO SELTAB-KIND,
      'CARRID' TO SELTAB-SELNAME,
      'A*'     TO SELTAB-LOW.
APPEND SELTAB.

MOVE: 'EQ'     TO SELTAB-OPTION,
      'LH'     TO SELTAB-LOW.
APPEND SELTAB.

* Filling TEXPR and FSEL
...


CALL FUNCTION 'LDB_PROCESS'
     EXPORTING
          LDBNAME                     = 'F1S'
          VARIANT                     = 'TEST_VARIANT'
          EXPRESSIONS                 = TEXPR
          FIELD_SELECTION             = FSEL
          DYN_NODE_TYPES              = DYN_NODE_TYPES
     TABLES
          CALLBACK                    = CALLBACK
          SELECTIONS                  = SELTAB
     EXCEPTIONS
          LDB_NOT_REENTRANT           = 1
          LDB_INCORRECT               = 2
          LDB_ALREADY_RUNNING         = 3
          LDB_ERROR                   = 4
          LDB_SELECTIONS_ERROR        = 5
          LDB_SELECTIONS_NOT_ACCEPTED = 6
          VARIANT_NOT_EXISTENT        = 7
          VARIANT_OBSOLETE            = 8
          VARIANT_ERROR               = 9
          FREE_SELECTIONS_ERROR       = 10
          CALLBACK_NO_EVENT           = 11
          CALLBACK_NODE_DUPLICATE     = 12
          CALLBACK_NO_PROGRAM         = 13
          CALLBACK_NO_CBFORM          = 14
          DYN_NODE_NO_TYPE            = 15
          DYN_NODE_INVALID_TYPE       = 16
          OTHERS            = 17.
IF SY-SUBRC <> 0.
  ...

In this example, the same callback routine (CALLBACK_FORM is called in program TESTPROG) at "GET" and "GET LATE" for the SPFLI nodes as well as at "GET" for SFLIGHT and SBOOK_DYN.
This routine might appear like this:

FORM CALLBACK_FORM USING NAME LIKE LDBN-LDBNODE  " Name of the node
                         WORKAREA                " Data
                         MODE     TYPE C         " G(et) or L(ate)
                         SELECTED TYPE C.        " Node desired?

  CASE NAME.
    WHEN 'SPFLI'.
*   WORKAREA has type SPFLI
      PERFORM HANDLE_SPFLI USING WORKAREA MODE SELECTED.
   WHEN 'SFLIGHT'.
*   WORKAREA has type SFLIGHT
      PERFORM HANDLE_SFLIGHT USING WORKAREA MODE SELECTED.
   WHEN 'SBOOK_DYN'.
*   WORKAREA has type SBOOK_US (as defined in DYN_NODE_TYPES)
      PERFORM HANDLE_SBOOK_US USING WORKAREA MODE SELECTED.
   ...
  ENDCASE.

ENDFORM.

The parameters have the following meaning:

  1. NAME: Name of the node
  2. WORKAREA: Actual data, for example the work areas from SPFLI and SFLIGHT in the example above.
  3. MODE: G at GET, L at GET LATE
  4. SELECTED: This parameter contains the value 'X' when the routine is called. If, for some reason, the record provided is rejected, the parameter must be reset to SPACE. In this case, the entire branch beneath the node is not processed. This can in the one hand lead to massive savings in terms of runtime, but also simplifies the coding. You do not have to check for each record from SFLIGHT whether it is actually required.

Note

When using different callback routines, parameter WORKAREA can and should be typed accordingly to the node data type for the different nodes. This also applies to nodes of type "Dynamic Dictionary Type" where the type assigned in LDB_NODE_TYPES is the type to be used.





Parameters

CALLBACK
DYN_NODE_TYPES
EXPRESSIONS
FIELD_SELECTION
LDBNAME
SELECTIONS
VARIANT

Exceptions

CALLBACK_NODE_DUPLICATE
CALLBACK_NO_CBFORM
CALLBACK_NO_EVENT
CALLBACK_NO_PROGRAM
DYN_NODE_INVALID_TYPE
DYN_NODE_NO_TYPE
FREE_SELECTIONS_ERROR
LDB_ALREADY_RUNNING
LDB_ERROR
LDB_INCORRECT
LDB_NOT_REENTRANT
LDB_SELECTIONS_ERROR
LDB_SELECTIONS_NOT_ACCEPTED
VARIANT_ERROR
VARIANT_NOT_EXISTENT
VARIANT_OBSOLETE

Function Group

SLDBFREE

TXBHW - Original Tax Base Amount in Local Currency   BAL Application Log Documentation  
This documentation is copyright by SAP AG.

Length: 16922 Date: 20240523 Time: 080408     sap01-206 ( 174 ms )