Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member

Introduction

When customer pricing requirements exceed the robust standard pricing functionality provided by SAP, we can code routines for requirement check, condition base value, and condition value maintained in transaction VOFM. This provides a great help, but they are old fashioned procedural, require registration each time as repairs, and do not have the rich memory management and other functionality provided in the object oriented context. This document describes a one-time setup for any SD implementation to provide a flexible way of enhancing your pricing with the new OO context.

Setup

  1. Create a BADI definition in SE18/SE80.

You may need to create an enhancement spot first.

Short Text

Check requirement and calculate base and condition values with formula

Use

This BADI gives more flexibility to the routines found in transaction VOFM and assigned in the pricing procedure. The BADI contains three methods which are called from requirement check routine 900, condition base value formula 900, and condition value formula 900.

The BADI is filter dependent on condition type.

Requirements

The condition type must be created and assigned in the pricing procedure. The relevant number 900 routines must also be assigned in the procedure. If the BADI implementation is not active and the requirement check routine 900 is assigned in the pricing procedure, the condition will not be created.

Standard settings

When a new condition type needs either a custom requirement, base value, or total value, create an implementation with filter equal to the condition type. Implement all three methods to keep the implementation consistent. In the price procedure for the condition type, assign routine 900 in the appropriate place. If only the requirement check method is needed, only assign the 900 routine in the check column, but leave the formula and base value columns empty.

   *"* components of interface ZIF_PRICE_COND_CALC
interface ZIF_PRICE_COND_CALC
  public .


  interfaces IF_BADI_INTERFACE .

  methods VALUE_CALCULATE
    importing
      !I_KOMK type KOMK
      !I_KOMP type KOMP
      !I_KOMT1 type KOMT1
      !I_KOMT2 type KOMT2
      !I_XKOMV_TAB type CPET_KOMV_INDEX_TAB
      !I_XWORKD type KWERT
      !I_XWORKE type KWERT
      !I_XWORKF type KWERT
      !I_XWORKG type KWERT
      !I_XWORKH type KWERT
      !I_XWORKI type KWERT
      !I_XWORKJ type KWERT
      !I_XWORKK type KOMV-KBETR
      !I_XWORKL type KOMV-KBETR
      !I_XWORKM type KOMV-KBETR
      !I_PREISFINDUNGSART type CHAR1
    changing
      !C_XKOMV_LINE type KOMV_INDEX .
  methods BASE_CALCULATE
    importing
      !I_KOMK type KOMK
      !I_KOMP type KOMP
      !I_KOMT1 type KOMT1
      !I_KOMT2 type KOMT2
      !I_XKOMV_TAB type CPET_KOMV_INDEX_TAB
      !I_XWORKD type KWERT
      !I_XWORKE type KWERT
      !I_XWORKF type KWERT
      !I_XWORKG type KWERT
      !I_XWORKH type KWERT
      !I_XWORKI type KWERT
      !I_XWORKJ type KWERT
      !I_XWORKK type KOMV-KBETR
      !I_XWORKL type KOMV-KBETR
      !I_XWORKM type KOMV-KBETR
      !I_XKOMV_LINE type KOMV_INDEX
    changing
      !C_XKAWRT type KAWRT
      !C_KOMV_BASE type ZSD_KOMV_BASE
    exceptions
      NO_CHANGE .
  methods REQUIREMENT_CHECK
    importing
      !I_KOMK type KOMK
      !I_KOMP type KOMP
      !I_KOMT2 type KOMT2
      !I_XKOMV_TAB type CPET_KOMV_INDEX_TAB
      !I_XWORKD type KWERT
      !I_XWORKE type KWERT
      !I_XWORKF type KWERT
      !I_XWORKG type KWERT
      !I_XWORKH type KWERT
      !I_XWORKI type KWERT
      !I_XWORKJ type KWERT
      !I_XWORKK type KOMV-KBETR
      !I_XWORKL type KOMV-KBETR
      !I_XWORKM type KOMV-KBETR
      !I_XKOMV_LINE type KOMV_INDEX
      !I_XVBAPU type VBAPU_TTY
    changing
      !C_KOMT1 type KOMT1
    exceptions
      NO_COND .
endinterface.

2. Add the code to call BADI's in VOFM routines

Enhance LV61ATOP to add this data declaration:

   DATA: ZBADI_PRICE_COND_CALC TYPE REF TO ZBADI_PRICE_COND_CALC.

