Can anyone tell me the procedure to create separate pricing routine for complex pricing procedure and where to assign in my pricing?
Govind A replied
To define Custom Z routine in Sales and Distribution module please follow the following steps.
o Transaction Code - VOFM (Maintain: Requirements and Formulas)
o Menu Path - Formulas --> Condition value.
o Go to bottom of the table control,
o Enter the routine number for Ex. 900 and some meaningful description,
o It will ask the Access key, enter the available access key. Now ABAP editor will be opened, you can switch off Modification Assistant from Menu EDIT �� Modification operation �� Switch off Assistant.
o In custom routine we can use KOMP structure, where we can get the pricing value,
o To access the whole condition record, we can use structure XKOMV. But to access this XKOMV structure we have to define one internal table of type INDEXED_KOMV and pass the structure XKOMV value to the new defined internal table.
o Depending upon the requirement you can refer KOMP or XKOMV structure in your code.
o The calculated result we have to pass to XWERT field, which will be display to the condition record.
o To activate the subroutine we have to first save the code and come out from the routine. In Maintain: Formulas Condition value screen, select routine to activate and select Edit menu �� Activate.
o After activating the custom routine, functional person will attach this custom routine to the condition type of the pricing procedure at AltCty column.
o Function person can define one field at Subto column for condition type, which we can use in our custom routine.
o For ex. We require to calculate the % discount depending upon the two condition type. To get the condition value for the both the condition type we have to select one field at Subto column. There are two types of fields, one is Copy value to and another one is Carry over value to. One store the condition value whereas second store Condition rate. Depending upon the requirement we can select the field type. Before using the Subto field please make sure that it is not referring to other condition type.
o To calculate the % you have to divide or multiply by 10000 not by 100 due to SAP current type.
This is an example of a code sample:
DATA: WORKFIELD(16) TYPE P DECIMALS 2.
CHECK KOMP-KZWI1 NE 0.
IF XWORKJ NE 0.
WORKFIELD = ( KOMP-KZWI1 - XWORKJ ) * 10000 / KOMP-KZWI1.
XKWERT = WORKFIELD.
XKWERT = 0.
Reward points pls.