Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Unit price issues

Former Member
0 Kudos

HI!

In m my smartform Im getting the unit price for my invoice from the condition table directly instead of calculating it (Total / Quantity) which creates the rounding up issues. SO this works fine for us but the problem occurs when the condition pricing is like 300/ 1000 L or 4000/ 1000Kgs , what happens is that in the output the unit price and quantity when multiplied contradicts , though the net price per line item shows correctly but suppose qty is 3 L and the unit price is 300/1000L so total os .9 dollars which is correct but in the form out put it shows qty= 3 unit price 300 and total .9 dollrs, which si contracdictory, so what I did I used a calculation gaain and divided by condition price by condition pricing unit so when its 300/1000L it would show .3 /L which is now ok but another problem rose with metric ton, since the selling unit is MT and the unit price now after dividing by condition pricngi unit makes it per KG so output would show like qty =3 unit price 4 and total = 12000 dollars , so heer unit price is wrong as it should have been 4000/ Ton as the total os 12000 dollars.

Is theer a way out to show the correct unit pricing as per the sales unit. I had used the code to just divide the total price of line item divided by the Quantity but then the rounding up issues came up which was not required .

read table is_bil_invoice-it_kond into gs_kond
with key bil_number = gs_gen_del-bil_number
itm_number = gs_gen_del-itm_number.
if sy-subrc = 0.
  g_unit_price = gs_kond-kbetr / gs_kond-kpein.
else.
** Loop around and get the price for it
  loop at is_bil_invoice-it_kond into gs_kond
  where bil_number = gs_gen_del-bil_number and
  itm_number = gs_gen_del-itm_number.
    if gs_gen_del-fkimg <> 0.
         g_unit_price = gs_kond-kbetr / gs_kond-kpein.
      endif.
*  g_unit_price = g_item_tot / gs_gen_del-fkimg.
    endif.
  endloop.
endif.
* Get unit price and tot price.
g_item_tot = gs_gen_del-netwr - gs_gen_del-kzwi3.
*IF gs_gen_del-fkimg <> 0.
*  g_unit_price = g_item_tot / gs_gen_del-fkimg.
*ENDIF.

thanks

1 ACCEPTED SOLUTION

Former Member
0 Kudos

To avoid rounding issue you can declare your variable as type f but when you write the value of this variable then you need to decided how much decimal place you want in the unit price.

In this case you can chnage all the quantity in a single unit (say KG) then calculated the unit price with this converted value. You can use SAP standard FM for quantity conversion.

3 REPLIES 3

Former Member
0 Kudos

To avoid rounding issue you can declare your variable as type f but when you write the value of this variable then you need to decided how much decimal place you want in the unit price.

In this case you can chnage all the quantity in a single unit (say KG) then calculated the unit price with this converted value. You can use SAP standard FM for quantity conversion.

0 Kudos

Well we would ike to grab the unit price directly from the condition mentioned in the billing documents , thats the reason this issue has errupted , We would like to pull it directly from teh document onto the invoice but as I said when its given per 1000 L or /1000 Kgs then the problem occurs as teh quantity may be in MT and the unit price in the condition on document maybe like 4000 dollars per 1000 KGS so it takes 4000 and multiplies bny quantity which is in MT which is 1000 times more than teh correct value. SO as per my piece of code its grabbing the unit price directly from teh condition in the billing document . If I just divide this unit price that I am gettimng from the condition table in Doc by the condition rate KPEIN then it works ok except in few cases like MT. The quantity will show 3 MT suppose and the unit price will be 4000/1000 = $4/ kgs so this will contradict the units but in case of per 1000L it would be ok as the resultant will be in litres only but in case of MT its converted to Kgs so basically a client will see 3 MT QTY for 4 / Kgs and price will be 12000 dollars which dosent look alright though teh resultant is correct prioce.

SO this becomes a special case when we dont need to divide by condition unit rate . My question is can be give such kind of exceptions in our code and proceed or will be wrong.

Thanks

0 Kudos

Any suggestions please.