on 11-15-2013 9:17 AM
Hi experts,
Please help me in creating an UDF. Below is the requirement.
Source
---Orders...................1-n
-----Header.................1-1
-------PONo.................1-1
-----Item...................1-n
-------Charecterestics......1-n
-----------ObjectNo
-----------ObjectType
-----------Groupcode
-----------CharDesc
-----------CharVal
-----------NumVal
:
:
etc
Target field will occur for every Orders.
Requirement is for all "Charecterestics"(will come 'n' times) check if "ObjectNo" matches with "PONo" (1 occurrence for each "Orders" but n number of "Orders" can come), if matches then check if value present in "CharVal" take the value else take value from "NumVal". If "ObjectNo" does not matches with "PONo" ignore that "Charecterestics".
Either of CharVal or NumVal will have value.
I tried with graphical mapping and it worked but the problem is, there are similar logic with different fields which are huge in number and for that I need a UDF which can be used everywhere.
Please help me out.
Hello,
Try this UDF:
Execution type: all values of a context
Input: var1, var2, var3, var4
for(int i=0;i<var2.length;i++)
{
if(var2[i].equals(var1[0]))
{
if(var3[i].length()>0)
result.addValue(var3[i]);
else
result.addValue(var4[i]);
}
}
Mapping:
PO_No --------\
Object_No**---------------------UDF------SplitByValue(Each value)---Target
CharVal**-------------/
NumVal**----------------/
** ->change the context of this field and set it to orders
Thanks
Amit Srivastava
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Amit,
Thanks for your prompt reply. I tried with the logic it worked a little. But for certain cases it is not working.
There might be scenarios where if CharVal is present then NumVal might not come(I mean the tag itself might not come as the occurrence is 0-1). In those case it is failing.
For example, I have tested with one Order and 3 characteristics. For the first one the Object_No is not matching and there is no tag for NumVal, for the 2nd Char the object number is matching but tag CharVal is absent. Ideally the program will pick the value from NumVal. But it is not able to pick the value from NumVal.
Let me know if I am not able to make you understand the scenario.
Hello,
>>There might be scenarios where if CharVal is present then NumVal might not come
This information was missing in ur previous post....so, to put things in perspective always try to post input and expected output structure.
Anyway, try below mapping:
Note - This time only change the context of Object_No field and set it to "Orders"
Thanks
Amit Srivastava
Hi,
Unless you share the target structure and field level logic, it will be difficult to imagine a solution.
Ambrish
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Subhra
Can you paste ur required target structure also.
Regards
Gagan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.