This document gives you clear understanding of XSLT Mapping, which shall convert source structure to specific target structure.
Below are different ways of achieving this conversion in XI,
- Message Mapping (Graphical Mapping using Mapping Editor in XI )
- Java Mapping
- ABAP Mapping
- XSLT Mapping
The rest of the document gives you pre-requisites and steps that are necessary for making use of XSLT Mapping.
- XSL – Extensible Style sheet Language
- XSLT – XSL Transformations, the purpose of this is for transformation of XML documents into other formats like XML, XHTML and etc.
- XPATH – XSLT uses XPATH to find information in an XML document. XPATH is used to navigate through elements and attributes in XML documents.
Steps required for developing XSLT Mapping
- Create a source data type and a target data type
- Create Message types for the source and target data types.
- Create Message Interfaces includes Inbound Message interface and Outbound Message interface.
- XSLT Mapping does not require creation of Message mapping, so don’t create any Message mapping.
- Create an .XSL file which converts source data type into target data type.
- Zip that .xsl file and import it into Integration Repository under Imported Archives.
- In Interface Mapping choose mapping program as XSL and specify this zip program. (Through search help you will get XSL Mapping programs that you imported under Imported Archives, select your corresponding XSL Program)
- Test this mapping program by navigating to Test tab.
By having look at above steps you can easily find out that this mapping is no where different from other mapping programs, here the challenging lies in creating an XSLT file. If you spend couple of minutes in studying XPATH tutorial you would be in ideal position to create an XSL Transformation (.xsl extension).
If you still find difficulties in generating XSL Transformation, then you can make use of a tool “Altova MapForce” which will create XSL file for you.
Steps for creating XSL file using this tool:
- Open the Alto MapForce, import the source .xml and .xsd file in it
- Similarly import the target .xml and .xsd in MapForce.
- These two data files should match with source and target data types in Integration Repository.
- Complete the graphical mapping using extensive list of XSLT functions available there.
- Save the mapping file.
- Click the XSLT tab. You will have the entire xslt logic there.
- Copy that content and save it as .xsl file.
- Zip above .xsl file and import the same into IR under Imported Archives.
Scenario demonstrating usage of XSLT Mapping
Take a business scenario where in business (Source System) sends an outbound delivery to their Logistics partner for transporting the same. But here the source business is running on SAP R/3 and corresponding Logistics partner is not on SAP, hence the interpretation of data/communication is different. Because source system sends delivery information in an IDoc (which will be handled by message control for delivery (VL01N/02N) and the target Logistics partner is not aware of these IDoc structures, so in order to provide a communication between these two we need some interface mechanism which takes IDoc structure and converts it into the format understandable by the target Logistics provider and vice versa.
Here the target system expects the xml files in CIDX format, so XI system takes IDoc as an input and converts it to an XML file adhering to CIDX naming standards.
Important steps to make this scenario:
– Import needed IDoc structure into IR, in our scenario import IDoc DESADV.DELVRY03
– Import corresponding XSD structure under External Definitions in IR. Here the corresponding CIDX message is Load Tender Motor.
– Import ZIP file corresponding to XSLT under Imported Archives in IR, which can transform source message to target structure.
Objects needed to be developed in IR
- Inbound Message Interface: Create Inbound Message Interface.
- Import XSL ZIP file.
- Provide path to corresponding zip file. Save it.
- Interface Mapping: Provide source interface as DESADV.DELVRY03 and Target interface as MI_IB_LoadTenderMotor.
- Now specify Mapping Program specific to XSL Type.
- Choose corresponding Archive program from the search help provided under “Name”.
- Now activate all the objects that are developed in IR.
Objects that need to be developed in ID
Business System: Create a business system-pointing source SAP R/3 system.
Business Service: Create a business service corresponding to target file system and don’t forget to assign outbound and inbound interfaces. Communication Channel: Create a communication channel of type File Adapter under Business service (w.r.t target system) to send a file to FTP server of target system. Define the target FTP server details as shown in the following screen:
Sender Agreement: No need as Source system is sending IDOC which is native to XI (but need to perform necessary steps through transactions IDX1 and IDX2).
Receiver Determination: Configure Receivers for corresponding Sender Service and Outbound Interface combination.
Interface Determination: Specify corresponding Inbound Interface and Interface Mapping for combination of Sender Service and Outbound Interface w.r.t specified Receiver in Receiver Determination.
Receiver Agreement: Create this corresponding to Receiver Business service and inbound interface combination and specify communication channel, which places file on the target system’s FTP server.
Altova MapForce to create XSLT
- Open Altova MapForce tool, before this activity, have XSD’s of both Source and Target structures on local machine.
- Create a new Mapping file
- Now import XSD’s of both Source and Target messages (which are Outbound and Inbound Messages in XI).
To do this go to Menu Item, Insert-> XML Schema/File
- Give path to Source message XSD (in this scenario xsd is corresponding to IDoc type DESADV.DELVRY03), after specifying the xsd it will look like as shown below
- In the same way repeat necessary steps for Target structure (in this scenario xsd is corresponding Load Tender Motor CIDX message)
- Now make use of functions that are available on left side and complete required mapping.
- Once you are done with mapping save it and then go to XSLT tab which is shown below of the mapping.
- There is required XSLT code, copy that and create an XSL file (extension .xsl) by simply pasting the above code. Now zip this XSL file and import the same in IR under Imported Archives.