mm-pricing based on custom fields - archive.sap.com

23
SDN Contribution MM-Pricing Based on Custom Fields © 2006 SAP AG 1

Upload: others

Post on 10-Jan-2022

5 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: MM-Pricing Based on custom fields - archive.sap.com

SDN Contribution

MM-Pricing Based on Custom Fields

© 2006 SAP AG 1

Page 2: MM-Pricing Based on custom fields - archive.sap.com

Applies to: SAP R/3 Release 4.7 onwards.

Summary The requirement was to determine Tax Code automatically in Purchase Order Lines via condition technique which involves custom fields (i.e. calculated based on some standard fields). Although we used this concept for automatic determination of Tax Code in Purchase Order Lines, (we used the Condition Type ‘NAVS’), but this can be applied to any condition type which derives values based on pricing. Created on: 5th June 2006

Author Bio (a) Name – Sandip Sanyal (b) Company name – IBM India Pvt. Ltd. (c) Field of work – SAP Technical (ABAP)

Table of Contents Procedure ........................................................................................................................................ 3

Flow Diagram ............................................................................................................................... 4 Implementation............................................................................................................................. 4

ABAP Development.................................................................................................................. 5 Configuration .......................................................................................................................... 14

Related Content............................................................................................................................. 23 Disclaimer and Liability Notice....................................................................................................... 23

© 2006 SAP AG 2

Page 3: MM-Pricing Based on custom fields - archive.sap.com

© 2006 SAP AG 3

Procedure This implementation involves some ABAP coding in User-Exit and BADI, as well as standard config. work e.g. extending field-catalog for pricing, creation of condition tables, access sequences etc. Please select which will be applicable / needed in your case. Each step is discussed in detail subsequently.

Page 4: MM-Pricing Based on custom fields - archive.sap.com

Flow Diagram

© 2006 SAP AG 4

BADIZAP1_CHECK_ALL_ITEMS

andZAP1_DEFINE_CALCTYP

Call ME21N/ME22Nor

Call BAPI_PO_CREATE1/BAPI_PO_CHANGE

PO Message from ExternalSystem

Enhancement on Pricing

Enhancement LMEKO001:Populate Z-fields in Pricing Header

Structure KOMK

Data enters in SAP

Enhancement LMEKO002:Populate Z-fields in Pricing Item

Structure KOMP

AccessSequence

Condition tableto Access?

(If any requirement (VOFM) exists,)No

Yes

Condition Table

Change in Header/Item

Should the changetrigger repricing?

Yes

NoPick Up Tax Code

PO Save

Implementation The whole implementation consists of the following steps: ABAP Development:

Page 5: MM-Pricing Based on custom fields - archive.sap.com

© 2006 SAP AG 5

Step 1. Extension of Pricing Structures KOMK and KOMP Step 2. Population of the custom fields via User-Exits Step 3. Creation of a CMOD project with function exits for pricing Step 4. Use of Business Add-ins for triggering re-processing of PO lines and subsequent re-pricing Step 5. Creation of pricing requirement via VOFM (Optional) Configuration: Step 1. Extension of Field catalog for condition tables Step 2. Creation of condition tables Step 3. Creation of access sequence Step 4. Maintenance of Condition Type Step 5. Maintenance of Pricing Schema

ABAP Development Step 1. Extension of Pricing Structures KOMK and KOMP:

Page 6: MM-Pricing Based on custom fields - archive.sap.com

KOMK contains a structure KOMKAZ for customer modification; where you can append your own append structure with your own fields, like:

Similarly KOMP contains a structure KOMPAZ for customer modification; where you can append your own append structure with your own fields.

Step 2. Population of the custom fields via User-Exits: Enhancement LMEKO001 (Extend communications structure KOMK for pricing): This enhance contains function exit EXIT_SAPLMEKO_001 where you can populate the custom fields you extended KOMK with.

© 2006 SAP AG 6

Page 7: MM-Pricing Based on custom fields - archive.sap.com

Enhancement LMEKO002 (Extend communications structure KOMP for pricing): This enhance contains function exit EXIT_SAPLMEKO_002 where you can populate the custom fields you extended KOMP with.

