cancel
Showing results for 
Search instead for 
Did you mean: 

Aritmetics operations with UDFS

Former Member
0 Kudos

Could somebody help me with this problem? SBO 6.5

What data type works properly to make aritmetics operations? I have 2 UDF in OINV table and i want to multiplicate them and divide by 100. I've try many things but system doesn't send me any error.

Only i´ve obtained and error when udf's data type is "Units and Totals" subtype "Amount" and i've checked this select with many data types.

I have this select:

SELECT (($[OINV.U_DtoAHM] * $[OINV.U_ImpAnt)/100) FROM OINV T0 WHERE T0.DocNum=$[OINV.DocNum] FOR BROWSE

to calculate a new discount in the invoice card but SBO doesn't calculate it.

And a stranger behavior:

With numeric (integer, I think) data type i obtained next results:

SELECT (($[OINV.U_DtoAHM] * $[OINV.U_ImpAnt)/100) FROM OINV T0 WHERE T0.DocNum=$[OINV.DocNum] FOR BROWSE

Doesn't work.

SELECT ((1000 * $[OINV.U_ImpAnt)/100) FROM OINV T0 WHERE T0.DocNum=$[OINV.DocNum] FOR BROWSE

Works properly.

AND

SELECT (($[OINV.U_DtoAHM] * 1000)/100) FROM OINV T0 WHERE T0.DocNum=$[OINV.DocNum] FOR BROWSE

Works properly.

Incredible...

Alberto Hermida

Thanks.

Message was edited by: Alberto Hermida Mouriño

Accepted Solutions (1)

Accepted Solutions (1)

Trinidad
Product and Topic Expert
Product and Topic Expert
0 Kudos

I had similar problems with formatted searches some time ago.

I solved it casting the values obtained.

Here you have a sample of a formatted search that works:

SELECT CAST($[$38.U_PrixAch] AS numeric(19,6))/(1-CAST($[$38.U_TauxM] AS numeric(19,6)))

Hope it solves your problem

Trinidad.

Former Member
0 Kudos

Thanks Trinidad

But it doesn`t work.

Have anyone any other idea?

Thanks for all.

Former Member
0 Kudos

The syntax you are using for the variables is designed to return a string. There is an additional parameter '.NUMBER' you can use to get SBO to treat the variable as a numeric item. I have included a simple example below (assumes value of UDF is 5).

SELECT $[ORDR.U_AZU_SPHR]

- Treats it as a string: select '5'

SELECT $[ORDR.U_AZU_SPHR.NUMBER]

- Treats it as numeric: select 5

This might solve your problem.

Regards,

John.

Answers (0)