Professional Documents
Culture Documents
Many PI consultants consider ABAP mapping to be very complex and hence avoid using it. However in
reality it is pretty easy. With this easy to follow step-by-step guide, ABAP mapping will be a cakewalk.
Java and XSLT mapping is already made simple for you earlier. Now lets master some ABAP stuff.
In SAP PI, ABAP Mapping is not enabled by default. We need carry out some configuration to register
the ABAP Mapping in the Exchange Profile. The step by step procedure of doing this is explained in this
article: How to register ABAP Mapping in Exchange Profile. Make sure this is done before you proceed
any further.
In the previous post, we discussed how easy it is to implement ABAP Mapping in SAP PI. This post
aims to provide a complete code walkthrough using a small example.
We will use same example we used while doing XSLT mapping. This time we will use ABAP mapping.
Lets say we have following XML as source message –
Our aim is to transform the above message into another message shown below such that first name and
last name is concatenated into a single field.
ABAP Mapping Implementation
Create an ABAP objects class say ZCL_SIMPLE_ABAP_MAPPING as explained in the previous post.
The class must implement the interface IF_MAPPING. The method EXECUTE of this interface will
serve as our ABAP mapping logic. Implement the EXECUTE method in the class as described below.
We will use SAP’s iXML parser to parse the source XML. The code for the execute method is given
below. The code is well commented for easy understanding.
METHOD if_mapping~execute.
* initialize iXML
TYPE-POOLS: ixml.
CLASS cl_ixml DEFINITION LOAD.
* create iXML factory object
DATA: ixmlfactory TYPE REF TO if_ixml.
ixmlfactory = cl_ixml=>create( ).
DATA: rc TYPE i.
DATA: len TYPE i.
DATA: idx TYPE i.
firstname = fname_iterator->get_next( ).
lastname = lname_iterator->get_next( ).
birthdate = bdate_iterator->get_next( ).
str_fname = firstname->get_value( ).
str_lname = lastname->get_value( ).
* create renderer
renderer = ixmlfactory->create_renderer(
ostream = ostream
document = odocument ).
rc = renderer->render( ).
ENDMETHOD. "IF_MAPPING~EXECUTE
Save and activate the changes. Carry out rest of the configuration as usual and test your interface.
This transaction requires the Sender details i.e. Sender Service/Party Name, Sender Interface Namespace, Sender
Interface; the Receiver details i.e. Receiver Service/Party Name, Receiver Interface Namespace, Receiver Interface And
Input XML source file.