on 12-18-2008 11:12 AM
Hi All
I am new to XI.I need the java code for Udf for the following structure.
i have two input and one out put as error.
order_nos----
\
-
user define function-------error message
/
order_details----
num of orders---- i.e. 10
order_details------ i.e. whole order records details
1.i have to compare the 1st input with 2nd one means if the ist input contain 10 means there are 10 orders in 2nd input.if not then i have to give error message .
2.then i have to check the fields in 2nd input has no null values.if no values the output will be error message.
Edited by: Rohit Kumar on Dec 18, 2008 4:43 PM
Hi,
Try like this
int len = 0;
if(a.length>b.length)
len = a.length;
else
len = b.length;
for(int i=0;i<len;i++)
{
if(b<i>.equals("") || (b.length != a.length))
result.addValue("Error Message");
else
result.addValue("SUCCESS");
}
Dont forget to use removeContext before both the inputs to UDF and then use the UDF with advance mode.
Thanks!
Edited by: Sudhir Tiwari on Dec 18, 2008 12:28 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Sudhir
thanks for your reply.
i have taken a variable and b as a array.so its giving error
if(a.length>b.length) ^ /usr/sap/SXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map06788e70ccf911dd9eb80017a451d1ec/source/com/sap/xi/tf/_ROD_SH_REQUEST_ABS_MM_.java:206: cannot resolve symbol
symbol : variable length location: class java.lang.String len = a.length; ^ /usr/sap/SXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map06788e70ccf911dd9eb80017a451d1ec/source/com/sap/xi/tf/_ROD_SH_REQUEST_ABS_MM_.java:211: cannot resolve symbol symbol : variable length location: class java.lang.String if(b<i>.equals("") || (b.length != a.length)) ^ /usr/sap/SXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map06788e70ccf911dd9eb80017a451d1ec/source/com/sap/xi/tf/_ROD_SH_REQUEST_ABS_MM_.java:212: cannot resolve symbol symbol : variable result location: class com.sap.xi.tf._ROD_SH_REQUEST_ABS_MM_ result.addValue("Error Message"); ^ /usr/sap/SXD/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map06788e70ccf911dd9eb80017a451d1ec/source/com/sap/xi/tf/_ROD_SH_REQUEST_ABS_MM_.java:214: cannot resolve symbol symbol : variable result location: class com.sap.xi.tf._ROD_SH_REQUEST_ABS_MM_ result.addValue("SUCCESS").
i am not able to solve it becos i dont know java.please reply.
Hi Sudhir
thanks for your continues help.i need some help so that i can fulfill my requirmrnt
this is my message mapping xml.
<?xml version="1.0" encoding="UTF-8" ?>
- <ns0:methodCall_MT xmlns:ns0="http://www.dfdsf">
<num_orders>10</num_orders>
<test_mode />
- <order_x> ( which is order details)
<order_id>t78tyu8t</order_id>
<order_date />
<mfg_id />
<catalog_id />
<first_name />
<last_name />
<recipient />
<message />
<address1 />
<address2 />
<address3 />
<city />
<state />
<zip />
<country />
<country_code />
<phone />
<subtotal />
<tax />
<shipping />
<total />
<shopatron_total />
<fulfiller_total />
<shipment_id />
- <additional_info>
<in_store_pickup />
- <express_shipping>
<express_shipping_flag />
<express_shipping_text />
<express_shipping_arrival />
</express_shipping>
</additional_info>
- <discount>
<discount_description />
<discount_percentage />
<discount_total />
</discount>
<lang_id />
<currency_id />
<packing_list />
<num_items />
- <items>
<item_id />
<quantity />
<price />
<part_number />
<fulfiller_total />
<shopatron_total />
- <options>
<option_x />
</options>
</items>
</order_x>
</ns0:methodCall_MT>
this my mapping where under one element number elements are there.when i am excuting the code to check the null value its always giving the there is null val but i have filled evrything.its due to first its checking the order_x and which will be always null.uder this all data will be filled.please suggest what to change in the udf.the code given by u is working fine but its failing in this scenario because it getting the parent filed is null.
Hi Rohit,
Your mapping will look like
Num_Orders---------------------------------------------------------------->
UDF----->Target
Order_ID(not detail)------>removeContext(Node Function)-->
Also according to your requirement the UDF will be like
int len = Integer.parseInt(a[0]);
for(int i=0;i<len;i++)
{
if(b.length != len){
result.addValue("Error Message");
break;
}
else if(b<i>.equals(""))
result.addValue("Error Message");
else
result.addValue("SUCCESS");
}
Thanks!
Hi,
try the following UDF,
if(Integer.parseInt(firstInput[0]) == secondInput.length)
{
for(int i = 0;i<secondInput.length;i++)
{
if(secondInput<i>.equals(""))
{
result.addValue("Error Message");
}
else
{
//logic to handle secondInput
}
}
}
else
{
result.addValue("Error Message");
}
-Rohit
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
If your input is just the value of order no, then you wont need a UDF, you can do it with standard functions.
First check if 2nd value has value or not, do that by using IF THEN using a blank constant if its true then
Use another IF THEN and check if 1st input is = to 2nd, if true then pass the value of 2nd input to output.
Hope this helps
Thanks
Saiyog
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.