使用ABAP Channel實現一個訂單跟蹤工具,提高日常工作效率
There are already many nice blogs introducing nice features provided by ABAP channels in community, for example ABAP Channels Examples.
In that blog some demo examples are explained. After going through those impressive tutorials and demos, have you ever thought about building some useful stuff for your daily work by leverage this powerful feature in ABAP?
As ABAPers we use various trace / monitor tools in our daily work, such as SAT and ST05. And in CRM, all business transactions are managed by so called One Order framework. This framework uses function module CRM_ORDER_MAINTAIN to create, update and delete the document.
Just look at this long list of importing parameters
As an CRM application developer I have to frequently check what data has been put into these importing parameters during my development and trouble shooting life. I am so lazy that sometimes for minor issue I am reluctant to open ABAP Debugger. Instead I use the trace tool: One order trace tool CRMD_TRACE_SET.
This trace tool still has some drawback: when I perform the operation under trace mode, it is impossible for me to review the trace result in the real time. In order to see the trace result, I have to terminate the trace and then review the result in SAPGUI.
Is there any more convenient way to see the trace data in real time? Yes, it is time now to practice using ABAP Channel.
I have built another trace tool on my own. Let’s first see what feature it can support:
(1) Open the trace monitor in browser, which is a BSP application:
(2) Go to your application to be traced and perform the operation as usual. In my example, I create a new service order, and maintain fields like Description, External Reference, Priority, Pricing Date and Currency.
Switch to my monitor application, all trace data are displayed in the real time
Since now all trace data are displayed directly in browser, it is much easier for me to search some data I am interested using text search than searching something in SAPGUI.
Here below is the step by step how to build this tool.
(1) tcode SAPC, create a new APC application, in my example my APC application name: ZORDER_LOG_APC. Click button “Generate Class and Service” to generate handler class and ICF node automatically. You can refer to my setting below.
(2) tcode SAMC, create an AMC application ZORDERLOG.
Maintain the automatically generate class from step 1 into Authorization Program column. So far all modelling task are done.
(3) Implement class CL_CRM_ORDER_LOGGER, which will be responsible to send the logged data to a web socket.
In the class_constructor, I get a message producer instance by passing the AMC application id and channel id which are created in step2.
The actual send of message is done by the send method of this instance:
(4) Redefine ON_START method of the APC handler:
In this method we just bind this APC application with AMC application we created in step 2.
METHOD if_apc_wsp_extension~on_start.
DATA: lo_request TYPE REF TO if_apc_ws_initial_request.
DATA: lo_binding TYPE REF TO if_apc_ws_binding_manager.
DATA: lx_error TYPE REF TO cx_apc_error.
DATA: lv_message TYPE string.
TRY.
lo_request = i_context->get_initial_request( ).
lo_binding = i_context->get_binding_manager( ).
lo_binding->bind_amc_message_consumer( i_application_id = 'ZORDERLOG'
i_channel_id = '/order_log' ).
CATCH cx_apc_error INTO lx_error.
lv_message = lx_error->get_text( ).
MESSAGE lv_message TYPE 'E'.
ENDTRY.
ENDMETHOD.
For method ON_MESSAGE, we can just keep it as empty.
(5) I create an enhancement on function module CRM_ORDER_MAINTAIN to inject my logger API there:
(6) In this last step, build an BSP application where a websocket is created to listen to the message sent from ABAP.
Create an BSP application with one page index.htm,
And paste the following HTML source code to it and activate:
<html ng-app="nameApp">
<head>
<meta charset="utf-8">
<title>Jerry's One Order Trace tool using ABAP Channels</title>
<script src="https://i042416.github.io/FioriODataTestTool2014/WebContent/angular/angular.js"></script>
<script>
var nameApp = angular.module('nameApp', []);
nameApp.controller('NameCtrl', function ($scope){
function getCurrentTime(){
return new Date().toLocaleString();
}
(function init(){
$scope.Ionames = ['Jerry\'s One order log tool'];
var startTime = 'Trace Start Time:' + getCurrentTime();
$scope.Ionames.push(startTime);
var that = $scope;
var sUrl = "wss://<host>:44300/sap/bc/apc/sap/zorder_log_apc";
var ws = new WebSocket(sUrl);
var onMessage = function(evt){
this.Ionames.push(getCurrentTime( ) + ':' + evt.data);
this.$apply()
};
ws.onmessage = onMessage.bind($scope);
})();
});
</script>
</head>
<body ng-controller="NameCtrl">
<ul>
<li ng-repeat="nameF in Ionames">{{nameF}}</li>
</ul>
</body></html>
You only need to use your own APC application url when creating Web socket instance.
要獲取更多Jerry的原創文章,請關注公眾號"汪子熙":
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24475491/viewspace-2715060/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 動手使用ABAP Channel開發一些小工具,提升日常工作效率
- 一個好用的SAP ABAP工作程式跟蹤工具
- 使用 ABAP 開發的一個基於 Web Socket 的小工具,能提高程式設計師日常工作效率Web程式設計師
- ABAP的許可權檢查跟蹤(Authorization trace)工具
- 使用ABAP實現一個最簡單的區塊鏈原型區塊鏈原型
- 使用ABAP實現Mock測試工具MockitoMockito
- 使用Spring Cloud Sleuth和OpenTelemetry實現分散式跟蹤SpringCloud分散式
- Oracle執行語句跟蹤 使用sql trace實現語句追蹤OracleSQL
- 在Unity中實現手部跟蹤Unity
- 淺談 Slack Channel 支援的一些提高工作效率的特性
- 使用dbms_monitor.session_trace_enable跟蹤一個會話Session會話
- 如何實現一個簡單的釋出訂閱模式模式
- 一個非侵入式跟蹤分析程式
- go 技巧: 實現一個無限 buffer 的 channelGo
- 如何實現Dolphinscheduler YARN Task狀態跟蹤?Yarn
- 一個提高工作效率的常用linux命令Linux
- 利用目標跟蹤來提高實時人臉識別處理速度
- 300行ABAP程式碼實現一個最簡單的區塊鏈原型區塊鏈原型
- Istio最佳實踐系列:如何實現方法級呼叫跟蹤?
- Qt - 原始碼跟蹤一個QtCreator就夠了QT原始碼
- 自己開發的一個SAP CRM訂單統計工具
- 幾個可以提高工作效率的 Python 內建小工具Python
- 在 React 應用程式中實現簡單的頁面檢視跟蹤器React
- 建立訂單實現冪等的一點思考
- MES改善實時生產跟蹤的7個技巧
- 基於OpenTelemetry實現Java微服務呼叫鏈跟蹤Java微服務
- 4個Excel技巧,提高你的工作效率!Excel
- PostgreSQL 跟蹤checkpointer出現死鎖SQL
- idea 使用外掛,提高工作效率Idea
- 如何用 MacBook 提高工作效率的【工具篇】Mac
- 日常工作效率工具集合:分享 7 款極簡免費小工具
- 擴充套件實現Unity協程的完整棧跟蹤套件Unity
- 使用 Python 和 Prometheus 跟蹤天氣PythonPrometheus
- 如何使用iPhone限制IP地址跟蹤iPhone
- ActionView - 更好用的問題需求跟蹤工具View
- 微服務分散式跟蹤工具Brave簡介微服務分散式
- 高效的任務跟蹤管理工具
- 使用WebSocket實現一個簡單的頁面聊天Web