cancel
Showing results for 
Search instead for 
Did you mean: 

Custom routine for pricing procedure not performing calculation

YABAPER
Explorer
0 Kudos
143

Hi everyone, I am doing some experimentation and trying to create a custom routine. I am not familiar with the process and running into some problems at the moment. In my code below, I am trying to give a user a discount if in the current month they have more than 3 orders over the value of 3000. I see some people use "komp" in their code, but what is this and how can it be implemented in my scenario? Can someone please shed some light as to where I am going wrong?

DATA: lv_order_count        TYPE i,
      lv_total_value        TYPE decimal10_2,
      lv_discount           TYPE decimal10_2,
      lv_discounted_value   TYPE decimal10_2,
      lt_vbak               TYPE TABLE OF vbak,
      ls_vbak               TYPE vbak,
      lv_first_day_of_month TYPE sy-datum.

lv_first_day_of_month = sy-datum(6) && '01'.

SELECT * FROM vbak INTO TABLE lt_vbak
   WHERE erdat BETWEEN lv_first_day_of_month AND sy-datum and netwr > 3000 AND kunnr = '1987653'.

lv_order_count = LINES( lt_vbak ).

 LOOP AT lt_vbak INTO ls_vbak.
    IF lv_order_count > 3.
      lv_discount = ls_vbak-netwr * '0.03'.
    ENDIF.
  ENDLOOP.

 

View Entire Topic
ArcherZhang
Product and Topic Expert
Product and Topic Expert
0 Kudos

Just return the 'xkwert=lv_discount' in your routine. You may check other routines('Alternative Calculation of Condition Amount' ) that are delivered by SAP in V/08 as a kind of example.

Instead of using ''Alternative Calculation of Condition Amount'' routine, for your case, it`s better to have 'Requirement', then only return TRUE/FALSE in there. But the prerequisite is first to define a discount VK12.

YABAPER
Explorer
0 Kudos
@ArcherZhang Would I not need to make use of the komk tables as well? Because I have tried that before but was not quite working out