Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the implementation of the SAP ABAP daemon

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

What this article shares with you is about the implementation of the SAP ABAP daemon. The editor thinks it is very practical, so I share it with you to learn. I hope you can get something after reading this article.

Many services of Linux system are implemented by daemons. The common daemons are system log process syslogd,web server httpd, mail server sendmail and database server mysqld.

So can reports with daemon characteristics be implemented in ABAP? This requirement is translated into ABAP terminology, that is, is it possible to develop an ABAP program that meets the following characteristics?

The terminal (SAPGUI or ABAP Development Tool) can continue to run after it is closed, and can continue to receive user input, process and push the results to the user.

Many friends will soon think of ABAP background homework. Yes, developing an ABAP report and starting it as a background job can indeed achieve the effect of running away from the terminal. However, this kind of background job can no longer accept user input in an ordinary way, and a more cumbersome solution is to adopt the producer-consumer idea and define a database table to act as a task queue; the user inserts the request into the database table, and the background job program periodically queries the database table, if it is not empty, the request is taken out and processed.

Another idea is to create a new node in the transaction code SICF and write the processing logic in its handler class so that consumers can send HTTP requests to the url that the ICF node is responsible for and receive the processing results.

In the previous article, Jerry, a 13-year-old ABAP veteran suggested: understanding these basic knowledge will do no harm to ABAP development. ABAP servers interact with the outside world through HTTP and will go through the module Internet Communication Manager (ICM). On the surface, the ABAP program implemented in this way barely imitates the effect of the daemon, but the performance of request processing is far from that of the real daemon. And it is essentially implemented with the help of Web server.

The good news is that ABAP Platform 1809, released by SAP in 2018, mentions some exciting new features, such as enhancements to Industrial Internet of things (Industrial IoT) and Machine-to-Machine communications, the introduction of MQTT, and native support for ABAP Daemons.

In this article, we use ABAP MQTT and ABAP Daemons newly introduced in ABAP platform 1809 to implement a Hello World-level ABAP daemon.

MQTT (Message Queuing Telemetry Transport, message queuing Telemetry Transport Protocol) is a lightweight communication protocol based on publish / subscribe mode, which is built on TCP/IP protocol. Because of its low overhead and low bandwidth consumption, it is widely used in the Internet of things, small devices, mobile applications and so on.

For more information on what's new in ABAP platform 1809, please refer to the SAP Community blog:

Https://1/abap-platform-for-sap-s4hana-1809/http://, you can use the following MQTT client implemented in webSocket to manipulate the broker:

Http://www.ket-client/

This broker is designed for testing purposes. After receiving the MQTT message, it will reply to the sender intact.

Connect MQTT broker in the constructor of the ABAP class, store the returned MQTT client instance in the class member variable mo_mqtt_client, and then use the publish method of the instance to send the message, the subscribe method to subscribe to the message, and the on_message method to receive the message.

Open the MQTT client and subscribe to abaptopic/jerry/test.

Then I first send a Hello World message to the channel on line 66, and broker will return it intact when it is received, but because my ABAP class does not subscribe to this channel, I will not receive a reply to this hello world message.

After line 68 subscribes to the channel, line 69 sends a second message to broker, and you will receive its reply this time.

Go back to the broker client and see two messages sent from the ABAP side:

Go back to the ABAP side and see the reply to the second message sent on line 69:

Once we understand the use of ABAP MQTT, we can start developing the ABAP daemon. Although the ABAP daemon does not directly use MQTT to interact with the consumer, mastering the use of this message notification mechanism is also helpful for us to understand how the ABAP daemon works.

Create a new ABAP class zcl_jerry_simple_daemon and set cl_abap_daemon_ext_base as its parent class.

These ON-beginning methods inherited from the base class are places where developers can implement custom logic when ABAP daemon life cycle events occur, such as when the system SHUTDOWN is triggered by the ON_SYSTEM_SHUTDOWN method implemented by the developer, where the daemon cleans up and exits gracefully.

The most useful method is undoubtedly ON_MESSAGE, which is where the daemon receives user input and responds.

For simplicity, when my daemon receives user input, it just pops up a pop-up dialog box that appears in SAPGUI:

The start of the daemon is realized by the start method of the framework class cl_abap_daemon_client_manager. The parameter lo_pcp passed in the start method on line 75 is passed as the daemon startup parameter, and pcp stands for Push Channel Protocol, a data structure for message transmission.

Start the daemon and name it jerry_daemon using the following statement:

Zcl_jerry_simple_daemon= > start (iv_daemon_name = 'jerry_daemon').

You can see all the running daemons in the transaction code SMDAEMON:

Open SAPGUI and send a message to jerry_daemon, the ABAP daemon, using the following method, and you will immediately see the dialog box popping up in the daemon's on_message method in SAPGUI:

Therefore, in the future, if we encounter ABAP programs that need to run away from the terminal for a long time and still need to respond to user input, in addition to ABAP background jobs and SICF services, there will be more ABAP daemons.

This is how the SAP ABAP daemon is implemented, and the editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report