1、概览
通过LDB_PROCESS函数可以允许任何程序访问逻辑数据库,允许一个程序访问多个逻辑数据库,当然也允许多次连续访问访问同个逻辑数据库。当使用LDB_PROCESS函数来访问逻辑数据库时,选择屏幕将不显示,其选择参数由FIELD_SELECTION参数传入。

2、LDB_PROCESS参数说明
LDBNAME
Name of the logical database you want to call.

VARIANT
Name of a variant to fill the selection screen of the logical database. The variant must already be assigned to the database program of the logical database. The data is passed in the same way as when you use the WITH SELECTION-TABLE addition in a SUBMIT statement.

EXPRESSIONS
In this parameter, you can pass extra selections for the nodes of the logical database for which dynamic selections are allowed. The data type of the parameter RSDS_TEXPR is defined in the type group RSDS. The data is passed in the same way as when you use the WITH FREE SELECTION addition in a SUBMIT statement.

FIELD_SELECTION
You can use this parameter to pass a list of the required fields for the nodes of the logical database for which dynamic selections are allowed. The data type of the parameter is the deep internal table RSFS_FIELDS, defined in the type group RSFS. The component TABLENAME contains the name of the node and the deep component FIELDS contains the names of the fields that you want to read.

The function module has the following tables parameters:

CALLBACK
You use this parameter to assign callback routines to the names of nodes and events. The parameter determines the nodes of the logical database for which data is read, and when the data is passed back to the program and in which callback routine.

SELECTIONS
You can use this parameter to pass input values for the fields of the selection screen of the logical database. The data type of the parameter corresponds to the structure RSPARAMS in the ABAP Dictionary. The data is passed in the same way as when you use the WITH SELECTION-TABLE addition in a SUBMIT statement.

3、LDB_PROCESS的CALLBACK回调参数的具体字段的说明
LDBNODE
Name of the node of the logical database to be read.

GET
A flag (contents X or SPACE), to call the corresponding callback routine at the GET event.

GET_LATE
A flag (contents X or SPACE), to call the corresponding callback routine at the GET LATE event.

CB_PROG
Name of the ABAP program in which the callback routine is defined.

CB_FORM
Name of the callback routine.

4、回调函数的编写
回调子程序的标准形式
FORM <subr> USING <node> LIKE LDBCB-LDBNODE
                  <wa>   [TYPE <t>]
                  <evt>
                  <check>.
......
ENDFORM.
其中参数说明作用:
<node> contains the name of the node.
<wa> is the work area of the data read for the node. The program that calls the function module LDB_PROCESS and the program containing the callback routine do not have to declare interface work areas using NODES or TABLES. If the callback routine is only used for one node, you can use a TYPE reference to refer to the data type of the node in the ABAP Dictionary. Only then can you address the individual components of structured nodes directly in the subroutine. If you use the callback routine for more than one node, you cannot use a TYPE reference. In this case, you would have to address the components of structured nodes by assigning them one by one to a field symbol.
<evt> contains G or L, for GET or GET LATE respectively. This means that the subroutine can direct the program flow using the contents of <evt>.
<check> allows the callback routine to influence how the program is processed further (but only if <evt> contains the value G). The value X is assigned to the parameter when the subroutine is called. If it has the value SPACE when the subroutine ends, this flags that the subordinate nodes of the logical database should not be processed in the function module LDB_PROCESS. This is the same as leaving a GET event block using CHECK in an executable program. If this prevents unnecessary data from being read, it will improve the performance of your program.

5、样例代码及说明
TABLES SPFLI.
SELECT-OPTIONS S_CARR FOR SPFLI-CARRID.

TYPE-POOLS: RSDS, RSFS.

DATA: CALLBACK TYPE TABLE OF LDBCB,
      CALLBACK_WA LIKE LINE OF CALLBACK.

DATA: SELTAB TYPE TABLE OF RSPARAMS,
      SELTAB_WA LIKE LINE OF SELTAB.

DATA: TEXPR TYPE RSDS_TEXPR,
      FSEL  TYPE RSFS_FIELDS.

*设置需要回调的数据节点和回调对应的子程序
CALLBACK_WA-LDBNODE     = 'SPFLI'.
CALLBACK_WA-GET         = 'X'.
CALLBACK_WA-GET_LATE    = 'X'.
CALLBACK_WA-CB_PROG     = SY-REPID.
CALLBACK_WA-CB_FORM     = 'CALLBACK_SPFLI'.
APPEND CALLBACK_WA TO CALLBACK.

CLEAR CALLBACK_WA.
CALLBACK_WA-LDBNODE     = 'SFLIGHT'.
CALLBACK_WA-GET         = 'X'.
CALLBACK_WA-CB_PROG     = SY-REPID.
CALLBACK_WA-CB_FORM     = 'CALLBACK_SFLIGHT'.
APPEND CALLBACK_WA TO CALLBACK.

*设置对应的选择屏幕的参数的传入值
SELTAB_WA-KIND = 'S'.
SELTAB_WA-SELNAME = 'CARRID'.

LOOP AT S_CARR.
  MOVE-CORRESPONDING S_CARR TO SELTAB_WA.
  APPEND SELTAB_WA TO SELTAB.
ENDLOOP.

*调用函数
CALL FUNCTION 'LDB_PROCESS'
     EXPORTING
          LDBNAME                     = 'F1S'
          VARIANT                     = ' '
          EXPRESSIONS                 = TEXPR
          FIELD_SELECTION             = FSEL
     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
          OTHERS                      = 13.

IF SY-SUBRC <> 0.
  WRITE: 'Exception with SY-SUBRC', SY-SUBRC.
