Skip to Content
 

I have written this blog to address the FAQ in SDN as discussed Conversion of source XML structure to single string using PI 7.1 and in many other threads.

Where there is a need to map complete input xml payload to a field of the target xml. Can this be done using the standard Graphical Mapping? The answer is YES in PI 7.1. 

 

Earlier we used to do this using Java Mapping or The specified item was not found. . But now we can achieve this using SAP PI 7.1 Mapping Enhancements Series: Copy XML Subtree, a new feature of PI 7.1.So we don’t need to create a Java Mapping with a lengthy code and thereby reduces the time spent in designing the mapping.

I am taking the same example which is explained in this Java Mapping wiki to make it simple to understand.  

 

Source Structure:

 srcdata

 

 

 

 

 

 

 

 

 

Target Structure

 

tardata

 

 

 

 

 

 

 

Assign The Mapping: 

 

Right-click on “Source Message Type” and select “Return as XML” in the dropdown menu. This will return XML.

To convert that to a string, here simply I am using trim function present in the Text function Category (you can use any text function , so that it treats input xml as string )

map

 

 

 

 

 

 

 

 

 

 

 

 

 

Source xml payload:    

srcpayload

 

 

 

 

 

 

 

 

 

 

 

 

Target xml payload:  

tarpayload

 

 

 

 

 

 

 

 

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/2620.But [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken] [original link is broken]

To report this post you need to login first.

14 Comments

You must be Logged on to comment or reply to a post.

    1. Jyothi Anagani Post author
      Thanks for your comment. But I think you didnot get my purpose of writing this blog. Here I am not explaining the CopyXML feature as already explained in the blog you mentioned.CopyXML-“This CopyXML feature can be used when we wish to copy an XML subtree from the source to target, exactly as is, by using this, we do not need to define the target elements”.
      Here In my blog I am trying to explain How to use the copyXML feature to convert complete input xml payload to String.
      As I have seen in so many threads asking for how to convert input xml payload to String using standard graphical mapping.But most of the suggestions were to use Java Mapping or XSLT Mapping.But using these mappings will take bit more time to develop. This blog is to assist who want to achieve the same functionality using Standard Graphical Mapping.
      Hope I answered your question. Please let me know if you have further query.
      (0) 
      1. Saravana Kumar Kuppusamy
        If i were to write a blog, and the feature was already explained in another blog, i would add a reference to that blog either in the beginning or end of my blog. I don’t see that done here.

        I will also do a search of SDN blogs as to whether this info is already documented and explain in my blog what i am doing differently.

        I would add the info you have blogged as a Wiki, saying i am applying copyxml feature to acheieve this specific functionality. And tell others that they could add the ways they have exploited this feature.

        Hope this clarifies why i made the comment.

        Thanks
        Saravana

        (0) 
        1. Jyothi Anagani Post author
          I have already given the reference for copyXML feauture in the begining of my Blog.
          And The reference points to the same link(blog) which you have mentioned.

          (0) 
  1. PRAVEEN KURNI
    Hi Jyothi,
    This is really helpful, If you are wroking on CLOB Data Type for an JDBC scenario.
    I worked for similar kind of scenario, where we used Java Mapping to get complete XML at source to target field which is of type CLOB(in SQL Server).
    Thanks for the information.
    Regards
    Praveen K
    (0) 
  2. Rajesh pasupula
    PI 7.1 mapping Features making PI more robust..I was wondering what the purpose of the Return XML context option during mapping..Now with this blog its clear now …Apart from the above if we can use the option  for any other pls provide the same..

    Cheers
    Rajesh

    (0) 
  3. Asif K
    I had to deal with issue sometime back and with a lot of trial and error I figured it out. In my case I used a substring and removed “< ?xml...utf-8?>“.
    (0) 
  4. Anoop Garg
    Jyothi,

    Good way to achieve one of requirements in a easier way..

    Do u see any workaround possible other than a simple adapter module if we receive target file here as an input file for any case & needs to read that?

    Regards,
    Anoop

    (0) 
  5. Faith khumalo

    How do you remove the namespace inside the string after the return xml?  I have a scenario file to string. I followed the blog but the string has the namespace inside. Also is there a way of making the string back to a tab delimited file? Can I change this in the adapter

    (0) 

Leave a Reply