Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

regarding sales and distribution

former_member197655
Active Participant
0 Kudos

how to create condition type with reference to an existing condition type

1 ACCEPTED SOLUTION

Former Member
0 Kudos

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

2 REPLIES 2

Former Member
0 Kudos

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

Former Member
0 Kudos

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.

To Create a routine in Transaction VOFM, follow these steps to create routine: You must need the Access Key to create a routines in this transaction because this will have a overall effect on the standard transaction related to deliveries.

Eg..

1. VOFM->Data Transfer->Deliveries

2. in Routine Number enter number say 802 (For example)

3. Enter Description

4. Double click on routine number, it will ask for access key, provide access key, then it will create include for the routines specified (for 802)

5. Copy and paste your code in the form created automatically in the include program and activate

6. go back -> then select the routines number say 802, go to Edit tab-> Activate, this will activate the routine number created

7. Now your routines will be created, tell the functional owner to assign this routines with the requirement.