cancel
Showing results for 
Search instead for 
Did you mean: 

Error in Formatted Search Calculation

0 Kudos

I am attempting to do what appears to be a fairly simple calculation.

In marketing documents use a formatted search (with a manual refresh) to calculate a price/per kg.

The formula is Gross Total (LC) / Weight. I am using the Gross Total because I want to take into account any discount applied.

SELECT $[38.288.number] / $[$38.58.number]

The behavior is very weird.

If I apply no discount it will calculate completely incorrectly. i.e. 5,040.00 / 2,100 will give me 2.

If I add even a 0.01% discount it will correctly calculate the amount - i.e. 2.4.

I have no idea where the number 2 is coming from.

I also tried an alternative calculation diving the gross price by the weight per item.

SELECT $[$38.20.number] / (($[$38.58.number] / $[$38.11.0]))

Any help would be appreciated.

I am running in SAP 9.2 Patch 02.

Accepted Solutions (1)

Accepted Solutions (1)

frank_wang6
Active Contributor
0 Kudos

If all number are integer, then the result is integer, this is where the 2 comes from.

So in your case, u need to force one of the number to be float

SELECT CAST($[38.288.number] AS DECIMAL(18,4))  / $[$38.58.number]



With one decimal inside calculation, everything should be fine.

0 Kudos

Thanks Frank. Seems obvious now, but I assumed if the result of two integers being divided was a decimal that is what the resulting number would be. Assumptions are killers!

It all works. Thanks so much.

Answers (0)