Skip to Content
avatar image
Former Member

XML File to Idoc scenario

Hi all,

I have a scenario XML file -> PI -> SAP (IDOC).

I have created this interface, and it's working fine for single XML tag comes in and maps and creates IDOC in SAP.

When multiple tags in the file (same XML file with two Idocs data), the scenario is falling.

Then i have changed the occurrence of the Idoc type and tried. Still it's showing error.

XML File Format.

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<IDOC>

-

-

</IDOC>

<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

<IDOC>

-

-

</IDOC>

How can i handle this scenario?

1. IF i delete one tag, my scenario will work. (Blocked portion)

2. But file will come as above, how can i handle, i am not using BPM.

Thanks,

Manju.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

6 Answers

  • avatar image
    Former Member
    Dec 23, 2010 at 12:22 PM

    dont change IDOC occurance type in IDOC structure.......just in msg mapping tab change the IDOC msg type occurance to 0..unbounded......then u will see a new header node Messages in target structure.......then do the mapping......

    Add comment
    10|10000 characters needed characters exceeded

    • Hi Manju,

      <?xml version="1.0"; encoding="UTF-8" standalone="yes" ?>

      <IDOC>

      <element>

      <element>

      </IDOC>

      <?xml version="1.0"; encoding="UTF-8" standalone="yes" ?>

      <IDOC>

      <element>

      <element>

      </IDOC>

      This structure shown above itself is going to throw errors in XI since there can be only one line with content

      " <?xml version="1.0"; encoding="UTF-8" standalone="yes" ?>". supposing that you have removed the second occurence of this line. I have one doubt here how are you removing the second occurence? Are you using java mapping or you are simply deleting it from the source message manually. If you are doing it manually then first thing to do is to shift to java mapping and delete the any other occurence of the line from source payload, except the first one( since you won't be doing it manually in real time environment. )

      Now after deletion of second occurence also you are getting errors . Lets see why

      Suppose now the message now looks something like this shown below

      <?xml version="1.0"; encoding="UTF-8" standalone="yes" ?>

      <IDOC>

      <element>

      <element>

      </IDOC>

      <IDOC>

      <element>

      <element>

      </IDOC>

      When ever we put an xml message in XI the parser reading the xml tries to create a tree structure out of it. In the tree structure there can be only one root element. Here the there are two root element i.e. <IDOC>. What I mean to say is that if you can convert the xml structure to one shown below then there will be no errors

      <?xml version="1.0"; encoding="UTF-8" standalone="yes" ?>

      <root>

      <IDOC>

      <element>

      <element>

      </IDOC>

      <IDOC>

      <element>

      <element>

      </IDOC>

      </root>

      or other way round is to convert it to form

      <?xml version="1.0"; encoding="UTF-8" standalone="yes" ?>

      <IDOC>

      <element>

      <element>

      <element>

      <element>

      </IDOC>

      But the problem in the last form is that you won't be able to understand where the first Idoc has ended.

      So to achieve this you can read the source use java mapping (Ex: DOM parser) remove nodes (the line <?xml version="1.0"; encoding="UTF-8" standalone="yes" ?>) from XML tree and insert new nodes like the <root>. Then map it onto corresponding Idoc structure.

      It would have been much easier if was a conversion from flat file to Idoc since in that case we use FCC which always produce correct xml structure. In your case the input itself is xml file thus you can always expect incorrect format.

      I am not sure whether XI will allow correction at mapping level or you have to correct it before mapping itself. Please at first try with java mapping. Then we can switch to alternatives.

      regards

      Anupam

      Edited by: anupamsap on Dec 27, 2010 11:43 AM

      Edited by: anupamsap on Dec 27, 2010 11:46 AM

  • avatar image
    Former Member
    Dec 23, 2010 at 01:57 PM

    Hi Manju,

    I would like to tell you one thing, there should be only one root node tag in the payload. This would only be accepted.

    Try to change the occurance of the source file root node to 0..unbounded and then try to map with the IDOC. Then if you try to send two IDOC data and test in your Message Mapping.

    This is simple like making a suplicate subtree.

    Thanks,

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 24, 2010 at 06:51 AM

    Hi manju ,

    idea Behind for changing Occurence in message mapping to get an Mapping like multimapping Like ( 1:N )

    On message mapping - Go to - Message Tab

    Change Occurence of Source and Target message both to 0 to Unbounded ...

    Then back to first tab ..Design ..

    Now mapping Part ..

    Message is map to massage

    Message 1 is map toi mEssagae 1

    you Row node ( Which contains Sub Node) will map to taget row..

    rest subnodes according to you ,,,,

    Now .. What will happen is .. On the basis of your source Structure ... No of IDOCs will be created on target Side.

    Hope this will help you ..

    Regards

    Prabhat Sharma.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Dec 24, 2010 at 07:16 AM

    Hi Manju,

    First of all please check your Source XML. The kind of xml that you are using is definately not a valid XML. You can check the validity of your xml @ |http://www.w3schools.com/XML/xml_validator.asp].

    Insida a xml file you can never have the top level tag more then once. Also you can save the xml file as .xsl on your local system and try to open with a browser. If its not opening properly this means the xml is not valid.

    Regards,

    Rahul Grover

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 25, 2011 at 11:20 AM

    Self Answered

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 25, 2011 at 01:37 PM

    Hi,

    Just change the IDOC occurance to unbounded..no need to change the occurances in operation mapping.

    In the File structure, u need to take one node and under that u have to add the fields related to IDOC.

    And then, test in mapping level, make a duplicate structure for that node but not at the message type level..

    If u make 3 duplicate subtrees then, at the target side u should get 3 idoc's.

    Regards,

    sunitha

    Add comment
    10|10000 characters needed characters exceeded