Skip to Content

As you all probably know while using local Advanced Adapter Engine (AAE) processing in SAP PI 7.1 the message is logged only once (during processing by sender adapter). This is great in terms of performance but what if we need to check the mapping output? Is there a way do do it somehow? It turns out that we don’t have such an option in standard yet. Is there any alternative then?

It turns out there is – a simplest adapter module there is…

Local AAE works in such a way that from the sender adapter it executes the receiver adapter so in the outbound message to PI processing you can see the adapter info logs of the receiver adapter and this is what we can use. The idea is to add an adapter module to the receiver adapter which will put the content of the message into the audit log of PI message processing. We can do it by writing a few lines of code:

 import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import javax.ejb.SessionContext; // Classes for Module development & Trace
import com.sap.aii.af.lib.mp.module.*;
import com.sap.engine.interfaces.messaging.api.*;
import com.sap.engine.interfaces.messaging.api.auditlog.*;

public class LogAdapterXMLBean implements SessionBean, Module {
 
 private SessionContext myContext;

 public void ejbRemove() {
 }

 public void ejbActivate() {
 }

 public void ejbPassivate() {
 }

 public void setSessionContext(SessionContext context) {
  myContext = context;
 }

 public void ejbCreate() throws CreateException {
 }

 public ModuleData process(ModuleContext moduleContext,
   ModuleData inputModuleData) throws ModuleException {

  AuditAccess audit = null;

  Object obj = null;
  Message msg = null;

  MessageKey key = null;
  try {
   obj = inputModuleData.getPrincipalData();
   msg = (Message) obj;
   key = new MessageKey(msg.getMessageId(), msg.getMessageDirection());
   audit = PublicAPIAccessFactory.getPublicAPIAccess()
     .getAuditAccess();
   audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,
     “Set this: Module called”);
   
   XMLPayload xmlpayload = msg.getDocument();
   
   audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,
   “Below the content of the message”);
   audit.addAuditLogEntry(key, AuditLogStatus.SUCCESS,
   xmlpayload.getText());
   
   
  } catch (Exception e) {
   ModuleException me = new ModuleException(e);
   throw me;
  }
 
  return inputModuleData;
 }

}

 

Then we just need to add the adapter module to our receiver communication channel which is using local AAE.

and Voilà – we should see the content of the target message in the audit section of the sender communication channel.

And the best part of that is that we can easily turn it ON and OFF whenever we like so it will not affect performance during life scenarios.

Please let me know if you like this idea 🙂

To report this post you need to login first.

13 Comments

You must be Logged on to comment or reply to a post.

      1. Sudharshan Aravamudan
        Michal,
        Excellent idea as usual 🙂

        Any thoughts on the detailed mapping trace in case of errors. It seems that AAE does not display the mapping trace (standrad/user added trace) in detail in the audit log.

        Thanks,
        Sudharshan N A

        (0) 
  1. JaiShankar Ramakrishnan
    Hi Michal

    Great idea!!! (Do I need to say as usual, isn’t that a given in Michal’s blogs?)

    Just wondering what is the logic behind getting the target message in sender channel? Should this not be part of Reciverf channel? What am I missing?

    Please enlighten

    (0) 
    1. Michal Krawczyk Post author
      hi,

      >>>Just wondering what is the logic behind getting the target message in sender channel? Should this not be part of Reciverf channel? What am I missing?

      there is no receive channel logging in “local AAE” – message is logged only once – in the sender channel 🙂

      Regards,
      Michal Krawczyk

      (0) 
  2. Yash Agarwal
    Its indeed a great blog and resolves a few of the anxious queries which we have with AAE.
    The other issue which we face is seeing mapping errors in AAE scenarios. How do we get that?

    Yash

    (0) 
    1. Michal Krawczyk Post author
      Hi,

      >>>The other issue which we face is seeing mapping errors in AAE scenarios. How do we get that?

      will let you know 🙂

      Regards,
      Michal Krawczyk

      (0) 
        1. Yash Agarwal
          Hi Michal,

          Any update on how to catch mapping errors in AAE scenarios in PI 7.1x (not 7.3 which is the talk of the town nowadays :))!

          – Yash

          (0) 

Leave a Reply