on 01-04-2012 11:39 AM
Hi Experts,
I need a UDF for this below business case we have vendor name which having length 45. that need to mapped with Name1 & name 2. in the Target.
for the name1 the condition is like if vendor name having length up to 35 that will comes in Name1 filed.
for the Name2 . the condition is like if the vendor name is having more vthan 35 i.e means 35 to 45 those charactes will be filled in Name 2
let me give one exampl
vendorname-pavankumar- will goes to name1 bcz it's length is below35
vendorname- pavankumar pavankumarpavankumarpavankumar
pavankumar
- kumar will comes in Name2 filed bcz its more than length 35
I Need UDF For NAME2 Condition
please help me out. bcz this is my first UDF . i have never done UDF before
Thanks in Advance
Pavan
Edited by: Pavan Kumar Thiruveedula on Jan 4, 2012 12:42 PM
Hi Pavan,
I think you can solve this using graphical mapping alone
vendorName-----> length------>
less ------->
constant(36)--->
ifwithoutelse ---->Name1
vendorname --->
same logic for name2 field also. I used standard text, boolean and arithmetic fuctions.
Regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Priyanka,
I applied the below logic
Venorname -
>length
Constant-35---> greater than-> if-> then--->vendorname substring(35, 10) -
> else constant() -
>name2. but the problem is here i am using substring so that mean it's length should be 45 mandatory. but in real time we have vendor name may have 36 character length or 37,38,39,40 etc up to 45. please help me out.
Thanks In Advance
Pavan
Hi Priyanka,
I will explian you what i have done from the start. i clicked on User-defined fuction in that i saw arguement follwed by Var1. in the var1 field i replaced with Vendor name and then i clicked create function in that i copied you UDF logic like below
String result ="";
if(VendorName.length > 35){
result = VendorName.subString(35,VendorName.length-1);
}
return result;
then i mapped with vendorname->title->Name2
and later i tested i am getting this error
Source text of object Message Mapping: MM_VendorMasterTransferToTRAX | http://thy.com/FI/AP/VendorMasterTransferToTRAX_0088 has syntax errors:
Function calculate, Line 2:
cannot find symbol symbol : variable length location: class java.lang.String if(VendorName.length > 35){ ^
Function calculate, Line 3:
cannot find symbol symbol : variable length location: class java.lang.String result = VendorName.subString(35,VendorName.length-1); ^
Function calculate, Line 3:
cannot find symbol symbol : method subString(int,int) location: class java.lang.String result = VendorName.subString(35,VendorName.length-1); ^ Note: /usr/sap/D04/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map3075e9cf36d011e185e800000049bc5e/source/com/sap/xi/tf/_MM_VendorMasterTransferToTRAX_.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors
plz help out i never worked on UDF's before. your assistance is very great full to me.
Regards,
Pavan
Hi Pavan,
Apologies I jumped this point of your second requirement. Logic for Name1 filed remains same as my earlier post.
for name 2 you need an UDF .
String dynamic(String vendorname)
{
int i,l;
l=vendorname.length();
if(l>35)
{
vendorname=vendorname.substring(35,vendorname.length());
}
else
{
vendorname="";
}
return vendorname;
}
Hi Priyanka,
I feel the UDF you wrote might be missing the last character of the string.
Regards
Anupam
Edited by: anupamsap on Jan 4, 2012 2:13 PM
Hi Pavan,
What is the occurrence of Name2 in the target.....If it is zero,please try with the below code...pass thestr as input to UDF
what you want to pass to field name2 whent the length greater than 35 add that one in else condition.
String result ="";
if(str.length > 35){
result = str.subString(35,str.length-1);
}
return result;
Regards,
Priyanka
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI Priyanka
i am getting this below error i just copied the UDF which you have given
Source text of object Message Mapping: MM_VendorMasterTransferToTRAX | http://thy.com/FI/AP/VendorMasterTransferToTRAX_0088 has syntax errors:
Function calculate, Line 2:
cannot find symbol symbol : variable str location: class com.sap.xi.tf._MM_VendorMasterTransferToTRAX_ if(str.length > 35){ ^
Function calculate, Line 3:
cannot find symbol symbol : variable str location: class com.sap.xi.tf._MM_VendorMasterTransferToTRAX_ result = str.subString(35,str.length-1); ^
Function calculate, Line 3:
cannot find symbol symbol : variable str location: class com.sap.xi.tf._MM_VendorMasterTransferToTRAX_ result = str.subString(35,str.length-1); ^ Note: /usr/sap/D04/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map6f346e5036cd11e1c1c900000049bc5e/source/com/sap/xi/tf/_MM_VendorMasterTransferToTRAX_.java uses unchecked or unsafe operations. Note: Recompile with -Xlint:unchecked for details. 3 errors
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.