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-ALV.rar_ABAP系统ALV_abap_abap开发alv”暗示我们将深入探讨ABAP ALV的使用,特别是在ABAP系统中的应用以及如何进行开发。 描述中提到“ABAP ALV总结,ALV格式,REUSE_ALV_GRID_DISPLAY_LVC函数使用”,...
标题:“ABAP官方教程--- BC400_EN_Col32”和“Introduction to the ABAP Workbench”(ABAP工作台介绍)。 描述:本文件是一份关于ABAP官方教程的介绍,该教程的全称为“BC400_EN_Col32”,涵盖了ABAP工作台的入门...
在“web-dynpro-abap-ui-element-tree”这个主题中,我们主要探讨的是Web Dynpro ABAP中的UI元素树结构,以及如何在Chapter 1, Curriculum (CV) Introduction中理解和应用这些知识。 在Web Dynpro ABAP中,UI元素是...
3. ABAP Workbench: ABAP工作台是SAP ABAP开发的核心环境,提供了开发、测试、调试ABAP程序的各种工具和功能。 4. Foundations and Concepts: 这部分强调了基础和概念的重要性,表明教程可能主要集中在基础知识点和...
标题:“TAW12_1_-_2005-Q2_-_A4_ABAP_Workbench_Concepts.pdf” - **TAW12_1**:这可能是文档的内部编号或名称。 - **2005-Q2**:表明文档的出版时间是2005年第二季度。 - **A4**:可能指的是文档的格式为A4纸张...
“ABAP开发基础教程”的学习者可以从ABAP trainning.xls这个文件中获取实践练习,这通常包括简单的编程任务、数据库操作示例以及如何使用ABAP与其他SAP组件集成的案例。通过这样的学习,初学者将能够逐步掌握ABAP...
本文档是《SAP中文教材全系列之ABAP-BC400_ZH》,为SAP ABAP编程语言的学习提供参考。文档包含了详细的ABAP课程内容,旨在帮助学员理解并掌握ABAP编程的基础知识和高级技能。以下将详细阐释文档所涵盖的知识点。 ...
由于这部分内容比较专业,我将尽量详细地阐述ABAP(Advanced Business Application Programming)逻辑数据库和数据库操作的概念和用法。 首先,ABAP是SAP系统中用于开发和扩展应用程序的主要编程语言。在进行数据库...
ABAP 开发中,函数是非常重要的一部分,合理地使用函数可以大大提高开发效率和代码质量。本文总结了 ABAP 中常用的函数,包括日期计算、表操作、数据转换、权限检查、报表生成、PDF 转换、日期转换、浮点数转换、...
为了更好地理解这一过程,你可以参考提供的文档:《用OLE DOI 实现ABAP导出EXCEL表格.docx》和《ABAP-透過OLE操作OFFICE.docx》。同时,《OLE.pdf》可能包含更深入的OLE和DOI技术细节,这对于优化和调试代码会非常有...
### SAP-ABAP-OO 实现 CL-SALV-TABLE 的关键知识点 #### 1. ABAP 面向对象的 ALV 显示方法 在 SAP 的 ABAP 环境中,ALV (Application List Viewer) 是一种非常常用的技术,用于在屏幕上以表格的形式展示数据。传统...
ABAP - Keyword Documentation This documentation describes the syntax and meaning of the keywords of the ABAP language and its object-oriented part ABAP Objects. Alongside this, language frameworks ...
在给定的示例中,作者通过一段ABAP程序展示了如何使用ALV进行一般列表显示。这段程序的主要功能是显示物料细节信息,包括物料编号(MATNR)、创建者(ERNAM)、创建日期(ERSDA)以及物料类别(LABOR)。 1. **数据...
详细介绍了SAP ABAP 高级编程技术
在ABAP中,ALV(Accelerated List Viewer)是一种用于显示和编辑表格数据的图形用户界面组件。在给定的代码示例中,展示了如何创建一个ALV网格,并处理用户对数据的更改,如删除行。以下是关键知识点的详细解释: 1...
在ABAP编程环境中,处理JSON数据是常见的任务之一。标题中的"ZUI2_JSON2_/UI2/CL_JSON_ui2/cl_json_abap_Ui2_cl_json_...通过这个类,你可以有效地在ABAP世界和JSON世界之间架起桥梁,从而更好地实现数据交换和处理。
通过使用ABAP工作流和Java工作流(WebFlow),可以设计和自动化业务流程。 2. **门户技术**:SAP NetWeaver Portal提供了一个统一的入口点,让用户能够访问所有所需的信息、应用和服务,实现个性化的工作环境。它...
通过以上步骤,你可以使用ABAP编程实现SAP ALV的多层输出,并灵活地调用系统方法以适应不同的业务需求。在实际项目中,你可能还需要考虑错误处理、用户界面优化和性能优化等问题。文件"ALV.txt"和"www.pudn.com.txt"...
在ABAP编程中,ALV (ABAP List Viewer) 是一个强大的工具,用于展示和编辑数据表。在处理用户输入时,我们有时需要对特定字段应用格式化或限制,这时`EDIT_MASK`就派上用场了。`EDIT_MASK`是ABAP中的一种功能,允许...
例如,在本案例中,创建的结构需要包含`ITEMNO_ACC`组件,这是因为`BAPI_ACC_DOCUMENT_POST`需要通过行项目号来定位特定的行项目。这里以`ITEMNO_ACC`为例,实际上可以根据具体的业务需求添加更多的字段。 ##### ...