Use ABAP channel to develop some small tools to improve daily work efficiency


Today’s story starts with ABAP games.

ABAP practitioners in China have more or less collected some ABAP games, such as the following.

Kill the stars:

Mine clearance:

From my friend Liu Meng, public account“SAP dry goods shop“Tetris in:

Draw with ABAP:

As well as the table tennis game developed with ABAP channel technology, which will be discussed today, can also support doubles and embarrassment.

I always have an idea in my mind. German developers, who are famous for their strictness and rigour, how would they react to these little games popular in ABAP ecosystem in China?

Last year, I did standard development in SAP Germany headquarters, and often attended some meetings. At one meeting, I and several other CRM German colleagues were waiting for the arrival of an S / 4hana colleague in the conference room. You may ask, Germany is known for being punctual. Why are working meetings late?

That’s because SAP’s German headquarters is very large, with more than 20 buildings in total. Below is the first building built by SAP Germany headquarters in Walldorf in late autumn. We used to call it building 1, and I was working in it.

The side of the building looks like this, taken in early summer:

More than 20 buildings are scattered around the park:

At that time, the S / 4hana colleagues who attended the meeting were working in building 3. They had just finished the last meeting. At Jerry’s walking speed, it took five minutes to walk to the conference room of Building 1.

While waiting for his colleagues, Jerry connected his computer to the projector and showed them to several other German colleagues. When my colleague Carsten, the chief architect of SAP CRM, saw the minesweeping game written by ABAP, he couldn’t help laughing and said that it was the most popular game he played under the Windows 98 system.

Finally, S / 4hana’s colleagues arrived at the conference room. At this time, the projector was playing the table tennis game written by ABAP channel. The German colleague stared at it for a while and said humorously, “am I in the wrong room?”

Here is the text.

    • *

ABAP channel is a new event driven communication technology released by NetWeaver 740. The underlying implementation is based on websocket and tcpsocket.

CRM consultants who have worked in the sap CRM call center must be impressed by the polling mechanism of this product. Because of the technical limitations at that time, there was no way to notify the foreground webclient UI interface whenever there was an event in ABAP background. In order to display the latest data, the foreground has to periodically initiate polling to the ABAP background at a fixed time interval.

This polling behavior can be easily observed with chrome developer tools: the figure below shows that CRM call center sends an HTTP request to the background every 1 second for polling.

In 2014, NetWeaver 740 released ABAP channel technology based on Web socket protocol, so CRM call center also adopted this technology to replace the previous clumsy and inefficient polling solution.

For more information, please refer to Henning’s blog:

Replace polling in CRM Interaction Center by ABAP Push Channel

Many colleagues of SAP Chengdu Research Institute who have done CRM development have dealt with Henning, who is a German with profound business knowledge in CRM field and very kind at the same time.

Many SAP practitioners have published various blogs about ABAP channel on SAP community website, including many examples developed by SAP itself, which are published together with NetWeaver.

Jerry will not repeat these examples. Please refer to this article for interested friends:

ABAP Channels Examples

Today, I want to share a specific example of how jerry can use ABAP channel to improve the efficiency of daily work analysis problems.

ABAP practitioners often need to use a variety of tracking and performance monitoring tools when doing projects, the most typical of which are ST05 and sat. Jerry really thinks these tools are very useful for ABAP developers. The only blog Jerry has read more than 100000 in SAP community is this article about alternative uses of ST05 and sat:

Six kinds of debugging tips to find the source code where the message is raised

(in September 2016, the sap community was revised and moved to the sap cloud platform. After the migration, all blogs have been cleared of reading, so now this blog only sees more than 40000, not 100000)

However, Jerry believes that at present, all these tools in NetWeaver have one limitation: developers have to manually open the tracking mode of the tool and run the application in this mode. After the operation, either turn off the tracking mode manually or turn off automatically by the tool. In other words, none of these tools can be used when the application is running.In real timeProvide information that developers need.

Last year, I participated in the reconstruction and prototype development of the original CRM one order framework migrating to S / 4hana in Germany. For details, please refer to my public account article: Hello world, S / 4hana for customer management 1.0.

