on 08-21-2012 8:55 AM
Dear All,
I am a freshman on PI (SAP also) and currently working on a Scenario which will import data from a xml to ERP. The xml file format is as the following:
<Data>
<Row>
<Header>
<field1>value 1</field1>
<field2>value 2</field2>
</Header>
<Item>
<fielda>test a1</fielda>
<fieldb>test b1</fieldb>
<fieldc>test c1</fieldc>
<fieldd>test d1</fieldd>
<fielde>test e1</fielde>
<fieldf>test f1</fieldf>
<fieldg>test g1</fieldg>
</Item>
<item>
<fielda>test a2</fielda>
<fieldb>test b2</fieldb>
<fieldc>test c2</fieldc>
<fieldd>test d2</fieldd>
<fielde>test e2</fielde>
<fieldf>test f2</fieldf>
<fieldg>test g2</fieldg>
</item>
</Row>
<Row>
<Header>
........
........
........
</Row>
</Data>
Field 1 and 2 in <Header> are the key for each <Item> in the same <Row>.
The Data will be imported to a flat table with the following structure:
[field1],[field2],[fielda],[fieldb],[fieldc],[fieldd],[fielde],[fieldf],[fieldg]
Since there is only 1 <Header> but have n <Item> in each row, How can I do the message mapping which can make the imported record like this:
[field1],[field2],[fielda],[fieldb],[fieldc],[fieldd],[fielde],[fieldf],[fieldg]
value 1, value 2,test a1, test b1, test c1, test d1, test e1, test f1, test g1
value 1, value 2,test a2, test b2, test c2, test d2, test e2, test f2, test g2
Limitation: The source xml file is provided from outsider which the format cannot be changed.
Thanks,
Andy
Hi Andy,
Check this pictures:
With the root's context you will have so much target item as source item:
Now you create so much field1 (field2 is the same) for target field 1, and it's neccesary to split by each value because you have different target context (target item context):
The other nodes you can assign directly:
Finally you can check with this example:
<?xml version="1.0" encoding="UTF-8"?>
<Data>
<Row>
<Header>
<field1>a</field1>
<field2>b</field2>
</Header>
<Item>
<fielda>1</fielda>
<fieldb>2</fieldb>
<fieldc>3</fieldc>
<fieldd>4</fieldd>
<fielde>5</fielde>
<fieldf>6</fieldf>
<fieldg>7</fieldg>
</Item>
<Item>
<fielda>21</fielda>
<fieldb>22</fieldb>
<fieldc>23</fieldc>
<fieldd>24</fieldd>
<fielde>25</fielde>
<fieldf>26</fieldf>
<fieldg>27</fieldg>
</Item>
</Row>
<Row>
<Header>
<field1>c</field1>
<field2>d</field2>
</Header>
<Item>
<fielda>1</fielda>
<fieldb>2</fieldb>
<fieldc>3</fieldc>
<fieldd>4</fieldd>
<fielde>5</fielde>
<fieldf>6</fieldf>
<fieldg>7</fieldg>
</Item>
</Row>
</Data>
If we check the queues:
And in the test tab:
Regards and good luck, welcome to the PI world.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Iñaki,
I just found that the xml file may have none <item>. How can I handle this case?
Regards,
Andy
yes earlier poster is correct , that is only one possiable by using "useOneAsMany" node function.
field1(h) ->item -> fielda(item level) -> useOneAsMany -> target field
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Andy,
Use UseoneAsManyNode Node function.
this is clearly explained in the below link.
http://www.saptechnical.com/Tutorials/XI/NodeFunctions/Page5.
Let us know if you find any difficulties
Thanks
Sai
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Andy,
You can achieve this by using concept called Context handling,
Please go through below links and hope you can solve your problem easliy,
http://scn.sap.com/thread/1804085
http://www.riyaz.net/sap/xipi-introduction-to-context-handling-in-message-mapping/5/
http://wiki.sdn.sap.com/wiki/display/XI/Explain+node+functions
Regards,
$HRI
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
9 | |
9 | |
7 | |
7 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.