on 08-12-2011 3:17 AM
Hi Experts,
I have a mapping requirement in which the sender field is Sales Area and target field is Sellimg space. Now, the condition is
Now, the mapping condition is:
If Blank then add '0'. Else if it has a numeric value with square meters(m2)(Ex:41,234.000m2), then convert it to square feet
and send only the result value. Remove any blank spaces, Remove m2 .Else if it has a numeric value with square feet(ft2)
(Ex:423.000ft2) send only the Numeric value.Remove the ft2.Remove any blank spaces.
Please let me know.
Regards,
Aniruddha
Hi,
Thanks again for your help, but in both the cases I need to remove the spaces if any as well. Also, it can be m2 or ft2, so I am not getting how to do the UDF for this, it will be great if you elaborate a bit on this.
Regards,
Aniruddha
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
You can use this logic:
Sender -> removeContext -> trim -> replaceString -> UDF -> FormatNumber: 0,000.000 -> Target
Constant:, --------------------------> /
Constant: --------------------------> /
UDF execution is: Single Values
Argument: input
if(input.equals("")){
return "0";
}
else{
Double temp;
if(input.indexOf("m2")>-1){
temp = Double.parseDouble(input.substring(0,input.indexOf("m2")))*10.7639;
}
else{
temp = Double.parseDouble(input.substring(0,input.indexOf("ft2")));
}
return temp+"";
}
Hope this helps,
Mark
Hi Aniruddha,
Here is the UDF for your requirement
public static String Function(String s)
{
try
{
if(s==null || s=="")
{
//if blank return 0
return "0";
}
int i,j,l;
double d;
s=s.trim();
String h="";
if((i=s.indexOf("m"))>=0)
{
h="";
for(j=0;j<i;++j)
{
if((s.charAt(j)>='0' && s.charAt(j)<='9')|| s.charAt(j)=='.')
{
h=h+s.charAt(j);
}
}
try
{
d=new Double(h).doubleValue() * 10.7639;
}
catch(NumberFormatException e)
{
return s;
}
s=""+d;
}
else if((i=s.indexOf("f"))>=0)
{
h="";
for(j=0;j<i;++j)
{
if((s.charAt(j)>='0' && s.charAt(j)<='9')|| s.charAt(j)=='.')
{
h=h+s.charAt(j);
}
}
s=""+h;
}
}
catch(Exception e)
{
e.printStackTrace();
}
return s;
}
Here is the series of input /output for this
input=null,output=0
input=,output=0
input=41,234.000m2,output=443838.6526
input=423.000ft2,output=423.000
input=67.834 m 2,output=730.1583926
input=0.06676 ft 2,output=0.06676
input= 1.3 ft2,output=1.3
regards
Anupam
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
this can be done easily,
fist use equals functions to check source value balnk or not, if blank then pass constant value.
else you need smal udf to get last two charcters fo source to determine m2 or ft2,if m2 then use format number to removes zeros and special characters then use multiple functiion,1 mt 10.7639 sqft multiple with 10.7639 .
Regards,
Raj
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
98 | |
11 | |
11 | |
10 | |
10 | |
8 | |
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.