<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Create target XML nodes based on field names in the source in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762009#M4790753</link>
    <description>&lt;P&gt;To get it other way around you need to find method that reads structure of the input. You can check this documentation: &lt;A href="https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/overview-summary.html" target="test_blank"&gt;https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/overview-summary.html&lt;/A&gt; for existing packages. You should find something in &lt;A href="https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/com/sap/aii/mappingtool/tf7/rt/package-summary.html"&gt;com.sap.aii.mappingtool.tf7.rt&lt;/A&gt; and &lt;A href="https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/com/sap/aii/mapping/api/package-summary.html"&gt;com.sap.aii.mapping.api&lt;/A&gt; packages.&lt;/P&gt;</description>
    <pubDate>Wed, 04 Oct 2023 08:33:01 GMT</pubDate>
    <dc:creator>fprokopiuk</dc:creator>
    <dc:date>2023-10-04T08:33:01Z</dc:date>
    <item>
      <title>Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaq-p/12762002</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;
  &lt;P&gt;I have a Requirement where in I need to map the field names from Source structure to the target structure...&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;For Example:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;My Source structure:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;field1&amp;gt;123&amp;lt;/field1&amp;gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;field2&amp;gt;XYZ&amp;lt;/field2&amp;gt;&lt;/P&gt;
  &lt;P&gt;&lt;STRONG&gt;Expected Target structure:&lt;/STRONG&gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;Node&amp;gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;Fieldname&amp;gt;field1&amp;lt;/Fieldname&amp;gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;Fieldvalue&amp;gt;123&amp;lt;/Fieldvalue&amp;gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;/Node&amp;gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;Node&amp;gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;Fieldname&amp;gt;field2&amp;lt;/Fieldname&amp;gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;Fieldvalue&amp;gt;XYZ&amp;lt;/Fieldvalue&amp;gt;&lt;/P&gt;
  &lt;P&gt;&amp;lt;/Node&amp;gt;&lt;/P&gt;
  &lt;P&gt;Can you please advise how to achieve this in Graphical Mapping of SAP PI (and maybe with an UDF)?&lt;/P&gt;
  &lt;P&gt;Best regards,&lt;/P&gt;
  &lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 14:11:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaq-p/12762002</guid>
      <dc:creator>pi_consultant1</dc:creator>
      <dc:date>2023-10-03T14:11:12Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762003#M4790747</link>
      <description>&lt;P&gt;Hi John,&lt;/P&gt;&lt;P&gt;An XSLT like the following would handle that mapping requirement (&lt;EM&gt;assuming a root node named root&lt;/EM&gt;) - &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;&amp;lt;?xml version="1.0" encoding="UTF-8"?&amp;gt;
&amp;lt;xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"&amp;gt;
    &amp;lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&amp;gt;
    &amp;lt;xsl:template match="root"&amp;gt;
      &amp;lt;xsl:copy&amp;gt;
        &amp;lt;xsl:for-each select="*"&amp;gt;
          &amp;lt;Node&amp;gt;
            &amp;lt;Fieldname&amp;gt;&amp;lt;xsl:value-of select="local-name()"/&amp;gt;&amp;lt;/Fieldname&amp;gt;
            &amp;lt;Fieldvalue&amp;gt;&amp;lt;xsl:value-of select="."/&amp;gt;&amp;lt;/Fieldvalue&amp;gt;
          &amp;lt;/Node&amp;gt;
        &amp;lt;/xsl:for-each&amp;gt;
      &amp;lt;/xsl:copy&amp;gt;
    &amp;lt;/xsl:template&amp;gt;
