3 Replies Latest reply: Feb 12, 2008 9:11 AM by Gaurav Jagya RSS

creating new formula via tcode VOFM, Formulas->Condition base value

Mindaugas Kazlauskas
Currently Being Moderated

Hi,

 

I need to create new formula via tcode VOFM, Formulas->Condition base value

 

How to do it?

 

for this I have:

1. number of this new formula

2. rule of calculations of the formula (ABAP code)

3. developer key

 

Will reward,

Regards,

Mindaugas

  • Re: creating new formula via tcode VOFM, Formulas->Condition base value
    Anji Reddy Vangala
    Currently Being Moderated

    Hi

    Take the Access Key with the help of BASIS people

    and create aroutine with the Number above 900

    and copy the code of the existing routine and modify it as per your changes

    VOFM is the transaction where you can maintain Requirement routines, which are assigned through cusomization.

    To create a routine you need access key & routine no. starts with "9".for ex. 901,902 etc.

    one important thing to note that even if you have some syntax errors inside your routine, it will get activated without errors. So, you need to do Main Program check before activation.

     

    Refer to SAP Note no : 327220,381348,156230.

     

    goto VOFM tcode for wrting the Routines

    from menu Requirements-> pricing

    You can create the pricing related routines here

    Use the Number from 900 only

    take the acess key and try to copy the existing routine and change the code to your requirement  and keep a break point and see

    Activate it before execution

     

     

     

    Regards

    Anji

  • Re: creating new formula via tcode VOFM, Formulas->Condition base value
    Gaurav Jagya
    Currently Being Moderated

    Hi,

     

    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.

    ELSE.

    XKWERT = 0.

    ENDIF.

     

     

     

    Regards,

    Gaurav

Actions