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

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、样例代码及说明

 1 TABLES spfli.
 2 SELECT-OPTIONS s_carr FOR spfli-carrid.
 3
 4 TYPE-POOLS: rsds, rsfs.
 5
 6 DATA: callback TYPE TABLE OF ldbcb,
 7       callback_wa LIKE LINE OF callback.
 8
 9 DATA: seltab TYPE TABLE OF rsparams,
10       seltab_wa LIKE LINE OF seltab.
11
12 DATA: texpr TYPE rsds_texpr,
13       fsel  TYPE rsfs_fields.
14
15 *设置需要回调的数据节点和回调对应的子程序
16 callback_wa-ldbnode     = ‘SPFLI‘.
17 callback_wa-get         = ‘X‘.
18 callback_wa-get_late    = ‘X‘.
19 callback_wa-cb_prog     = sy-repid.
20 callback_wa-cb_form     = ‘CALLBACK_SPFLI‘.
21 APPEND callback_wa TO callback.
22
23 CLEAR callback_wa.
24 callback_wa-ldbnode     = ‘SFLIGHT‘.
25 callback_wa-get         = ‘X‘.
26 callback_wa-cb_prog     = sy-repid.
27 callback_wa-cb_form     = ‘CALLBACK_SFLIGHT‘.
28 APPEND callback_wa TO callback.
29
30 *设置对应的选择屏幕的参数的传入值
31 seltab_wa-kind = ‘S‘.
32 seltab_wa-selname = ‘CARRID‘.
33
34 LOOP AT s_carr.
35   MOVE-CORRESPONDING s_carr TO seltab_wa.
36   APPEND seltab_wa TO seltab.
37 ENDLOOP.
38
39 *调用函数
40 CALL FUNCTION ‘LDB_PROCESS‘
41   EXPORTING
42     ldbname                     = ‘F1S‘
43     variant                     = ‘ ‘
44     expressions                 = texpr
45     field_selection             = fsel
46   TABLES
47     callback                    = callback
48     selections                  = seltab
49   EXCEPTIONS
50     ldb_not_reentrant           = 1
51     ldb_incorrect               = 2
52     ldb_already_running         = 3
53     ldb_error                   = 4
54     ldb_selections_error        = 5
55     ldb_selections_not_accepted = 6
56     variant_not_existent        = 7
57     variant_obsolete            = 8
58     variant_error               = 9
59     free_selections_error       = 10
60     callback_no_event           = 11
61     callback_node_duplicate     = 12
62     OTHERS                      = 13.
63
64 IF sy-subrc <> 0.
65   WRITE: ‘Exception with SY-SUBRC‘, sy-subrc.
66 ENDIF.
67
68 *SPFLI节点对应的回调处理函数
69 FORM callback_spfli USING name  TYPE ldbn-ldbnode
70                           wa    TYPE spfli
71                           evt   TYPE c
72                           check TYPE c.
73   CASE evt.
74     WHEN ‘G‘.
75       WRITE: / wa-carrid, wa-connid, wa-cityfrom, wa-cityto.
76       ULINE.
77     WHEN ‘L‘.
78       ULINE.
79   ENDCASE.
80 ENDFORM.                    "CALLBACK_SPFLI
81
82 *SFIGHT节点对应的回调处理函数
83 FORM callback_sflight USING name  TYPE ldbn-ldbnode
84                             wa    TYPE sflight
85                             evt   TYPE c
86                             check TYPE c.
87   WRITE: / wa-fldate, wa-seatsocc, wa-seatsmax.
88 ENDFORM.                    "CALLBACK_SFLIGHT

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

资料来源sap library.

时间: 2024-09-29 03:35:29

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

Logical Databases逻辑数据库

声明:原创作品,转载时请注明文章来自SAP师太技术博客:www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将追究法律责任!原文链接:http://www.cnblogs.com/jiangzhengjun/p/4293511.html 主要组成部分... 300 结构(Structure)... 301 选择(Selections)... 302 数据库程序(Database program)... 305 LDB程序结构... 307 FORM P

翻译:逻辑数据库(1):组成

调试SAP标准程序的时候遇到了逻辑数据库相关的部分,顺便翻译一下ABAP的官方帮助文件作为练习.欢迎指正. 逻辑数据库      逻辑数据库是一种特别的开发对象,它在Logical Database Builder中编辑,并且可以通过一个层次树结构(hierarchical tree structure)中的节点们为其它ABAP程序提供数据.逻辑数据库最通常的目的是从数据库表中释放数据,尽管其它的应用也可以做到这点. 通过使用外键关系,逻辑数据库提供一个跨数据库表的层次视图.如果这些关系中的部分

