关于SAP的事务提交和回滚(LUW)

SAP 数据更新之数据库事务SAP LUW 1.DB LUW2.从数据库编程的角度来看,DB LUW是一个不可分割的数据库操作序列,以事务的提交或回滚结束3.DB LUW要么完全由数据库系统执行,要么根本不执行4.如果DB LUW中发生错误,则自DB LUW中所有数据库更改都将被回滚(SAP中事务的回滚称为反转5.DB LUW中发生的数据库更改直到事务提交后才真正写入数据库。在发生这种情况之前,您可以使用数据库回滚来撤消更改6.在SAP系统中,可以隐式或使用显式命令触发数据库提交或回滚。 阅读详情
From the point of view of database programming, a database LUW is an inseparable sequence of database operations that ends with a database commit. The database LUW is either fully executed by the database system or not at all. Once a database LUW has been successfully executed, the database will be in a consistent state. If an error occurs within a database LUW, all of the database changes since the beginning of the database LUW are reversed. This leaves the database in the state it was in before the transaction started.
 
The database changes that occur within a database LUW are not actually written to the database until after the database commit. Until this happens, you can use a database rollback to reverse the changes. In the SAP System, database commits and rollbacks can be triggered either implicitly or using explicit commands.
隐式事务提交(自动提交事务)Implicit Database Commits
A work process can only execute a single database LUW. The consequence of this is that a work process must always end a database LUW when it finishes its work for a user or an external call. Work processes trigger an implicit database commit in the following situations:
·        When a dialog step is completed
Control changes from the work process back to the SAP GUI.
·        When a function module is called in another work process (RFC).
Control passes to the other work process.
·        When the called function module (RFC) in the other work process ends.
Control returns to the calling work process.
·        When a WAIT statement interrupts the work process.
Control passes to another work process.
·        Error dialogs (information, warning, or error messages) in dialog steps.
Control passes from the work process to the SAP GUI.
显式提交事务Explicit Database Commits
There are two ways to trigger an explicit database commit in your application programs:
·        Call the function module DB_COMMIT
The sole task of this function module is to start a database commit.
·        Use the ABAP statement COMMIT WORK
This statement starts a database commit, but also performs other tasks (refer to the keyword documentation for COMMIT WORK).
隐式事务回滚(自动回滚事务)(Implicit Database Rollbacks)
The following cases lead to an implicit database rollback:
·        Runtime error in an application program
This occurs whenever an application program has to terminate because of an unforeseen situation (for example, trying to divide by zero).
·        Termination message
Termination messages are generated using the ABAP statement MESSAGE with the message type A or X. In certain cases (updates), they are also generated with message types I, W, and E. These messages end the current application program.
显式回滚事务(Explicit Database Rollbacks)
You can trigger a database rollback explicitly using the ABAP statement ROLLBACK WORK. This statement starts a database rollback, but also performs other tasks (refer to the keyword documentation for ROLLBACK WORK).
From the above, we can draw up the following list of points at which database LUWs begin and end.
开始数据库事务A Database LUW Begins
·        Each time a dialog step starts (when the dialog step is sent to the work process).
·        Whenever the previous database LUW ends in a database commit.
·        Whenever the previous database LUW ends in a database rollback.
结束数据库事务A Database LUW Ends
·        Each time a database commit occurs. This writes all of the changes to the database.
·        Each time a database rollback occurs. This reverses all of the changes made during the LUW.
Database LUWs and Database Locks
As well as the database changes made within it, a database LUW also consists of database locks. The database system uses locks to ensure that two or more users cannot change the same data simultaneously, since this could lead to inconsistent data being written to the database. A database lock can only be active for the duration of a database LUW. They are automatically released when the database LUW ends. In order to program SAP LUWs, we need a lock mechanism within the R/3 System that allows us to create locks with a longer lifetime (refer to The SAP Locking Concept).
 相关连接 http://blog.csdn.net/CompassButton/archive/2006/12/15/1444415.aspx 

Trackback: http://tb.blog.csdn.net/TrackBack.aspx?PostId=1490220


SAP ABAP | 接口技术:tRFC (事务性 RFC) 的一致性与底层机制 本文深入解析SAP系统中tRFC(事务性RFC)的工作原理与排错方法。tRFC通过LUW(逻辑工作单元)机制确保异步调用的顺序性、上下文一致性和事务完整性,所有调用在COMMIT WORK后作为一个整体执行或回滚。系统通过TID(事务ID)唯一标识每个LUW,并将数据持久化存储在ARFCSSTATE和ARFCSDATA表中。文章详细介绍了tRFC的执行流程、异常处理机制,并重点说明如何使用SM58事务码进行监控和排错,包括查看失败记录、分析错误信息以及手动干预执行过程。掌握这些核心原理和工具能有效提升SAP 阅读详情

相关推荐

SAP ABAP开发避坑指南:当增强遇到隐式提交,如何用PERFORM ON COMMIT保住数据一致性?

本文深入探讨SAP ABAP开发中隐式提交导致的数据一致性问题,重点介绍如何使用PERFORM ON COMMIT机制确保原子性更新。通过实际案例解析,展示如何结合UPDATE TASK处理复杂业务场景,并提供异常处理和性能优化建议,帮助开发者规避常见陷阱。

weixin_30588675的博客 303

SAP_ABAP_关于COMMIT WORK、ROLLBACK WORK

COMMIT WORK: 显示提交 ROLLBACK WORK: 回滚提交 ABAP中的COMMIT WORK有两种机制:一种是程序运行结束自动COMMIT WORK;一种是碰到I类型的消息/屏幕完成/一个屏幕出口自动COMMIT WORK。...

SAP旅途 9572

彻底理解 SAP 中的 Database LUW:事务一致性、提交回滚、隔离级别与 ABAP 实战

SAP开发中数据一致性问题往往源于事务边界处理不当。Database LUW(数据库逻辑工作单元)是确保操作原子性的核心概念,它要求一组数据库操作要么全部成功(通过database commit持久化),要么全部撤销(通过database rollback回滚)。开发中需注意显式/隐式提交的区别,以及隔离级别对数据可见性的影响。业务场景如银行转账、订单创建等必须确保相关操作在同一事务中完成,避免"半成功"数据状态。理解Database LUW与SAP LUW的区别,正确使用COMMIT

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1793

SAP 常用基础函数总结

COMMIT WORK AND WAIT 同步更新,该语句执行后会等待所有更新函数都执行完后才继续执行后面的代码,执行结果可以通过sy-subrc来判断事务提交是否成功。ls_button-on_client_click = lv_url. "这是重点,跟普通的按钮不一样ON_CLIENT_CLICK。rv_value = cl_bsp_dlc_view_descriptor=>field_type_link. “获取链接。********代码逻辑。**--Read到对应的TABIX。

qq_36952606的博客 1225

在 SAP LUW 里看懂 RAP 信息流:用 CDS Transient 字段把交互期的上下文安全带到 Late Save

SAP RAP 事务模型中外部触发的正确处理方式 本文探讨了在 SAP RAP 项目中处理保存成功后外部触发的常见挑战。RAP 的严格事务模型将操作分为交互期和保存序列两个阶段,要求开发者必须将外部系统通知、异步流程触发等动作放置在保存成功后的正确时机。文章提出了一种工程实践方案:通过 CDS Transient 辅助字段(使用 cast 构造的非持久化字段)将交互期收集的上下文信息传递到保存阶段,在 Late Save 时安全执行外部触发。这种方法既保持了数据模型的纯净性,又确保了事务的原子性,避免在事务

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1222

在 BOPF 里把事务管明白:Transaction Manager 与 Service Manager 的分工、边界与实战

本文深入解析了SAP S/4HANA中BOPF框架的核心机制,重点阐述了Service Manager和Transaction Manager的分层设计理念。Service Manager负责业务对象的服务操作入口,处理查询、修改等独立操作;而Transaction Manager则负责将多个操作组织成事务单元,确保数据一致性。文章通过实际案例对比了只读场景和修改场景下的最佳实践,指出在数据写入时必须引入Transaction Manager来管理事务边界,避免直接提交导致的运行时错误。同时揭示了Servi

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 940

DB luw and sap luw

SAP-LUW汇总篇

qq_44034095的博客 273

Update Task 里的禁用语句:为什么一行 COMMIT WORK 足以让整个过账崩盘

SAP ABAP Update Task 禁用语句详解 在 SAP ABAP 开发中,CALL FUNCTION...IN UPDATE TASK 是确保事务一致性的关键机制。然而,Update Task 中执行某些语句会导致运行时错误,如 COMMIT_IN_POSTING 或 POSTING_ILLEGAL_STATEMENT,因为这些操作会破坏事务边界或更新控制器的调度秩序。本文总结了 Update Task 中绝对禁止的语句类型,包括显式提交/回滚、隐式提交操作(如屏幕调用、事务跳转)以及 Nati

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 1393

结合实例快速理解SAP中SAP/DB LUW 机制

首先LUW(Logic Unit of Work)是什么意思,从字面意思理解逻辑单元,可以把一些列的数据库操作(即多个 DB LUW)放入一个"集合",统一提交和回滚,从而来保证数据库更新的一致性。在SAP中,由于业务处理复杂,涉及到的DB也很多,业务是分好几步去完成的,所以需要和数据库多次交互来更新数据,但是每次DB LUW并不受我们控制,和数据库的交互都会更新数据进去,业务最后一步出错,那么这个业务不算是完整的,需要把之前存进数据库的业务数据全部回滚,所以带来了很多的不便。所以SAP引入了SAP LUW

SAP自学之路 2975

SAP ABAP 服务器是如何处理用户从 SAPGUI 里发起的请求的?

摘要:本文深入解析SAP ABAP系统中对话请求的处理机制,从Dynpro屏幕的PBO/PAI节拍到工作进程复用原理。文章通过一个财务报销单案例,详细说明Screen 100→105→110的完整处理流程,包括事务模型、数据库交互及提交回滚要点。重点阐释了SAP如何通过roll-in/roll-out机制实现工作进程复用,确保多用户并发请求的高效处理,同时保持事务的ACID特性。文中还提供了可运行的最小化代码示例,帮助读者理解抽象概念的具体实现。

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 120

在Cursor IDE中集成Datadog监控:自然语言查询实战指南

在云原生和微服务架构中,可观测性(Observability)已成为保障系统稳定性的核心技术支柱。其核心原理是通过日志(Logs)、指标(Metrics)和追踪(Traces)三大支柱,实时采集并呈现系统的运行状态。这项技术的价值在于,它让开发者能够透视复杂的分布式系统,快速定位性能瓶颈与故障根因。在实际的工程实践中,开发人员常常需要在编码环境与监控平台之间频繁切换,这种上下文切换严重影响了排障效率。本文聚焦于如何利用Model Context Protocol(MCP),将强大的Datadog可观测性平台

weixin_42519772的博客 348
上一篇: 理解ORACLE数据库字符集
下一篇: 关于search help Exit和样例
techweb
博客等级 码龄19年 226粉丝 3842原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值