[ABAP Mapping] No output

Hey,
try to do a scenario like "How to use ABAP mapping in SAP XI 3.0", but got no output.
Is it correct that we don't need a namespace for abap mapping? In the "How to" document the namespace field is empty, but in sxmb_moni he says:
<b>  <SAP:AdditionalText>com.sap.aii.af.ra.ms.api.DeliveryException: error while processing the request to rfc-client: com.sap.aii.af.rfc.afcommunication.RfcAFWException: error while processing message to remote system:com.sap.aii.af.rfc.core.client.RfcClientException: could not get functionname from XML requst: com.sap.aii.af.rfc.RfcAdapterException: failed to read funtionname from XML document: missing namespace declaration(2)</SAP:AdditionalText> </b>
But he takes the ABAP mapping, because in ABAP code I create following trace node:
<i>  DATA: l_trace TYPE string.
  CONCATENATE 'Chris Sender Service = ' l_sender_service INTO l_trace.
  trace->trace( level = '1'
  message = l_trace ).</i>
And in sxmb_moni he got it:
<i><Trace level="1" type="T">Chris Sender Service =BS_Reisebuero2</Trace> </i>
In sxi_mapping_test he writes, that the mapping was successful, but didn't create the output structure. Do I have a wrong ABAP code? Could it be, that I have a wrong append_child??
Here it is (it equals the how to):
<i>
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 source elements**********************************
get message content of tag <carrid>
  DATA: carrid TYPE REF TO if_ixml_node_collection.
  carrid = idocument->get_elements_by_tag_name( 'carrid' ).
get message content of tag <connid>
  DATA: connid TYPE REF TO if_ixml_node_collection.
  connid = idocument->get_elements_by_tag_name( 'connid' ).
get message content of tag <fldate>
  DATA: fldate TYPE REF TO if_ixml_node_collection.
  fldate = idocument->get_elements_by_tag_name( 'fldate' ).
***********get meta datas****************************************
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 'Chris Sender Service = ' l_sender_service INTO l_trace.
  trace->trace( level = '1'
  message = l_trace ).
build up output document =============================================
create output document
  DATA: odocument TYPE REF TO if_ixml_document.
  odocument = ixmlfactory->create_document( ).
create element SXIDEMO_AIRL_FLIGHT_CHECKAVAIL and add it to the document
  DATA: sxidemo TYPE REF TO if_ixml_element.
  sxidemo = odocument->create_simple_element(
                       name = 'SXIDEMO_AIRL_FLIGHT_CHECKAVAIL_chris'
                       parent = odocument ).
add FLIGHT_KEY node to the output document
  DATA: flight_key TYPE REF TO if_ixml_node.
  flight_key = carrid->get_item( index = 0 ).
  DATA irc TYPE i.
  irc = sxidemo->append_child( flight_key ).
***********add elements to output document *******************
add carrid node to the output document
  DATA: outcode1 TYPE REF TO if_ixml_node.
  outcode1 = carrid->get_item( index = 0 ).
  irc = flight_key->append_child( outcode1 ).
add connid node to the output document
  DATA: outcode2 TYPE REF TO if_ixml_node.
  outcode2 = connid->get_item( index = 0 ).
  irc = flight_key->append_child( outcode2 ).
add fldate node to the output document
  DATA: outcode3 TYPE REF TO if_ixml_node.
  outcode3 = fldate->get_item( index = 0 ).
  irc = flight_key->append_child( outcode3 ).
Testen einer manuellen eingabe
  outcode1 = odocument->create_simple_element(
                          name = 'passengerName'
                          value = 'Christian Riekenberg'
                          parent = flight_key ).
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.
</i>
thanks
chris
Message was edited by:
        Christian Riekenberg

Hi,
I took a working scenario, that is runnable with java- and graphical mapping.
Just change it to ABAP-Mapping.
I just had forget to include the namespace into abap mapping. So the output has to look like:
<ns1:SXIDEMO_AIRL_FLIGHT_CHECKAVAIL <b>xmlns:ns1="urn:sap-com:document:sap:rfc:functions"</b>>
That was the missing namespace. Another problem was my created structure. I used the function append_child with a wrong input.
Your tip, that I'm able to use the debugger in
sxi_mapping test was great. So points for you!
Message was edited by:
        Christian Riekenberg

