on 10-03-2023 3:11 PM
Hi experts,
I have a Requirement where in I need to map the field names from Source structure to the target structure...
For Example:
My Source structure:
<field1>123</field1>
<field2>XYZ</field2>
Expected Target structure:
<Node>
<Fieldname>field1</Fieldname>
<Fieldvalue>123</Fieldvalue>
</Node>
<Node>
<Fieldname>field2</Fieldname>
<Fieldvalue>XYZ</Fieldvalue>
</Node>
Can you please advise how to achieve this in Graphical Mapping of SAP PI (and maybe with an UDF)?
Best regards,
John
Hello John,
For UDF + graphical mapping alternative you can refer to this blog: https://blogs.sap.com/2012/11/05/message-mapping-play-around-with-target-structure/.
However I would go with XSLT option here which Ryan suggested.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you Filip.
This is a useful blog, however my usecase is exactly the other way around. So the source looks like this:
<Items>
<CompanyA>abc corp</CompanyA>
<CompanyB>xyz info</CompanyB>
</Items>
And the target like this:
<Rows>
<Key>CompanyA</Key>
<Value>abc corp</Value>
</Rows>
<Rows>
<Key>CompanyB</Key>
<Value>xyz info</Value>
</Rows>
…
It would be great to know exactly what to do if its the other way around...
I also will look at the XSLT option.
Regards,
John
To get it other way around you need to find method that reads structure of the input. You can check this documentation: https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/overview-summary.html for existing packages. You should find something in com.sap.aii.mappingtool.tf7.rt and com.sap.aii.mapping.api packages.
As an alternative you can use "Return as XML" option and parse it in udf using javax.xml.parser. Example of reading xml node names: https://stackoverflow.com/questions/10784036/retrieving-xml-node-names.
User | Count |
---|---|
71 | |
9 | |
8 | |
6 | |
6 | |
6 | |
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.