Dynamic logical database calls

 TYPE-POOLS: RSDS, RSFS

 DATA CALLBACK LIKE LDBCB OCCURS
 DATA SELTAB   LIKE RSPARAMS OCC
 DATA TEXPR    TYPE RSDS_TEXPR.
 DATA FSEL     TYPE RSFS_FIELDS.
 DATA DYN_NODES TYPE DYN_NODES.
 DATA DYN_NODE_TYPES TYPE DYN_NO

 * Creating and filling the CALL
 CALLBACK-LDBNODE     = 'SPFLI'.
 CALLBACK-GET         = 'X'.
 CALLBACK-GET_LATE    = 'X'.
 CALLBACK-CB_PROG     = 'TESTPRO
 CALLBACK-CB_FORM     = 'CALLBAC
 APPEND CALLBACK.

 CLEAR CALLBACK.
 CALLBACK-LDBNODE     = 'SFLIGHT
 CALLBACK-GET         = 'X'.
 CALLBACK-CB_PROG     = 'TESTPRO
 CALLBACK-CB_FORM     = 'CALLBAC
 APPEND CALLBACK.

 *  Nodes with type "Dynamic Dic
 CALLBACK-LDBNODE = 'SBOOL_DYN'.
 CALLBACK-GET     = 'X'.
 CALLBACK-CB_PROG = 'TESTPROG'.
 CALLBACK-CB_FORM = 'CALLBACK_FO
 APPEND CALLBACK.

 * Use US version of node SBOOK_
 MOVE: 'SBOOK_DYN' TO DYN_NODES-
       'SBOOK_US'  TO DYN_NODES-
 APPEND DYN_NODES TO DYN_NODE_TY

 * SELTAB selections
 MOVE: 'I'      TO SELTAB-SIGN,
       'CP'     TO SELTAB-OPTION
       'S'      TO SELTAB-KIND,
       'CARRID' TO SELTAB-SELNAM
       '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.
  ...

你可能感兴趣的:(database)