on 10-16-2009 9:46 AM
Hi,
I have an UDF where I create Idoc depending on the source message. But if the right input isn't entered I don't want to create any Idoc. but since I have an "else" with return in the end of the code it automatically creates an Idoc even if the wanted value is not entered.
Do you know what should be in the return statement in order to not create any Idoc?
if(a.equals("X"))
{
return Idoc;
}
else if(a.equals("Y"))
{
return Idoc;
}
else {
return "";
}
thanks
Hi Sonny
use this code .for or operator we have to use "||" as shown below in the code
for(int i=0;i<a.length();i++)
{
if(a<i>.equals("X")||a<i>.equals("Y"))
result.addValue(Idoc<i>);
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sonny,
If this is your code
for(int i=0;i<a.length();i++)
{
if(a<i>.equals("X")||a<i>.equals("Y"))
result.addValue(Idoc<i>);
}
Then tell me what are you giving in "a" and "Idoc" input fields Also can you paste what you see in the display queue (right click udf-> display queue)?
Regards
Suraj
Edited by: S.R.Suraj on Oct 16, 2009 8:54 AM
the field Idoc does not have any value. that is the parameter that pushes out the Idoc. in the graphip mapping that is the Item. that means for each "X" or "Y" a new Item should be created.
i ran your last suggestion and got:
Cannot produce target element /MBGMCR03/IDOC. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd
which means that it's something with me mapping but I only have 2 inputs so I don't see what could be wrong
Hi Sonny,
>>the field Idoc does not have any value. that is the parameter that pushes out the Idoc. in the graphip mapping that is the Item. that means for each "X" or "Y" a new Item should be created.
For each "X" and "Y" you want one IDOC (in output) to be created right? The in your code replace result.addValue(Idoc<i>) with result.addValue("")
>>Cannot produce target element /MBGMCR03/IDOC. Check xml instance is valid for source xsd and target-field mapping fulfills requirements of target xsd
please don't simply execute mapping. First check the display queue of this udf and see whether you got the desired number in output. That is say to have input X, X, Z,Y then you should have 3 idocs created in output. Check if it is getting created
If it is done then this thread is answered. Because what follows next is the mapping logic correctness which should be done on a field by field basis. And for that you need to see which fiedl is not getting generated and need to find out why (remember X,X,Z,Y shoudl generate IDco for 1,2 and 4th value. how to make sure that the third value is not there in output.) These things need to be adjusted.
Hope you will be able to do so
Regards
Suraj
yes change it to Queue.
use this UDF
if(a[0].equals("X")||a[0].equals("Y"))
{
result.addValue("Idoc");
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You have to convert it to Advanced UDF and there you will not require to define any else part in your UDF, which will solve your problem.
Regards,
Sarvesh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi, ok this was very helpful thank you.
but I want to populate several Idocs if the source message includes both "X" and "Y".
in this code that I have now it only types out either one of them even if both are in the source message.
do you know how I can put "or" between the rules instead of "else if"?
if (a[0].equals("X"))
{
result.addValue(Idoc[0]);
}
else if(a[0].equals("Y"))
{
result.addValue(Idoc[0]);
}
Hi Sonny,
Is your IDOC a single value or a queue of values?
If it is a queue of values, then you should modify your code like this.
for(int i=0;i<idoc.length();i++)
{
else if(a[0].equals("X"))
{
result.addValue(Idoc<i>);
}
else if(a[0].equals("Y"))
{
result.addValue(Idoc<i>);
}
else {
result.addSuppress();
}
}
Regards,
Ravi Kanth Talagana
Hi,
Use Queue type UDF for this.
In your else statement use
result.addSuppress(); instead of "".
Hope this helps,
Edited by: Mark Dihiansan on Oct 16, 2009 10:51 AM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
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.