Skip to Content
Technical Articles
Author's profile photo NarayanaSwamy Mariyala

Notification/Response from SAP PI in Asynchronous Scenario

Hi All,

This blog will give a quick overview on achieving the below use cases without involvement any 3rd party system development.

  • How to avoid duplicate transactions to the target system based on business Key/File Name etc.
  • How to send acknowledge back to sender with “another call” or to the logger DB without need of receiver acknowledgment.

IFlow/Interface to be developed with Sender and two receivers.(One actual receiver and second receiver which is sender with the dedicated receiver comm.channel).

Avoiding duplicates:

First Mapping

1)User defined search to be configured for the business key or file name which ever would be the unique for the transaction.

2)Message Retention to be defined for the respective interface to ensure the User defined search key entries availability on DB table: XI_AF_LMS_DATA.

Note: This is needed since default archive Job might clear the entries.

Retention(Days) should be defined based on the business case.

Configuration and Administration——>Message Retention

Message Retention can be validated using the option

Message Details:—>Persist value is matching as per the duration defined in the Message Retention.

3)Build an another sub process with simple request and response structures and AdapterMessageMonitoringVi api for the SOAP Action@getUserDefinedSearchMessages.

Expose this subprocess as a webservice and make a SOAP Lookup to ensure whether this transaction is valid or not. If we get the response for <rn7:number>1</rn7:number> then it is valid otherwise it’s already have one message sent.

Note: In case of first transaction get’s failed for any reasons and if it is really valid transaction to process with the same business key/file name from source side then it is advisable to consider other parameters as well. Subprocess is not mandatory but it is good to have for better governance.

API Schema can be downloaded using anyother tool and I used SOAP UI and below is the process.

  • Create new SOAP Project by calling the URL: http://<pohostname>:<poportname>/AdapterMessageMonitoring/basic?wsdl&mode=ws_policy&style=document
  • Download the wsdl by Select–>basicBinding(rightclick)—>Export Definition.

It is required XSLT mapping/JAVA mapping to form the response message in the mapping.

Working XSL Code as below.

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
 xmlns:ns0="urn:AdapterMessageMonitoringVi">
 <xsl:output omit-xml-declaration="yes" indent="yes"/>
 <xsl:strip-space elements="*"/>

 <xsl:template match="node()|@*">
     <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
 </xsl:template>

 <xsl:template match="getUserDefinedSearchMessagesResponse">
  <xsl:element name="ns0:{name()}" namespace="urn:AdapterMessageMonitoringVi">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>

<xsl:template match="Response">
  <xsl:element name="ns0:{name()}" namespace="urn:AdapterMessageMonitoringVi">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>

<xsl:template match="number">
  <xsl:element name="ns1:{name()}" namespace="urn:com.sap.aii.mdt.server.adapterframework.ws">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>

<xsl:template match="list">
  <xsl:element name="ns1:{name()}" namespace="urn:com.sap.aii.mdt.server.adapterframework.ws">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>
 
 <xsl:template match="AdapterFrameworkData">
  <xsl:element name="ns1:{name()}" namespace="urn:com.sap.aii.mdt.server.adapterframework.ws">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>
 
 <xsl:template match="messageID">
  <xsl:element name="ns1:{name()}" namespace="urn:com.sap.aii.mdt.server.adapterframework.ws">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>
 
 <xsl:template match="receiverName">
  <xsl:element name="ns1:{name()}" namespace="urn:com.sap.aii.mdt.server.adapterframework.ws">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>
 
 <xsl:template match="status">
  <xsl:element name="ns1:{name()}" namespace="urn:com.sap.aii.mdt.server.adapterframework.ws">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template>
 
 <xsl:template match="parentID">
  <xsl:element name="ns1:{name()}" namespace="urn:com.sap.aii.mdt.server.adapterframework.ws">
   <xsl:copy-of select="namespace::*"/>
       <xsl:apply-templates select="node()|@*"/>
  </xsl:element>
 </xsl:template> 
  
</xsl:stylesheet>

 

4)Lookup the above service based on business key and fetch the status.

 

Acknowledgement to Sender:

Second Mapping

1)Need to write an udf to fetch the message ID. Output would be the child message ID

2) Timer/Sleep thread : Which should be as low as possible since many transaction might be on hold which might cause heap memory issue. This step is optional since default resend job will run for every 5 mins which will also take the message thru in next steps.

3)Sub process to be developed to the AdapterMessageMonitoringVi api for the SOAP Action@getMessagesWithSuccessors and fetch the parent message ID based on the child message ID. This should be exposed as a SOAP Lookup and can be plugged in. This response message would require XSL/JAVA mapping and above code can be used with little changes. Sub process is not mandatory but it is recommended to give the quick visibility for any failures instead of direct lookups to the api.

4)Another subprocess to be developed to fetch the Delivered status of the message which was sent to the actual receiver. SOAP Action: getMessagesWithSuccessors.

5)Based on the response message we can trigger the notification to the receiver back(Sender).

 

Hope this will helpful and this solution can be considered based on the system load.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.