cancel
Showing results for 
Search instead for 
Did you mean: 

Example of Abap Mapping

Former Member
0 Kudos

Hi,

Could u plz give me the simple Abap Mapping coding, which can understand easily...

Tnx & Rgds,

sasi

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Sasi,

Steps to create ABAP code are as follows:

--> Enable the iXML library.

--> Create the main factory for the iXML library.

--> Create a XML stream factory.

--> Create the input stream.

--> Parse the input document.

--> Build the Output document.

--> Render the Output document.

My Scenario consisted of Concat and Date change functionalities.

The Code to achieve the same is given below:

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( ).

  • data declaration to get message content of tags in <incode>

DATA: incode TYPE REF TO if_ixml_node_collection.

  • build up output document =============================================

  • create output document

DATA: odocument TYPE REF TO if_ixml_document.

odocument = ixmlfactory->create_document( ).

DATA : outcode TYPE REF TO if_ixml_node,

irc TYPE i.

DATA : element_value TYPE string,

val_name TYPE string,

val_add TYPE string,

name_add TYPE string.

  • create element msgtype and add it to the document

DATA: msgtype TYPE REF TO if_ixml_element.

msgtype = odocument->create_simple_element(

name = 'MT_ABAP_RX'

parent = odocument ).

  • create element 'Employee' and add it to the output document

DATA: pemployee TYPE REF TO if_ixml_element.

pemployee = odocument->create_simple_element(

name = 'Employee'

parent = msgtype ).

  • Employee_Code

incode = idocument->get_elements_by_tag_name( 'Employee_Code' ).

outcode = incode->get_item( index = 0 ).

element_value = outcode->get_value( ).

  • create element 'EMPLOYEE_CODE' and add it to the output document

DATA: pcode TYPE REF TO if_ixml_element.

pcode = odocument->create_simple_element(

name = 'Employee_Code'

value = element_value

parent = pemployee ).

  • Name

incode = idocument->get_elements_by_tag_name( 'First_Name' ).

outcode = incode->get_item( index = 0 ).

element_value = outcode->get_value( ).

val_name = element_value.

incode = idocument->get_elements_by_tag_name( 'Last_Name' ).

outcode = incode->get_item( index = 0 ).

element_value = outcode->get_value( ).

val_add = element_value.

CONCATENATE val_name val_add INTO name_add SEPARATED by space .

  • create element 'Name' and add it to the output document

DATA: pname TYPE REF TO if_ixml_element.

pname = odocument->create_simple_element(

name = 'Name'

value = name_add

parent = pemployee ).

  • Joining_Date

incode = idocument->get_elements_by_tag_name( 'Joining_Date' ).

outcode = incode->get_item( index = 0 ).

element_value = outcode->get_value( ).

  • create element 'Joining_Date' and add it to the output document

DATA: pdate TYPE REF TO if_ixml_element.

pdate = odocument->create_simple_element(

name = 'Joining_Date'

value = element_value

parent = pemployee ).

  • Level

incode = idocument->get_elements_by_tag_name( 'Level' ).

outcode = incode->get_item( index = 0 ).

element_value = outcode->get_value( ).

  • create element 'Level' and add it to the output document as 'Designation'

DATA: level TYPE REF TO if_ixml_element.

level = odocument->create_simple_element(

name = 'Designation'

value = element_value

parent = pemployee ).

  • 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 ).

irc = renderer->render( ).

endmethod.

Hope this is of help.

Regards,

Lavita.

P.S. Do reward points if the information is useful to you.

Answers (4)

Answers (4)

Former Member
0 Kudos

HI,

ABAP mappings run on ABAP Stack and are developed in the ABAP workbench of the Integration Server.

You normally do not need to use the ABAP mappings and is preferable for someone with ABAP programming background. I should say JAVA functions would suffice any complex scenarios.

refer step by step guides for ABAP Mapping

ABAP Mapping

https://www.sdn.sap.com/irj/sdn/advancedsearch?cat=sdn_all&query=abap+mapping&adv=false&sortby=cm_rn...

How to Use ABAP Mapping in Exchange Infrastructure 3.0 (NW2004)

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5c46ab90-0201-0010-42bd-9d030259...

SAP Network Blog: Testing ABAP Mapping

/people/sameer.shadab/blog/2005/09/29/testing-abap-mapping

SAP Network Blog: How to call XI ABAP Mapping via RFC

/people/ricardoandres.maienza/blog/2007/04/06/how-to-call-xi-abap-mapping-via-rfc

SAP Network Blog: XI: ABAP mapping logs - more standard = better visibility

/people/michal.krawczyk2/blog/2006/09/20/xi-abap-mapping-logs--more-standard-better-visibility

SAP Network Blog: Dynamically sending a mail to the PO creator using XSLT- ABAP Mapping

/people/rahul.nawale2/blog/2006/11/01/dynamically-sending-a-mail-to-the-po-creator-using-xslt-abap-mapping

You need to provide the name of your mapping program maually , you see it is an input box.

just provide the name of abap mapping program it will work.

and one more thing you cannot test abap mapping program in integration builer you need to test in abap only.

use tcode: SXI_MAPPING_TEST for testing abap mapping

Thanks

Swarup

Former Member
0 Kudos
Former Member
0 Kudos

Hi,

This Link will help you with basic understanding and how to do ABAP Mapping.......with example......great starter kit....

http://saptechnical.com/Tutorials/XI/ABAPMapping/page1.htm

Thanks,

Kishore.

Former Member
0 Kudos

Hi,

Check with these ABAP Mapping blogs and find out the solution for you

/people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi

This document will help you to create ABAP Mapping .

https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how%20to%20...

How to Use ABAP Mapping in Exchange Infrastructure 3.0 (NW2004)

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/5c46ab90-0201-0010-42bd-9d030259...

SAP Network Blog: How to call XI ABAP Mapping via RFC

/people/ricardoandres.maienza/blog/2007/04/06/how-to-call-xi-abap-mapping-via-rfc

SAP Network Blog: Testing ABAP Mapping

/people/sameer.shadab/blog/2005/09/29/testing-abap-mapping

/people/udo.martens/blog/2006/08/23/comparing-performance-of-mapping-programs

An ad-on

/people/michal.krawczyk2/blog/2006/09/20/xi-abap-mapping-logs--more-standard-better-visibility

Regards

Seshagiri