Skip to Content

Multiple Source Fields to Single Target Field

Hello PI Experts,

Needed help with message mapping, I have multiple source fields with multiple structures and need to pass it to a single target field. What is the best way to achieve this? Can anybody share any idea or perhaps UDF code? Can this be achieved using 'Return as XML' in graphical message mapping?

Thanks,

John

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

5 Answers

  • Best Answer
    Posted on Dec 31, 2013 at 04:42 PM

    Please check the below doc for 'Retrun as Xml' use case -

    http://scn.sap.com/people/jyothi.anagani/blog/2010/06/17/convert-the-input-xml-to-string-in-pi-71-using-standard-graphical-mapping

    If your requirement is simillar then you can go for it 😊

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 31, 2013 at 04:45 PM

    Concat all fields and use UDF

    Suppose if i have 2 fields Field 1 & Field 2

    • Concat Field 1 & Field 2
    • Pass it UDF using all value of context.

    UDF code you can use as below

    for (int i=0;i<var1.length;i++)
    {
    s=s.concat(var1[i] );
    }

    result.addValue(s);

    I am not sure if i understood your problem correctly.Let us know more details

    Add a comment
    10|10000 characters needed characters exceeded

    • Vikrant,

      Thanks for your help.

      I tried doing the way put in your reply but getting the output with values only, does not give like <field1>value</field1>, etc. This is not the output expected. Please see below:

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

      <ns0:MT_Target xmlns:ns0="urn:mmtest"><strg2xml>onetwothreefourfivesixseveneightnineteneleventwelvethirteenfourteenfifteen</strg2xml></ns0:MT_Target>

  • Posted on Dec 31, 2013 at 04:38 PM

    Hi John,

    Can you provide additional details. May be sample xml and target structure.

    You can use concat function and appened all the fields and send it to one target field.

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 31, 2013 at 05:07 PM

    John I recommend UDF or Java Mapping.

    Try the code provide fro Virkrant.

    Kind regards,

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Dec 31, 2013 at 07:15 PM

    Hello,

    >>I have multiple source fields with multiple structures and need to pass it to a single target field.

    U want ur source structure to be returned as xml string or xml structure??

    “Return as XML” – returns the source node as XML structure (due to the presence of Xml definition tag <?xml version="1.0" encoding="UTF-8"?> ) which eventually create xml nodes beneath ur target element instead of assigning xml string value to it.

    In case you want to pass input structure as a xml string to ur target field then u have to remove XML declaration before assigning source node to target element.

    Something like:

    Source Node (Return as XML)

    Constant (<?xml version="1.0" encoding="UTF-8"?>)------Replace String --- Target Field

    Constant()

    Thanks

    Amit Srivastava

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.