ABAP Daemon Framework
Use ABAP Daemons, to implement event handling.
ABAP Daemons are long-living ABAP sessions. The application server takes care that once an ABAP Daemon was started, there is no limit for the lifetime of such ABAP session.
Even if there is an ABAP runtime error, or a work process in the application server crashes, the ABAP Daemon session gets restarted immediately.
ABAP Daemons have event-driven programming model (similar to ABAP Channels) which contains the typical event handler API for your implementation needs with such methods like on_start, on_message, on_error etc.
You can start an ABAP Daemon and send messages to it. Please consider, that each ABAP Daemon runs under a given user, and therefore the messages to it can be sent only within the same client. If you need to send the system-wide messages to your ABAP Daemon you can use ABAP Messaging Channel (AMC).
ABAP Daemons are available with SAP NetWeaver AS ABAP 7.52. The startup configuration was added to ABAP Daemons in ABAP platform 1809.
Demo programs
- DEMO_ABAP_MINI_DAEMON
- demo_abap_daemon
Use cases
- Just imagine if multiple sensors are connected to the ABAP system, the ABAP server receives too many incoming messages. These messages cannot be processed concurrently, but it is possible to queue them by starting an ABAP Daemon session and sending messages to it. This central scheduling ABAP Daemon session will be always available for event processing.
- You can also use ABAP Daemons for lightweight background activities like e.g. tracing, logging, clean-up of resources, synchronization of caches. The advantage is, that the logging, tracing etc. messages are sent to the ABAP Daemon without DB commit using ABAP Messaging Channel (AMC), therefore sending event to the ABAP Daemon will not break your LUW (Logical Unit of Work).
- You can also use ABAP Daemons for very frequent periodic tasks e.g. like health checks. The advantage is that you do not need to create a new ABAP session for each task execution and no background work process is needed. For heavyweight periodic tasks, that run at most once a day, we recommend using batch jobs.
- You can use ABAP Daemon also as a proxy session for external communication
- Let suppose user/business want to procure some asset/item ( e.g. laptop/ Heavy machinery for factory). So in this process, different document are created to complete the procurement. After each documents(or events) creation/posting, I want certain custom table to be updated & outbound IDOC message should be trigger. The step of updating the table & sending IDOC will be handle by daemon instance. Below are I tried to explain how complete business process will flow for my example.
- Example from SCN
- ( https://blogs.sap.com/2020/05/17/implement-adf-abap-daemon-framework/ )
- Business/user raise request in some portal of the legacy system for procurement of asset and request details sent to S/4 HANA (1909) system via interfacing technology AIF (Application Interface Framework).
- Upon receiving AIF message, different documents created (e.g. Internal Order, Asset Master & Purchase Requisition).
- The document created in this step needs to be updated in the custom table (for reference) & trigger an outbound is sent.
- The next step, Purchase Order created with reference to the Purchase requisition. The Purchase order also needs to be updated in the custom table & trigger an outbound is sent.
- Next step, supplier sends physical asset. This leads good receipt in the S/4 HANA. The goods receipt details were received via AIF which results in Material document posting. The Material documents need to be updated in the custom table & trigger an outbound is sent.
- Lastly, the Supplier sends an invoice via AIF which leads to purchase Invoice creation in the system in S/4 HANA. The Invoice documents need to be updated in the custom table & an outbound is sent
- Each Inbound/Outbound message or document create/change/delete can be considered as event in ABAP.
Comments
Post a Comment