Sunteți pe pagina 1din 6

ABAP Mapping Prerequisites: Setting the Additional Type parameter in Exchange Profile: Goto http://XIHOME:50000/exchangeProfile

Set the value of com.sap.aii.repository.mapping.additionaltypes as R3_ABAP|Abapclass; R3_XSLT| XSL (ABAP Engine)

After setting the parameters we would be able to see the new mappings (Abapclass, XSL, XSL (ABAP Engine)) in the interface mapping.

Input MessageType and Output MessageType are created as below:

Creation of ABAP class in R/3: Step 1: Goto Transaction SE24 and create a class.

Step 2: Goto Interface tab and then add interface: - IF_MAPPING

Step 3: Goto Methods tab, double click the method IF_MAPPING~EXECUTE and add the custom code.

Step 4: Save and activate the method IF_MAPPING~EXECUTE. Now the class is ready for usage in Integration Repository.

Interface Mapping: Goto Interface Mapping. Select the Mapping Program type as ABAP Class. Provide the ABAP Class created in ABAP Stack of PI.

Testing the ABAP Mapping: Step 1: Goto Transaction sxi_monitor_test. Fill the sender and receiver interface details. Execute the Mapping test

Step 2: In the next screen load your input xml and execute the xml.

Step 3: Final screen will have the below message

Output Message after Mapping:

Sample ABAP Mapping code:


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( stream_factory = streamfactory istream = istream document = idocument ). iparser->parse( ). * get first name from input XML data: fname type string. data: lname type string. data: el_element type ref to if_ixml_element. el_element = idocument->find_from_name('FName'). fname = el_element->get_value( ). * get last name from input XML el_element = idocument->find_from_name('LName'). lname = el_element->get_value( ). * concat first name and last name data: concatString type string. concatenate fname lname into concatString. * build up output document ========================================== * create output document data: odocument type ref to if_ixml_document. odocument = ixmlfactory->create_document( ). * create element 'XSLOutput_MT' and add it to the document data: msgtype type ref to if_ixml_element. msgtype = odocument->create_simple_element( name = 'Output_MT' parent = odocument ).

* create element 'Records' and add it to the output document data: elementRecord type ref to if_ixml_element. elementRecord = odocument->create_simple_element( name = 'Records' parent = msgtype ). * create element 'Name' and add it to the output document data: elementName type ref to if_ixml_element. elementName = odocument->create_simple_element( name = 'Name' value = concatString parent = elementRecord ). * 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( ostream = ostream document = odocument ). renderer->render( ). endmethod.

S-ar putea să vă placă și