SAP R/3 форум ABAP консультантов
Russian ABAP Developer's Club

Home - FAQ - Search - Memberlist - Usergroups - Profile - Log in to check your private messages - Register - Log in - English
Blogs - Weblogs News

Custom Routine for Sales and Distribution Module (Tr. VOFM)



 
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD
View previous topic :: View next topic  
Author Message
admin
Администратор
Администратор



Joined: 01 Sep 2007
Posts: 1639

PostPosted: Tue Sep 04, 2007 5:37 pm    Post subject: Custom Routine for Sales and Distribution Module (Tr. VOFM) Reply with quote

Custom Routine for Sales and Distribution Module (Tr. VOFM)

Applies to: SAP 4.6C
Author: Nilesh Shete

Summary
In pricing procedure there are different condition types and some time we can not use direct this condition type in pricing procedure as it is based on different condition. In such situation we have to define custom routine. In Sales and Distribution module I have define custom routine to calculate Condition value for some condition types.
Depending on the business processes used it may be necessary to influence the standard behavior of R/3 applications. For that purpose the VOFM function provides a corresponding environment in order to be able
to develop and manage customer-specific logic simply.
The system stores the objects generated via the VOFM in the Customizing of the respective application area (Pricing, message determination and so on) and its programs call the objects correspondingly.


Introduction
First of all I will explain what is the difference between Condition Value and Condition base value?
o Condition value is nothingbut the calculated value depending upon the specified condition orpricing
condition type. The include name will start with RV64A* and subroutine name will be Form routine:
FRM_KONDI_WERT_<ROUTINE NUMBER>.
o Whereas Condition base value are used to validatefor the particular pricing condition type value. .
The include name will start with RV61A* and subroutine name will be Form routine:
FRM_KONDI_WERT_<ROUTINE NUMBER>.
Important Points

Defining custom routine we have to keep in mind few important points;
o Access key for each custom routine. VOFM objects are subject to SSCR registration
o Required authorization to define custom routine.
o Understand the requirement and check whether it is possible to incorporate in the custom routine or
not
o We have customer number range from 900 to 999 for custom routine.
o Execute 'RV80HGEN' report after completing the routine in each system.
Step to Follows

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 personwill attach thiscustom 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 theSubto 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:

Sample Code 1
Code:
       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.

Sample code 2
Code:
      DATA: WORKFIELD(16) TYPE P DECIMALS 2,
                   WORKFIELD1 LIKE KOMP-FACTOR,
             WORKFIELD2 LIKE KOMP-FACTOR.
      DATA: ZKOMV TYPE STANDARD TABLE OF INDEXED_KOMV
                                                        WITH HEADER LINE INITIAL SIZE 50.
      CLEAR: XKWERT.

      READ TABLE ZKOMV WITH KEY KSCHL = C_PRICE.
      IF SY-SUBRC = 0.
        WORKFIELD2 = ZKOMV-KWERT.
      ELSE.
        READ TABLE ZKOMV WITH KEY KSCHL = C_PRICE1.
          IF SY-SUBRC = 0.
            WORKFIELD2 = ZKOMV-KWERT.
        ENDIF.
      ENDIF.
      CHECK WORKFIELD2 NE 0.
      IF WORKFIELD1 NE 0.
        WORKFIELD = ( WORKFIELD1 - WORKFIELD2 ) * 10000 / WORKFIELD2.
        XKWERT = WORKFIELD.
      ELSE.
        XKWERT = 0.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Russian ABAP Developer's Club Forum Index -> SD All times are GMT + 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum


All product names are trademarks of their respective companies. SAPNET.RU websites are in no way affiliated with SAP AG.
SAP, SAP R/3, R/3 software, mySAP, ABAP, BAPI, xApps, SAP NetWeaver and any other are registered trademarks of SAP AG.
Every effort is made to ensure content integrity. Use information on this site at your own risk.