VOFM Routines–A Short Guide

VOFM routines are primarily used in SD, Billing area to alter the standard business processes. Ex: Determine the price of pricing condition dynamically etc. It can be considered as one of form of Enhancements.

VOFM routines can be used to propose/alter the business process and it can be triggered for particular condition. Ex: Pricing condition ZCIL which will trigger the routine whenever it’s used.
VOFM routines are created using TCODE VOFM

image



There are various categories in VOFM like Data Transfer, Requirements, Formulae’s etc. Depending upon the category, the routine or exit will be called. Ex: any routine done in Formula’s category will be triggered during the computation of formula of a particular pricing condition. One has to choose the correct category and create a new routine.

In this example I am choosing, Formulas, >> Conditions value. (Meaning I can change the conditions value using this routine for a particular pricing condition)
image
We can create a new entry here. All 9XX entries are custom routines. Please note that it will ask for Access key as you these routines will be in a standard program.

Create a new routine and give a description to it.
Activate the routine by clicking Edit >> Activate.

Now we have to assign this routine to the required pricing procedure. Its normally done by SD functionals. You can also do it yourself in tcode v/08.

Choose the relevant pricing procedure and click double click on Control in left hand side.

image

Now it lists all the Pricing conditions and Step numbers of that billing type. Enter your routine number accordingly in the right category. Ex: If its requirement routine, do it in Reqt column, if its calculation/formula routine specify it in Cal Type column

image

Let’s go back to our VOFM routine: Double click on the routine number in VOFM to go inside the routine where you can edit the code. Here you can do a normal ABAP coding. It’s important to note that standard SAP process will be followed after your modification. To know what all values you can modify using the routine, create a break point and see the Global tab.

image

Be very careful in changing the values. Remember that it will be triggered wherever that pricing condition is used. And it’s not recommended to change other tables/variables data apart from what the routine is designed for. Ex: In Formula >> Conditions vale routine do not change the Base Condition value even though you can forcibly change.

One important thing to remember in these routines the fixed point arithmetic is not enabled. Thus normal addition/subtraction/division operations will lead to erroneous and weird answers.
I will cover about the fixed point arithmetic in another post. For the time being, if you want to do any arithmetic operations inside the routine, make sure you create a new Z program and call that Z program subroutine.

Ex: I am changing the condition value of the pricing condition (xkwert) by calling the subroutine of another Z program which does all arithmetic computation
PERFORM f_compute_condval IN PROGRAM Z_PROGRAM  USING komp-aubel
                      komp-vgpos
                      komk-kurrf_dat
CHANGING xkwert.