Additional Blogs by Members
cancel
Showing results for 
Search instead for 
Did you mean: 
raeijpe
Contributor
0 Kudos

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.







!https://weblogs.sdn.sap.com/weblogs/images/455/sdn_wl1_1.jpg|height=267|alt=image|width=600|src=http...!





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.









!https://weblogs.sdn.sap.com/weblogs/images/455/sdn_wl1_3.jpg|height=354|alt=image|width=600|src=http...!





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.









!https://weblogs.sdn.sap.com/weblogs/images/455/sdn_wl1_4.jpg|height=336|alt=image|width=600|src=http...!





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

http://sdn.sap.com/sapxsl”.







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'.









!https://weblogs.sdn.sap.com/weblogs/images/455/sdn_wl1_6.jpg|height=295|alt=image|width=600|src=http...!





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.







14 Comments