Sunteți pe pagina 1din 5

SDN Contribution

Custom Routine for Sales and Distribution Module

Applies to:
SAP 4.6C

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.

Author(s):

Nilesh Shete

© 2006 SAP AG 1
Company: Tata Consultancy Services Ltd. Mumbai India

Created on: 30 June 2006

Author Bio
Name - Nilesh Shete,

Company Name- Tata Consultancy Services Ltd. . Mumbai India

Working as SAP Technical Consultant ABAP Workbench on different areas SAP –External
system interface, ABAP reporting, ALV, BAPI, etc.

© 2006 SAP AG 2
Introduction

First of all I will explain what is the difference between Condition Value and Condition base value?

o Condition value is nothing but the calculated value depending upon the specified condition or pricing
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 validate for 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 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.

© 2006 SAP AG 3
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:

Sample Code 1

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.

© 2006 SAP AG 4
Sample code 2

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.

ZKOMV[] = XKOMV[].

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.

Disclaimer and Liability Notice


This document may discuss sample coding or other information that does not include SAP official interfaces
and therefore is not supported by SAP. Changes made based on this information are not supported and can
be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods
suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of
this technical article or code sample, including any liability resulting from incompatibility between the content
within this document and the materials and services offered by SAP. You agree that you will not hold, or
seek to hold, SAP responsible or liable with respect to the content of this document.

© 2006 SAP AG 5

S-ar putea să vă placă și