Register a requirement routine 900 (or another available in customer namespace), condition base value routine 900, and condition formula routine 900 in VOFM and add the below code:

Requirement Code:

Include          RV61A900

FORM.

   *This BADI is also called from base formula 900 and condition value formula 900.

  GET BADI ZBADI_PRICE_COND_CALC
    FILTERS
    kschl = komt1-kschl.

* If not implemented, exclude
  IF ZBADI_PRICE_COND_CALC->IMPS IS INITIAL.
    sy-subrc = 4.
    EXIT.
  ENDIF.

  CALL BADI ZBADI_PRICE_COND_CALC->REQUIREMENT_CHECK
    EXPORTING
      I_XVBAPU     = xvbapu[]
      I_KOMK       = komk
      I_KOMP       = komp
      I_KOMT2      = komt2
      I_XKOMV_TAB  = xkomv[]
      I_XWORKD     = xworkd
      I_XWORKE     = xworke
      I_XWORKF     = xworkf
      I_XWORKG     = xworkg
      I_XWORKH     = xworkh
      I_XWORKI     = xworki
      I_XWORKJ     = xworkj
      I_XWORKK     = xworkk
      I_XWORKL     = xworkl
      I_XWORKM     = xworkm
      I_XKOMV_LINE = xkomv
    CHANGING
      C_KOMT1      = komt1
    EXCEPTIONS
      NO_COND      = 1
      others       = 2.

ENDFORM.

Condition base value code:

Include          RV63A900

   FORM FRM_KOND_BASIS_900.
*{   INSERT         DEVK907971                                        1
DATA zkomv_base TYPE zsd_komv_base.

GET BADI ZBADI_PRICE_COND_CALC
  FILTERS
  kschl = xkomv-kschl.

CALL BADI ZBADI_PRICE_COND_CALC->BASE_CALCULATE
  EXPORTING
    I_KOMK       = komk
    I_KOMP       = komp
    I_KOMT1      = komt1
    I_KOMT2      = komt2
    I_XKOMV_TAB  = xkomv[]
    I_XWORKD     = xworkd
    I_XWORKE     = xworke
    I_XWORKF     = xworkf
    I_XWORKG     = xworkg
    I_XWORKH     = xworkh
    I_XWORKI     = xworki
    I_XWORKJ     = xworkj
    I_XWORKK     = xworkk
    I_XWORKL     = xworkl
    I_XWORKM     = xworkm
    I_XKOMV_LINE = xkomv
  CHANGING

    C_XKAWRT     = xkawrt
    c_komv_base  = zkomv_base
  EXCEPTIONS
    NO_CHANGE    = 1
    others       = 2.

IF zkomv_base IS NOT INITIAL.
   MOVE-CORRESPONDING zkomv_base TO xkomv.
ENDIF.
*}   INSERT
ENDFORM.

Condition Value code:

Include          RV64A900

   FORM FRM_KONDI_WERT_900.
*{   INSERT         DEVK907971                                        1
GET BADI ZBADI_PRICE_COND_CALC
  FILTERS
  kschl = xkomv-kschl.

CALL BADI ZBADI_PRICE_COND_CALC->VALUE_CALCULATE
  EXPORTING
    I_KOMK             = komk
    I_KOMP             = komp
    I_KOMT1            = komt1
    I_KOMT2            = komt2
    I_XKOMV_TAB        = xkomv[]
    I_XWORKD           = xworkd
    I_XWORKE           = xworke
    I_XWORKF           = xworkf
    I_XWORKG           = xworkg
    I_XWORKH           = xworkh
    I_XWORKI           = xworki
    I_XWORKJ           = xworkj
    I_XWORKK           = xworkk
    I_XWORKL           = xworkl
    I_XWORKM           = xworkm
    I_PREISFINDUNGSART = preisfindungsart
  CHANGING
    C_XKOMV_LINE       = xkomv.
  xkwert = xkomv-kwert.

ENDFORM.

Implementation

Now when you need a new condition type with code, you can easily create a new implementation of the BADI in SE19/SE80. In the pricing procedure, you assign these routines.

It is now easier for me to create new pricing functionality with all the benefits of object oriented classes. I do not need to bother basis for registration keys either. I hope this makes your life easier too. :smile:

3 Comments
Labels in this area