write mapping message to RWB audit log when ICO is used in PI 730
The integrated Configuration(ICO) is recommended to be used in PI 730 because of the high performance of AAE. However the mapping error track mechanism is not as user friendly as that in ABAP stack. For the traditional ID contents combination in ABAP stack, no matter message mapping, java mapping or XSLT mapping is used, the error message can either simplly send out by throwing an exception or using <xsl:message/> and the error message will be shown in the ERROR tag in tcode: SXI_MONITOR. By analysing the error message in SXI_MONITOR is one of the most effective ways for a PI developer to locate the defect.
However when ICO is used, this becomes a different story. In the audit log of runtime workbench, the log just shows information like message is retrieved into the queue, the mapping is failed/successful etc. It won’t display mapping error message, nor can it show the message from the exception directly. Java class like Abstracttrack cannot populate message to the audit log either.
I just found a way to write message from mapping to RWB audit log by using Java class AuditAccess. Wish you find it useful for you. Here is the tutorial when XSLT mapping is used. For message mapping or Java mapping, the process is almost the same.
Prerequisits:
1. you have to know how to use NWDI to develop Java class
2. you have to know how to create imported archive in PI ESR
3. you have to know how to get the source message id in the mapping process.
Steps:
1. download the JAR file com.sap.aii.af.ms.ifc_api.jar
2. create a Java class in NWDS and import the JAR file as the external source. Here is the Java source code ( i am totally new to Java. please ignore silly mistakes made in Java programming)
package com.xxx.util;
import com.sap.engine.interfaces.messaging.api.*;
import com.sap.engine.interfaces.messaging.api.auditlog.*;public class errorLog {
public static void execute(String errorMsg,String messageid) {
MessageKey key = null;
AuditAccess audit = null;
try{
audit = PublicAPIAccessFactory.getPublicAPIAccess().getAuditAccess();
key = new MessageKey(messageid, MessageDirection.OUTBOUND);
audit.addAuditLogEntry(key, AuditLogStatus.ERROR, errorMsg);
}catch (Exception e) {
Exception me = new Exception(e);
}
}
}
Info: there are two import parameters of the method:
a) The message you want to displayed in the audit log;
b) The source message id.
3. Create an imported archive by using the JAR file exported from the developed Java class.
4. In your XSLT mapping, insert the following relevant code:
4.1 Add a namespace prefix definition like this
<xsl:stylesheet version=”1.0″ …. xmlns:el=”com.xxx.util.errorLog”>
4.2 Receive runtime constant messageid. For message mapping or java mapping, message id can be get by deriving dynamic configuration.
4.3 Pass message by calling Java method
<xsl:choose>
<xsl:when test=”function-available(‘el:execute’)”>
<xsl:value-of select=”el:execute($message,$MessageId)”/>
</xsl:when>
<xsl:otherwise>errorLog->execute is not available.</xsl:otherwise>
</xsl:choose>
info:
Constant $message will be the error message to be displayed in the audit log;
Constant $MessageId is the message ID from runtime
Here is the sceenshot of the result:
wish you find it useful. 🙂
Nice to know on this.
But we can always see exact error in case of mapping errors in monitoring tool - audit log.
It shows the same message which you will get when you test the mapping with same payload in test tab of Message mapping.
Thanks for putting uses of AuditAccess class.
Cheers,
Divyesh
Divyesh Vasani .
Yes we can find the error messages in audit log . But the process is too complex.
There is no communication channel logs now .
only way is go to message mapping errors and then audit logs .
🙁 monitoring is now another challenge in new PI.
Hi Stephen,
Thanks for the blog.
I have a very similar requirement like above. I tried exactly the same code in my jar as provided by you and called the errorLog class from graphical mapping using UDF. I could see the messageID successfully deilvered to the errorLog class, but on executing the message is not failing in AE. The message gets successfully delivered without creating any auditlog entry for error.
Can you please also inform if there is any separate configuration is required to make this work or do we need to separately raise a runtime exception before calling the addAuditLogEntry() method.
Regards,
Rahul
hi Rahul
After the error message has been sent to the log, you'd raise an exception to stop the mapping.
Then you can check the log in the NWA, to see what has happened in the runtime.
btw, how many times did you call the errorLog method in your mapping?
Hi Stephen,
Thanks for the quick reply.
I am calling the errorLog method only once in my mapping. Also I tried throwing RuntimeException after errorLog method returns but I am getting only the exception message as a generic mapping exception.
Regards,
Rahul
Hi Stephen ..
Thanks for sharing your find.. Will it work for AAE scenarios in PI 7.1x ?
Regards,
Krishna
Hi Stephen...
I got same as above scenario. I am using same code as above for java but couldnot able to get the error in RWB.
My code in XSLT is as follows:
<xsl:choose>
<xsl:when test="$result=''">
<xsl:choose>
<xsl:when test="function-available('el:execute')">
<xsl:value-of select="el:execute('UNITS',$MID)"/>
<xsl:message terminate="yes"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="NULL"/>
</xsl:otherwise>
</xsl:choose>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$result"/>
</xsl:otherwise>
</xsl:choose>
Regards,
Ramji.
Hi,
Can anyone help me to resolve the above issue.
Thanks & Regards,
Ramji.
hi Ramenji
please refer to the log writen by Vadim:
Process Integration (PI) & SOA Middleware
it seems that the AAE cannot recognise any UUID without hyphens. i've tried it and it works. wish you find it useful.
Hi Stephen,
I tried to use the import statements
import com.sap.engine.interfaces.messaging.api.*;
import com.sap.engine.interfaces.messaging.api.auditlog.*;
but its giving errors. Do I need to include some external jar files in the scenario to eradicate the errors.
Thank you so much for writing this very helpful blog.
Regards
Anupam