判斷ABAP程式碼是否處於update模式下執行的工具類
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的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2712061/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 如何在CRM和C4C中用程式碼判斷當前是否處於configuration模式模式
- 判斷ssh遠端命令是否執行結束
- c#中判斷類是否繼承於泛型基類C#繼承泛型
- Linux判斷上一個語句是否執行成功Linux
- BAT批處理判斷服務是否正常執行(批處理命令綜合應用)BAT
- Java非同步判斷執行緒池所有任務是否執行完成的方法Java非同步執行緒
- php下利用curl判斷遠端檔案是否存在的實現程式碼PHP
- golang中判斷兩個slice是否相等與判斷值下的 陣列是否相等Golang陣列
- 判斷一個數是否為質數(程式碼)
- 在首頁判斷是否登入並執行登陸
- C語言判斷檔案是否存在,判斷檔案可讀可寫可執行C語言
- Go小工具系列——判斷元素是否存在於陣列中Go陣列
- 在Linux中,如何使用shell指令碼判斷某個服務是否正在執行?Linux指令碼
- Class.isAssignableFrom判斷A類是否可賦值給B類賦值
- delphi 判斷類是否實現介面,獲取類實現的介面
- node.js 多個非同步過程判斷執行是否完成Node.js非同步
- sh指令碼判斷路徑是否存在指令碼
- Windos bat批處理指令碼,判斷是終端命令列執行,還是雙擊執行BAT指令碼命令列
- 用程式碼判斷當前系統是否支援某個版本的feature
- 如何判斷一個元素文字是否換行?
- PHP判斷一個字串是否包含亂碼PHP字串
- 如何判斷網校原始碼是否值得使用?原始碼
- 如何讓 ABAP 報表在後臺作業的模式下執行模式
- 基於機率判斷矩陣A*B是否等於C矩陣
- 程式碼段——C#判斷時間是否在某個範圍C#
- 判斷字串是否為空字串
- python 判斷是否為中文Python
- 判斷字串是否唯一字串
- 判斷URL字串是否合法字串
- python判斷是否為listPython
- 如何通過Java程式碼判斷當前的環境是否支援JRE 9Java
- jstack判斷執行緒狀態JS執行緒
- 而井教你判斷當前Javascript執行環境是否支援async函式JavaScript函式
- 判斷單連結串列是否關於中心對陣
- 判斷一個物件是否為空物件,判斷一個物件中是否有空值物件
- MYSQL 一個特殊需求在不同的MYSQL配置產生不同的結果 與 update 0 是否需要應用程式判斷MySql
- 判斷應用所執行的CPU型別型別
- JavaScript判斷字串是否為空JavaScript字串