on 12-05-2008 7:57 AM
Hi...
I am having structure like,
Source Structure
Root
Node1---(0unbounded)
Element1
Node2----(0unbounded)
Element2
Target Stucture
Root
Node--(0-unbounded)
Element3
The target Element3 should be Element1 * Element2------> Element3
My requirement should be
if Node1 is repeating and Node2 is occuring only once or
if Node 2 is repeating and Node1 is occuring only once
i need to get the output.
eg:
Node1
Element---2
Node 1
Element--4
Node2
Element ---3
Output should be like....
Node
Element----6
Node
Element----13
Can you please help in this maaping issue.
Regards
Leela
Hi,
The below solution works fine
Node1-->exists----\
or----->createif--->Node
Node2--->exists---/
Element1---\
--->multiply(UDF)---->SplitByValue(Each Value)--->Element3
Element2---/
Change the context of Element1 to Node1 and Element2 to Node2.
udf
Use cache parameter context
public void multiply(String[] a,String[] b,ResultList result,Container container)
{
//write your code here
int op ;
if(a.length < b.length)
{
for(int i = 0; i < a.length; i++)
{
for(int j = 0; j < b.length; j++)
{
op = (Integer.parseInt(a<i>) * Integer.parseInt(b[j]));
result.addValue(Integer.toString(op));
}
}
}
else
{
for(int i = 0; i < b.length; i++)
{
for(int j = 0; j < a.length; j++)
{
op = (Integer.parseInt(a[j]) * Integer.parseInt(b<i>));
result.addValue(Integer.toString(op));
}
}
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi malini,
I have mapped like
Node1--Exists---
or----
Target Node.
Node2--Exists---
Element1------
UDF----split by value---Target Element3
Element2------
while executing i am getting the below error
/usr/sap/P70/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map6557e710c2bd11dda10f001d09112880/source/com/sap/xi/tf/_MM_Test_.java:75: illegal start of expression public void multiply(String[] a,String[] b,ResultList result,Container container) ^ /usr/sap/P70/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map6557e710c2bd11dda10f001d09112880/source/com/sap/xi/tf/_MM_Test_.java:106: ';' expected ^ 2 errors
Can you please help where i have done wrong.
Regards,
Leela
Hi malini,
Below is the UDF code i am using.
public void multiply(String[] a,String[] b,ResultList result,Container container)
{
//write your code here
int op ;
if(a.length < b.length)
{
for(int i = 0; i < a.length; i++)
{
for(int j = 0; j < b.length; j++)
{
{
op = (Integer.parseInt(a<i>) * Integer.parseInt(b[j]));
}
result.addValue(Integer.toString(op));
}
}
}
else
{
for(int i = 0; i < b.length; i++)
{
for(int j = 0; j < a.length; j++)
{
{
op = (Integer.parseInt(a[j]) * Integer.parseInt(b<i>));
}
result.addValue(Integer.toString(op));
}
}
}
}
Can you please find any errors in that?
Hi Leela
My requirement should be
if Node1 is repeating and Node2 is occuring only once or
if Node 2 is repeating and Node1 is occuring only once
i need to get the output.
I think this works without UDF as well
http://www.flickr.com/photos/32274480@N06/3085628230/
Thanks
Gaurav
Hi friends,
Thanks for your replies. My query was solved.I have done the mapping what Gaurav has specified.
I have mapped like...
Node1--Exists----
or -
CreateIf -
TargetNode
Node2--Exists----
Element1(Context -Root)--
Multiply -
Split By Value -
Target Element.
Element2(Context -Root)--
Thanks,
Leela
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey thanks alot for all your tip....
thanks..
Sidd.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
i think there is problem with []...
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hey sorry,
Just change the a to a<i>.
(a<i>*b[j])....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Leela,
You can use the UDF,
select context and two input elements,
for (int i=0; i<a.length; i++)
{ for (int j = 0; j< b.length; j++)
{
result.addValue((a<i>*b[j]));
}
}
let me know if this works or not.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Siddhesh,
While testing with the YDF you have given i am getting the below error.
/usr/sap/P70/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Mapc8621bb0c2a811dd96a9001d09112880/source/com/sap/xi/tf/_MM_Test_.java:67: operator * cannot be applied to java.lang.String[],java.lang.String result.addValue((a*b[j])); ^ 1 error
Below is the source file i am having
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_In xmlns:ns0="http://Test">
<Node1>
<Element1>2</Element1>
<Element2/>
</Node1>
<Node2>
<Element3>3</Element3>
</Node2>
<Node2>
<Element3>4</Element3>
</Node2>
</ns0:MT_In>
Regards,
Leela
Hi Sekhar,
Both the Nodes are having the same occurence.
Below is the source structure
<?xml version="1.0" encoding="UTF-8"?>
<ns0:MT_In xmlns:ns0="http://Test">
<Node1>
<Element1>2</Element1>
</Node1>
<Node2>
<Element3>3</Element3>
</Node2>
</ns0:MT_In>
Node1 and Node2 are 1--unbounded
Regards,
Leela
User | Count |
---|---|
86 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.