Skip to Content
avatar image
Former Member

Mapping issue

Hello people,

Ive a mapping issue. This is how the situation is

Input file looks like this with occurrence <b>0..4</b>

<b>OrganisationFormattedName</b>

Output file looks like this:

<b>CompanyName1

CompanyName2</b>

The value of the first OrganisationFormattedName has to be filled in CompanyName1 and the second value of OrganisationFormattedName in CompanyName2.

Can anyone help me to the right direction?

Regards,

Kamran

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

6 Answers

  • Best Answer
    avatar image
    Former Member
    Aug 16, 2007 at 03:46 PM

    Hi,

    you need to use constant function "copy value"

    you need to map like

    OrganisationFormattedName -><b>[copy value (0)]</b> -> CompanyName1

    OrganisationFormattedName-><b>[copy value (1)]</b> -> CompanyName2

    Mapping issue

    dont forget my points. 😊

    Regards

    Pushkar

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 03:21 PM

    Kamran:

    I worked same you working on..my scenario is SRM -XI-FTP... the mapping was done from PurchaseOrderRequest_out to xCML file... i used the following simple mapping with one UD "GetValue"

    <b>Org.Name > Map with Default Value > Get Value--->Company Name</b>

    Code for Simple UD " Get Value"

    for(int i=0; i<a.length;i++){
    
     if(i==0)
      result.addValue(a<i>);
    }

    if you want first element give i == 0

    second element give i == 1..

    thats it

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      HI Guru,

      Ive the same scenario with the same input and output. Ill try this and let you know.

      Regards,

      Kamran

  • avatar image
    Former Member
    Aug 17, 2007 at 03:10 PM

    Hi all,

    Ive another question about the next situation, can I use the same function for the next situation?

    Input file looks like this with occurrence 0..unbounded

    <Item>

    <ShipToLocation>

    <Address>

    <OrganisationFormattedName></OrganisationFormattedName>

    </Address>

    </ShipToLocation>

    </Item>

    Output file looks like this:

    <LineItem>

    <ShipToAddress>

    <CompanyName1></CompanyName1>

    <CompanyName2></CompanyName2>

    </ShipToAddress>

    </LineItem>

    So for example there can be 2 Items in the source message therefore 2 OrganisationFormattedName.

    In the target message we will have 2 LineItems and 2 CompanyName1 and 2 CompanyName2.

    Regards,

    Kamran

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Justin Santhanam

      Raj and Paul,

      Its working now. I dont know how to thank you. I dont have enough points to give for all of your efforts. 😊 Really appreciate it.

      Kind regards,

      Kamran

  • Aug 16, 2007 at 02:58 PM

    Hi Kamran,

    I suggest you to use the two following mappings :

    - UseOneAsMany

    - Split by value

    This would look like

    OrganisationFormattedName -> UseOneAsMany ->Split by value ->CompanyName

    You will have as many nodes created as there are occurences in your source field.

    Regards,

    Laurent.

    Reward points if helpfull.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 03:04 PM

    For your case you need to create the 2 UDF for each Company name to filer the first value and second value. You can't do this with Standard functions according to my knowledge.

    Create the UDF which always return the first element of OrganisationFormattedName and another UDF which always return the second element of OrganisationFormattedName map to CompanyName1 and CompanyName2 respectively.

    Warm Regards,

    Vijay

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Aug 16, 2007 at 03:10 PM

    My documentation on the TakeWhich Function will solve whatever you need...

    The TakeWhich function-

    Use this function if you have an xml document with entries with the same xml tag in order, but you only want a certain entry for mapping. This will also work if you want a certain entry for many contexts of entries.

    Function inputs are the node you want to map from, the number of the entry that you want, and the total number of entries in the context.

    Example:

    Function inputs- data, 3, 4

    Source-

    <row>

    <data>test1</data>

    <data>test2</data>

    <data>test3</data>(we want this one)

    <data>test4</data>

    </row>

    <row>

    <data>test5</data>

    <data>test6</data>

    <data>test7</data>(and this one)

    <data>test8</data>

    </row>

    Destination-

    <destination>test3</destination>

    <destination>test7</destination>

    public void TakeWhich (String[] a,String[] b,String[] c,ResultList result,Container container){

    /**

    *This function is used to grab certain entries from series of entries with the same xml

    *tag

    *a- node with same xml tags, b- which node you want, c-number of nodes in a context

    *Created by Paul Schroeder July 2007

    */

    int i = Integer.parseInt(b[0]);

    int i2 = Integer.parseInt(c[0]);

    int count=1;

    for(int j=0;j<a.length;j++)

    {

    if(count==i)

    {

    result.addValue(a[j]);

    result.addContextChange();

    }

    if(count==i2)

    {

    count=0;

    }

    count++;

    }

    }

    take out the result.addContextChange(); if you have your destination entries in the same context, which it looks like you do.

    and in teh mapping use the XI provided function removeContexts before this function

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Actually, leave teh addContextChange in there.... I was thinking it was for somethign else

      lol, Vijay, I just put the implementation of exactly what you said.