Similar Messages

  • XSLT samples for XML- ABAP mapping

    Hi all,
    Does anyone have a XSLT samples for XML->ABAP mapping ?
    regards

    first create XSLT program by copy pasting the below given code and give the program name as "Y_TEST"
    <b>XSLT code</b>
    <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
      <xsl:strip-space elements="*"/>
      <xsl:output indent="yes"/>
      <xsl:template match="NewDataSet">
        <asx:abap xmlns:asx="http://www.sap.com/abapxml" version="1.0">
          <asx:values>
            <OUTTAB>
              <xsl:for-each select="Table">
                <OUTTAB1>
                  <AIRPORTCODE>
                    <xsl:value-of select="AirportCode"/>
                  </AIRPORTCODE>
                  <CITYOFAIRPORTNAME>
                    <xsl:value-of select="CityOrAirportName"/>
                  </CITYOFAIRPORTNAME>
                  <COUNTRY>
                    <xsl:value-of select="Country"/>
                  </COUNTRY>
                  <COUNTRYABBRIVATION>
                    <xsl:value-of select="CountryAbbrviation"/>
                  </COUNTRYABBRIVATION>
                  <COUNTRYCODE>
                    <xsl:value-of select="CountryCode"/>
                  </COUNTRYCODE>
                  <GMTOFFSET>
                    <xsl:value-of select="GMTOffset"/>
                  </GMTOFFSET>
                  <RUNWAYLENGTHFEET>
                    <xsl:value-of select="RunwayLengthFeet"/>
                  </RUNWAYLENGTHFEET>
                  <RUNWAYELEVATIONFEET>
                    <xsl:value-of select="RunwayElevationFeet"/>
                  </RUNWAYELEVATIONFEET>
                  <LATITUDEDEGREE>
                    <xsl:value-of select="LatitudeDegree"/>
                  </LATITUDEDEGREE>
                  <LATITUDEMINUTE>
                    <xsl:value-of select="LatitudeMinute"/>
                  </LATITUDEMINUTE>
                  <LATITUDESECOND>
                    <xsl:value-of select="LatitudeSecond"/>
                  </LATITUDESECOND>
                  <LATITUDENPEERS>
                    <xsl:value-of select="LatitudeNpeerS"/>
                  </LATITUDENPEERS>
                  <LONGITUDEDEGREE>
                    <xsl:value-of select="LongitudeDegree"/>
                  </LONGITUDEDEGREE>
                  <LONGITUDEMINUTE>
                    <xsl:value-of select="LongitudeMinute"/>
                  </LONGITUDEMINUTE>
                  <LONGITUDESECONDS>
                    <xsl:value-of select="LongitudeSeconds"/>
                  </LONGITUDESECONDS>
                  <LONGITUDEEPERW>
                    <xsl:value-of select="LongitudeEperW"/>
                  </LONGITUDEEPERW>
                </OUTTAB1>
              </xsl:for-each>
            </OUTTAB>
          </asx:values>
        </asx:abap>
      </xsl:template>
    </xsl:stylesheet>
    <b>just create a type 1 program and paste the below given code.</b>
    report y_consume_webservice .
    data: wf_user type string .
    data: wf_password type string .
    types: begin of outtab1 ,
       airportcode(6)  ,
       cityofairportname(50),
       country(30)  ,
       countryabbrivation(10),
       countrycode(6)  ,
       gmtoffset(10)  ,
       runwaylengthfeet(15),
       runwayelevationfeet(15),
       latitudedegree(10)  ,
       latitudeminute(10)  ,
       latitudesecond(10)  ,
       latitudenpeers(10)  ,
       longitudedegree(10)  ,
       longitudeminute(10)  ,
       longitudeseconds(10)  ,
       longitudeeperw(10) ,
       end of outtab1 .
    data: outtab type  table of outtab1.
    data: wf_o like line of outtab .
    data: g_okcode like sy-ucomm .
    data: my_container   type ref to cl_gui_custom_container .
    data: g_dock type ref to cl_gui_docking_container .
    data: mygrid type ref to cl_gui_alv_grid .
    data: wf_field_cat type lvc_t_fcat .
    data: wf_field_cat_wa like line of wf_field_cat ,
          wf_is_layout type lvc_s_layo .
    data: wf_fld_cat type slis_t_fieldcat_alv .
    data: wf_fld_cat_wa like line of wf_fld_cat .
    data: wf_repid like sy-repid .
    data: int_tab_name type slis_tabname .
    data: xslt_err type ref to cx_xslt_exception .
    constants:
    * encoding for download of XML files
    encoding     type string value 'utf-8' .
    data: rlength type i,
          txlen type string  .
    data: http_client type ref to if_http_client .
    data: wf_string type string .
    data: wf_string1 type string .
    data: wf_proxy type string ,
          wf_port type string .
    selection-screen: begin of block a with frame .
    parameters: uri2(132) type c lower case .
    selection-screen skip 1.
    parameters: user(50) lower case,
                password(50) lower case ,
                p_proxy(100) lower case default 'proxy.xxx.com' ,
                p_port(4) default '80'.
    selection-screen: end of block a .
    at selection-screen output.
      loop at screen.
        if screen-name = 'PASSWORD'.
          screen-invisible = '1'.
          modify screen.
        endif.
      endloop.
    start-of-selection .
    clear wf_string .
    concatenate
    '<?xml version="1.0" encoding="utf-8"?>'
    '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">'
    '<soap:Body>'
    '<GetAirportInformationByCountry xmlns="http://www.webserviceX.NET">'
    '<country>' uri2 '</country>'
    '</GetAirportInformationByCountry>'
    '</soap:Body>'
    '</soap:Envelope>'
    into wf_string .
    clear :rlength , txlen .
    rlength = strlen( wf_string ) .
    move: rlength to txlen .
    clear: wf_proxy, wf_port .
    move: p_proxy to wf_proxy ,
          p_port to wf_port .
    call method cl_http_client=>create
      exporting
        host          = 'www.webservicex.net'
        service       = '80'
        scheme        = '1'
        proxy_host    =  wf_proxy
        proxy_service =  wf_port
      importing
        client        = http_client.
    http_client->propertytype_logon_popup = http_client->co_disabled.
    wf_user = user .
    wf_password = password .
    call method http_client->authenticate
      exporting
        proxy_authentication = 'X'
        username             = wf_user
        password             = wf_password.
    call method http_client->request->set_header_field
      exporting
        name  = '~request_method'
        value = 'POST'.
    call method http_client->request->set_header_field
      exporting
        name  = '~server_protocol'
        value = 'HTTP/1.1'.
    call method http_client->request->set_header_field
      exporting
        name  = '~request_uri'
        value = '/airport.asmx'.
    call method http_client->request->set_header_field
      exporting
        name  = 'Content-Type'
        value = 'text/xml; charset=utf-8'.
    call method http_client->request->set_header_field
      exporting
        name  = 'Content-Length'
        value = txlen.
    call method http_client->request->set_header_field
      exporting
        name  = 'SOAPAction'
        value = 'http://www.webserviceX.NET/GetAirportInformationByCountry'.
    call method http_client->request->set_cdata
      exporting
        data   = wf_string
        offset = 0
        length = rlength.
    call method http_client->send
      exceptions
        http_communication_failure = 1
        http_invalid_state         = 2.
    call method http_client->receive
      exceptions
        http_communication_failure = 1
        http_invalid_state         = 2
        http_processing_failed     = 3.
    clear wf_string1 .
    wf_string1 = http_client->response->get_cdata( ).
    replace all occurrences of
        '<' in wf_string1 with '<' .
    replace all occurrences of
    '>' in wf_string1 with '>' .
    replace all occurrences of
    'xmlns=' in wf_string1 with 'xmlns:xsl=' .
    try .
        call transformation (`Y_TEST`)
                source xml wf_string1
                result     outtab = outtab.
      catch cx_xslt_exception into xslt_err.
        data: s type string.
        s = xslt_err->get_text( ).
        write: ': ', s.
        stop.
    endtry .
    break-point .
    Try this and give me your feedback.
    Regards
    Raja

  • Java Mapping, XSLT Mapping, ABAP Mapping

    Hi Experts,
                     Could any one explain what is the main features of the following Mapping. How to pick the mapping?
    Java Mapping - When to use and what is the advantage.
    ABAP Mapping - When to use and what is the advantage.
    XSLT Mapping - When to use and what is the advantage.
    Graphical Mapping - When to use and what is the advantage.
    cheers,
    Sunee

    There are 4 types of mapping in XI
    1. Graphical Mapping
    2. XSLT Mapping
    3. JAVA Mapping
    4. ABAP Mapping
    When to use Message mapping
    1 When the logic for your mapping is simple and straight forward, you can use
    Advantages of message mapping
    1)Easy to use.
    2) has GUI drag and drop.
    3) used for simple mapping cases
    4) it does not involve any complex logic
    Disadvantages of message mapping
    1)has limitation in terms of complex hierarchy
    When to use Java mapping
    1) Java mapping are used when graphical mapping cannot help you.
    Advantages of Java Mapping
    1)you can use Java APIs and Classes in it.
    2) file look up or a DB lookup is possible
    3) DOM is easier to use with lots of classes to help you create nodes and elements.
    Disadvantages of Java mapping
    1)SAX parser is not easy to develop
    2)DOM parser is intensive
    3) Java knowledge is required
    4) bit complexer
    XSLT Mapping - When to use
    1)When the required output is other than XML like Text, Html or XHTML (html displayed as XML )
    2)When default namespace coming from graphical mapping is not required or is to be changed as per requirements.
    3)When data is to be filtered based on certain fields (considering File as source)
    4)When data is to be sorted based on certain field (considering File as source)
    5)When data is to be grouped based on certain field (considering File as source)
    Advantages of using XSLT mapping
    1)XSLT program itself defines its own target structure.
    2)XSLT programs can be imported into SAP XI. Message mapping step can be avoided. One can directly go for interface mapping once message interfaces are created and mapping is imported.
    3)XSLT provides use of number of standard XPath functions that can replaces graphical mapping involving user defined java functions easily.
    4)File content conversion at receiver side can be avoided in case of text or html output.
    5)Multiple occurrences of node within tree (source XML) can be handled easily.
    6)XSLT can be used in combination with graphical mapping.
    7)Multi-mapping is also possible using xslt.
    8)XSLT can be used with ABAP and JAVA Extensions
    Disadvantages of using XSLT mapping
    1)Resultant XML payload can not be viewed in SXMB_MONI if not in XML format (for service packs < SP14).
    2)Interface mapping testing does not show proper error description. So errors in XSLT programs are difficult to trace in XI but can be easily identified outside XI using browser.
    3)XSLT mapping requires more memory than mapping classes generated in Java.
    4)XSLT program become lengthier as source structure fields grows in numbers.
    5)XSLT program sometimes become complex to meet desired functionality.
    6)Some XSL functions are dependent on version of browser.
    Advantages of Abap Mapping
    1) A person comfortable with OOABAP can go for ABAP mapping instead.
    Disadvantages of Abap Mapping
    1) Abap knowledge is required
    2) bit compexer
    For further info on each of the mapping, refer to these links,
    Graphical Mapping,
    http://help.sap.com/saphelp_nw04/helpdata/en/6d/aadd3e6ecb1f39e10000000a114084/content.htm
    http://help.sap.com/saphelp_nw04/helpdata/en/43/c4cdfc334824478090739c04c4a249/content.htm
    XSLT Mapping
    http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/content.htm
    http://www.w3.org/TR/xslt20/
    Java Mapping
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm
    DOM parser API
    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html
    Check this blog on Mapping:
    /people/ravikumar.allampallam/blog/2005/02/10/different-types-of-mapping-in-xi
    Also, check this thread for more info,
    Different types of Mapping in XI

  • Problem in ABAP mapping

    Hi ,
    I am working with a scenerio where i have 2 diff system to send the data depending upong the sending payload data.
    I am using ABAP mapping where i am able to send accros the data, below is my code
    METHOD IF_MAPPING~EXECUTE.
      BREAK-POINT.
      * initialize iXML
      TYPE-POOLS: IXML.
      CLASS CL_IXML DEFINITION LOAD.
      DATA: L_IXML TYPE REF TO IF_IXML.
    *creating the Interface by calling the create method in class C_IXML
      CALL METHOD CL_IXML=>CREATE
    EXPORTING
       TYPE   = 0
        RECEIVING
          RVAL   = L_IXML.
    create stream factory
      DATA: STREAMFACTORY TYPE REF TO IF_IXML_STREAM_FACTORY.
      CALL METHOD L_IXML->CREATE_STREAM_FACTORY
        RECEIVING
          RVAL = STREAMFACTORY.
    create input stream
      DATA: ISTREAM TYPE REF TO IF_IXML_ISTREAM.
      CALL METHOD STREAMFACTORY->CREATE_ISTREAM_XSTRING
        EXPORTING
          STRING = SOURCE
        RECEIVING
          RVAL   = ISTREAM.
    *This iXML factory can create an empty XML document object named IDOCUMENT.
    initialize input document
      DATA:  IDOCUMENT TYPE REF TO IF_IXML_DOCUMENT.
      CALL METHOD L_IXML->CREATE_DOCUMENT
        RECEIVING
          RVAL = IDOCUMENT.
    parse input document
      DATA: IPARSER TYPE REF TO IF_IXML_PARSER.
      CALL METHOD L_IXML->CREATE_PARSER
        EXPORTING
          DOCUMENT       = IDOCUMENT
          ISTREAM        = ISTREAM
          STREAM_FACTORY = STREAMFACTORY
        RECEIVING
          RVAL           = IPARSER.
      IPARSER->PARSE( ).
      DATA: EL_ELEMENT TYPE REF TO IF_IXML_ELEMENT,
            VALUE TYPE STRING.
      DATA: ROOT TYPE REF TO IF_IXML_ELEMENT.
    get message content of tag
      DATA: INCODE  TYPE REF TO IF_IXML_NODE_COLLECTION,
            INCODE1 TYPE REF TO IF_IXML_NODE_COLLECTION,
            INCODE2 TYPE REF TO IF_IXML_NODE_COLLECTION,
            INCODE0  TYPE REF TO IF_IXML_NODE_COLLECTION.
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
        EXPORTING
         DEPTH     = 0
          NAME      = 'MANDT'
         NAMESPACE = 'urn:sap-com:document:sap:rfc:functions'
        RECEIVING
          RVAL      = INCODE0 .
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
      EXPORTING
         DEPTH     = 0
        NAME      = 'EMPNO'
         NAMESPACE = 'urn:sap-com:document:sap:rfc:functions'
      RECEIVING
        RVAL      = INCODE.
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
    EXPORTING
         DEPTH     = 0
    NAME      = 'EMPNAME'
         NAMESPACE = 'urn:sap-com:document:sap:rfc:functions'
    RECEIVING
    RVAL      = INCODE1.
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
    EXPORTING
         DEPTH     = 0
    NAME      = 'DEPARTMENTNAME'
         NAMESPACE = 'urn:sap-com:document:sap:rfc:functions'
    RECEIVING
    RVAL      = INCODE2.
      DATA: URI TYPE STRING.
      URI = 'urn:sap-com:document:sap:rfc:functions'.
    * build up output document =============================================
    create output document
      DATA: ODOCUMENT TYPE REF TO IF_IXML_DOCUMENT.
      CALL METHOD L_IXML->CREATE_DOCUMENT
        RECEIVING
          RVAL = ODOCUMENT.
    DATA: RET_VALUE TYPE I.
    **At this point you can add the nodes (elements, attributes) into the document. First you have to declare the root element node.
      DATA: L_ELEMENT_ROOT TYPE REF TO IF_IXML_ELEMENT.
      DATA: NODE_LIST_COLLECTION TYPE REF TO IF_IXML_NODE_COLLECTION.
    add node to the output document
      DATA: OUTCODE0 TYPE REF TO IF_IXML_NODE.
      DATA: OUTCODE  TYPE REF TO IF_IXML_NODE.
      DATA: OUTCODE1 TYPE REF TO IF_IXML_NODE.
      DATA: OUTCODE2 TYPE REF TO IF_IXML_NODE.
      DATA: INDEX1 TYPE SY-INDEX.
      DATA: INDEX TYPE SY-INDEX.
      DATA IRC TYPE I.
      TYPES:  BEGIN OF TY_IMPORT,
               MANDT             TYPE MANDT,
               EMPNO             TYPE STRING,
               EMPNAME           TYPE STRING,
               DEPARTMENTNAME    TYPE STRING,
         END OF TY_IMPORT.
      DATA: IT_IMPORT TYPE STANDARD TABLE OF TY_IMPORT.
      DATA: WA_IMPORT TYPE                 TY_IMPORT.
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
        EXPORTING
       DEPTH     = 0
          NAME      = 'MANDT'
       NAMESPACE = ''
        RECEIVING
          RVAL      =  NODE_LIST_COLLECTION.
      DATA: LENGTH TYPE I.
      CALL METHOD NODE_LIST_COLLECTION->GET_LENGTH
        RECEIVING
          RVAL = LENGTH.
      WHILE INDEX < LENGTH.
       CALL METHOD IDOCUMENT->FIND_FROM_NAME
         EXPORTING
           DEPTH     = index
           NAME      = 'EMPNO'
           NAMESPACE = ''
         RECEIVING
           RVAL      = EL_ELEMENT .
        CALL METHOD INCODE0->GET_ITEM
          EXPORTING
            INDEX = INDEX
          RECEIVING
            RVAL  = OUTCODE0.
       EL_ELEMENT = IDOCUMENT->FIND_FROM_NAME( 'MANDT' ).
        VALUE = OUTCODE0->GET_VALUE( ).
        WA_IMPORT-MANDT  = VALUE.
        CLEAR: VALUE.
        CALL METHOD INCODE->GET_ITEM
          EXPORTING
            INDEX = INDEX
          RECEIVING
            RVAL  = OUTCODE.
       EL_ELEMENT = IDOCUMENT->FIND_FROM_NAME( 'EMPNO' ).
        VALUE = OUTCODE->GET_VALUE( ).
        WA_IMPORT-EMPNO  = VALUE.
        CLEAR: VALUE.
        CALL METHOD INCODE1->GET_ITEM
          EXPORTING
            INDEX = INDEX
          RECEIVING
            RVAL  = OUTCODE1.
       EL_ELEMENT = IDOCUMENT->FIND_FROM_NAME( 'EMPNAME' ).
        VALUE = OUTCODE1->GET_VALUE( ).
        WA_IMPORT-EMPNAME  = VALUE.
        CLEAR: VALUE.
        CALL METHOD INCODE2->GET_ITEM
          EXPORTING
            INDEX = INDEX
          RECEIVING
            RVAL  = OUTCODE2.
       EL_ELEMENT = IDOCUMENT->FIND_FROM_NAME( 'DEPARTMENTNAME' ).
        VALUE = OUTCODE2->GET_VALUE( ).
        WA_IMPORT-DEPARTMENTNAME  = VALUE.
        CLEAR: VALUE.
        APPEND WA_IMPORT TO IT_IMPORT.
        CLEAR WA_IMPORT.
        ADD 1 TO INDEX.
      ENDWHILE.
      TYPES: BEGIN OF TY_DATA,
              DATA TYPE STRING,
                    END OF TY_DATA.
      DATA: IT_DATA TYPE STANDARD TABLE OF TY_DATA,
            WA_DATA TYPE TY_DATA.
      DATA: SSSS TYPE STRING.
      IF SOURCE IS NOT INITIAL.
        CALL FUNCTION 'ECATT_CONV_XSTRING_TO_STRING'
          EXPORTING
            IM_XSTRING  = SOURCE
            IM_ENCODING = 'UTF-8'
          IMPORTING
            EX_STRING   = SSSS.
      ENDIF.
    render document ======================================================
    create output stream
      DATA: XX TYPE STRING.
      DATA: XX_1 TYPE STRING.
      DATA: XX1 TYPE STRING.
      DATA: XX2 TYPE STRING.
      DATA: T1 TYPE STRING VALUE ''.
      DATA: T TYPE STRING VALUE '<DATA><MANDT>'.
      LOOP AT IT_IMPORT INTO WA_IMPORT.
       CLEAR: XX1.
       IF SY-TABIX = 1.
        IF WA_IMPORT-EMPNO = '000000000022'.
          CONCATENATE  T WA_IMPORT-MANDT '</MANDT>'
         '<EMPNO>' WA_IMPORT-EMPNO '</EMPNO>'
         '<EMPNAME>' WA_IMPORT-EMPNAME '</EMPNAME><DEPARTMENTNAME>'
         WA_IMPORT-DEPARTMENTNAME '</DEPARTMENTNAME></DATA>'
          INTO XX1   .
         IF SY-TABIX = 1.
         ELSE.
          CONCATENATE    XX1   XX_1 INTO XX_1.
         ENDIF.
        ELSE.
          CONCATENATE  T WA_IMPORT-MANDT '</MANDT>'
    '<EMPNO>' WA_IMPORT-EMPNO '</EMPNO>'
    '<EMPNAME>' WA_IMPORT-EMPNAME '</EMPNAME><DEPARTMENTNAME>'
    WA_IMPORT-DEPARTMENTNAME '</DEPARTMENTNAME></DATA>' INTO XX1   .
          CONCATENATE XX1 XX INTO XX.
         ENDIF.
        ENDIF.
        AT LAST.
          CONCATENATE '<?xml version="1.0" encoding="UTF-8"?><ns1:ZTEST1 xmlns:ns1="urn:sap-com:document:sap:rfc:functions">'
        XX_1 INTO XX_1.
          CONCATENATE  XX_1 '</ns1:ZTEST1>' INTO XX_1.
          CALL FUNCTION 'ECATT_CONV_STRING_TO_XSTRING'
    EXPORTING
      IM_STRING         = XX_1
    IM_ENCODING       = 'UTF-8'
    IMPORTING
    EX_XSTRING        = RESULT.
        EX_LEN            = .
          CONCATENATE '<?xml version="1.0" encoding="UTF-8"?><ns1:ZTEST1 xmlns:ns1="urn:sap-com:document:sap:rfc:functions">'
    XX        INTO XX.
          CONCATENATE XX '</ns1:ZTEST1>' INTO XX.
         CONCATENATE XX_1 XX INTO XX.
          CALL FUNCTION 'ECATT_CONV_STRING_TO_XSTRING'
            EXPORTING
              IM_STRING         = XX
             IM_ENCODING       = 'UTF-8'
           IMPORTING
             EX_XSTRING        = RESULT
        EX_LEN            =
        ENDAT.
      ENDLOOP.
    ENDMETHOD.
    here above result parameter will have the target data..But it sends the that same data to both the system , If i will be able to recursively call this method, then i be able to solve the prob easily as first time result will send one data to one system and next time to other system,

    Hi munish,
    I dont think there is any thing wrong with the ABAP code.
    Try testing your ABAP mapping using transaction code SXI_MAPPING_TEST in XI.
    Enter the Details asked and then enter TEst data in XML format.. 
    Also, you can make use of the Trace element to find out if there is any thing wrong with the code.
    Include the following Statements after every step in the ABAP code to ensure that the particular step is completed successfully.
    data : l_trace type string.
    concatenate l_trace '<Message you want to display>' into l_trace.
    trace->trace(level = '<level>'
    message =l_trace).  
    The trace is visible in SXMB_MONI (click on "Trace" in the left pane to view).
    using this you will get to know i the code is functioning as desired.
    Regards,
    Yashaswee.

  • ABAP Mapping: ostream with multiple sibling tags (ixml_document_fragment ?)

    Hallo,
    during ABAP Mapping I have the following problem:
    I want to return a message to XI Java stack in the following format:
    <?xml version="1.0"?><ns0:MT_FILE_PAXAR_INB xmlns:ns0="http://logimoda.com/ns_paxar">
    <Recordset>
    [... child tags which values are retrieved from fields of each record of an internal table]
    </Recordset>
    </ns0:MT_FILE_PAXAR_INB>
    I want n <Recordset>, one for each record of the internal table "t_etichette", which is populated by:
    CALL FUNCTION 'ZXI_ETICHETTE_COMPOSIZIONE_PEZ'
    Now, i'm not able to append n sibling <Recordset>, only one is appended to parent <ns0:MT_FILE_PAXAR_INB>.
    I guess the solution is ixml_document_fragment or using someway an iteration, but I don't know how...
    Any suggestion?
    Thanks all in advance:)
    PS below my current source code:
    METHOD if_mapping~execute .
    1.0 Def. Data Types - Start **********************************
      DATA:
            wa_t_richieste  TYPE          zppst_input_etichette_pezzo,
            t_richieste     TYPE TABLE OF zppst_input_etichette_pezzo,
            wa_t_etichette  TYPE          zppst_output_etichette_pezzo,
            t_etichette     TYPE TABLE OF zppst_output_etichette_pezzo,
            wa_t_logelab    TYPE          zppst_esito_etichette_pezzo,
            t_logelab       TYPE TABLE OF zppst_esito_etichette_pezzo.
    1.1 Def. Data Types - End   **********************************
    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 ).
      DATA: val_nodo  TYPE string,
            nome_nodo TYPE string,
            nome_el   TYPE string
      DATA: ta_data TYPE STANDARD TABLE OF ztabxml,
            wa_data TYPE ztabxml.
    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: element  TYPE REF TO if_ixml_element.
      DATA: articolo TYPE REF TO if_ixml_element.
      DATA: collo    TYPE REF TO if_ixml_element.
      DATA: l_trace  TYPE string.
      DATA: child    TYPE REF TO if_ixml_node.
      DATA: nr_art   TYPE REF TO if_ixml_node_collection.
      DATA: dest    TYPE rfcdest,
            wa_cust TYPE zxi_cust,
            mandt   TYPE sy-mandt.
      SELECT SINGLE * FROM zxi_cust INTO wa_cust
             WHERE parname1 = 'RFC_DEST'
               AND parname2 = 'R/3'.
      dest  = wa_cust-parvalue1.
      mandt = dest+7(3).
    1.2 Mapping XML -> items      ************************************
      CLEAR    nome_nodo.
      CLEAR    child.
      CLEAR    ciclo.
      element = idocument->find_from_path_ns(
                                     path    =
    '/RIGA'
                                 default_uri = '' ).
      nome_el = element->get_name( ).
      ciclo = 'true'.
      WHILE ciclo = 'true'.
    Mandante
        MOVE mandt TO wa_t_richieste-mandt.
        IF nome_el = 'RIGA'.
          child = element->get_first_child( ).
          WHILE child IS BOUND.
            nome_nodo = child->get_name( ).
            val_nodo  = child->get_value( ).
            CASE nome_nodo.
              WHEN 'COD_MSGEXPORT'.
    Identificativo da Logimoda
                MOVE val_nodo TO wa_t_richieste-zcodeidoc.
              WHEN 'C0001'.
    Commessa
                MOVE val_nodo TO wa_t_richieste-j_3acomord.
            ENDCASE.
            child = child->get_next( ).
          ENDWHILE.
          APPEND wa_t_richieste TO t_richieste.
          CLEAR: wa_t_richieste.
          element ?= element->get_next( ).
          IF NOT element IS BOUND.
            EXIT.
          ENDIF.
          nome_el = element->get_name( ).
        ELSE.
          ciclo = 'false'.
        ENDIF.
      ENDWHILE.
    1.3 call RFC     ************************************************
      DATA: return TYPE sy-subrc.
      DATA: t_return TYPE TABLE OF bapiret2.
      DATA: st_return TYPE bapiret2.
      DATA: mess_exc TYPE string.
      DATA: t_error_text TYPE string.
      CLEAR: return.
      CLEAR: t_return.
      REFRESH: t_return.
      CALL FUNCTION 'ZXI_ETICHETTE_COMPOSIZIONE_PEZ'
        DESTINATION
        dest
       EXPORTING
    TO DO: Y or N ??
         fl_alv       = ' '
        TABLES
          t_richieste  = t_richieste
          t_etichette  = t_etichette
          t_logelab    = t_logelab
        EXCEPTIONS
          no_richieste = 1
          no_etichette = 2
          no_plant     = 3
          OTHERS       = 4.
      IF ( ( sy-subrc <> 0 )      AND
           ( dest <> 'MZ1CLNT400' )
        DATA subrc TYPE sy-subrc.
        CASE subrc.
          WHEN 1.
           LOOP AT t_logelab INTO st_logelab WHERE type EQ 'E'.
            CONCATENATE 'ABAP MAPPING ERROR: '
                         'NO_RICHIESTE'
                         INTO mess_exc.
            trace->trace( level = '1'
                          message = mess_exc ).
            RAISE EXCEPTION TYPE cx_mapping_fault
                  EXPORTING error_code = '90'
                            error_text = 'NO_RICHIESTE'.
           ENDLOOP.
          WHEN 2.
          WHEN 3.
          WHEN OTHERS.
        ENDCASE.
      ENDIF.
    1.4 build up output document *****************************************
      DATA: ret_value TYPE i.
      DATA: uri       TYPE string.
      uri = 'http://logimoda.com/ns_paxar'.
    create output document
      DATA: odocument TYPE REF TO if_ixml_document.
      odocument = ixmlfactory->create_document( ).
    Test - Start ***********
    DATA: root_ns TYPE REF TO if_ixml_namespace_decl.
    root_ns = odocument->create_namespace_decl(
          name   = 'ns0'
          prefix = 'ns0'
          uri    =  uri ).
    ret_value = odocument->set_namespace_prefix(
    prefix = 'ns0'
    ret_value = odocument->set_namespace_uri(
    uri = 'ns0'
    root = odocument->create_element_ns(
    name   = 'ns0'
    prefix = 'ns0'
    uri    = 'http://logimoda.com/ns_paxar'
    Test - End   ***********
    create root XML tag
      DATA: root TYPE REF TO if_ixml_element.
      root = odocument->create_simple_element_ns(
         name   = 'MT_FILE_PAXAR_INB'
         prefix = 'ns0'
         uri    = uri
        value = temp
         parent = odocument ).
      DATA: ns_xml_attr TYPE REF TO if_ixml_attribute.
      ns_xml_attr = odocument->create_attribute_ns(
      name   = 'ns0'
      prefix = 'xmlns'
      uri    = 'http://logimoda.com/ns_paxar'
      ret_value = ns_xml_attr->set_value( uri ).
      ret_value = root->set_attribute_node_ns(
       new_attr = ns_xml_attr
    create recordset tag (<= see ref. in FTP Comm. Channel)
      DATA: recordset TYPE REF TO if_ixml_element.
    recordset = odocument->create_simple_element(
        name = 'Recordset'
        value = temp
        parent = root ).
    Test - Start ***********
      DATA: doc_fragm TYPE REF TO if_ixml_document_fragment.
      doc_fragm = odocument->create_document_fragment( ).
    create recordset tag (<= see ref. in FTP Comm. Channel)
      recordset = odocument->create_simple_element(
         name = 'Recordset'
        value = temp
         parent = doc_fragm ).
      DATA: ref_child TYPE REF TO if_ixml_node.
      ret_value = root->insert_child(
      new_child = doc_fragm
      ref_child = ref_child
    DATA: recordset_array TYPE REF TO if_ixml_node_collection.
    recordset_array->append_item(recordset_el).
    Test - End   ***********
    XI Inbound Message: MT_FILE_PAXAR_INB
      DATA: zcodeidoc       TYPE REF TO if_ixml_element.
      DATA: j_3acomord      TYPE REF TO if_ixml_element.
      DATA: werks           TYPE REF TO if_ixml_element.
      DATA: trilog_yseason  TYPE REF TO if_ixml_element.
      DATA: temp TYPE string.
      LOOP AT t_etichette INTO wa_t_etichette.
    HERE IS THE PROBLEM, HOW TO DO IT ?
        ret_value = root->insert_child(
         new_child = recordset
         ref_child = recordset
        CLEAR temp.
        MOVE wa_t_etichette-zcodeidoc TO temp.
        zcodeidoc  = odocument->create_simple_element(
        name = 'ZCODEIDOC'
         value = temp
        parent = recordset ).
        CLEAR temp.
        MOVE wa_t_etichette-j_3acomord TO temp.
        j_3acomord  = odocument->create_simple_element(
           name = 'j_3acomord'
         value = temp
           parent = recordset ).
        CLEAR temp.
        MOVE wa_t_etichette-werks TO temp.
        werks  = odocument->create_simple_element(
         name = 'WERKS'
         value = temp
         parent = recordset ).
        CLEAR temp.
       MOVE wa_t_etichette-trilog_yseason TO temp.
        trilog_yseason  = odocument->create_simple_element(
           name = 'trilog_yseason'
         value = temp
           parent = recordset ).
        CLEAR wa_t_etichette.
      ENDLOOP.
    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.
      DATA irc TYPE i.
      renderer = ixmlfactory->create_renderer( ostream = ostream
      document = odocument ).
      irc = renderer->render( ).
    1.4 for debug ********************************************************
    Uploading Files and Manipulating their Content
    (SAP Library - Business Server Pages)
    http://help.sap.com/saphelp_nw2004s/helpdata/en/ba/78d3c747b24546ab1c1499a054d8a5/content.htm
      DATA: conv_out TYPE REF TO cl_abap_conv_out_ce.
      conv_out = cl_abap_conv_out_ce=>create(
               encoding = 'UTF-8'
               endian = 'L' ).
    conversion string => xstring *********************************
    conv->convert( EXPORTING data = out
                    IMPORTING buffer = result ).
    conversion xstring => string *********************************
      DATA: outxml TYPE string.
      DATA: conv_in   TYPE REF TO cl_abap_conv_in_ce.
      conv_in = cl_abap_conv_in_ce=>create( input = result ).
      conv_in->read( IMPORTING data = outxml ).
    store file txt on PC for test purpose - Start          ********
      DATA: dataset_str_xml  TYPE string,
            debug_allowed(1) TYPE c,
            l_xml_size       TYPE i.
        dataset_str_xml = '/usr/sap/XIT/ZXI_PARAX_TEST_XML.xml'.
        OPEN DATASET dataset_str_xml FOR OUTPUT
             IN TEXT MODE ENCODING DEFAULT.
        TRANSFER outxml TO dataset_str_xml.
        CLOSE DATASET dataset_str_xml.
    store file txt on PC for test purpose - End            ********
    ENDMETHOD.

    create recordset tag (<= see ref. in FTP Comm. Channel)
    recordset = odocument->create_simple_element(
    name = 'Recordset'
    value = temp
    parent = doc_fragm ).
    this object must be created inside your loop...

  • ABAP Mapping :: for multi files

    Dear Experts,
    We are doing an Idoc to file interface, using ABAP mapping.
    This is 1:n mapping i.e receiver message interface is 0..unbounded.
    We have achieved the mapping for 1:1. But when I test for multi, i get an error in moni saying
    Parsing error after multi mapping.Expected Message<i> instead of Item
    Item is the name of the node that has to be created multiple times.
    Has anyone done multi mapping in ABAP?? Any idea why this error....may be we are missing something.
    Any idea as to how we can progress???
    Thanks in advance
    Regards
    Shobha

    Hi,
    Surely u can use an ABAP mapping for this.
    Sounds like your problem is your not using correct output structure for multi mapping.
    As with any type of multi mapping your structure should reflect this. Your target payload must thus have the following structure:
    <?xml version="1.0" encoding="UTF-8"?>
    <ns0:Messages xmlns:ns0="http://sap.com/xi/XI/SplitAndMerge">
         <ns0:Message1>
              <unboundedPayload/>
         </ns0:Message1>
    </ns0:Messages>
    The <unboundedPayload> element in above should of course be replaced with your actual payload - I believe 'Item' in your case, if that is in fact the root node of your actual payload.
    Regards,
    Daniel

  • ABAP MAPPING : Getting An Error

    hi all
    i am using a scenario where i am sending data from r/3(prog)>xi>R/3(RFC).
    in between i am using ABAP MAPPING
    i am getting an error:
    ERROR:  "" MP: Exception caught with cause com.sap.aii.af.ra.ms.api.RecoverableException: java.lang.StringIndexOutOfBoundsException: String index out of range: -7: com.sap.aii.af.rfc.afcommunication.RfcAFWException: java.lang.StringIndexOutOfBoundsException: String index out of range: -7""
    the ABAP MAPPING which i am using:
    METHOD IF_MAPPING~EXECUTE.
      BREAK-POINT.
      * initialize iXML
      TYPE-POOLS: IXML.
      TYPE-POOLS: IXML.
      DATA: L_IXML TYPE REF TO IF_IXML.
    *creating the Interface by calling the create method in class C_IXML
      CALL METHOD CL_IXML=>CREATE
    EXPORTING
       TYPE   = 0
        RECEIVING
          RVAL   = L_IXML.
    create stream factory
      DATA: STREAMFACTORY TYPE REF TO IF_IXML_STREAM_FACTORY.
      CALL METHOD L_IXML->CREATE_STREAM_FACTORY
        RECEIVING
          RVAL = STREAMFACTORY.
    create input stream
      DATA: ISTREAM TYPE REF TO IF_IXML_ISTREAM.
      CALL METHOD STREAMFACTORY->CREATE_ISTREAM_XSTRING
        EXPORTING
          STRING = SOURCE
        RECEIVING
          RVAL   = ISTREAM.
    *This iXML factory can create an empty XML document object named IDOCUMENT.
    initialize input document
      DATA:  IDOCUMENT TYPE REF TO IF_IXML_DOCUMENT.
      CALL METHOD L_IXML->CREATE_DOCUMENT
        RECEIVING
          RVAL = IDOCUMENT.
    parse input document
      DATA: IPARSER TYPE REF TO IF_IXML_PARSER.
      CALL METHOD L_IXML->CREATE_PARSER
        EXPORTING
          DOCUMENT       = IDOCUMENT
          ISTREAM        = ISTREAM
          STREAM_FACTORY = STREAMFACTORY
        RECEIVING
          RVAL           = IPARSER.
      IPARSER->PARSE( ).
      DATA: ROOT TYPE REF TO IF_IXML_ELEMENT.
    get message content of tag
      DATA: INCODE  TYPE REF TO IF_IXML_NODE_COLLECTION,
            INCODE1 TYPE REF TO IF_IXML_NODE_COLLECTION,
            INCODE2 TYPE REF TO IF_IXML_NODE_COLLECTION,
            INCODE0  TYPE REF TO IF_IXML_NODE_COLLECTION.
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
        EXPORTING
         DEPTH     = 0
          NAME      = 'MANDT'
         NAMESPACE = ''
        RECEIVING
          RVAL      = INCODE0 .
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
      EXPORTING
         DEPTH     = 0
        NAME      = 'EMPNO'
         NAMESPACE = ''
      RECEIVING
        RVAL      = INCODE.
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
    EXPORTING
         DEPTH     = 0
    NAME      = 'EMPNAME'
         NAMESPACE = ''
    RECEIVING
    RVAL      = INCODE1.
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
    EXPORTING
         DEPTH     = 0
    NAME      = 'DEPARTMENTNAME'
         NAMESPACE = ''
    RECEIVING
    RVAL      = INCODE2.
      DATA: URI TYPE STRING.
      URI = 'urn:sap-com:document:sap:rfc:functions'.
    * build up output document =============================================
    create output document
      DATA: ODOCUMENT TYPE REF TO IF_IXML_DOCUMENT.
      CALL METHOD L_IXML->CREATE_DOCUMENT
        RECEIVING
          RVAL = ODOCUMENT.
      DATA: RET_VALUE TYPE I.
    *At this point you can add the nodes (elements, attributes) into the document. First you have to declare the root element node.
      DATA: L_ELEMENT_ROOT TYPE REF TO IF_IXML_ELEMENT.
      CALL METHOD ODOCUMENT->CREATE_ELEMENT_NS
        EXPORTING
          NAME   = 'ZTEST1'
          PREFIX = 'ns1'
          URI    = 'urn:sap-com:document:sap:rfc:functions'
        RECEIVING
          RVAL   = L_ELEMENT_ROOT.
      DATA: L_ELEMENT_NODE TYPE REF TO IF_IXML_ELEMENT.
      CALL METHOD ODOCUMENT->CREATE_SIMPLE_ELEMENT
        EXPORTING
          NAME      = 'ZTEST1'
         NAMESPACE = 'xmlns ns1 urn:sap-com:document:sap:rfc:functions'
          PARENT     = ODOCUMENT
       VALUE     = '?xml version="1.0" encoding="UTF-8"?'
        RECEIVING
          RVAL      = L_ELEMENT_ROOT.
      DATA: ATTRIBUTE TYPE REF TO IF_IXML_ATTRIBUTE.
      CALL METHOD ODOCUMENT->CREATE_ATTRIBUTE_NS
        EXPORTING
          NAME   = 'ZTEST1'
          PREFIX = 'xmlns'" ns1="urn:sap-com:document:sap:rfc:functions"'
          URI    = 'urn:sap-com:document:sap:rfc:functions'
        RECEIVING
          RVAL   = ATTRIBUTE.
      RET_VALUE = ODOCUMENT->SET_NAMESPACE_PREFIX(
    PREFIX = 'ns1').
      CALL METHOD ATTRIBUTE->SET_VALUE
        EXPORTING
          VALUE = URI
        RECEIVING
          RVAL  = RET_VALUE.
      CALL METHOD L_ELEMENT_ROOT->SET_ATTRIBUTE_NODE_NS
        EXPORTING
          NEW_ATTR = ATTRIBUTE
        RECEIVING
          RVAL     = RET_VALUE.
      DATA: NODE_LIST_COLLECTION TYPE REF TO IF_IXML_NODE_COLLECTION.
    add node to the output document
      DATA: OUTCODE0 TYPE REF TO IF_IXML_NODE.
      DATA: OUTCODE  TYPE REF TO IF_IXML_NODE.
      DATA: OUTCODE1 TYPE REF TO IF_IXML_NODE.
      DATA: OUTCODE2 TYPE REF TO IF_IXML_NODE.
      DATA: INDEX1 TYPE SY-INDEX.
      DATA: INDEX TYPE SY-INDEX.
      DATA IRC TYPE I.
      CALL METHOD IDOCUMENT->GET_ELEMENTS_BY_TAG_NAME
        EXPORTING
       DEPTH     = 0
          NAME      = 'MANDT'
       NAMESPACE = ''
        RECEIVING
          RVAL      =  NODE_LIST_COLLECTION.
      DATA: LENGTH TYPE I.
      CALL METHOD NODE_LIST_COLLECTION->GET_LENGTH
        RECEIVING
          RVAL = LENGTH.
      WHILE INDEX < LENGTH.
        CALL METHOD IDOCUMENT->CREATE_SIMPLE_ELEMENT
          EXPORTING
            NAME      = 'DATA'
       NAMESPACE = ''
            PARENT     = L_ELEMENT_ROOT
       VALUE     =
          RECEIVING
            RVAL      =  L_ELEMENT_NODE .
        CALL METHOD INCODE0->GET_ITEM
          EXPORTING
            INDEX = INDEX
          RECEIVING
            RVAL  = OUTCODE0.
        CALL METHOD INCODE->GET_ITEM
          EXPORTING
            INDEX = INDEX
          RECEIVING
            RVAL  = OUTCODE.
        CALL METHOD INCODE1->GET_ITEM
          EXPORTING
            INDEX = INDEX
          RECEIVING
            RVAL  = OUTCODE1.
        CALL METHOD INCODE2->GET_ITEM
          EXPORTING
            INDEX = INDEX
          RECEIVING
            RVAL  = OUTCODE2.
        CALL METHOD L_ELEMENT_NODE->APPEND_CHILD
          EXPORTING
            NEW_CHILD = OUTCODE0
          RECEIVING
            RVAL      = IRC.
        CALL METHOD L_ELEMENT_NODE->APPEND_CHILD
          EXPORTING
            NEW_CHILD = OUTCODE
          RECEIVING
            RVAL      = IRC.
        CALL METHOD L_ELEMENT_NODE->APPEND_CHILD
          EXPORTING
            NEW_CHILD = OUTCODE1
          RECEIVING
            RVAL      = IRC.
        CALL METHOD L_ELEMENT_NODE->APPEND_CHILD
          EXPORTING
            NEW_CHILD = OUTCODE2
          RECEIVING
            RVAL      = IRC.
        ADD 1 TO INDEX.
      ENDWHILE.
    render document ======================================================
    create output stream
      DATA: OSTREAM TYPE REF TO IF_IXML_OSTREAM.
      CALL METHOD STREAMFACTORY->CREATE_OSTREAM_XSTRING
        EXPORTING
          STRING = RESULT
        RECEIVING
          RVAL   = OSTREAM.
    DATA: IPARSER TYPE REF TO IF_IXML_PARSER.
      CALL METHOD L_IXML->CREATE_PARSER
        EXPORTING
          DOCUMENT       = ODOCUMENT
          ISTREAM        = ISTREAM
          STREAM_FACTORY = STREAMFACTORY
        RECEIVING
          RVAL           = IPARSER.
      IPARSER->PARSE( ).
    create renderer
      DATA: RENDERER TYPE REF TO IF_IXML_RENDERER.
      CALL METHOD L_IXML->CREATE_RENDERER
        EXPORTING
          DOCUMENT = ODOCUMENT
          OSTREAM  = OSTREAM
        RECEIVING
          RVAL     = RENDERER.
      IRC = RENDERER->RENDER( ).
    ENDMETHOD.
    plz help me out ASAP
    thnks
    kalyan

    hi
        all
    now the situation is that i am able to send the data to R/3,
    But in RWB-->MessageMonitoring ->version>Message Contents i am getting a error :
    *XML Parsing Error: not well-formed
    Location: http://aipid:50000/mdt/messagecontentservlet?attachment=0
    Line Number 1, Column 176:*
    <?xml version="1.0"?><ns1:ZTEST1 xmlns:ns1="urn:sap-com:document:sap:rfc:functions"><DATA><MANDT>210</MANDT><EMPNO>000000000023</EMPNO><EMPNAME>C</EMPNAME></DATA></ns1:ZTEST1 xmlns:ns1="urn:sap-com:document:sap:rfc:functions">
    it is not converted into XML ,the underline is the error which it is showing.
    it would be great if any one can figure it out what might be the cause of this error
    thanks
    kalyan

  • Receiver determintation using Abap Mapping

    Hi,
    I configured a scenario in which I'm using extended receiver determination to determine the receiver of an incoming message. (The reason for this is that there is only one XI system and two ECC systems - DEV and QAS. By means of the setting in a customizing table it can be determined whether the message is sent to DEV or QAS. The message can't be sent to both systems because it is a synchronous interface). The receiver determination calls an Interface Mapping which has target interface Receiver Determination. I made an Abap Mapping program in which the customize table is read and the output message is formed as follows (according to the structure of the Receivers message):
          lrf_output_document = lrf_ixml_factory->create_document( ).
          lrf_receivers = lrf_output_document->create_simple_element( name = 'Receivers'
                                                                      parent = lrf_output_document ).
          lrf_receiver  = lrf_output_document->create_simple_element( name = 'Receiver'
                                                                      parent = lrf_receivers ).
          lrf_element   = lrf_output_document->create_simple_element( name = 'Party'
                                                                      value = ' '
                                                                      parent = lrf_receiver ).
          lrf_element->set_attribute( name = 'agency'
                                                 value = ' ' ).
          lrf_element->set_attribute( name = 'scheme'
                                                value = ' ' ).
          lrf_element   = lrf_output_document->create_simple_element( name = 'Service'
                                                        value  = 'DEV'
                                                        parent = lrf_receiver ).
    To fill the RESULT field a stream factory is instantiated and a XSTRING is created. When I send a message to the system, the receiver determination dumps: Error when parsing receiver listLength of XML document 129 Error when parsing receiver listLength of XML Document 129 System expected the element 'Receivers'
    Looks like the XSTRING has not got the right structure and can not be parsed into the Receivers message. However, when I create a CSTRING, the message looks OK. I also changed the encoding (Codepage 4103).
    When I replace the Abap mapping with a message mapping, the receiver determination works OK. However, in that case it is not possible to read the customizing table. I really need the Abap mapping.
    Has anyone ever filled the Receivers massage by means of Abap mapping. Any feedback will be appreciated!

    Hi,
    there is a easier way - totally based on my blogs
    create an abap mapping that will feed the dynamicconfiguration in ABAP (with z "Z" namespace) - similar thing shown in my blog
    /people/michal.krawczyk2/blog/2007/04/26/xipi-throwing-generic-exceptions-from-any-type-of-mapping
    and you don't need to create the XML in ABAP mapping just parse it, fill DC and send the same source to the target
    (so you don't change the XML)
    then add a message mapping to your interface mapping in which you will only use dynamicconfig value
    to populate the receiver segment
    nice and clean way
    Regards,
    Michal Krawczyk

  • Java Mapping/UDF/ABAP mapping to capture payload

    Hi,
    could you please provide me Java mapping code samples (or UDF code) to save payloads of a message based on Message ID
    i have a synchronous scenario where i have payloads in sxmb_moni for request and response with different message IDs. So pelase let me know how to save those request and response payloads to a file.
    it would be great if you provide the stpes to implement and java code samples....if it is possible with ABAP mapping also please let me know te steps.
    Best Regards....SARAN

    Try with this code
    import com.sap.mw.jco.IFunctionTemplate;
    import com.sap.mw.jco.IRepository;
    import com.sap.mw.jco.JCO;
    public class PayloadExtractor {
        // The MySAP.com system we gonna be using
        static final String SID = "SID";
        // The repository we will be using
       IRepository repository;
        JCO.Field msgkeyField;
        public PayloadExtractor() {
            try {
                System.out.println("*** Creating the Pool... ***");
                JCO.addClientPool(SID, 10, "001", "user", "pwd", "EN", "host", "00");
                repository = JCO.createRepository("RecoverRepository", SID);
            } catch (JCO.Exception ex) {
                System.out.println("RecoverXI Caught an exception: \n" + ex);
        // Retrieves and prints information about the remote system
        public void getPayload() {
            // A messageID from your XI/PI
            String key = "48CD01EB3D27021BE1008000C0A8477D";
            final String pipelineID = "CENTRAL";
            byte[] msgkey = key.getBytes();
            try {
                IFunctionTemplate ftemplate = repository.getFunctionTemplate("SXMB_READ_MESSAGE_VERSION_RAW");
                if (ftemplate != null) {
                    System.out.println("*** Creating client and function... ***");
                    JCO.Function function = ftemplate.getFunction();
                    JCO.Client client = JCO.getClient(SID);
                    JCO.Structure struct = function.getImportParameterList().getStructure("MESSAGEKEY");
                    struct.setValue(key, "MSGID");
                    struct.setValue(pipelineID, "PID");
                    // SELECTION must be like this!
                    function.getImportParameterList().getField("SELECTION").setValue("2");
                    // This is the msg version number, where 000 is the first (Inbound); the last can be caught from the function output (see below).
                    // Setting this strongly depends on what you want to get: basically before or after the mapping...
                    function.getImportParameterList().getField("VERSION_REQUEST").setValue("000");
                    System.out.println("*** Calling... ***");
                    client.execute(function);
                    JCO.Table tb = function.getExportParameterList().getTable("MESSAGEPAYLOAD");
                    if (tb.getNumRows() > 0) {
                        // There could be multiple payloads (even if usually it's only one)
                        do {
                            String plstr = new String(tb.getField("PAYLOAD").getByteArray());
                            System.out.println(
                                "*** Payload found *** " + tb.getField("NAME").getString() + " *** BEGIN ***");
                            System.out.println(
                                "Message Last Version: "
                                    + function.getExportParameterList().getField("MAXVERSION").getString());
                            System.out.println(plstr);
                            System.out.println(
                                "*** Payload found *** " + tb.getField("NAME").getString() + " ***  END  ***");
                        } while (tb.nextRow());
                    } else {
                        System.out.println("*** No payload found! ***");
                    // Release the client into the pool
                    JCO.releaseClient(client);
                } else {
                    System.out.println("Function SXMB_READ_MESSAGE_VERSION_RAW not found in backend system.");
            } catch (Exception ex) {
                System.out.println("Caught an exception: \n" + ex);
        protected void cleanUp() {
            System.out.println("*** Cleaning... ***");
            JCO.removeClientPool(SID);
        public static void main(String[] argv) {
            PayloadExtractor e = new PayloadExtractor();
            e.getPayload();
            e.cleanUp();
    -Madhu

  • DOM Programming in class for ABAP Mapping?

    Hi All!!
    I am struggling in transforming XML to be mapping target structures in using ABAP Mapping.
    so i am on developing class with DOM.
    i would like to know how many <person> derived from source xml, so what method should i use so that i can get that result. or does anyone idea how to work with multirecord to output XML?
    data: incode1 type ref to if_ixml_node_collection,
            incode2 type ref to if_ixml_node_collection,
    get message content of tag <FirstName>
      incode1 = idocument->get_elements_by_tag_name( 'FirstName' ).
      incode2 = idocument->get_elements_by_tag_name( 'LastName' ).
    <?xml version="1.0" encoding="UTF-8"?>
    *Source XML
    <ns:Personalinfo xmlns:ns="http://sap.com/test/ABAPMapping">
    <person>
      <FirstName>ABAP</FirstName>
      <LastName>ITEM1</LastName>
    </person>
    <person>
      <FirstName>ABAP</FirstName>
      <LastName>ITEM2</LastName>
    </person>
    </ns:Personalinfo>
    Message was edited by: Tony

    Tony,
    You need to use the method get_length. Try something like: -
    *Get the list of child nodes
      child_nodes = idocument->get_children( ).
    *Get the number of children within child_nodes.
      int         = child_nodes->get_length( ).
    Thanks
    Martin

  • Creating multiple idocs in ABAP mapping

    Hi,
    my scenario is source message (JDBC) to target message (idoc).
    There can be multiple idocs (unbounded).
    I am using ABAP mapping to create the Idoc XML structure. For this i use function module IDX_IDOC_TO_XML.
    The idoc is getting created but the problem occurs in case of generating multiple idoc instances.
    I changed the idoc occurence to unbounded & used the new idoc external definition in the interface mapping.
    I also call the IDX_IDOC_TO_XML & create the output stream factory in a loop (per idoc ).
    However only 1 idoc gets generated every time.
    Can someone suggest how to create the multiple idocs.
    Regards
    Prasenjit

    Hi Prasenjit,
    In order to generate multiple idoc first of all you need to change the target structure with multiple occurence...that you have already done...
    Now while generating XML in abap mapping you have to make sure you have element idoc(with its content) repeating for your "N" number of idocs...
    can you please copy paste your final xml generated...
    Nilesh

  • Abap mapping: remove a parent or child node.

    Hi all,
    I will trying to remove a parent node (and all childs related to it) or a specific child (field) om my XML input message to obtain a new output message.
    Reading the meaning of the methods remove_node and remove child (if_ixml_node) I can not find a solution in writing the right Abap code.
    My ouput document is so defined:
    data: outcode type ref to if_ixml_node.
    I receive the following error message when I try to find all possibilities.
    Runtime Errors         OBJECTS_OBJREF_NOT_ASSIGNED_NO
    If someone can give me a simple code for solving my issue, I will appreciate this.
    Thanks,
    Regards,
       Giovanni

    Hi,
    this link explain the signature that is how to use all the methods  including the method u want
    [http://help.sap.com/saphelp_nw04/helpdata/en/bb/57669ddca511d4990b00508b6b8b11/frameset.htm]
    and this for complete library for ABAP mapping[http://help.sap.com/saphelp_nw04/helpdata/en/bb/57669ddca511d4990b00508b6b8b11/frameset.htm]
    Thanks and regards,
    Kubra Fatima.

  • ABAP Mapping Pretty Print

    Hi Everybody,
    I have an issue with linefeed in ABAP Mapping.The ouput document generated by ABAP Mapping is as follow:
    <?xml version="1.0" encoding="utf-8" ?<Header Node><T_H><SEND_ID value="XYZ"/>
    <REC_ID value="PQR"/>
    <DATE value="2007"/>
    </T_H>
    <O_H><L_NO value="252517"/>
    <W_NO value="298"/>
    <U_NO value="298"/>
    </O_H>
    </Header Node>
    If we can see the above payload, i have the <Header Node> coming in the same line as that of the utf-8 and also the subnode <T_H> starting in the same line and its first field <SEND_ID > in the same line.The same is repeating for the second subnode <O_H>. I want to do a pretty print for this payload.I have used the method <b>set_pretty_print( )</b> in the ABAP Mapping, but there is no effect of this on the output.
    To make it clear let me give the required output Xml
    <?xml version="1.0" encoding="utf-8" ?
    <Header Node>
    <T_H>
    <SEND_ID value="XYZ"/>
    <REC_ID value="PQR"/>
    <DATE value="2007"/>
    </T_H>
    <O_H>
    <L_NO value="252517"/>
    <W_NO value="298"/>
    <U_NO value="298"/>
    </O_H>
    </Header Node>
    Can anybody help me out on this.
    Thanks & Regards,
    Zabiula

    Insert a new line character as per the ABAP rules in the generated XML. It is normally "/n" for microsoft based languages. Not sure what it is in ABAP. May be an ABAPer must be able to help you.
    VJ

  • ABAP-Mapping with CALL TRANSFORMATION

    Hi everybody,
    I got an ABAP mapping that uses CALL TRANSFORMATION:
    TRY.
          CALL TRANSFORMATION (strxsltid)
            SOURCE XML IDOCXML_DOCUMENT
            RESULT XML result.
        CATCH cx_xslt_abap_call_error INTO lr_oref.
          text = lr_oref->get_text( ).
      ENDTRY.
    The TRANSFORMATION returns result THAT GETS ALREADY serialized!
    On base of the result I want to create an new output document:
    * Create output document
      DATA: li_odocument TYPE REF TO if_ixml_document.
      li_odocument = NEW_DOCUMENT.
    * Render document
      DATA: li_ostream TYPE REF TO if_ixml_ostream.
      li_ostream = li_streamfactory->create_ostream_xstring( result ).
    * Create renderer
      DATA: li_renderer TYPE REF TO if_ixml_renderer.
      li_renderer = li_ixmlfactory->create_renderer( ostream = li_ostream
                                                     document = li_odocument ).
      li_renderer->render( ).
    --> The problem is, that already CALL TRANSFORMATION creates a output document. so at the end of the mapping I got a new document wich includes the result of CALL TRANSFORMATION  and NEW_DOCUMENT in one document.
    How can I suppress CALL TRANSFORMATION from writing the output-stream?
    Thanks regards
    Mario
    Edited by: Mario Müller on Feb 24, 2010 2:27 AM

    no answers

  • Abap mapping - Error in Control Framework

    Hi Gurus,
    Scenario: IDOC - -- XI -
    Http (post)
    i am using ABAP mapping for IDOC to XML. I am able to test it using sxi_mapping_test which gives me output XML. But, when i test the scenario from RWB, it fails with "SYSFAIL" error in inbound queue as per moni.
    error - "Error in Control Framework".
    Looks like it did not even go to message mapping pipeline step.
    Please help.
    Thank you,
    mk

    HI,
    Hope you have done all the necessary pre-requisites for ABAP mapping
    This may help u- http://help.sap.com/saphelp_47x200/helpdata/en/55/bff20efe8c11d4b54a006094b9456f/content.htm
    just cross verify with this guide-
    https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/e3ead790-0201-0010-64bb-9e4d67a466b4
    Please also try to debug as follows...
    put a break point inside your class/method....
    goto tcode SXI_MAPPING_TEST....give in the configuation details of your scenario...and when you execute, give the IDOC-XML, copy it from SXMB_MONI where you are getting the error....
    when you execute, it shoudl stop at the break point that you had set in your class....continue debugging using 'F6' function key, and check where you are hitting this error...
    The chances are that the FM that converts IDOC-XML to flat file format might not have been executed correctly...
    Thanks
    Swarup

Maybe you are looking for

  • TC First Backup Queston

    From what I understand is that the very first time TC runs it needs to backup the whole machine. I have my TC mounted over a network and it starts to back up and fails after backing up between 5 and 15 gigs. What I am thinking of doing is connecting

  • Empty white folder but has number next to it!

    After changing a blue folder name in .Mac on my MacBook using the Mail application, a white folder appeared. There is one blue subfolder inside. All my emails in that white folder have disappeared. Next to the white folder is the number 2150, the num

  • How to wipe everything and start over from the beginning in Lightroom 4

    i had photos all over the place including in Lightroom I moved them all to an external hard drive now I want to reinstall Lightroom but can't find the disc. How to wipe everything and just restart.

  • Final cut crashes on open - Error Code Attached

    I started a new project and as soon as I added the video files final cut would crash. Now when I open it, it will crash about 10 seconds later everytime. Computer info: MacBopok Pro Retina, 15-inch, Late 2013 Processor  2.6 GHz Intel Core i7 Memory 

  • SetLocation does not set the location

    Hi, I have just come to a very strange problem. I cloned a JComponent after implementing the Cloneable interface. The second object is moved across a work sheet and then setLocation is called on the first element using the second element's position,