on 07-20-2006 1:46 PM
Dear Xi Experts,
In my scenario i need to build a UDF for the next structure;
In my query I want to check, if on <b>message2</b> the <b><Key></b> value is <u>Businessday</u> then put the <b><text></b> into <b>Target</b> <Businessday>. If the Key value not exist then put the value from <b>Message1</b> the <u>Businessday</u> into Target <Businessday>.
Here is a graphic with the else-condition, but it doesn't work neither
http://photos1.blogger.com/blogger/3087/1595/1600/3.jpg
the problem is not that the if-condition wouldn't work. while sending a single key with value, it works. but when i have several keys, it only shows the first one.
http://photos1.blogger.com/blogger/3087/1595/1600/2.jpg
This is not possible with graphical mapping tool.
<b>Could anyone help me?</b>
Regards,
Fatih
Try following:
Key
equalS
Constant / ifWithoutElse
Text /
Key
equalS - exists - if - external
Constant / /
external
This double checking is necessary as the queues of text and external are not in range.
Regards
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Stefan,
Thank you for the answer. your solution seems to be right. it works if the values are set correctly. but if i use an incorrect value it doesn't work. the value needs to be checked on correctnes. if a key isn't set, then it should take the key of message1, but it doesn't.and if the key isn't set at all, it should take the key from message1.
thanks,
Fatih
Hi Fatih,
I was too quick. The problem in this mapping is the different lenght of the queues. You have to remove entries from the key and text queues but the exists function does remove values. It is difficult to achieve this with standard functions. It might be easier with UDF.
You can use the function of Amit, but I think you need a 4th parameter to asign a constant with the value you want to compare the key.
Regards
Stefan
<b>Dear XI experts,</b>
The problem in my mapping is the compare. It doesn't work. Please see the following picture and code.
<b><a href="http://photos1.blogger.com/blogger/3087/1595/1600/wewewe.jpg">Screenshot</a></b>
public void UDF1(String[] key,String[] text,String[] constant,String[] msg,ResultList result,Container container){
for ( int i = 0; i < key.length; i++ ) {
if ( key.equals(constant[0])){
result.addValue (text[0]);
}
else
result.addValue(msg[0]);
}
}
Could anyone help me?
Regards,
Fatih
Hi
i this udf, if any one of the value is false, it will populate false value right ?
so there is a problem.
I think,it is overwriting the latest values.
So can you try with Split By value after this function.
But one morething, can you store all these values in a Vector and then populate these vector in a loop. i.e
if success
store/append that text[0] value
else store/append msg[0].
So your Vector contains all the values true/false.
Atlast populate these.
Hopefully it works.
Regards,
Moorthy
Hi Fatih,
you forgot the array index of key:
public void UDF1(String[] key,String[] text,String[] constant,String[] msg,ResultList result,Container container){
for ( int k = 0; k < key.length; k++ ) {
if ( key<b>[k]</b>.equals(constant[0])){
result.addValue (text[0]);
<b>return;</b>
}
}
result.addValue(msg[0]);
}
Stefan
Hi,
In the code, you have mentioned
<b>if ( <i>key</i>.equals(constant[0])){</b>
You are not specifying an index for the key. So,we wouldnt be able to get the required output here.
Try using key [\i\].
Does constant[] array have only one element?
If no, change the code to make it key<i>.equals(constant[\i\])
Similarly, make sure you are using the right index for the arrays text[]and msg[].
Regards,
Smitha.
Hello Stefan, Krishan,Amit and Smitha
this is my solution ;
public void UDF1(String[] key,String[] text,String[] constant,String[] msg,ResultList result,Container container){
for ( int i = 0; i );
break;
}
}
for (int j = 0 ; j < msg.length ; j++){
if (!(key[j].equals(constant[0]))) {
result.addValue(msg[j]);
}
}
Thanks for the useful answers!
Fatih
Message was edited by: Fatih Kökce
Message was edited by: Fatih Kökce
Hi
You can do it by using node functions Createif(),removecontext(),splitByValue().
thanks
Prasad Babu
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Fatih,
I guess the requirement is to check which key matches the Businessday and map its corresponding text, else the Businessday itself, right?
in that case apart from if-else.... use removeContext function for key and text nodes. Then pass key, text and Businessday respectively to the advanced UDF getText as below:
public void getText(String[] a, String[] b, String[] c,
ResultList result,
Container container)
{
for ( int i = 0; i < a.length; i++ )
{
if( a<i>.equals(c[0]))
result.addValue(b<i>);
}
if ( result.length == 0 )
result.addValue(c[0]);
}
Regards
Amit
Hello Krishna,
I have already have those steps;
http://photos1.blogger.com/blogger/3087/1595/1600/10.jpg
but it doesn't worked.
Regards,
Fatih
right click on your input fields in the given mapping ( as in the diagram) then it will show different nodes/segments . Click on the Root level (Message Type level) there
More on
http://help.sap.com/saphelp_nw2004s/helpdata/en/ee/b88c4037fba62be10000000a1550b0/content.htm
Thanks
User | Count |
---|---|
88 | |
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.