cancel
Showing results for 
Search instead for 
Did you mean: 

query about decimal point field in mapping

Former Member
0 Kudos

hi,

In interface one field is supposed , Both dollars and cents will be formatted with an implied decimal point before the last two digits in the data. 

for exm : input is -620.27. then output should be -000062027. Maximum length of the field is 10.

if input is 44.44.then output should be 0000004444.

In this way.

Name of the field is Pay_Amount.

how do i get this mapping?

Regards,

Sanghamitra

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

chk this UDF:

input will be var1

Execution type "Single value"


String a = var1.replace("." , "");
int len=a.length();
if(a.startsWith("-"))
{
String k1 = a.replace("-","");
for(int i=0;i<10-len;i++)
{
k1="0" +k1;
}
return ("-" + k1) ;
}
else 
{
for(int i=0;i<10-len;i++)
{
a ="0" +a;
}
return  a;
}

Former Member
0 Kudos

How do i find the length of the substring using UDF ?

Regards,

Sanghamitra

former_member854360
Active Contributor
0 Kudos

HI,

You can use standard length function in graphical mapping.

Former Member
0 Kudos

Use the replace string function to replace decimal point with null. Then pass the value to a udf.

Write a udf (value cached) and pass the input a= value from Pay_Amount and b - required length of field (10)

public String AddLeading(String a,String b,Container container){

String temp = new String(String.valueOf(Integer.parseInt(a)));

int temp1 = Integer.parseInt(b);

for(int i = 0; (temp1 - a.length()) > i ; i++)

{

temp = "0" + temp;

}

return(temp);

}

RaghuVamseedhar
Active Contributor
0 Kudos

Hi,

Use arthimatic unction 'multiply' and 'formatNumber'.

1.multiply with 100

2.Then furmat number with 0000000000.

Regards,

Raghu_Vamsee