如何實現SAP GUI的自定義語法檢查(Syntax check)
There are already blogs in SCN which introduce how to implement a custom check in ABAP code inspector or ATC check. For example this blog Code Inspector – How to create a new check from Peter Inotai.
Recently for training purpose I need to demo a custom syntax check directly performed in SAP GUI by hotkey Ctrl+F2.
Let’s first have a look what could be achieved: Open a method in Class builder and click syntax check icon or press Ctrl+F2:
Then my custom syntax check is triggered and warning message is raised within class builder, if the total lines of the current method has exceeded a hard-coded threshold say 100. I feel this way of custom syntax check more convenient compared with custom Code inspector check or ATC check which will display check result in a separate window.
The custom syntax check against total number of source code lines in this example does not make too much sense, in the future I will provide another meaningful example.
Limitations
Only works in Form-based class builder, no test is done in ABAP in Eclipse yet. ( I still use SAPGUI in my daily work ) Some prerequisite knowledge before custom syntax check implementation The example in this blog is built on the Netweaver with version below:
We application developer might consider it is a natural part that our operations ( for example double click a method in class builder, double click a table field in ABAP Dictionary ) in SAPGUI is responded, however the processing under the hood is far more complex than our imagination. Consider the following sequence diagram when you double click a class method in class builder:
Every operation in ABAP workbench issued by end user is encapsulated by an instance of class CL_WB_REQUEST containing all detail information about the give operation for example the object type and name of clicked object( class method, transparent table or any other repository object ), together with operation type.
Different operation type has different kind of handler class to serve the request, which are centrally maintained in table WBREGISTRY. The content of this table is exposed by class CL_WB_REGISTRY.
The class CL_WB_MANAGER works as a mediator which communites with these tools in a uniform way via instances of CL_WB_REQUEST.
Sometimes the handler logic operation is so complex that the corresponding handler class for it could not simply be determined by looking up static tableWBREGISTRY. In this case the additional determination logic could be written by code via implementation of interface IF_WB_DECISION_CLASS.
Step by step to implement custom syntax check
Step1. Create a new class ZCL_WB_CLEDITOR by inheriting from standard class ZCL_WB_CLEDITOR.
The main logic is done in the redefinition of method CHECK_METHOD_SOURCE. First the standard check logic in super class is done, if syntax error is found, display them to end user and skip my custom syntax check, otherwise perform custom syntax check in line 14.
You wonder why CL_WB_CLEDITOR should be inherited? Well I just know from debugging that when syntax check icon or Ctrl+F2 is pressed, this class is called:
Step2. Create a new class ZCL_OO_METHOD_REQ_DISPATCHER by copying from standard class CL_OO_METHOD_REQ_DISPATCHER. Create a new post exit on method GET_TOOL_FOR_REQUEST:
The implementation is simple:
Note:
(1) You can directly enhance standard class CL_OO_METHOD_REQ_DISPATCHER. I do not prefer this way since it is a standard class, although the enhancement is not actual modification on that standard class, by copying a new Z class from it and playing round with Z class, I can prevent my system admin from being too nervous…
(2) You can directly modify source code of method GET_TOOL_FOR_REQUEST if you copy a new class. However it is the most convenient approach to simply replace all determination result of CL_WB_CLEDITOR with ZCL_WB_CLEDITOR in post exit. 3. If you choose to copy a new class ZCL_OO_METHOD_REQ_DISPATCHER, do not forget to replace the value in column TOOL from CL_OO_METHOD_REQ_DISPATCHER to ZCL_OO_METHOD_REQ_DISPATCHER. Once done, it should look like below:
Step3. Be default for performance reason the tool registration is stored in share memory instead of database table. As a result in order to make your changes take effect, you could declare the following user parameter explicitly:
I know this parameter by debugging this method:
So far all steps are done. Now you can test in Class builder with form builder mode. If you would like to achieve custom syntax check in SE38 instead, you could use the same idea ( find corresponding handler class for SE38 via debugging ) described in this blog.
Update on 2017-04-15
I have provided a real example to simulate Covariance syntax check in ABAP: Covariance in Java and simulation in ABAP.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2713952/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- SAPGUI裡實現自定義的語法檢查GUI
- 如何自定義python語法.Python
- TypeScript reflect-metadata 結合方法裝飾器實現的一個自定義語法檢查的例子TypeScript
- 使用PHP實現詞法分析與自定義語言PHP詞法分析
- 如何將自定義XML檢視注入SAP Fiori Elements應用XML
- 淺談如何實現自定義的 iterator
- 如何讓SAP C4C自定義BO實現附件上傳的功能
- SAP WM中階儲存型別的容量檢查– Check According to Maximum Weight型別
- EventSource的自定義實現
- 抽象語法樹 Abstract syntax tree抽象語法樹
- flutter 修正你的 dart damn syntax 語法FlutterDart
- C#中檢查null的語法糖,非常實用C#Null
- SAP WM中階Storage Type的Capacity Check – 根據貨架最大數量檢查
- 如何實現 axios 的自定義介面卡 adapteriOSAPT
- 淺談如何實現自定義的 iterator 之二
- Flutter自定義實現神奇的卡片切換檢視Flutter
- 如何把一個ABAP檢視新增到SAP GUI的收藏夾裡GUI
- Flutter自定義View的實現FlutterView
- Flutter自定義Banner的實現Flutter
- Eloquent ORM 自定義 builder——實現 find_in_set 查詢ORMUI
- SAP UI5 Mock 伺服器如何實現自定義 Function Import試讀版UIMock伺服器FunctionImport
- oracle語法相容--如何透過with recursive語法來實現oracle的分層查詢Oracle
- JavaScript新增型別語法Type SyntaxJavaScript型別
- C#中檢查null的語法糖C#Null
- CSS語法檢查利器之csslintCSS
- 如何實現swipe、tap、longTap等自定義事件事件
- 自定義註解例項實現SQL語句生成SQL
- 自定義SpringMVC部分實現SpringMVC
- 自定義實現Complex類
- Android自定義拍照實現Android
- Net 實現自定義Aop
- 聊聊自定義實現的SPI如何與spring進行整合Spring
- 前端工程化之路-語法檢查前端
- 如何利用 Netty 實現自定義協議通訊?Netty協議
- 如何實現 SAP UI5 路由失敗時顯示自定義的 NOT Found 頁面試讀版UI路由面試
- HarmonyOS NEXT應用開發—自定義檢視實現Tab效果
- SAP Spartacus 自定義Popover指令,如何實現彈出對話方塊自動關閉功能
- 【VIEW】Oracle如何查詢固定檢視的定義或底層sql語句ViewOracleSQL