Applying Enterprise Integration Patterns in SAP ABAP

2
5

In this article, I will try to explain how to apply Enterprise Integration Patterns in ABAP. Do not be scared with the sophisticated term. By the time you finish reading this page you would realize it is the hi-fi name given to the sequence of patterns messages coming to SAP. 🙂 . So please be with me.

Gregor, H & Woolf, B. (2003), “Learning the technology, however, is just the first step—the real goal is to learn how to effectively apply the technology”.

Since 2001 in my entire professional career I worked in Microsoft Technologies. But in 2013 the company I work started a transformation project and I got the once in a lifetime opportunity to start as an ABAP developer I took the courses and did my certification. I was seasoned in Microsoft areas but I was still a beginner at SAP ERP world and my first challenge was to fix an incident that was a high priority for the company.

The problem was that the message transactions at SAP POS DM (Point of Sale Data Management) were duplicating. The problem occurred when the sender system for external reasons re-sent a pack of messages, in consequence, duplicating transactions which could be visualized in the POSDM Workbench (T-Code /POSDW/MON0) and the impact for the business was that the management department couldn’t reconcile the sales figures of the day.

SAP POS DM (Point of Sale Data Management)

SAP POSDM assumed that at times you would have some transactions duplicated because it needs to resend the message (for some business need) but just a few exceptions, not hundreds of duplicate messages every day. So from the point of view of integration, we can relay in the sender so every message of every asynchronous interface should implement the Idempotent Receiver (one that can safely receive the same message multiple times) integration pattern. This, of course, was not yet implemented at the message bus service. In our case, the sender was SAP PI and the receiver configuration was an RFC adapter direct call that doesn’t support the quality of service.

The Idempotent Receiver pattern resolves how a message receiver deals with duplicate messages. Another alternative could be at the services layer such as web service, a reliable message that could guarantee ATOMIC message transaction (i.e. a set of distinct changes as a single operation) but that would be another post. Today we would see what we did to implement Idempotent Pattern in the receiver interface in SAP ABAP using Enterprise Integration Patterns.

An enhancement or a custom ABAP program Idempotency according to Gregor, H & Woolf, B. (2003) can be achieved through two primary means:

  1. Explicit “de-duping“, i.e. the removal of duplicate messages.
  2. Defining the message semantics to support Idempotency.

In our case, e decided to use option number one by keeping track of messages that it already received with the help of a unique message identifier. For this we identified the Remote Function Module (RFC) that was used in the message flow to transmit messages from PI to SAP. The prized RFC was /POSDW/CREATE_TRANSACTIONS_EXT. We were looking for an option to enhance it and lucky, at the very beginning of the function we found and enhancement point. So without any hesitation we implemented the enhancement point section to meet our requirement. 🙂

Explicit "de-duping", i.e. the removal of duplicate messages.

Our design approach was simple yet effective considering the need of the hour. We created a transparent table for recording the messages received with a unique key using the GUID (Global Unique Identifier). This GUID was part of the incoming parameters of the function and it is sent and generated by SAP PI for each message. The second field FECMOVTO was the timestamp that we used for archiving purposes.

GUID

Once we created the table we implemented the pattern. If the incoming message did not exist in the table then it would be persisted else it would be discarded. Simple and sweet. Isn’t it? 🙂

implemented the pattern

According to Gregor, H & Woolf, B. (2003), a unique message identifier simplifies this task and helps detect those cases where two legitimate messages with the same message content arrive. By using a separate field, the message identifier, we do not tie the semantics of a duplicate message to the message content.

DATA GROWTH

There was another concern for our IT Architect team. That is, what about the table size? With time old records should be archived. For this, we wrote a simple deletion program using the time stamp saved in the table.

This program gets the total number of records defined in the input parameters and delete from the table for data prior to the date indicated in the selection screen.

SAP ABAP Training

Remember, I was a fresher to SAP ERP and SAP ABAP. This was my first assignment as an ABAPer. A scary one though. 🙂 But some principles hold good across technologies. For me, knowing how to use patterns provided me the solutions in ABAP (even without much experience). And I might decide to use this pattern again in future in any other new platforms as well. 🙂 Just the syntax changes, the developer’s mind designs/develops in the same manner across platforms. Isn’t it? 🙂

References:

Gregor, H & Woolf, B. (2003). Enterprise Integration Patterns. USA: Addison-Wesley Professional.

OASIS Standard, 15 November 2004, Web Services Reliable Messaging TC

WS-Reliability 1.1

https://en.wikipedia.org/wiki/Universally_unique_identifier

We put a lot of effort in conceptualizing, testing and writing each and every article. If you could pass this link to at least 5 colleagues/friends who you think would benefit from our post, it would be a great favor to our team. We want our articles to reach to as many audiences as possible so that everyone would benefit and our team would remain motivated and our work does not get lost in this huge ocean of the internet.

Please, please share our post in your professional and social media and introduce your friends/colleagues/co-workers to our blog page.

Also, check our popular step by step tutorials on some of the important topics of SAP ABAP.

1. ABAP for SAP HANA Tutorials
2. ABAP Web Dynpro Tutorials
3. GOS Tutorial
4. OOPs ABAP Tutorial
5. HANA Tutorial
6. SAP Netweaver and OData Tutorial
7. SAP Adobe Form Tutorial
8. SAP Fiori Tutorial
9. SAPUI5 Tutorial
10. SAP Screen Personas Tutorials

2 COMMENTS

LEAVE A REPLY

Please enter your comment!
Please enter your name here