© 2006 SAP AG 7

Page 8: MM-Pricing Based on custom fields - archive.sap.com

© 2006 SAP AG 8

Note: - These exits are triggered when pricing is calculated in a purchase order. So for PO creation and change, these are triggered before ‘Save’. Additionally, these can be triggered manually doing a ‘Re-pricing’ via ME21N/ME22N.

Page 9: MM-Pricing Based on custom fields - archive.sap.com

Click on this

Then click on this

Exits are triggered. Step 3. Creation of a CMOD project with function exits for pricing: Create a project (CMOD), include these enhancements and then activate.

© 2006 SAP AG 9

Page 10: MM-Pricing Based on custom fields - archive.sap.com

Step 4. Use of Business Add-ins for triggering re-processing of PO lines and subsequent re-pricing Use the following BADI definitions to trigger re-pricing in case of change in certain header and item fields in a purchase order: 1. ME_CHECK_ALL_ITEMS: Create an implementation using this definition. This BADI enforces the processing of all the items again in case of change in certain PO header fields by use of a flag CH_X_RECALCULATE. Mark the flag CH_X_RECALCULATE = ‘X’ in case change in a field for which you want the re-pricing to be triggered. (Compare the old values in the structure IM_X_OEKKO with the new values in the structure IM_X_EKKO)

© 2006 SAP AG 10

Page 11: MM-Pricing Based on custom fields - archive.sap.com

2. ME_DEFINE_CALCTYPE: Create an implementation using this definition. This BADI sets the pricing type in case of change in certain PO header and item fields by use of CH_X_LF_CALCTYPE. Mark CH_X_LF_CALCTYPE = ‘B’ in case change in a field for which you want the re-pricing to be triggered. (Compare the old values in the structure IM_X_OEKKO/ IM_X_OEKPO with the new values in the structure IM_X_NEKKO/IM_X_NEKPO).

© 2006 SAP AG 11

Page 12: MM-Pricing Based on custom fields - archive.sap.com

Step 5. Creation of Pricing requirement via VOFM (Optional) You can further restrict the access to condition records via pricing routines defined in transaction VOFM. Here you can determine whether access to be made or not. Like in the following example, we had a Z-table where we maintained the list of condition records to access for a particular combination of taxation country and transaction class. In this routine we are checking whether the current condition table (which is going to be hit) is relevant (comparing against that Z-table) or not for the taxation country and transaction class. And if not relevant, we are setting the value of sy-subrc (set automatically by the SELECT statement) so that the current access is skipped.

© 2006 SAP AG 12

Page 13: MM-Pricing Based on custom fields - archive.sap.com

© 2006 SAP AG 13

Page 14: MM-Pricing Based on custom fields - archive.sap.com

Configuration Step 1. Extension of Field catalog for condition tables In this step, you extend the field catalog for condition tables to include fields that are not available for the purpose in the standard system. In SPRO (IMG) take the following path: Material Management -> Purchasing -> Conditions -> Define Price Determination Process -> Extend Field Catalog for Condition tables. Here, enter those field names which you want to use in a condition table (the fields you extended KOMK and KOMP with).

© 2006 SAP AG 14

Page 15: MM-Pricing Based on custom fields - archive.sap.com

Step 2. Creation of condition tables In this step, you define the price dependencies. In SPRO (IMG) take the following path: Material Management -> Purchasing -> Conditions -> Define Price Determination Process -> Maintain Condition Table. You can make prices, discounts and surcharges dependent on almost all the fields in a purchasing document. You define these dependencies with the aid of condition tables. In a condition table, you specify the combination of fields for which you can create condition records. (SAP Recommendation: - You should not change the condition tables that are included in the standard version of the SAP System.) Actions

1. Check the extent to which you can use the condition tables that are supplied with the standard SAP System. To do this, you can display these condition tables.

2. Before creating a new condition table, you should check whether the existing fields of the field catalog are sufficient for your requirements. If you wish to use a field for price determination which is not

