gpt4 book ai didi

java - 通过 JCo 以事务方式调用 BAPI RFC

转载 作者:行者123 更新时间:2023-12-04 14:05:07 24 4
gpt4 key购买 nike

首先,我不是 SAP/BAPI 开发人员。我们有一个 java 应用程序,它使用 JCo 库通过 RFC 调用一些 BAPI。问题是是否有任何方法可以在单个事务中调用其中的多个。

我认为正确的做法是

  • 开始 JCoContext
  • 执行一些 RFC
  • 调用 BAPI_TRANSACTION_COMMIT
  • 结束 JCoContext

例如我们想这样称呼这些系统 bapis:BAPI_CATIMESHEETMGR_INSERTBAPI_CATIMESHEETMGR_CHANGE

但出于某种原因,无论我们做什么,所有的东西都会被提交。我想了解到底是什么提交了这些数据。提交是那些 BAPI 的一部分还是某种 JCo“功能”?

最佳答案

开始学习 RFC 事务模型的好地方是 this piece of help ,您可以在其中阅读有关创建自定义 BAPI 的指南:

BAPIs must not execute 'COMMIT WORK' commands.Reason: The caller should have control of the transaction. Several BAPIs should be able to be combined within one LUW. For more information see Transaction Model for Developing BAPIs.The following commands must not be used:

  • CALL TRANSACTION
  • SUBMIT REPORT
  • SUBMIT REPORT AND RETURNDatabase changes can only be made through updates.
    Reason: The RFC executes an implicit database commit.

所以是的,通常您的假设是正确的,隐式提交发生在 RFC 中。

此外,"Transaction Model for Developing BAPIs" help section包含有关您的场景的重要说明:

The following restrictions apply to combining several BAPIs in one LUW:

  • If an instance was created, modified or deleted by a write BAPI, a read BAPI can only access the most recent data if a COMMIT WORK has taken place.
  • It is not possible to make two write accesses on the same instance within one LUW. For example, you cannot first create and then change the object within the same LUW.
  • You can, however, create several instances of the same object type within an LUW.

因此您将无法实现您想要的:在一个 LUW (Logical Unit of Work) 中创建 (BAPI_CATIMESHEETMGR_INSERT) 和更改 (BAPI_CATIMESHEETMGR_CHANGE) 时间表。

它必须在两个 LUW(两个 RFC 调用)中完成。

关于java - 通过 JCo 以事务方式调用 BAPI RFC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68815610/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com