Using ABAP XSLT Extensions for XI Mapping
Introduction
The fist time I looked at SAP XI,
I searched for the best way to
perform value mapping with data from SAP. Today we can use XSLT mapping
at the ABAP core in SAP XI 3.0 with the best solution there is: ABAP
XSLT extensions. In this weblog I will show you how easy it can be done
to use SAP Abap functions in your XSLT.
An XSLT Mapping
Before focussing on the
sap data we will focus on the XSLT
itself. We want to translate source of system A into target structure B.
Source System A:
Target System B
:Male</b></Title><br>
<Name>Robert Eijpe</Name><br>
<Street>Huizermaatweg
243A</Street><br>
<Zipcode>1276 LJ</Zipcode><br>
<City>Huizen</City><br>
<Country><b>NL</b>
If we compare the XSLT result with
the needed xml for system B, we have
a value mismatch at the tags Title and Country. We will use
SAP XSLT extensions to solve this problem.
A basic SAP XSLT Mapping
When the XSLT mapping is ready, we
can create a XSLT transformation at
the SAP XI Abap core. With transaction XSLT_TOOL we start the
SAP XSLT Editor.
After pushing the
“Create” button, we have to fill out the following
pop-up. It is important to choose ‘XSLT Program’ as
Transformation Type.
We proceed to the tab
‘SourceCode’ and copy the generated XSLT from our
XSTL tool into de editor field. After this we can activate the
Transformation.
Testing the SAP XSLT Mapping
Before we continue, we have to
test the transformation within SAP. This is important because SAP XSLT
is based on the XSLT 1.0 standard, but SAP didn’t support all
features of the XSLT 1.0 standard at the ABAP stack. SAP has
also added some features of the XSLT 2.0 standard. More info can be
found in SAP XSLT Processor
Reference from SAP help.
Before testing can be done we have
to save the System A xml into a file on our local PC. From
the XSLT Editor we enter the SAP XSLT test tool by pressing the []
button. We can also go directly to the tool starting transaction XSLT.
We have to fill out the source
path of the xml System A file and press the button “View
HTML”. If SAP supports all features of the XSLT,
you will get the same result as in the external XSLT tool.
Now we are ready for the SAP Extensions.
Using SAP XSLT Extensions
In the sap help we found the
Additional SAP Functions and Statements .
We will use these to solve our
value mismatches.
We choose as a class
type for an ‘usual ABAP Class’. The instantiation will be ‘public’ and
the class will be marked as ‘final’.
Now we add a public static method
named ‘GETCOUNTRY’ to the class.
We declare the importing and
returning parameters and implement the method.
Use the XSLT Mapping within SAP XI 3.0
Having done all this our XSLT
Mapping program ‘Z_SDN_SYSTEM_A_TO_B’ with SAP XSLT Extensions at the
ABAP engine is ready for use in SAP XI.





but this weblog showed me I have to try it:)
thx Robert 🙂
Regards,
michal
This could be very useful for the folks more comfortable with the ABAP stack. Thanks for bringing this up!
Regards,
Bhanu
just a little comment: User-defined functions were incorporated in XSLT 2.0 (after we had sap:function) and SAP XSLT supports xsl:function as well (http://www.w3.org/TR/2002/WD-xslt20-20021115/#stylesheet-functions). The official syntax should be preferred.
Cheers - Karsten
I would think that the integration server pipeline sends the message to the J2EE stack, where it is analysed to see if the mapping is java, abap or external libraries.
If it is ABAP, the message is sent back to the ABAP stack over JCo. Hence, the overhead of JCo is not avoided in case of ABAP XSLT approach.
I believe I'm right.
If you look in the pipeline, you will see in xi for the mapping step the method CALL_RUNTIME of class CL_MAPPING_XMS_PLSRV3.
In this method, xi will decide if it stays on the abap core or will call the J2EE mapping engine. See source below
...
case l_step-maptype.
when c_maptype_identity.
...
when c_maptype_r3_xslt or c_maptype_r3_abap.
call method call_r3_runtime
exporting p_type = l_step-maptype
p_source = p_source
p_program = l_step-prog
receiving p_target = l_temp.
...
when c_maptype_xslt or c_maptype_java.
...
call method call_java_runtime
exporting p_dest = me->dest
p_external_steps = l_external_steps
p_source = p_source
importing p_result = l_temp.
...
With regards,
Robert Eijpe
Very good web log. I'll try it out.
Cheers, Raj Senthil
Hi <br/><br/>I have tried this but i am getting following error.<br/><br/>unknown sdn:GetTitle Function .I have included http"//www.sap.com/sapxsl namespace and I have added sap:function just before <xsl:temlate><br/><br/>But it is giving that error mentioned above..<br/><br/>thanks<br/>N.Prasad Babu
I am new to XI and XSLT mapping.
I have worked on 2-3 XSLT mappings in SAP XI.
I was trying to use ABAP XSLT extensions in SAP XI after reading your blog.
The blog is very well done and very explanatory.
However I face a problem which I am unable to solve.Please help.
I am using SAP XI 3.0 with SP 14.
I was able to create the XSLT transformation in XSLT_TOOL transaction and it tested successfully.
I then went ahead and created the data types,message types and message interfaces in SAP XI.
However when I try to create the Interface mapping and try to include the mapping program over there I face a problem.The options available to me for Mapping Program Type are -
1. Message Mapping
2. Java
3. XSL
No option for "XSL(ABAP Engine)" is available as mentioned in ur blog.
Also if I select the XSL option and try to select the mapping program I only get the imported XSLT mappings in XI.
Please help.If there is anything that needs to be activated in order for the mapping to be included.
Regards,
Ritu
XI Customizing is not completedEngine)
Thank you very much for your help!
Ritu
Hi!Julio
I am getting the following error while calling my test method to get the country_code as in the above example.
Runtime error
Reason :
When processing the ABAP method call of GETCOUNTRY of the class Z_GET_COUNTRY_DETAILS, the CX_SY_DYN_CALL_ILLEGAL_METHOD exception occurred
I could able to test my method in the class builder successfully.
Would like to know the exact reason for this and appreciate any solution to avoid this.
Regards
Vijay