The class cl_system_transaction_state contains several useful utility methods:
- get_in_update_task: return the flag whether current code is running with normal work process or in update work process
- get_on_commit: return flag whether current code is called because of a previous registration via PERFORM ON COMMIT and triggered by COMMIT WORK
- get_sap_luw_key: return current LUW ID I just use a very simple report to test them. First I call the FM ZSQF in a normal way, then call it via update task, then register it with PERFORM ON COMMIT and trigger it via COMMIT WORK.
WRITE: / 'Direct call ZSQF begin...'.
DATA(lv_luw_key) = cl_system_transaction_state=>get_sap_luw_key( ).
WRITE:/ 'LUW key in main program:', lv_luw_key.
CALL FUNCTION 'ZSQF'.
WRITE: / 'Direct call ZSQF end...'.
CALL FUNCTION 'ZSQF' IN UPDATE TASK.
PERFORM call_fm ON COMMIT.
COMMIT WORK AND WAIT.
lv_luw_key = cl_system_transaction_state=>get_sap_luw_key( ).
WRITE:/ 'LUW key in main program after COMMIT WORK:', lv_luw_key.
FORM call_fm.
WRITE:/ 'ZSQF is called on COMMIT begin...'.
CALL FUNCTION 'ZSQF'.
WRITE:/ 'ZSQF is called on COMMIT end...'.
ENDFORM.
In the function module ZSQF, I just print out the three flags.
DATA(lv_in_update) = cl_system_transaction_state=>get_in_update_task( ).
DATA(lv_on_commit) = cl_system_transaction_state=>get_on_commit( ).
DATA(lv_luw_key) = cl_system_transaction_state=>get_sap_luw_key( ).
WRITE: / 'Am I in update task? ' , lv_in_update.
WRITE: / 'Am I triggered via PERFORM ON COMMIT?', lv_on_commit.
WRITE: / 'Current LUW Key' , lv_luw_key.
The execution result shows the fact that the normal FM call, the FM registered to COMMIT WORK and the update task all run within the same LUW, and also proves the explanation of COMMIT WORK in ABAP help: “The COMMIT WORK statement closes the current SAP LUW and opens a new one”.
The WRITE keyword executed in update task will not generate any output in SE38 list, and apart from switching on “update debugging” and check the three flags in debugger, there is also another way to log the content of the variable like lv_luw_key: Just create a new checkpoint group via tcode SAAB, specify option “Log” for Logpoints and maximum validity period.
Then append the following code in the FM implementation:
IF lv_in_update = 1.
LOG-POINT ID ZUPDATELOG SUBKEY 'Current LUW KEY' FIELDS lv_luw_key.
ENDIF.
Now after report execution, go to tcode SAAB, click Log tab, and we can find the content of lv_luw_key which is logged by the above ABAP code LOG-POINT ID ZUPDATELOG SUBKEY ‘Current LUW KEY’ FIELDS lv_luw_key.
要获取更多Jerry的原创文章,请关注公众号"汪子熙":
相关推荐
SAP ABAP 代码备份下载到本地程序代码
ABAP代码性能指导 ABAP代码性能指导 ABAP代码性能指导
ABAP 代码下载备份 1.5.1
ABAP代码规范二例 内容节选: ******************************** 变量命名规则 Type Name:T_ Internal tables (global): gt_ Internal Tables (Local):it 工作区(structure): wa_ 全局变量: g_ 局部变量: l_ Ranges ...
abap代码规范,高效abap、modern abap
ABAP OLE颜色代码
SAP+ ABAP开发实用教程:顾问培训资料,含实例代码和教程,详细描述ABAP开发过程:数据表读法、程序规范、代码实例、调试方法以及ABAP开发环境和总体介绍、 ABAP语法示例 、ALV控件的使用、 实战Form设计 ,分基础、...
ABAP 代码共享 这些程序为报表程序,希望对大家有用 部门领用单.txt
abap代码规范,标准化规范简单abap程序!
ABAP编辑器快速调用函数时自动填充调用参数 和 声明变量
如果正创建ABAP/4程序模块,则必须在运行程序之前创建事务代码(关于创建事务代码的详细信息,参见《对话编程简介》)。 出于测试目的,可以先不进行保存,直接运行某个不是模块存储部件的程序。编辑器保留一个包含...
对于大家想学sap ABAP开发的来说,ABAP的T-Code是很重要的,但是,事务代码有很多,大家也不可能全部都能记住的,所以特吧ABAP事务代码列出来,大家可以参考的
SAP ABAP 1.4.4代码下载
不多说了,绝对适合新手中手学习的好资料。一共有112份源代码。
abap程序在代码上的一些调优方法, 主要包含:open SQL上的写法调优, 标准内表、排序内表、哈希内表的时间复杂度及在何时使用, 针对程序中老语法部分的修改,例如老语法内表定义时occurs的使用
ABAP GIT 项目 AI SDK FOR ABAP 代码
使用ABAP运行时间分析工具SE30优化程序,通过二八分析原理,进行程序的优化,做到以最快的时间,获得最大的效果
批量下载BOM到EXCEL-ABAP代码
以实例详解ABAP报表中如何加入权限判断,配有图片,标注说明等,让你的思路为之一清……
sap 代码管理工具 abapgit abap版本管理工具帮助我们快速备份版本