Skip to Content

PO 7.5: XSL map with Java functions

Dear experts,

We are moving to SAP PO 7.5 and have XSL maps that call java functions.

I looked at the following guidelines/threads:
https://help.sap.com/viewer/0b9668e854374d8fa3fc8ec327ff3693/7.5.8/de-DE/4bf40f2cc0c33de4e10000000a42189e.html
https://archive.sap.com/discussions/thread/3424360

I modified one of our XSL maps in the following way.
I added the namespace for xsltc from apache and also added the cast for the Tracer Class:

<xsl:stylesheet
xmlns:xsltc="http://xml.apache.org/xalan/xsltc"
...
>
...
<xsl:variable name="traceLog">
   <xsl:value-of select="concat('TU details of product',$Matnr,' are incomplete')"/>
</xsl:variable>
<!-- TRACE BEGIN -->
<xsl:variable name="__function" select="trace:warning(xsltc:cast('com.edi.eai.xslthelper.log.XSLTracer',$traceLog))"/>
<!-- TRACE END -->
<xsl:message terminate="yes">
   <xsl:value-of select="xsltc:cast('com.edi.eai.xslthelper.log.XSLTracer',$traceLog)"/>
</xsl:message>
...
</stylesheet>


The Java code itself looks like this:

package com.edi.eai.xslthelper.log;

import com.sap.aii.mapping.api.MappingTrace;
import java.util.Map;

public class XSLTracer
{
  private static final String MAPPING_TRACE = "MappingTrace";
  private static MappingTrace trace;
  
  public static void initTrace(Map inputparam)
  {
  trace = (MappingTrace)inputparam.get("MappingTrace");
  }
  
  public static void warning(String logString)
  {
  try
  {
  trace.addWarning(logString);
  }
  catch (Exception localException) {}
  }
}


However, when I run the scenario which is an outbound MATMAS IDoc it fails because details of the material are not maintained but I do not get the expected message "TU details of product 665445 are incomplete" in the message log.

Instead I get:
Cannot convert data-type 'result-tree' to 'com.edi.eai.xslthelper.log.XSLTracer'

Please help me to find out what I am doing wrong.
Did I miss something in the XSL map?

Thank you, Peter

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    avatar image
    Former Member
    Oct 21, 2017 at 07:13 AM

    I was reading the documentation.you need to cast when passing the objects to the method. In your class it is just string.

    Here you are trying to convert string to type XSLtracer.can you check removing cast and pass only trace log.

    <xsl:variable name="__function" select="trace:warning($traceLog)"/>
    
    Add comment
    10|10000 characters needed characters exceeded