cancel
Showing results for 
Search instead for 
Did you mean: 

XML File to Idoc scenario

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (6)

Answers (6)

Former Member
0 Kudos

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

Former Member
0 Kudos

Self Answered

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

Former Member
0 Kudos

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,

Former Member
0 Kudos

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

Former Member
0 Kudos

Hi Rajeev,

I have copied the XML and changed and uploaded to the external definition, which changed automatically in Message mapping.

That's is fine...How to handle the above situation.

Thanks,

Manju.

Former Member
0 Kudos

this will not work.....dont change IDOC occurance and dont upload in external definition.....leave IDOC as it is.....in msg mapping, there is a tab for msg type occurance.........change that to 0..unbounded for IDOC msg type..........

RKothari
Contributor
0 Kudos

Hi,

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

As I understand, only 1 XML tag is allowed in a valid XML file.

You can verify the same by placing the source payload in Test tab of message mapping.

I guess you can use Java mapping to remove any additional XML tag from source payload and then use message mapping.

-Rahul

Former Member
0 Kudos

Hi Rajeev,

Thanks for that option, If i use that option to 0 to unbounded.

When i am trying to say i am geetting the log as.

The source structure, target structure, or a function library has been changed or could not be found in the Enterprise Services Repository. The mapping definition contains elements or attributes that do not exist in the changed structure, or functions that were changed in a function library. The relevant entries will be deleted.

Target structure has no such path: /PEXR2002/IDOC. Skipping mapping Node with path /PEXR2002/IDOC not found in source structure Target structure has no such path: /PEXR2002/IDOC/@BEGIN. Skipping mapping Node with path /PEXR2002/IDOC/@BEGIN not found in source structure

Do you mean, again i need to start mapping each one every segment or what?

Thanks

Manju.

Former Member
0 Kudos

my suggestion......copy the existing msg mapping.........then in the copied version do all the mappings again after changing occurance...... in interface mapping use this msg mapping and test ur scenario..

Former Member
0 Kudos

Hi Rajeev,

As you said i have changed the occurrence and re-mapped.

NOw i am getting error as

Unable to display tree view; Error when parsing an XML document (The processing instruction target matching "[xX][mM][lL]" is not allowed.)

When i delete one tag and try, it is working. But i need to execute both.

Thanks,

Manju.

former_member200962
Active Contributor
0 Kudos
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<IDOC>
-
-
</IDOC>
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<IDOC>
-
-
</IDOC>

This is not a valid XML message....can you ask the sending application to create a file which has just one <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> tag in the whole file?

Unless you remove the additional XML tags (either sender removes it or you remove it in mapping) your scenario is not going to work.

Regards,

Abhishek.

Former Member
0 Kudos

Hi Abhishek,

If i remove the additional tag <?xml version="1.0" encoding="UTF-8" standalone="yes" ?>

Made like this.

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

<IDOC>

-

-

</IDOC>

<IDOC>

-

-

</IDOC>

i am getting the below error.

Unable to display tree view; Error when parsing an XML document (The markup in the document following the root element must be well-formed.)

Thanks,

Manju.

former_member200962
Active Contributor
0 Kudos

Only removing the XML tag wont help...you should also ensure that the test data which you are using is in accordance with the structure that you have defined as source.....and also your receiver structure should be populated by the test data....check the occurence of your IDOC.

try to manually enter the test data in IR and check.

anupam_ghosh2
Active Contributor
0 Kudos

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