Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

How to convert hierarchy XML to CSV/Excel format using PI/XI

Former Member
0 Kudos

posted in PI forum but not many replies, please bear with me as I am in crunch time*

Hi All,

I am working with SAP PI/XI for the first time and need some help file conversion of complex hierarchy XML to CSV file using PI. I have done plenty of research on SDN and could find much related to what I want to do.

Here is the example of how my input XML would look like:

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

<PartyMaster type="OrgHierarchy" name="Compass Group Owned">

<PartyMasterHierarchy>

<Hierarchy level="3" nodeName="Bon Appetit Sector" type="Sector" ID="A00000" refID="A00000">

<Hierarchy level="4" nodeName="BA Division" type="Division" ID="AB0000" refID="AB0000" >

<Hierarchy level="5" nodeName="BA East Coast Region" type="Region" ID="ABE000" refID="ABE000">

<Hierarchy level="6" nodeName="Engstrom, John RVP" type="District" ID="ABE01" refID="ABE01" >

</Hierarchy>

</Hierarchy>

</Hierarchy>

</Hierarchy>

<Hierarchy level="3" nodeName="Levy Sector" type="Sector" ID="K00000" refID="K00000".

<Hierarchy level="4" nodeName="Levy Sector Division" type="Division" ID="K90000" refID="K90000">

<Hierarchy level="5" nodeName="Levy Sector Region" type="Region" ID="K99000" refID="K99000">

<Hierarchy level="6" nodeName="TBA Total" type="District" ID="K9901" refID="K9901"> </Hierarchy>

</Hierarchy>

</Hierarchy>

</Hierarchy>

</PartyMasterHierarchy>

</PartyMaster>

I would like to get CSV output in the format below

DISPLAY_NAME, DOCUMENT_DESCRIPTION, PARENT, EXTERNAL_ID, ORG_UNIT_TYPE

Bon Appetit Sector, Bon Appetit Sector,constant value, A00000, constant value

Levy Sector, Levy Sector, constant value, K00000, constant value

BA Division, BA Division, A00000, AB0000, constant value

Levy Sector Division, Levy Sector Division, K00000, K90000, constant value

BA East Coast Region, BA East Coast Region, AB0000, ABE000, constant value

Levy Sector Region, Levy Sector Region, K90000, K99000, constant value

Engstrom John RVP, Engstrom John RVP, ABE000, ABE01, constant value

TBA Total ,TBA Total ,K99000, K9901, constant value

1) How do I go about this? I think I have to configure an adapter but which adapter would give me the desired result?

2) How do I tell PI when to pick the file from and where to place it after conversion? Could this be done in adapter configuration?

Any help will be greatly appreciated.

Thanks.

--Mithun

4 REPLIES 4

Former Member
0 Kudos

Hi Mithun,

You might try this step below :

1. As for xsd schema fo the xml or create xsd schema base on the sample xml file using tools like xmlspy or others free tools.

2. import you xsd schema as outbound Data type

3. apply mapping from source to target (csv).

Configuration

Sender file adapter (without content conversion)

Receiver file adapter (with content conversion).

so the sender adapter will be monitoring inbound directory and write the result to another directory.

Thank You and Best Regards

Fernand.

0 Kudos

Thanks for your feedback Fernad.

I have XSD schema for XML and wondering if there are any tutorials on how to acheive the below!

Sender file adapter (without content conversion)

Receiver file adapter (with content conversion).

"so the sender adapter will be monitoring inbound directory and write the result to another directory."

Sorry, I did not understand what you were trying to explain above. Could you please give me more details if possible?

Thanks.

Mithun

0 Kudos

Looking at your input/output, I am guessing that you will need mapping to convert it to a XML structure similar to your output structure... Once you do that, your File content conversion will be much simple...

As to mapping, this appears to be complext mapping... download some software like altova XML spy and see how to do XSLT mapping; ...and you can read in SAP help or SDN how to load your XSLT mapping into XI/PI.

My personal feeling is that you are probably going to better answer in PI forums than here, though... Unless you want to use an ABAP transformation program to transform this XML file into Flat file (without using XI/PI)

0 Kudos

Thaks for your time and feedback Chris.