ABAP mappings are
mapping programs in
ABAP objects that
customers can implement using the ABAP Workbench.
Note the prerequisites in the sections Purpose and Integration as well as the Restrictions in Mapping Development with the ABAP Workbench.
An ABAP mapping comprises an ABAP class that implements the interface IF_MAPPING in the package SAI_MAPPING. The interface has a method EXECUTE with the following signature:
Exporting Parameter
Parameter |
Meaning |
SOURCE |
Source XML document |
PARAM |
Parameter object for read access to runtime constants (see below) |
TRACE |
Trace object for writing messages in the mapping trace (see below) |
Exporting Parameters
Parameter |
Meaning |
RESULT |
Target XML document |
Exception: CX_MAPPING_FAULT
Applications can decide themselves in the method EXECUTE how to import and change the source XML document. If you want to use the XSLT processor of SAP Web AS, you can use the ABAP Workbench to develop a stylesheet directly (see XSLT Mappings (ABAP Engine)) rather than using ABAP mappings.
You use the trace object to write messages in the mapping trace, which you can view in message monitoring. If using the method TRACE, you enter the trace level and the output message:
Trace Level |
Meaning |
0 |
No trace is written |
1 |
Warnings are output |
2 |
Warnings and error information are output |
3 |
Warnings, error information, and debugging information are output |
Alternatively, you can use the methods TRACE1, TRACE2, or TRACE3 to write messages for trace levels 1, 2, or 3 in the trace.
The trace
level that you set for an Integration Engine pipeline determines which
messages appear in monitoring. See:
Changing/Displaying
Configuration..
In ABAP mapping you can read access message header fields. To do this, an object of type IF_MAPPING_PARAM is transferred to the EXECUTE method. The interface has constants for the names of the available parameters and a method GET, which returns the respective value for the parameter name. The constants are the same as in Java-Mapping-API (SAP NetWeaver 2004 und 7.0) where there is no constant MAPPING_TRACE for ABAP mappings. Instead, the trace object is transferred directly using the parameter TRACE of the method IF_MAPPING~EXECUTE (see above).
Example: Accessing a Runtime Constant
Method IF_MAPPING~EXECUTE. * Get mapping constant SENDER_SERVICE data: l_sender_service type
string. ENDMETHOD. |
The following example shows how you execute an ABAP mapping using the iXML parser. The following XML document is to be converted.
Outbound Payload of a Message Sent to the Integration Server
<?xml version="1.0"
encoding="UTF-8" ?> <Order> <Passenger> <Flight> <Flight> <Flight> </Order> </ns0:BookingOrders> |
The outbound payload is to be processed using the following ABAP mapping program:
ABAP Mapping Program
method IF_MAPPING~EXECUTE. * initialize iXML type-pools: ixml. class cl_ixml definition load. * create main factory data: ixmlfactory type ref to if_ixml. ixmlfactory = cl_ixml=>create( ). * create stream factory data: streamfactory type ref to if_ixml_stream_factory. streamfactory = ixmlfactory->create_stream_factory( ). * create input stream data: istream type ref to if_ixml_istream. istream = streamfactory->create_istream_xstring( source ). * parse input document ============================================== * initialize input document data: idocument type ref to if_ixml_document. idocument = ixmlfactory->create_document( ). * parse input document data: iparser type ref to if_ixml_parser. iparser =
ixmlfactory->create_parser( iparser->parse( ). * get message content of tag <BookingCode> data: incode type ref to if_ixml_node_collection. incode = idocument->get_elements_by_tag_name( 'BookingCode' ). * get XI header data (here: "Sender Service") data: l_sender_service type string. l_sender_service = param->get( if_mapping_param=>sender_service ). * add trace (appears in message monitoring) data: l_trace type string. concatenate 'Sender Service = ' l_sender_service into l_trace. trace->trace( level =
'1' * build up output document ========================================== * create output document data: odocument type ref to if_ixml_document. odocument = ixmlfactory->create_document( ). * create element 'SenderService' and add it to the document data: msgtype type ref to if_ixml_element. msgtype =
odocument->create_simple_element( * create element 'SenderService' and add it to the output document data: elementsender type ref to if_ixml_element. elementsender =
odocument->create_simple_element( * add node to the output document data: outcode type ref to if_ixml_node. outcode = incode->get_item( index = 0 ). data irc type i. irc = msgtype->append_child( outcode ). * render document =================================================== * create output stream data: ostream type ref to if_ixml_ostream. ostream = streamfactory->create_ostream_xstring( result ). * create renderer data: renderer type ref to if_ixml_renderer. renderer =
ixmlfactory->create_renderer( irc = renderer->render( ). endmethod. |
More
information:
iXML ABAP Objects
Jumpstart
Target Payload After Executing the ABAP Mapping Program
<?xml version="1.0" ?> <MsgOut> <SenderService>Test_ABAP_Mapping_BS</SenderService> <BookingCode>2KY34R</BookingCode> </MsgOut> |