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 =
ldb_incorrect =
ldb_already_running =
ldb_error =
ldb_selections_error =
ldb_selections_not_accepted =
variant_not_existent =
variant_obsolete =
variant_error =
free_selections_error =
callback_no_event =
callback_node_duplicate =
OTHERS = . IF sy-subrc <> .
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. "CALLBACK_SPFLI *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. "CALLBACK_SFLIGHT

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

资料来源sap library.

通过LDB_PROCESS函数使用逻辑数据库的更多相关文章

  1. Logical Databases逻辑数据库

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  2. [SAP ABAP开发技术总结]逻辑数据库

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  3. 逻辑数据库设计 - 需要ID(谈主键Id)

    本文的目标就是要确认那些使用了主键,却混淆了主键的本质而造成的一种反模式. 一.确立主键规范 每个了解数据库设计的人都知道,主键对于一张表来说是一个很重要,甚至必需的部分.这确实是事实,主键是好的数据 ...

  4. flask 在视图函数里操作数据库

    在视图函数里操作数据库 在视图函数里操作数据的方式和在python shell中的联系基本相同,只不过需要一些额外的工作.比如把查询结果作为参数 传入模板渲染出来,或是获取表单的字段值作为提交到数据库 ...

  5. 【LoadRunner】利用lr_db_connect函数对Oracle数据库压测的完整流程

    项目中常常会有直接对数据库进行压测的需求,以前都是通过Jmeter实现的,但是Jmeter本身图表及结果收集方面没有Loadrunner那么强大,所以利用loadrunner工具自己的函数整理了一个脚 ...

  6. 【ABAP系列】SAP 的逻辑数据库解析

    公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 的逻辑数据库解析   前 ...

  7. PRO*C 函数事例 2 -- 数据库操作

    Pro*C Oracle 的嵌入式开发,数据库处理部分最好能提取到一个模块,按照对不同数据库表的操作分成不同的.pc文件(如 DbsInstStat.pc).将此模块编译成库(c文件编译时链接此库), ...

  8. 用openrowset函数操作远程数据库

    OPENROWSET 包含访问 OLE DB 数据源中的远程数据所需的全部连接信息.当访问链接服务器中的表时,这种方法是一种替代方法,并且是一种使用 OLE DB 连接并访问远程数据的一次性的.特殊的 ...

  9. Oracle的overlaps函数转换其他数据库语法

    首先,来介绍一下Oracle的overlaps函数的用法: overlaps函数是用来判断两个时间段是否有重叠的 比如说计算 (a,b),(c,d) 就可以写成: select * from dual ...

随机推荐

  1. beeline连接hive

    beeline -u jdbc:hive2://192.168.1.77:10000 zeppelin default jdbc: jdbc:hive2://nn01.ooccpp.com:2181/ ...

  2. spring boot(10) 基础学习内容

    A Spring boot(10) 基础学习内容 B SpringBoot(16) 基础学习内容

  3. jsonignore的一个坑

    import org.fasterxml.jackson.annotate.JsonIgnore; 和 import org.codehaus.jackson.annotate.JsonIgnore; ...

  4. JavaScript 给表格排序

    (function(){ var mTable=document.getElementById('table'); var sort=function(el,index,desc){ var mTbo ...

  5. FZU Problem 2238 Daxia & Wzc's problem

    Daxia在2016年5月期间去瑞士度蜜月,顺便拜访了Wzc,Wzc给他出了一个问题: Wzc给Daxia等差数列A(0),告诉Daxia首项a和公差d; 首先让Daxia求出数列A(0)前n项和,得 ...

  6. Hadoop完全分布式环境下,DataNode进程正常启动,但是网页上不显示DataNode节点

    Hadoop完全分布式环境下,上传文件到hdfs上时报错: // :: WARN hdfs.DFSClient: DataStreamer Exception org.apache.hadoop.ip ...

  7. android 开发-(Contextual Menu)上下文菜单的实现

    在android3.0以后,安卓设备不在提供物理的菜单按键,同时,android应用提供了另外的菜单实现机制,来替代之前的菜单创建方式.安卓设备中,平常可以使用长按住某个内容弹出菜单选项.这就是我们需 ...

  8. WPF使用Aspose.Words导出Word文档

    一.创建Word文档模板 分析需要导出的word文档,将固定的内容和由程序生成的内容分开; 创建一个word(例如:Template.doc)文档,将固定的内容按照一定的格式写入当前文档中; 打开Te ...

  9. nginx fpm生产环境的权限设置

    http://www.2cto.com/Article/201307/231770.html

  10. 初始html(常用标签)

    今天我们来学习Web前端的一些知识,这一阶段需要记忆的东西相对来说比较多,需要花时间记忆以及做好练习. 一.HTML初识 1.web服务本质 import socket def main(): soc ...