Advanced Mapping question.

All,
we have 2 input messages, that need to be mapped into the output message.
<source1>
<response><id>1</id><cat>prodid</cat><value>PRD01</value></response>
<response><id>1</id><cat>name</cat><value>Name01</value></response>
<response><id>1</id><cat>price</cat><value>20.00</value></response>
<response><id>2</id><cat>prodid</cat><value>PRD02</value></response>
<response><id>2</id><cat>name</cat><value>Name02</value></response>
<response><id>2</id><cat>price</cat><value>30.00</value></response>
</source1>
<source2>
<product><id>1</id><prodid></prodid><isbn>isbn1</isbn><name></name><price></price></product>
<product><id>1</id><<prodid></prodid><isbn>isbn2</isbn><name></name><price></price></product>
</source2>
The target is exactly similar to source2 message. But the values of the nodes <prodid>, <name>, <price> needs to be populated from source1 message by matching the <id> and node name.
<target>
<product><prodid>PRD01</prodid><isbn>isbn1</isbn><name>Name01</name><price>20.00</price></product>
<product><prodid>PRD02</prodid><isbn>isbn2</isbn><name>Name02</name><price>30.00</price></product>
</target>
How can we do this using Advanced UDF?
Thanks

Check the following SAP Help link. It has a similar example.
http://help.sap.com/saphelp_nw04/helpdata/en/d9/cea942ad920c31e10000000a1550b0/frameset.htm
Thanks.