defined for this usage in the standard system, you must include it in the field catalog (see Extend Field Catalog for Condition Tables). You can only include fields that are included in table KOMG, KOMK or KOMP. 3. Create new condition tables. To do so, copy a similar condition table and proceed as follows:

• Enter the name of the table you wish to create. (Note that you can only choose names between 501 and 999. If you make no entry, the system will automatically assign a consecutive number.)

© 2006 SAP AG 15

Page 16: MM-Pricing Based on custom fields - archive.sap.com

• Specify whether you wish to create the table with or without a validity period.

© 2006 SAP AG 16

• Enter a description for the condition table.

• From the list of allowed fields that are included in the field catalog and which can be extended

there, choose your desired fields for the condition table.

Page 17: MM-Pricing Based on custom fields - archive.sap.com

• Generate the new condition table.

Note: You can only maintain conditions for a new condition table if the condition table is used in an access sequence. After you create condition tables, you have to upload condition records into those tables. For this, you can use transaction XK15, or there is standard batch input program available - RV14BTCI. (Object 0070).

© 2006 SAP AG 17

Page 18: MM-Pricing Based on custom fields - archive.sap.com

Step 3. Creation of access sequence In this step you define access sequences. In SPRO (IMG) take the following path: Material Management -> Purchasing -> Conditions -> Define Price Determination Process -> Define Access Sequences. An access sequence is a search strategy with the aid of which the SAP System searches for valid condition records of a certain condition type. For example, you can stipulate for a price that the SAP System first searches for a price for a specific plant, and then for a generally applicable price. (SAP recommendation: - If you define your own access sequences, the key should begin with the letter Z, as SAP keeps these name slots free in the standard system.) You should not change the access sequences that are included in the standard SAP system. Actions 1. Create new access sequences by copying and changing similar existing ones. In doing so, enter an alphanumeric key, which can have a maximum of 4 characters, and a descriptive text.

2. Maintain the accesses for the access sequence by specifying the condition tables in the desired sequence. The sequence indicates the order of priority of the accesses.

© 2006 SAP AG 18

Page 19: MM-Pricing Based on custom fields - archive.sap.com

You can display and choose the defined combinations of key fields using the "possible entries" facility.

© 2006 SAP AG 19

Page 20: MM-Pricing Based on custom fields - archive.sap.com

Step 4. Maintenance of Condition Type In this step you define condition types. In SPRO (IMG) take the following path: Material Management -> Purchasing -> Conditions -> Define Price Determination Process -> Define Condition Types. The condition types are used to represent pricing elements such as prices, discounts, surcharges, taxes, or delivery costs in the SAP System. These are stored in the system in condition records. For our purpose (tax code determination in PO Line) condition type ‘NAVS’ (Non-Deductible Tax) is applicable. However, to keep the standard condition type as it is, we copied ‘NAVS’ to ‘ZAVS’ and attached the access sequence to it.

© 2006 SAP AG 20

Page 21: MM-Pricing Based on custom fields - archive.sap.com

Step 5. Maintenance of Pricing Schema In this step, you define the calculation schemas. In the MM area, a calculation schema - a framework of steps used to calculate or determine something - is used among other things to calculate costs, prices, period-end rebates, and taxes. In SPRO (IMG) take the following path: Material Management -> Purchasing -> Conditions -> Define Price Determination Process -> Define Calculation Schema. (Note: - This concept is referred to in the Sales and Distribution (SD) area as a pricing procedure.) We copied the standard pricing schema RM0000 (Purchasing Document (Big)) to ZM0000 and replaced condition type ‘NAVS’ by ‘ZAVS’.

© 2006 SAP AG 21

Now you are finished with the all the required development!

Page 22: MM-Pricing Based on custom fields - archive.sap.com

Now that we are done, let’s have a look what this whole process does. Create a PO using BAPI_PO_CREATE1 (ME21N would also work). If it finds a condition record, it will pick up the tax code automatically.

Also, change in the PO would affect change in tax code (depending on the condition record).

© 2006 SAP AG 22

Page 23: MM-Pricing Based on custom fields - archive.sap.com

© 2006 SAP AG 23

Related Content None

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.