逻辑数据库设计 - 单纯的树(递归关系数据)(转)

逻辑数据库设计 - 单纯的树(递归关系数据) 相信有过开发经验的朋友都曾碰到过这样一个需求.假设你正在为一个新闻网站开发一个评论功能,读者可以评论原文甚至相互回复. 这个需求并不简单,相互回复会导致无限多的分支,无限多的祖先-后代关系.这是一种典型的递归关系数据. 对于这个问题,以下给出几个解决方案,各位客观可斟酌后选择. 一.邻接表:依赖父节点 邻接表的方案如下(仅仅说明问题): CREATE TABLE Comments( CommentId int PK, ParentId int, --

[ABAP技术总结]逻辑数据库

目录导航 声明:原创作品,转载时请注明文章来自SAP师太博客,并以超链接形式标明文章原始出处,否则将追究法律责任!原文出自: 6.      逻辑数据库... 56 6.1.           组成... 56 6.2.           结构... 56 6.3.           选择屏幕(Selections)... 57 6.3.1.        PARAMETERS屏幕参数扩充... 58 6.3.2.        SELECTION-SCREEN格式化屏幕... 58 6.

kettle中使用javascript步骤和fireToDB函数实现自定义数据库查询

kettle中使用javascript步骤和fireToDB函数实现自定义数据库查询 假设你需要实现非传统的数据库查询操作,为了讨论这种情景,我们假设你需要读取数据库中的正则表达式,然后检查输入的每行的字段匹配表达式的个数. 在javascript步骤执行数据库查询 在javascript步骤初始化的时候,查询数据库,获取正则表达式记录集.然后每一行的输入数据循环检查是否匹配表达式,如果匹配,记录变量加一,最后把结果写到到前行的新增字段中.思路很清楚,但是如何在javascript步骤实现数据库

函数的逻辑读成零

drop table t; CREATE TABLE T AS SELECT * FROM DBA_OBJECTS; CREATE OR REPLACE FUNCTION F_NO_RESULT_CACHE RETURN NUMBER AS V_RETURN NUMBER; BEGIN SELECT COUNT(*) INTO V_RETURN FROM T; RETURN V_RETURN; END; / set autotrace on statistics SELECT F_NO_RESU

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

公众号:SAP Technical 本文作者:matinal 原文出处:http://www.cnblogs.com/SAPmatinal/ 原文链接:[ABAP系列]SAP 的逻辑数据库解析 前言部分 大家可以关注我的公众号,公众号里的排版更好,阅读更舒适. 正文部分 T-CODE:SE36 逻辑数据库好像是HR模块用的比较多 如果谁有HR350,可以分享一下,非常感谢 当数据量很大,而且很耗时间的时候 用逻辑数据库,可以提高数据读取速度 理解上应该是把数据集放到一块 不用我们平时写OPENS

◆◆0使用逻辑数据库PNP开发HR报表

HR开发中会经常用到逻辑数据库,其中PNP逻辑数据最常用的. 人事数据的信息类型数据都存放在PAnnnn这些表中,PNP其实就是从这些表中抓取的数据.现在已经用PNPCE(支持concurrent employment)取代PNP,但是因为PNP已经用得相当普遍而且够用,很多报表还是基于PNP的,这里举个PNP的例子. 1, 指定逻辑数据库PNP 创建程序是在属性界面输入逻辑数据库PNP 下图selection screen处可以选择000或900两个选择屏幕,000是主数据的选择屏,900是薪

逻辑数据库设计 - 单纯的树(递归关系数据)

相信有过开发经验的朋友都曾碰到过这样一个需求.假设你正在为一个新闻网站开发一个评论功能,读者可以评论原文甚至相互回复. 这个需求并不简单,相互回复会导致无限多的分支,无限多的祖先-后代关系.这是一种典型的递归关系数据. 对于这个问题,以下给出几个解决方案,各位客观可斟酌后选择. 一.邻接表:依赖父节点 邻接表的方案如下(仅仅说明问题): CREATE TABLE Comments( CommentId int PK, ParentId int, --记录父节点 ArticleId int, Co