Similar Messages

  • Advanced mapping from IDOC to SOAP with reversed 3 level context change

    Hi everyone.
    I am having a though time mapping the HRMD_A01 IDOC into a SOAP message. The reason is that the reciever expects an xml structure where the root node is cost center instead of employee which is the case in the IDOC.
    Mapping from:
    IDOC (1..1)
       E1PLOGI (1..unb)
         SEGMENT (String)
         OBJID (String)
         E1PITYP (1..unb)
           E1P0001 (1..unb)
             SEGMENT (String)
             KOSTL (String)
    To this structure:
    List (1..1)
      CostCenters (1..unb)
        KOSTL (String)   ----> Mapped against KOSTL above
        Employees (1..unb)
          OBJID (String)   ----> Mapped against OBJID above  
    I expect several occurances of E1PLOGI which states multiple employees sent in the IDOC. I also expect several occurences of E1P0001 containing cost centers.
    My conclusion is that I need an advanced mapping and I have created one which collects all KOSTL for the IDOC context, deletes duplicates, and creates the CostCenters segment. This is now working. But my problem is that I can't create the employees segment in the right place. They are only created once under the first CostCenters node.
    Here's the java-code for mapping between KOSTL and CostCenters/KOSTL:
    public void costCenters(String[] var1, ResultList result, Container container) throws StreamTransformationException{
      Set set = new HashSet(Arrays.asList(var1));
      String[] array2 = (String[])(set.toArray(new String[set.size()]));
      Arrays.sort(array2);
      for (int i = 0; i < array2.length; i++) {
        result.addValue(array2<i>);
    Any ideas on how to proceed?
    Best Regards

    Hi,
      Do the mapping like below.
      UDF should be select as context.
    List (1..1)
      CostCenters (1..unb)
        KOSTL (String)   ----> Mapped against KOSTL above
        Employees (1..unb)
          OBJID (String)   ----> Mapped against OBJID above
    Mapping:
    KOSTL(RightSelectChange the context to E1PITYP)--UDF--Removecontext--CostCenters
    KOSTL(RightSelectChange the context to E1PITYP)--UDF--SplitbyValue(Each Value)--KOSTL
    constant---Employees
    OBJID----------------------------------------------Use One As Many---SplitByValue (EachValue)----------OBJID
    KOSTL(RightSelectChange the context to E1PITYP)--UDF---
    KOSTL(RightSelectChange the context to E1PITYP)--UDF---
    Regards,
    Prakasu.M
    Edited by: prakasu on May 20, 2009 3:28 PM

  • CRMXIF_REL_SAVE_M01 - Mapping Question

    Hello All,
    I have a mapping question, hope some one can answer my question. Please see the link first and the see my question
    http://www.flickr.com/photos/8764045@N06/4265246260/sizes/o/
    I'm mapping the CRM IDOC to the JDBC Call. I have small problem here. All the target fields are Mandatory 1..1 .
    I will explain with an example:
    I have field from source E102BUS_EI_STRUC_TEL_DATA/COUNTRY mapped to target field.
    I used Map With Default so that even if the values are not there frm the source the target field will be mapped with blank.
    But the problem is the parent node for E102BUS_EI_STRUC_TEL_DATA is E102BUS_EI_BUPA_TELEPHONE is 0.999999 , so sometimes that segment is not coming. In this case Map with Default won't work. Map with Default willl work only if the Parent node is present.
    If you ask me to do Exists node function on E102BUS_EI_BUPA_TELEPHONE and then apply Map with Default, then even this won't work.
    Apologize if I confused you guys. Please let me know if you need more clarification.
    Thanks!
    Raj.

    Hi Raj,
    Try to do a mapping like this
    E102BUS_EI_STRUC_TEL_DATA(context E102S_EI_BUPA_TELEPHONE_CON)--mapwithdefault-->then
    E102BUS_EI_BUPA_TELEPHONE-->exists------------------------------------------------------------------>if---->splitbyValue
    let us say this output (the output of splitbyvalue) as 'VALUE'
    VALUE-----------------------------------------------> then
    VALUE|-->count--->greater----------------------->if----->targetField                            
          Constant(0)---->              Constant(blank)-->else
    Regards
    Suraj

  • A top difficulty mapping question

    Hello
    dose anyone can give solution for this mapping question?
    soruce :
    <header>header</header>
    <item>
         <A>a1</A>
         <B>b1</B>
         <C>c1</C>
    </item>
    <item>
         <A>a2</A>
         <B>b2</B>
         <C>c2</C>
    </item>
    <item>
         <A>a3</A>
         <B>b3</B>
         <C>c3</C>
    </item>
    target:
    <header>header</header>
    <item>
         <A>a1,a2,a3  .....</A>
         <B>b1,b2,b3  .....</B>
         <C>c1,c2,c3  .....</C>
    </item>
    The numbers of item is not fixed,it is unbounded.
    so the target line length is not fixed at design time
    welcome any hits,
    Thanks !!
    BR,
    Jeffrey

    Hi,
    Use cache parameter as Context.
    public void add_element(String[] a,ResultList result,Container container)
      //write your code here
    String c = "";
    int i;
    for(i= 0 ; i < a.length; i++)
             c = c + a<i> ;
             if(i != (a.length-1))
                  c = c + ",";
    result.addValue(c);
    A(src)-->removecontext->UDF--->A(tgt)
    B(src)--->removecontext->UDF--->B(tgt)
    C(src)--->removecontext->UDF--->C(tgt)

  • Mapping question: How to display only hole numbers..??

    Hi all
    I have 3 fields in my message mapping where I need to convert them to hole numbers. This includes Invoice amount, Brutto and Netto weight. If Invoice amount says '2300.30' in my IDoc it should be '2300' in the xml document. If amount says '2300.70' result should be '2301'in my xml document. The same logic should be applied to the 2 weight fields.
    Thanks in advance
    Peter

    hi Peter,
    have you tried using <b>round</b> function?
    it's a standard function from the arithmetic functio group in the message mapping
    BTW
    with this function:
    2300.30 gives 2300
    2300.70 gives 2301
    tested
    description:
    round
    O = integer value back that is closest to the value of argument I. Corresponds to the Java function java.lang.Math.round().
    Regards,
    michal
    <a href="/people/michal.krawczyk2/blog/2005/06/28/xipi-faq-frequently-asked-questions">XI FAQ - Frequently Asked Questions</a>

  • Many-to-many mapping question

    Hi,
    I'm working with two classes Car and Customer. The Car class has a Vector of Customers and the Customer class has a Vector of Car. Both are related by a many to many mapping.
    I have noticed that I have to set one of the vector to read only to avoid the error message "More than one writable many-to-many mapping can not use the same relation table" in the mapping workbench.
    I can understand that but is there a way to work around, I mean to be able to add a car to a customer and add a customer to a car with the both vectors?
    Is there something to do with the cache?
    I use Vector for the collection or Map class, have I to do otherwise?

    Hello Vladislav, I understand your first question in this thread, but I'm not sure I follow the rest, so let me respond to your first post:
    "I have noticed that I have to set one of the vector to read only to avoid the error message "More than one writable many-to-many mapping can not use the same relation table" in the mapping workbench.
    I can understand that but is there a way to work around, I mean to be able to add a car to a customer and add a customer to a car with the both vectors?"
    The issue here is that with a Many to Many mapping the mapping is responsible for writing to the association table. So, you have a "CAR_CUST" association table. Imagine you add a Car "101" to a customer "501" and the requisite customer "501" to that car "101" in your object model. Then the association table should only be updated once, with an entry of "101, 501". But since the M-M is mapped in both directions, you need to tell TopLink which of these to consider as the "master" when updating the database.
    If you didn't make one of the M-M mappings "read only", then TopLink would insert "101, 501" twice in the association table, and then at a later date you would see that the customer 501 had two 101 cars!
    We do have a feature that allows for TopLink to maintain bidirectional relationships such that if you add or remove a target from one relationship, TopLink will automatically add/remove it from the opposite direction. In my opinion this is lazy programming! A good Java developer should insist on keeping his model up to date on his own. This feature was added because it's part of the EJB spec, not necessarily because it's a good idea ;)
    - Don
    Is there something to do with the cache?
    I use Vector for the collection or Map class, have I to do otherwise?

  • Mapping question

    Hello,
    I have a rather simple question regarding a mapping.
    Lets say my input message is as following:
    <mes1>
       <seg1>
          <name1>Peter</name1>
          <street1>HighCrt</street1>
       </seg1>
       <seg2>
          <name2>Vlad</name2>
          <sub2>Trickst</sub2>
       </seg2>
       <seg2>
          <name2>Rinaldo</name2>
          <sub2>fiave</sub2>
       </seg2>
    </mes1>
    My output should be:
    <out>
       <put>
          <name>Peter</name>
          <name>Vlad</name>
          <name>Rinaldo</name>
       </put>
    </out>
    So my output field "name" should created in case I have a "name1" field in the source message and additionally it should be created for every "seg2" element that is present in the source message and it should be filled with the value of "name2".
    How can I in the mapping trigger that the "name" element of the output message will be generated for each of the two described elements of the source message?
    Best Regards,
    Peter

    Hi,
    Could be possible using user defined function.
    Create a user defined Function with  cache = context
    public void createNodeName(String[] a,String[] b,ResultList result,Container container){
    if ( a.length > 0 )
      result.addValue ( a[0] ) ;
    for ( int i = 0; i < b.length; i++ )
         result.addValue ( b<i> );
    in Mapping use
    1. name1 as first argument
    2. name2 with removeContext as second argument

  • Mapping - Questions

    Hi,
       I have few basic questions regarding mappings.
       1)  I think we can do everything by using Graphical Mapping. Then what is the purpose for Java, XSLT and ABAP mapping? Please give me an example for this...
       2) Which mapping will give better performance? Is there any comparison document available in SDN?
      Appreciate your help!
    Thanks,
    Vivek

    hi,
    Mapping Techniques
    XI provides 3 standard ways of interface mapping between source and target.
    Graphical mapping
    Java Mapping
    XSLT Mapping
    Two more additional mapping types can be activated in XI by making changes to the exchange profile. Those two mappings are
    ABAP mapping
    XSLT mapping with ABAP Extensions
    Graphical Mapping
    Graphical mapping is a common approach followed by everyone for generating desired target structure. It involves simple drag-n-drop to correlate respective nodes (fields) from source and target structure. It hardly involves coding. (Exception - User defined functions). But sometimes with graphical mapping it is difficult to produce required output. For example ... text/html output, namespace change, sorting or grouping of records etc.
    ABAP Mapping
    A person comfortable with Object Oriented ABAP can go for ABAP mapping instead.
    Java Mapping
    Java Mapping uses 2 types of parsers. DOM and SAX. DOM is easier to use with lots of classes to help you create nodes and elements, but , DOM is very processor intensive.
    SAX parser is something that parses your XML one after the other, and so is not processor intensive. But, it is not exaclty easy to develop either.
    XSLT Mapping
    One can also think of Java mapping as another option but it is a bit complex and required knowledge of Java. In such cases, XSLT mapping can be the best approach to meet the requirements.
    check these links too..
    Mapping:
    http://help.sap.com/saphelp_nw04/helpdata/en/c8/b78d406b305537e10000000a1550b0/frameset.htm
    For Java Mapping:
    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/frameset.htm
    For XSLT Mapping:
    http://help.sap.com/saphelp_nw04/helpdata/en/73/f61eea1741453eb8f794e150067930/frameset.htm
    Error handling in XSLT Mapping:
    http://help.sap.com/saphelp_nw04/helpdata/en/8a/7672f7d7e444439fd7024f806221a4/frameset.htm
    You can also refer some How to guides:
    XI New Mapping Features article,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi%203.0%20new%20mapping%20features%20article.evn
    Generic XSLT Mapping and Sample Code,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/xi%20code%20samples/generic%20xslt%20mapping%20and%20sample%20code.pdf
    How to use ABAP-MApping in XI3.0,
    https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/library/xi/3.0/how%20to%20use%20abap-mapping%20in%20xi%203.0.pdf
    Thanks,
    Vijaya.

  • ABAP Mapping Questions

    Hi,
    I am trying to get my head around ABAP mappings and have a few questions.
    In the below code sample which I find in every example and blog it talks about specific steps -
    *initialize iXML, * create iXML factory object, * create streamfactory object, * create input stream object, * initialize the input xml document, * parse the input xml document
    In these steps the code is always exactly the same so my question is are these just standard steps that are implemented every single time an abap mapping is used and hence only standard lines that never have to be changed or will they be different depending on the mapping.
    I am trying to work out where I will begin my coding.
    So would somebody be so kind as to give me a brief explanation of the above mentioned steps.
    Thank you
    METHOD if_mapping~execute.
    * initialize iXML
      TYPE-POOLS: ixml.
      CLASS cl_ixml DEFINITION LOAD.
    * create iXML factory object
      DATA: ixmlfactory TYPE REF TO if_ixml.
      ixmlfactory = cl_ixml=>create( ).
    * create streamfactory object
      DATA: streamfactory TYPE REF TO
      if_ixml_stream_factory.
      streamfactory = ixmlfactory->create_stream_factory( ).
    * create input stream object
      DATA: istream TYPE REF TO if_ixml_istream.
      istream = streamfactory->create_istream_xstring( source ).
    * initialize the input xml document
      DATA: idocument TYPE REF TO if_ixml_document.
      idocument = ixmlfactory->create_document( ).
    * parse the input xml document
      DATA: iparser TYPE REF TO if_ixml_parser.
      iparser = ixmlfactory->create_parser(
      stream_factory = streamfactory
      istream = istream
      document = idocument ).
      iparser->parse( ).

    Hi,
         The above lines you mentioned deal with initialization of the iXML parser for parsing through the XML payload, so they would remain the same for all mapping where you are parsing the input payload.
    The coding for you specific mapping will begin after this, something like :
    * Implements the DOM generating interface to the parser
      iparser->parse( ).
      emp_node_collection = idocument->get_elements_by_tag_name_ns( name = 'Order' ).
      emp_node_length = emp_node_collection->get_length( ).
      emp_node_iterator = emp_node_collection->create_iterator( ).
    where you start reading the xml node values.
    Hope this helps.
    Regards

  • 856 xslt Mapping question ...

    I was asked in the jdev forum to post this here as well :)
    Ramesh,
    I hate to keep bugging everyone but i have another question.
    I am trying to transform data into an X-12 856 document (outbound). I have most of the looping and everything working. My only issue is how do you handle the parent child relationships in the HL01/02 ? Since xpath does not let you increment a variable how can you keep the count of the HL loops let alone tell the HL02 (parent's HL01) We are using a SOPI scenario and the items need to be subordinate to the appopriate pack level.
    I really appreciate all the time and awnsers you have given me so far :)
    Thank you in advance,
    Jaden

    Hi,
    There is a way to handle x=x+1 in XSLT....here it is..assume u want to sum all the elements of an arraylist in an XML...create a temporary variable(TransCountSumVar) and do a foreach and group them in one more variable (Transactions_Count2)
    <xsl:variable name="TransCountSumVar">
                  <xsl:for-each select="/ns1:TotalDate/ns1:price">
                                   <Transactions_Count2>
                      <xsl:value-of select="number(ns1:price)"/>
                                  </Transactions_Count2>
                  </xsl:for-each>
    </xsl:variable>now get the sum of those in Transactions_Count2 as follows
    <xsl:variable name="TComp" select="sum(exsl:node-set($TransCountSumVar)/Transactions_Count2)"/>where Tcomp is another variable with holds the final sum and be sure to the the namespace xmlns:exsl="http://exslt.org/common" in XSL at name space declarations.

  • Mapping question - concat two nodes

    hi all,
    i need to map a node with many occurrencies to a node with only one ocurrency, and i need to concat all the values from the source node into the target node.
    example:
    <delivery> 1..unbounded      -->       <data> 0..1
    <delivery> "this is "
    <delivery> "an example"
    result
    <data> "this is an example"
    does anybody know how can i solve this qestion?
    thanks in advanced.
    regards, Fabian

    Hi,
    Go for UDF...
    pass the source data as queue input to the UDF(i.e array)..in that udf loop over the source input and do concat inside the loop and pass the final result to the target element...
    string target = "";
    for(int i =0 ;i<input.length;i++)
    target = target + input<i>;
    if there are multiple contexts in this then need to handle the same
    HTH
    Rajesh

  • One to one mapping question -- can I just map a lookup field for queries?

    I have a table with a state code. I'd like to have a "virtual lookup" on the java class to a region table. I.e., this java class "studies" has a state code. I can map a one-to-one to the descriptor class that has the ref table, but I'd like to have a property in the java class pre-mapped to the "region" field in this lookup so for querying i can just use:
    ReadAllQuery q = new ReadAllQuery();
    q.setReferenceClass(study.class);
    q.setSelectionCriteria(new ExpressionBuilder().get("Region").equal(Region));
    to get all the studies for a particular region.
    am I going about this wrong? or do I have to get the reference table descriptor fromt he one to one map and do something different?

    well,on the way home last nite, I realized I'd had a complete brain fart. I've done this before. I just set up a 1-1 map between descriptors and then built the query like this:
    q.setSelectionCriteria(new ExpressionBuilder().get("refFPO").get("FPO_NO").equal(FPO));
    You can get the pointer to the "refFPO" which is the the descriptor mapped 1-1, then appended the column you wish to get.
    I still went ahead and amended my class to include a read-only, non-toplink mapped attribute "FPO" which just gets the reference variable pointing to "refFPO.getFPO_NO();
    I answered my own question just in case anyone wondered ....

  • Complex mapping question (aggregate)

    Hello all,
    For example, i have a xml structure in input :
    <XML Input Structure>
    <Line1>
    <Country> Fr </country>
    <Currency> EUR <Currency>
    <Town> Paris </Town>
    <MT> 10 </MT>
    </Line1>
    <Line2>
    <Country> Fr </country>
    <Currency> EUR <Currency>
    <Town> Paris </Town>
    <MT> 10 </MT>
    </Line2>
    <Line3>
    <Country> USA</country>
    <Currency> DOL <Currency>
    <Town> Chicago </Town>
    <MT> 20 </MT>
    </Line3>
    <Line4>
    <Country> USA</country>
    <Currency> DOL <Currency>
    <Town> Detroit </Town>
    <MT> 20</MT>
    </Line4>
    </XML Input Structure>
    In output, i want to aggregate the field "MT" only  when fields "Country, Currency and Town" are the same in order to have something like that :
    <XML Output Structure>
    <Line1>
    <Country> Fr </country>
    <Currency> EUR <Currency>
    <Town> Paris </Town>
    <MT> 20 </MT>
    </Line1>
    <Line2>
    <Country> USA</country>
    <Currency> DOL <Currency>
    <Town> Chicago </Town>
    <MT> 20 </MT>
    </Line2>
    <Line3>
    <Country> USA</country>
    <Currency> DOL <Currency>
    <Town> Detroit </Town>
    <MT> 20 </MT>
    </Line3>
    </XML Output Structure>
    I am not a specialist in java so i would like to knowi if it's possible to do it with node standard functions ? if not, what is the best solution : XSLT, Java mapping, UDF ?
    Thanks by advance,
    JP
    Edited by: Jean-Philippe PAIN on Dec 16, 2008 12:14 PM

    hi,
    with standard it would be pretty hard
    but with a simple UDF (with 4 inputs) you can aggregate
    and output it quite easily
    try with a udf if you don't want to go for java mapping
    Regards,
    Michal Krawczyk
    http://mypigenie.com XI/PI FAQ

  • 1-1 mapping question

    I am trying to post the question in a different way. My previous post on the related subject can be found at Re: 1-1 mapping
    Two entities, Parent and Child, where a Parent has a Child (privately owned) or zero Child.
    In object model, Parent has an attribute child; Child does not have a parent attribute.
    Two tables, Parent and Child, with constraint where a child record cannot exist without its parent record (i.e. Child table has a foreign key to the Parent table).
    Class Parent and Child are mapped to table Parent and Child respectively.
    How do we define the 1-1 mapping in the Mapping Workbench so that Parent and Child can be inserted into the tables in one unif of work?
    Any comment or help would be greatly appreciated.
    Haiwei

    You can't do this as you described. You must have and map a relationship from child to parent in order to be able to map the 1-1 from parent to child (since your foreign key is in the child table).
    - Don

  • Advanced Network Question - SSH tunneling through time capsule

    Hi!
    I have a small question. I just got a time capsule the other day and things are working great with it. At home, internet speeds are what they should be and everything is fine. I replaced it with a linksys, which I consistently got 6.5/1 up. After replacing it, I'm now getting 7.5 down/1mbps up, which is what I am subscribed to.
    I used to ssh into my linux box and tunnel web traffic over SSH so when I'm on the road, other's can't sniff my traffic. Basically, I setup firefox to use a socks server, then ssh into home with a dynamic port mapping.
    On the linksys (wrt54g), this worked great, and the speeds were acceptable (about 1mbps down/1mbps up). However, after switching the linksys with the time capsule, it seems like the speeds have slowed down tremendously. I'm now getting about 200k down and 1 mbps up when I ssh and tunnel web traffic through my home.
    I know that this isn't anything people normally do, but it works great and prevents people from spying on my web traffic when I'm away from home. I was just wondering if anybody has any ideas on why it might be slower now that I replaced it with the time capsule.
    Thanks!

    Hello H Salk. Welcome to the Apple Discussions!
    Enabling NAT on any Internet router, not just the AirPort & Time Capsule, will affect data transfer rates (in both directions) to devices connected either by wire or wireless to that router.

Maybe you are looking for