Skip to Content
avatar image
Former Member

Mapping Issue - Multiple Segments

My mapping problem is as follows:

Source:

A 1..unbounded

item1 0..1

item2 0..1

Target:

A 1..unbounded

item1 0..1

item2 0..1

The values of item2 in source are unimportant.The issue is selecting the values for item2 in Target from a specified data base table with 1 column and replicating the node A in Target as many times as the number of rows in data base table.

For example, data base table is: (10,20,30) ->one column

3 rows, source is:

<A>

<item1> 1 </item1>

<item2> 2 </item2>

</A>

The target must be:

<A>

<item1> 1 </item1>

<item2> 10 </item2>

</A>

<A>

<item1> 1 </item1>

<item2> 20 </item2>

</A>

<A>

<item1> 1 </item1>

<item2> 30 </item2>

</A>

I've started this way (not sure is the right one):

1. Writing Lookup function in JAVA (it works) which returns ArrayList (named v) of all the values in data base table

2. Writing advanced udf (cache: queue) named Set:

public void Set(String[] item1, String[] item2, ....)

{

ArrayList v=Lookup("TABLE"), item1List, item2List;

item1List = new ArrayList();

item1List = new ArrayList();

GlobalContainer g=container.getGlobalContainer();

for(int i=0; i<item1.length; i++)

{ if(!item1.equals(ResultList.CC))

for(int j=0; j<v.size(); j++)

{ String s = (String)v.get(j));

item1List.add(item1<i>);

item2List.add(s);

result.addValue(item1<i>);

result.addValue(s);

}

}

g.setParameter("ITEM1",item1List.toArray());

g.setParameter("ITEM2",item2List.toArray());

}

3.Mapping item1, item2 --> Set --> A

4.Writing 2 advanced udf (cache queue ) named getItem1, getItem2 and mapping as folows:

getItem1 --> item1

getItem2 --> item2

public void getItem1(String[] a, .....)

{

globalContainer g=container.getGlobalContainer();

String[] item1 = (String[]) g.getParameter("ITEM1");

for(int i=0; i<item1.length; i++)

{

result.addValue(item1<i>);

result.addValue(ResultList.CC);

}

}

getItem2 is identical to the above function

What am I missing (since I'm new to XI) ?

The algorithm is wrong ?

I have this mapping error:

null pointer in getItem1

cannot produce target element A check xml instance is valid for source xsd and so on...

All idea or hint will really help,

Thanks

Message was edited by: carmen simcha

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Feb 20, 2006 at 03:38 AM

    Hi carmen,

    Though not the exact solution to what you are looking, my suggestion would be to go for Java Mapping using either DOM or SAX parser. This would enable you to do both Database lookup and also crete your destination message without any problem watsoever.

    For any info on Java Mapping, look at the following links,

    http://java.sun.com/j2se/1.4.2/docs/api/org/w3c/dom/package-frame.html

    http://help.sap.com/saphelp_nw04/helpdata/en/e2/e13fcd80fe47768df001a558ed10b6/content.htm

    Hope this helps.,

    regards,

    bhavesh

    Add comment
    10|10000 characters needed characters exceeded

  • Feb 20, 2006 at 10:28 AM

    Hi Carmen,

    This not an XI problem.

    You simply cannot cast Object[] to String[].

    <i>String[] item1 = (String[]) g.getParameter("ITEM1");</i> does not work.

    You can exchange the ArrayList directly:

    g.setParameter("ITEM1",item1List);
    g.setParameter("ITEM2",item2List);

    and take the values out of here:

    globalContainer g=container.getGlobalContainer();
    ArrayList item1 = (ArrayList) g.getParameter("ITEM1");
    for(int k=0; k<item1.size(); k++)
    {
    result.addValue((String)item1.get(k));
    result.addValue(ResultList.CC);
    }

    Regards

    Stefan

    Add comment
    10|10000 characters needed characters exceeded