After the prototype development is completed, it has to be tested. I have to do a series of the same operations on the new s4crm UI as the old CRM before, and then observe whether the input parameters passed in the API and the output parameters returned by the API are correct.

At first, I used to set breakpoints in the API and check them in the ABAP debugger. Soon I found that the efficiency was very low: as the CRM development consultants all know, the number of input and output parameters of APIs such as CRM? Order? Maintain / read is very large. In the ABAP debugger, you have to select one and double-click it to see it. After reading it, you can go back and double-click it to see the other. If you want to check all the parameters of the API, you need to use the mouse more than 100 times.

What jerry can’t stand is the repetitive physical work. Is there any way for NetWeaver to be like the cloud foundation programming environment of SAP cloud platform?

cf logs <app name>After the command, what happens when the running application generates logs that are splashed on the browser? Yes! Use ABAP channel.

So I started to develop a tool. See how to use this tool: a BSP application, accessed in the browser:

Then switch to the one order application directly and operate as usual. For example, to create a new service order, maintain the following fields:

Then switch back to the tool I made. The input and output parameter contents of one order API have beenIn real timeIt’s displayed in the browser, and there’s no need to go to the debugger to perform tedious click operations.

Because it is displayed through a browser, I can also search by keywords directly using Ctrl + F, which is not possible in sapgui. Later, I also recommended this tool to Carsten.

Here are the detailed development steps of the tool.

1. Transaction code SAPC, create a new APC (ABAP push channel) application zorder ﹣ log ﹣ APC, and select websocket as the connection type.

Click the “generate class and service” button to automatically generate the processing class and ICF node.

2. Create a new AMC (ABAP message channel) application named zorderlog with transaction code SAMC.

Maintain the name of ABAP class automatically generated by APC application in the first step under authorization program. The purpose of this step is to specify the ABAP processing class name for data sending and receiving through websocket in the ABAP channel scenario. Set channel ID/order_logCopy it down.

3. From the above figure, I know that I have specified the ABAP class CL? CRM? Order? Logger to send the logs generated by the application calling the one order API to the web socket. Therefore, this class needs to be programmed in this step. The full code is on my GitHub, and I’ll just cover the main points here.

In the static constructor, the AMC ID and channel ID created in the second step are passed into the constructor of the producer. Indeed, the scenario of ABAP channel is a typical producer / consumer mode. Messages produced in ABAP background are sent to the browser through web socket for consumption.

The message is sent through the send method below.

4. Redefine the on start method of the processing class automatically generated by the APC application in step 1:

In this method, the APC application created in the first step is bound to the AMC application created in the second step.

5. Create an enhancement for API CRM? Order? Maintain to inject my CL? CRM? Order? Logger. In this way, every time the API is called, it will automatically log and send it to the browser through the web socket.

The above five steps are the implementation of ABAP channel producers. Here is the development of the consumer, the web application running in the browser.

Create a BSP application and maintain the following code in index.htm:

Line 17 declares the web socket URL for front and back communication:

In this way, the development of consumers is finished.

In the actual work, when you encounter tedious and time-consuming physical work, you can also think about whether you can use tools to reduce workload and improve work efficiency. Thank you for reading.

More reading

  • Talk about C language and ABAP
  • Jerry’s ABAP, Java and JavaScript
  • Jerry’s collection of ABAP original technical articles
  • What ABAP developers should learn in the future
  • Jerry’s May Day holiday in 2017: ABAP implementation of eight classical sorting algorithms
  • Where are the developers over 35 years old of SAP Chengdu Research Institute?
  • The double stick road of an SAP developer

For more original Jerry articles, please pay attention to the public account “Wang Zixi”:

Recommended Today

Sharing 10 useful methods of laravel 5.8 sets

This article is forwarded from the professional laravel developer community, original link:… In laravel, there is a very useful class for manipulating arrays, called collections. I believe that every developer of laravel has used the collection more or less, especially when operating eloquent. In this article, I will list 10 common methods. 1. Weight […]