Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
former_member190293
Active Contributor

Recently I've seen the question about the ability to change messge data (or even message structure) in file pass-through scenario.

As we speak about "pass-through" it means that we didn't do any ESR development, thus we have no existing mapping objects in hands.

Ok, let's take that question as basis for our test scenario.

We have a source message containing some employees info in the form of .csv flat file:

ID0001,John Smith,20011001,Male

ID0002,Mary Ann Key,20000321,Female

And we want to send this message to receiver system in XML format:

       <ns:MT_Employees_List xmlns:ns="urn://ns_train">
        <Employees>
          <Employee>
           <EmployeeID>ID0001</EmployeeID>
           <Name>John Smith</Name>
           <DateOfBirth>20011001</DateOfBirth>
           <Gender>Male</Gender>

          </Employee>

          <Employee>
           <EmployeeID>ID0002</EmployeeID>
           <Name>Mary Ann Key</Name>
           <DateOfBirth>20000321</DateOfBirth>
           <Gender>Female</Gender>

           </Employee>

        </Employees>

   </ns:MT_Employees_List>


This pass-through scenario can be easily done by setting up File Content Conversion in our sender File channel and creating ICO object with dummy interfaces/namespaces in Integration Directory.

Now let's slightly change our requirements and say that we want to have emplyee's birth date in "dd/mm/YYYY" format in our target message (as per requirement in question mentioned above). As I'm lazy enough to start with ESR development or custom adapter module implementation in this case I'd prefer to unleash the power of XSL transformation and let the MessageTransformBean do the most of work instead of me :wink: .

XSL transformation for data format change:

<?xml version='1.0'?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="@*|node()">

  <xsl:copy>

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

    </xsl:copy>

</xsl:template>

<xsl:template match="DateOfBirth">

  <DateOfBirth>

  <xsl:value-of select="concat(substring(., 7, 2), '/', substring(., 5, 2), '/', substring(., 1, 4))"/>

  </DateOfBirth>

</xsl:template>

</xsl:stylesheet>

We put this transformation to our PI server file system and just add the MesasgeTransformBean in our receiver File communication channel with parameters:

Transform.Class = com.sap.aii.af.sdk.xi.adapter.XSLTConversion

XSLTConversion.XSLTFileName = /usr/sap/PID/SYS/global/NOVATOUR/Inbound/XSLT/BC_Train_Test.xsl

As the result we can see desired changes in message data:

<ns:MT_Employees_List xmlns:ns="urn://ns_train">
<Employees>
<Employee>
<EmployeeID>ID0001</EmployeeID>
<Name>John Smith</Name>
<DateOfBirth>01/10/2001</DateOfBirth>
<Gender>Male</Gender>

</Employee>

<Employee>
<EmployeeID>ID0002</EmployeeID>
<Name>Mary Ann Key</Name>
<DateOfBirth>21/03/2000</DateOfBirth>
<Gender>Female</Gender>

</Employee>

</Employees>

</ns:MT_Employees_List>

Regards, Evgeniy.

3 Comments
Labels in this area