cancel
Showing results for 
Search instead for 
Did you mean: 

putting a decimal in between the value i am getting from a UDF

Former Member
0 Kudos

Hi Friends

I am having this below UDF which is mapped to a split by value and then to the target field my problem is

this UDF is sending me a value of 7 digits like 0003000.

But i want to put this value in the target as 4 on the left side of the decimal and 3 on the right of the decimal .

I know i have to put some concat decimal in this UDF but dont know how to can any one please help its very critical.

Points will surely be rewarded

Thanks

//write your code here

int length = Quantity.length;

String[ ] count = new String[length] ;

String y = "0";

String z = "I";

int list = 0;

for(int i = 0; i <length; i++)

{

if(Trans_void_Flag<i>.equals(y) && Trans_Type<i>.equals(z) )

{

count[list] = Quantity<i>;

list ++;

}

}

for(int j = 0; j <list; j++)

result.addValue(count[j] );

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Aquarian,

Map the output of this UDF to 'abs' arithmetic function, then map the output of the 'abs' function to 'formatnumber' as told to you earlier.

I believe, it should solve the problem.

Thanks,

Varun

Former Member
0 Kudos

Hi Varun

Can you please explain me how to use this abs function .

actually i used that Format function before but it dint solved the problem .

my input value from the UDF is 7 values in a string that i have to break into 4 , 3 with a decimal in between can you please tell me to solve this .

Thanks

Former Member
0 Kudos

Hello,

you can do it exactly like described here:

Regards

Patrick

Former Member
0 Kudos

Hi,

use substring function.

give input to substring funcion,in fubstring function write 0..4 it will give first four digit output. use another substring function again give the input and this time in use the 3..7 it will give the remaining 3 digit output.

Now give first input to concat function and use constant function with value "." (decimalpoint). output of concat is given to another concat function with second input as the remaining 3 digit.

Thnx

Chirag

Former Member
0 Kudos

Hi Aquarian,

//write your code here

int length = Quantity.length;

String[ ] count = new Stringlength ;

String y = "0";

1) In this piece of code you have used variable 'count' as a string array so i assume you are getting more than one values for 'count':

for(int j = 0; j <list; j++)

result.addValue(count[j] );

2) Now you are mapping the output to 'splitbyvalue' function to put every value in separate context

So I am suggesting you to do such a mapping:

UDF output ---> abs ---> FormatNumber ---> Target field

Please note that the target field should have occurrances 0...unbounded or same occurrences as the source field.

3) For example, by the mapping i have suggested, the output would be:

If this UDF is sending you a value of 7 digits like 0003000.

Output --> 3000.000

Note: 'abs' is the fourth function from left, if you open the arithmetic section of standard functions, it return the absolute value of the string, as in your example 3000 is the absolute value of 0003000.

And FormatNumber would add the decimal point that you need.

Please feel free to ask for more help.

Thanks,

Varun

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi

you can use the function in the following way.

use the substring function and the concatinate function.

the output of the UDF will go to the substring function (set substring as 0..3)

so u willget the output as 0003.

then use the constant function with value as dot(.).

n now both the input, constant and the output of substring give to the concatinate function.

this will give the output as 0003.

now agin use the substring function (set value as 4..7)

now agian the output of previous concatinate and the output of substring give to new concatinate finction

this will give the result as 0003.0000

now output of the concatinate should be mapped to the target.

i think this will solve ur problem

if you still face the problem please reply me back

Thanks

Rinku

Former Member
0 Kudos

Hi Aquarian,

You could also use standard functions of Substring and Concat to achieve the same functionality

To your source field (coming from your UDF), put a Substring function which takes the values from position 0, characters 4

Then put the Substring function for taking the rest of the values i.e from position 4, characters 3.

Concatenate these two using the Concat function, and use the period (decimal point) as ur Delimiter in the properties.

The output then goes to the target.

I also am trying out the solution by UDF. If i get lucky in doing that, i'll post the solution immediately.

Hope this helps.

Regards,

Lavita.

P.S. Do reward points if the information is useful.