ENDIF.

*SPFLI节点对应的回调处理函数
FORM CALLBACK_SPFLI USING NAME  TYPE LDBN-LDBNODE
                          WA    TYPE SPFLI
                          EVT   TYPE C
                          CHECK TYPE C.
  CASE EVT.
   WHEN 'G'.
      WRITE: / WA-CARRID, WA-CONNID, WA-CITYFROM, WA-CITYTO.
      ULINE.
    WHEN 'L'.
      ULINE.
  ENDCASE.
ENDFORM.

*SFIGHT节点对应的回调处理函数
FORM CALLBACK_SFLIGHT USING NAME  TYPE LDBN-LDBNODE
                            WA    TYPE SFLIGHT
                            EVT   TYPE C
                            CHECK TYPE C.
  WRITE: / WA-FLDATE, WA-SEATSOCC, WA-SEATSMAX.
ENDFORM.

注意:通过'LDB_PROCESS'函数访问逻辑数据库时,请不要在程序属性里绑定逻辑数据库,否则会出LDB_ALREADY_RUNNING错误。
资料来源sap library.

ABAP--通过LDB_PROCESS函数使用逻辑数据库相关推荐

  1. ABAP 通过LDB_PROCESS函数使用逻辑数据库

    更多内容关注公众号:SAP Technical 各位可以关注我的公众号:SAP Technical 样例代码及说明 TABLES SPFLI. SELECT-OPTIONS S_CARR FOR SP ...

  2. 通过LDB_PROCESS函数使用逻辑数据库

    样例代码及说明 TABLES SPFLI. SELECT-OPTIONS S_CARR FOR SPFLI-CARRID. TYPE-POOLS: RSDS, RSFS. DATA: CALLBACK ...

  3. 重新学习一下ABAP里面的逻辑数据库

    之前以为逻辑数据库就仅仅是个选择界面那么简单,其实不是的,逻辑数据库还有很多名堂的. 逻辑数据常常要与 "START-OF-SELECTION"连合着一起使用. NODES: sp ...

  4. Logical Databases逻辑数据库

    主要组成部分 结构(Structure) 选择(Selections) 数据库程序(Database program) LDB程序结构 FORM PUT_XXX性能问题 GET_EVENT内表 报表程 ...

  5. 逻辑数据库读取bseg

    相关t-code sldb 一定要清空 :转到-〉属性-〉逻辑数据库设定 *&--------------------------------------------------------- ...

  6. 以下哪个函数不能选择mysql数据库_PHP使用以下哪个函数连接MySQL数据库服务器...

    PHP使用以下哪个函数连接MySQL数据库服务器 更多相关问题 (6分)化合物A分子式为C6H120,能与苯肼作用,但不发生银镜反应.A经催化氢化得化合物B(C6H140).B(6分)化合物A分子式为 ...

  7. Query 操作手册 (新增逻辑数据库)

    基本概念 QUERY是SAP的一项简单报表工具,它可为没有编程基础的用户用来生成简单的报表.它有图形化的界面,你可在上面托托拽拽,然后就可以见到你要的报表,可是这只是简单的应用,其实每个工具功能都是比 ...

  8. R语言广义线性模型函数GLM、广义线性模型(Generalized linear models)、GLM函数的语法形式、glm模型常用函数、常用连接函数、逻辑回归、泊松回归、系数解读、过散度分析

    R语言广义线性模型函数GLM.广义线性模型(Generalized linear models).GLM函数的语法形式.glm模型常用函数.常用连接函数.逻辑回归.泊松回归.系数解读.过散度分析 目录

  9. R语言dplyr包filter函数通过逻辑条件过滤数据实战

    R语言dplyr包filter函数通过逻辑条件过滤数据实战 目录 R语言dplyr包filter函数通过逻辑条件过滤数据实战 #导入dplyr包 #仿真数据

最新文章

  1. Stern-Brocot树
  2. Java不可变类作为参数传递遇到的坑
  3. Quartz Scheduler插件–隐藏的宝藏
  4. 解决ie6中fixed不起作用的问题
  5. 机器学习深度学习知识点总结
  6. 安装Linux操作系统(RHEL5.0)
  7. eXeScope 使用中的小技巧
  8. 【CF335E】 Counting Skyscrapers(期望)
  9. NYOJ 找球号(二)(哈希表)
  10. python学习的一些总结
  11. RK3288开发板GPIO介绍
  12. 高级人工智能之语音识别
  13. VUE 自定义子组件v-bind及v-on指令的大小写问题
  14. HTML简单汇总(不全)
  15. 深入了解开源智能家居平台,解决品牌割裂的终极利器?
  16. 入职大半年 -- 工作分享
  17. dede文章命名规则改变方法
  18. 操作系统之虚拟存储管理 java python 实现 最优(Optimal)置换算法 先进先出(FIFO)页面置换算法 LRU(Least Recently Used)置换算法
  19. 淘宝皇冠级卖家猜透马云心思 悄然独立革命
  20. 企业寄件,设置自动发送短信教程

热门文章

  1. Linux-Rsync项目实战(详细) 备份全网服务器数据生产架构方案
  2. 第3章 IP寻址
  3. 移动端web开发,click touch tap区别
  4. XML DOM Node List
  5. drf实现常用数据缓存
  6. exit()和_exit()函数
  7. 原 荐 简单说说Kafka中的时间轮算法
  8. NGINX访谈:软件负载均衡、API网关和服务网格的企业采用状况
  9. WPF的Clipboard.SetText()有问题
  10. XcodeGhost风波过后,苹果如何防范风险?