&amp;lt;/xsl:stylesheet&amp;gt;&lt;BR /&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Ryan Crosby&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 15:11:37 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762003#M4790747</guid>
      <dc:creator>Ryan-Crosby</dc:creator>
      <dc:date>2023-10-03T15:11:37Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762004#M4790748</link>
      <description>&lt;P&gt;Thank you Ryan,&lt;/P&gt;&lt;P&gt;Would this also be possible with the graphical mapping and perhaps an UDF? &lt;/P&gt;&lt;P&gt;The client prefers that...&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 15:41:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762004#M4790748</guid>
      <dc:creator>pi_consultant1</dc:creator>
      <dc:date>2023-10-03T15:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762005#M4790749</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;pi.consultant1&lt;/SPAN&gt; I'm sure it can be done with graphical mapping but it's not worth the effort.  The XSLT option took mere minutes, but using graphical mapping requires that you know the field names at build time and they may never change.  The XSLT would work if the field names were changed to Field1, Field2 or MyField1, MyField2, but graphical mapping would break immediately.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 16:37:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762005#M4790749</guid>
      <dc:creator>Ryan-Crosby</dc:creator>
      <dc:date>2023-10-03T16:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762006#M4790750</link>
      <description>&lt;P&gt;Hello John,&lt;/P&gt;&lt;P&gt;For UDF + graphical mapping alternative you can refer to this blog: &lt;A href="https://blogs.sap.com/2012/11/05/message-mapping-play-around-with-target-structure/" target="test_blank"&gt;https://blogs.sap.com/2012/11/05/message-mapping-play-around-with-target-structure/&lt;/A&gt;. &lt;/P&gt;&lt;P&gt;However I would go with XSLT option here which Ryan suggested.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Oct 2023 17:17:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762006#M4790750</guid>
      <dc:creator>fprokopiuk</dc:creator>
      <dc:date>2023-10-03T17:17:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762007#M4790751</link>
      <description>&lt;P&gt;Thank you Filip. &lt;/P&gt;&lt;P&gt;This is a useful blog, however my usecase is exactly the other way around. So the source looks like this:&lt;/P&gt;&lt;P&gt;&amp;lt;Items&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;&lt;STRONG&gt;CompanyA&lt;/STRONG&gt;&amp;gt;abc corp&amp;lt;/&lt;STRONG&gt;CompanyA&lt;/STRONG&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;&lt;STRONG&gt;CompanyB&lt;/STRONG&gt;&amp;gt;xyz info&amp;lt;/&lt;STRONG&gt;CompanyB&lt;/STRONG&gt;&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/Items&amp;gt;&lt;/P&gt;&lt;P&gt;And the target like this: &lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;Rows&amp;gt;&lt;/P&gt;&lt;P&gt;     &amp;lt;Key&amp;gt;&lt;STRONG&gt;CompanyA&lt;/STRONG&gt;&amp;lt;/Key&amp;gt;&lt;/P&gt;&lt;P&gt;     &amp;lt;Value&amp;gt;abc corp&amp;lt;/Value&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/Rows&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;Rows&amp;gt;&lt;/P&gt;&lt;P&gt;     &amp;lt;Key&amp;gt;&lt;STRONG&gt;CompanyB&lt;/STRONG&gt;&amp;lt;/Key&amp;gt;&lt;/P&gt;&lt;P&gt;     &amp;lt;Value&amp;gt;xyz info&amp;lt;/Value&amp;gt;&lt;/P&gt;&lt;P&gt;&amp;lt;/Rows&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;       …&lt;/P&gt;&lt;P&gt;It would be great to know exactly what to do if its the other way around...&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;I also will look at the XSLT option.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 07:46:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762007#M4790751</guid>
      <dc:creator>pi_consultant1</dc:creator>
      <dc:date>2023-10-04T07:46:40Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762008#M4790752</link>
      <description>&lt;P&gt;Thank you Ryan,&lt;/P&gt;&lt;P&gt;I will look into this, however the client prefers a graphical mapping and its a very big xml with already lots of other UDF's.&lt;/P&gt;&lt;P&gt;So it would be nice to have have graphical mapping option too.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;John&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 07:49:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762008#M4790752</guid>
      <dc:creator>pi_consultant1</dc:creator>
      <dc:date>2023-10-04T07:49:17Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762009#M4790753</link>
      <description>&lt;P&gt;To get it other way around you need to find method that reads structure of the input. You can check this documentation: &lt;A href="https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/overview-summary.html" target="test_blank"&gt;https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/overview-summary.html&lt;/A&gt; for existing packages. You should find something in &lt;A href="https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/com/sap/aii/mappingtool/tf7/rt/package-summary.html"&gt;com.sap.aii.mappingtool.tf7.rt&lt;/A&gt; and &lt;A href="https://help.sap.com/doc/javadocs_nw75_sps04/7.5.4/en-US/PI/com/sap/aii/mapping/api/package-summary.html"&gt;com.sap.aii.mapping.api&lt;/A&gt; packages.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 08:33:01 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762009#M4790753</guid>
      <dc:creator>fprokopiuk</dc:creator>
      <dc:date>2023-10-04T08:33:01Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762010#M4790754</link>
      <description>&lt;P&gt;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: &lt;A href="https://stackoverflow.com/questions/10784036/retrieving-xml-node-names" target="test_blank"&gt;https://stackoverflow.com/questions/10784036/retrieving-xml-node-names&lt;/A&gt;. &lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 08:45:02 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762010#M4790754</guid>
      <dc:creator>fprokopiuk</dc:creator>
      <dc:date>2023-10-04T08:45:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create target XML nodes based on field names in the source</title>
      <link>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762011#M4790755</link>
      <description>&lt;P&gt;&lt;SPAN class="mention-scrubbed"&gt;pi.consultant1&lt;/SPAN&gt; I'm now with an organization that does not have a PI/PO system and the graphical mapping tool in CPI leaves much to be desired.  That said, XSLT is far more powerful and flexible IMO than the trusty old graphical mappings.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Oct 2023 11:49:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/create-target-xml-nodes-based-on-field-names-in-the-source/qaa-p/12762011#M4790755</guid>
      <dc:creator>Ryan-Crosby</dc:creator>
      <dc:date>2023-10-04T11:49:25Z</dc:date>
    </item>
  </channel>
</rss>

