判斷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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 判斷當前程式是否正在執行
- 判斷當前程式是否"以管理員身份執行"的
- 判斷某過程是否在執行的方法
- 判斷一個時間是否處於指定的時間段內程式碼例項
- Android判斷服務是否在執行Android
- 如何在CRM和C4C中用程式碼判斷當前是否處於configuration模式模式
- javascript判斷是否是觸屏程式碼JavaScript
- 舒服的判斷當前應用是否處於前臺
- Windows下bat指令碼判斷埠是否可用WindowsBAT指令碼
- 判斷ssh遠端命令是否執行結束
- c#中判斷類是否繼承於泛型基類C#繼承泛型
- BAT批處理判斷服務是否正常執行(批處理命令綜合應用)BAT
- 判斷字串中是否包含Emoji表情程式碼字串
- 判斷app是否是第一次執行APP
- 判斷手機是否安裝app的javascript程式碼APPJavaScript
- 使用android SharedPreference判斷程式是否第一次執行Android
- Java非同步判斷執行緒池所有任務是否執行完成的方法Java非同步執行緒
- golang中判斷兩個slice是否相等與判斷值下的 陣列是否相等Golang陣列
- js判斷指定的值是否為整數的程式碼JS
- php下利用curl判斷遠端檔案是否存在的實現程式碼PHP
- js判斷時間格式是否正確程式碼JS
- js判斷元素是否為空程式碼例項JS
- js判斷是否是IE瀏覽器程式碼JS瀏覽器
- Android程式碼判斷手機是否已rootAndroid
- 判斷一個數是否為質數(程式碼)
- 在首頁判斷是否登入並執行登陸
- Linux判斷上一個語句是否執行成功Linux
- Android 判斷當前執行緒是否是主執行緒的兩種方法Android執行緒
- 判斷兩個ip地址是否屬於同一個網段程式碼
- QTP測試指令碼的維護 - 使用Update執行模式和Maintenance執行模式QT指令碼模式AINaN
- C語言判斷檔案是否存在,判斷檔案可讀可寫可執行C語言
- 判斷url連結地址是否合法的例項程式碼
- linux指令碼-判斷程式是否存在,從而可以做預警處理..Linux指令碼
- 在Linux下判斷系統當前是否開啟了超執行緒Linux執行緒
- jQuery判斷按下的是否是enterEnter鍵jQuery
- Go小工具系列——判斷元素是否存在於陣列中Go陣列
- javascript判斷元素是否具有指定樣式類JavaScript
- js判斷文字框是否為空程式碼例項JS