Extensibility of The Sales and Distribution Price List: SAP Enhancement Package 7 For SAP ERP 6.0
Extensibility of The Sales and Distribution Price List: SAP Enhancement Package 7 For SAP ERP 6.0
Example Words or characters quoted from the screen. These include field names, screen titles,
pushbuttons labels, menu names, menu paths, and menu options.
Textual cross-references to other documents.
EXAMPLE Technical names of system objects. These include report names, program names,
transaction codes, table names, and key concepts of a programming language when they
are surrounded by body text, for example, SELECT and INCLUDE.
Example Output on the screen. This includes file and directory names and their paths, messages,
names of variables and parameters, source text, and names of installation, upgrade and
database tools.
Example Exact user entry. These are words or characters that you enter in the system exactly as
they appear in the documentation.
<Example> Variable user entry. Angle brackets indicate that you replace these words and characters
with appropriate entries to make entries in the system.
CUSTOMER
© 2012 SAP AG. All rights reserved. 2
Document History
CUSTOMER
© 2012 SAP AG. All rights reserved. 3
Table of Contents
4 Example ................................................................................................................................ 16
4.1 Scenario.................................................................................................................................................16
4.2 Assumptions .........................................................................................................................................16
4.3 Enhancing the Price List Report .......................................................................................................... 17
4.3.1 Adding a Field as a Selection Criteria ................................................................................. 17
4.3.2 Adding the Field in the Output Table ..................................................................................18
4.4 Enhancing Price Inquiry API ................................................................................................................19
CUSTOMER
© 2012 SAP AG. All rights reserved. 4
1 Extensibility New SD Price List
The new Creation of Price Lists (transaction V_NLN) (SDPIQPRICELIST) report uses a new mass enabled pricing
Interface (PIQ_API) for pricing for several customers or materials at once. It does not involve a transactional
context anymore, but instead uses a new standalone pricing interface. This new pricing interface offers a similar
flexibility and extensibility as the existing transactional pricing interface.
Creation of price lists for customers also has to be flexible in terms of the structure of the result list and regarding
further processing options. Such possibilities for enhancements are available for the new report.
The price list creation is done in function module API_PIQ_SDPRICELIST. It offers the complete functionality like
the price list creation report SDPIQPRICELIST and can be used in customer projects as well. The API offers all
enhancement possibilities described in this document. Additionally there is a BAPI defined like the API for usage
when the price list creation should be triggered from a remote system, via remote function call.
1.1 API_PIQ_SDPRICELIST
API_PIQ_SDPRICELIST can be used whenever a price list should be generated from within an ABAP program and
an RFC call is not required.
1.1.1 Parameters
Importing
Parameters
Parameter IS_SELCRIT contains the selection criteria. As a minimal set of selection criteria it is necessary to
pass a value for the sales area (VKORG/VTWEG/SPART) and a material and a customer. There are range table
parameters like MATNR, KUNNR. It is also possible to pass a list of materials and a list of customers in the
component MATNR_TAB and KUNNR_TAB. The user can either use the range table or the internal table format for
search.
CUSTOMER
© 2012 SAP AG. All rights reserved. 5
In case it is required to have further selection criteria, enter these values in component additional_selcrit. See
chapter Extensibility of Output and Selection Criteria for further information about extensibility of selection
criteria.
Parameter IS_OUTPUT_FORMAT controls how the price list should be processed, for example if it should be sent
by email.
Parameter IS_CONTROL_DATA contains parameters like language, price date, sales order type, a flag “delete zero
prices” and the structure KOMK_NAME_VALUE and KOMP_NAME_VALUE. This can be used in case the caller of the
API wants to pass pricing attributes to the pricing logic executed in the price list report. See chapter Extensibility
of Pricing Attributes for further information.
Optional Parameter IT_OUTPUT_FIELDS can be used in order to reduce the fields used for the price list output.
By default, the output uses the fields defined in the customizing tables (see chapter Extensibility of Output and
Selection Criteria ). In this table parameter you can pass a subset of fields from the customizing table, in case the
current price list should have fewer fields.
Exporting Parameters
TYPE
ER_RESULT REF TO DATA Result table
TYPE
ER_RESULT_LINE_TYPE REF TO CL_ABAP_STRUCTDESCR Runtime Type Services
TYPE
ER_RESULT_TABLE_TYPE REF TO CL_ABAP_TABLEDESCR Runtime Type Services
IF_PIQ_SDPRICELIST_
WRAPPER=>TDT_FIELD_
ET_FIELD_DESCRIPTION TYPE TXT Description for Output fields (labels)
The price list result is returned in the dynamic parameter ER_RESULT. Metadata describing the type of the result
list is provided in parameter ER_RESULT_LINE_TYPE and ER_RESULT_TABLE_TYPE.
Parameter ET_FIELD_DESCRIPTION contain the description of the fields (field labels), as they can be defined as
well by customizing.
Parameter EV_MSG_LOG_HNDL returns a message log handle. The message log can be read using functions like
BAL_LOG_MSG_READ.
1.2 BAPI_PIQ_SDPRICELIST
The BAPI has two more importing parameters, which can be set to increase the price list creation performance.
IV_NO_INPUT_CHECK disables consistency checks for the input parameters. It should be used when the caller of
the BAPI can ensure that only consistent and correct selection criteria are used. When parameter
IV_ONLY_PRICING_RESULT is set, only the pricing result is returned. The result list is not enriched with material
CUSTOMER
© 2012 SAP AG. All rights reserved. 6
and customer related data and BAdi Method POST_PROCESSING and BAdI method PROCESS_OUTPUT is skipped
for performance reasons.
Furthermore, BAPI_PIQ_SDPRICELIST executes an authority check using authorization object PIQ_BAPI with
authority 01.
Importing
Parameters
IV_ONLY_PRICING_R
ESULT TYPE FLAG General Flag
The dynamic exporting parameter for the result list from PIQ_SDPRICELIST is mapped into static parameter
ET_PRICING_RESULT and ET_OUTPUT_EXTENSION. ET_PRICING_RESULT contains the result of the pricing API,
whereas ET_OUTPUT_EXTENSION contains the additional fields which the price list should contain and which are
maintained in customizing table PIQC_FIELD_LST_S / PIQC_FIELD_LST_C.
In order to enable the BAPI to copy the output fields from customizing table PIQC_FIELD_LST_C to parameter
ET_OUTPUT_EXTENSION, you must execute function module PIQ_GEN_OUTPUT_STRUCT in the target
system/target client with DDIC change authority. The system generates a DDIC structure
(PIQS_OUTPUT_EXTENSION_CLNT*), which is used by the BAPI for mapping the custom output fields.
Exporting Parameters
Fields defined in
ET_OUTPUT_EXTENSION TYPE BAPIPAREXTAB PIQC_FIELD_LST_S(_C)
CUSTOMER
© 2012 SAP AG. All rights reserved. 7
2 Enhancements of the Price list report
The price list creation functionality can be enhanced in several ways. It is possible to add new selection criteria.
Changes to the price list result structure (new or different fields) can be easily added in Customizing.
Additionally, BAdIs provide the possibility to influence the customers and materials for which the price list is
created. The result of the pricing call can be modified by a BAdI and additional types of output processing for the
list can be implemented.
During price list creation, customer related data and material related data is collected from the master data
tables, which is needed for the execution of pricing and which is needed for enriching the price list result table.
This is done in two SQL select statements: one for the customer related data and one for the material related
data. These SQL selects take into account the selection criteria and the fields necessary for pricing and the result
list.
In order to provide a maximum of flexibility, the fields for the pricing result list can be customized. Three
customizing tables are provided. For each table, one Customizing activity is provided for the SAP standard
delivery and one for custom-defined entries.
This table describes the metadata used for joining master data tables to the customer table KNVV or to the
material table MVKE. It describes which key field from the target table is joined to which source field from the
CUSTOMER
© 2012 SAP AG. All rights reserved. 8
source table. Additionally constant values can be defined or a table can be joined taking into account the
language.
PIQC_TABMETADT_S contains the entries from the SAP standard deliveries. Custom-defined entries should be
done in the customizing table PIQC_TABMETADT_C.
Example:
The system should display the language dependent material description from table MAKT. The SQL table-join uses
table/field MVKE-MATNR which is joined to MAKT-MATNR. Additionally MAKT-SPRAS (language) is part of the join, it
gets filled by the system with the current language.
It is not directly the table name for the definition of the SQL join condition used but a table alias. Using this alias
definition, it is possible to define several join conditions to the same table.
CUSTOMER
© 2012 SAP AG. All rights reserved. 9
2.2 Extensibility of Pricing Attributes
Price Attributes are fields whose values influence the pricing. During condition access in the core pricing logic, this
data is needed for accessing the single condition table records. For example, a condition from condition table
A030 requires (among others) the field KONDM (material pricing group) to be filled. These price attributes are
usually determined in the price inquiry APIs which are used by the SD price list. However, since this price attribute
is already preset on the selection screen, the system can pass this value to the underlying pricing interface. This
field has therefore ‘Source Type’ as ‘Item Caller Data’ in the Customizing table PIQC_PREP_FLD_S. In
Customizing table PIQC_FIELD_LST_S, an entry exists for field kondm saying from which table field the kondm
value should be read.
You can add other search criteria into price list search screen using enhancement point
ES_PIQ_SDPRICELIST_EXT3. Its value can be passed to the price list API by using ABAP macro
transfer_select_option in ES_PIQ_SDPRICELISR_EXT6. This field value can also be passed to the pricing
core using similar customizing as described below.
An entry in the price list Customizing ( table PIQC_FIELD_LST_C ) is required because it has to be specified
from which master data table the value should be read and if the table can be accessed when the material data is
selected or when the customer data is selected .
In such cases, the price attribute in the Customizing table PIQC_PREP_FLD_C/ PIQC_PREP_FLD_S has to have
“Source Type” set to “Global Caller Data”, “Head Caller Data”, or “Item Caller Data” . Additionally, the price list
report has to know that it has to fill this price attribute. Therefore, an entry in Customizing table
PIQC_DB_ALIAS_S/ PIQC_DB_ALIAS_C has to be made as well, specifying Field Name, Source Table / Source
Field /Table Alias and the type of Select .
Another use case is for some special KOMK/KOMP fields. Pricing inquiry accepts the pricing procedure (KALSM),
document procedure (KALVG), local currency (HWAER) as global parameter, item category (PSTYV), quantity
(MGAME) as item attributes. If these values are fixed values for price lists creation, they can be added to the UI
using enhancement spot ES_PIQ_SDPRICELIST_EXT4. The values can be passed to pricing by
ES_PIQ_SDPRIRCELIT_EXT6 using macro ADD_NAME_VALUE (coding example
add_name_value 'KALSM' kalsm 'KOMK'.) In pricing core, these values will be used for this price list. No further
Customizing table entries are required for this special case.
CUSTOMER
© 2012 SAP AG. All rights reserved. 10
2.3 Enhancement Points in Transaction V_NLN / Report
SDPIQPRICELIST
The following enhancement points provide possibilities for enhancements in the price list report:
ES_PIQ_SDPRICELIST_EXT1
You can use this enhancement point when you want to add a selection field to the section for customer data.
ES_PIQ_SDPRICELIST_EXT2
You can use this enhancement point when you want to add a selection field to the section for material master
data. For example, if you want to add the material group as a selection field, you insert the following statement at
this enhancement point:
SELECT-OPTIONS: matkl FOR mara-matkl
ES_PIQ_SDPRICELIST_EXT3
You can use this enhancement point when you want to add a field to the section for control data. For example, if
you want to add the pricing procedure as a pricing attribute field to the control data, you insert the following
statement at this enhancement point:
parameters: kalsm type kalsm_d
ES_PIQ_SDPRICELIST_EXT4
You can use this enhancement point when you want to add a field to the section for price list output.
ES_PIQ_SDPRICELIST_EXT5
You can use this enhancement point when you want to add your own section to the UI for transferring data to the
price list creation API.
ES_PIQ_SDPRICELIST_EXT6
You can use this enhancement point to transfer your fields to the pricing API. For example, given the previous
example for extension point ES_PIQ_SDPRICELIST_EXT2, you insert the following statement at enhancement
point ES_PIQ_SDPRICELIST_EXT6:
transfer_select_option 'MARA' 'MATKL' matkl
Given the previous example for enhancement point ES_PIQ_SDPRICELIST_EXT3, you insert the following
statement at enhancement point ES_PIQ_SDPRICELIST_EXT6:
add_name_value 'KALSM' kalsm 'KOMK'
CUSTOMER
© 2012 SAP AG. All rights reserved. 11
2.4 BAdIs
2.4.1 BADI_PIQ_SDPRICELIST
Method PREPARE_PRICING
This BAdI method is executed before the pricing is done. It can be used for making changes to the control data of
the pricing call and for modifying the pricing attributes. These are passed with the parameters cs_global ,
cs_head and cs_item, depending if the attribute is relevant for all price lists, or if it is on customer level or if it is on
material level.
Method PROCESS_RESULT
BAdI method PROCESS_RESULT is called after the price list has been calculated. It can be used to influence the
calculated price lists before they are processed for output. You can do changes to the price list result table and to
the field labels of the result structure.
CUSTOMER
© 2012 SAP AG. All rights reserved. 12
2.4.2 BADI_PIQ_SDPRICELIST_OUTPUT
Method PROCESS_OUTPUT
This method can be used to define own processing steps of the price list result. SAP provides a standard
implementation of this BAdI method which sends the price list result via email to a mail recipient. Possible
implementations on customer project basis could be for example to put the individual price lists to an FTP server.
Parameters:
SAP Structure which passes data like pricing data, sales document type,
IS_CONTROL_DATA
language, pricing attribute structures and others
IR_RESULT Dynamic table parameter which holds the price list result
IR_RESULT_LINE_TYPE ABAP Structure descriptor which describes the type of the result parameter
IT_CUSTOMERS List of customer numbers for which the price lists has been generated
IT_FIELD_DESCRIPTION Field labels of the result structure, as described in IMG customizing (table
PIQC_FIELD_TXT_C / PIQC_FIELD_TXT_S)
Handle for the BAL Message log. The messages can be retrieved from the log
IV_MESSAGE_LOG using BAL_LOG_MSG_READ. New messages can be added with function
BAL_LOG_MSG_ADD.
CUSTOMER
© 2012 SAP AG. All rights reserved. 13
3 Enhancements in the Price Inquiry API
The price inquiry API offers the possibility to execute a pricing for several materials and for several customers in
one single step. It is optimized for mass transactions like the SD price list.
When pricing should be executed for a material/customer combination, the system requires some data (pricing
attributes) which are needed in order to access the correct pricing condition tables. As this price inquiry API does
not use a SD sales order simulation or does not simulate an SD invoice, there is customizing necessary to define
the sources for the filling of the price attributes.
This filling of the pricing attributes is a major step in customizing. When the defined pricing procedure uses
customer individual fields in the condition access, the mapping for these pricing attributes has to be defined. SAP
delivers the settings for the standard pricing attributes in the customizing tables of the price inquiry API. For
individual customer defined price attributes, these settings have to be made in Customizing activity "Define
Sources for Pricing Communication Structures".
If the filling of the price attribute requires a more complex logic which cannot be easily modeled in the
Customizing activity, there is BAdI BADI_PIQ_PREPARE (enhancement spot ES_PIQ_PREPARE).
For the standard set of pricing attributes the mapping information is already available.
This mapping is visible in Customizing under Sales & Distribution -> Basic Functions -> Pricing -> Price Lists ->
Price Inquiry ->Define Sources for Pricing Communication Structures (Display Standard Sources). In the same
Customizing node you can define additional sources for pricing communication structure fields.
You usually have to add additional sources when you use own communication structure fields (structure KOMK
and KOMP, or KOMKAZ and KOMPAZ) in pricing routines from transaction VOFM or userexits in pricing which
utilize these additional fields. This is needed in order to make the Price Inquiry API recognize the fields used by
CUSTOMER
© 2012 SAP AG. All rights reserved. 14
you and to give further information how these fields should be filled during a pricing execution in the Price Inquiry
API layer.
As a help for finding out which additional fields are used, there is the report VFPRCCUERATTR which can be
accessed in Customizing under Sales & Distribution -> Basic Functions -> Pricing -> Price Lists -> Price Inquiry-
>Edit Fields Used in Pricing Enhancements.
This report does a scan over the coding used in pricing user exits and pricing routines (transaction VOFM). It
scans pricing requirements, scale base formulas, condition base formulas, condition value formulas and group
key routines. Additionally, you can browse into the routines and userexit in order to find out what fields are used.
Using this BAdI method it is possible to adapt the head and item data.
Using this BAdI Method it is possible to adapt pricing attributes in the pricing communication structure KOMK and
KOMP before the pricing is executed .
CUSTOMER
© 2012 SAP AG. All rights reserved. 15
4 Example
4.1 Scenario
In the customer master, the field "Customer Group 1" (KNVV- KVGR1) is used to assign customers to specific
customer group values. This attribute is required to function as a selection field in the price list report and it also is
used in the pricing itself to determine discounts.
It is described here how the price list report and the price inquiry API has to be enhanced.
4.2 Assumptions
We assume that the scenario is already working in the pricing during sales order entry. Here we describe the
additional steps necessary for enhancing the price list report.
In detail, this means you already have done the following:
- Enhanced pricing structure KOMKAZ with the field ZZKVGR1
- Enhanced the field catalog for pricing in sales
- Created a condition table containing field ZZKVGR1
- Created an appropriate access sequence
- Created an appropriate condition type
- Included the condition type into the used pricing procedure
- Have maintained the price condition master data
CUSTOMER
© 2012 SAP AG. All rights reserved. 16
4.3 Enhancing the Price List Report
You must first add the field to the customer specific fields of the price list report in Customizing under Sales and
Distribution -> Basic Functions -> Pricing -> Price Lists -> Selection and Result -> Define Fields.
Additionally, the report SDPIQPRICELIST, which represents transaction V_NLN, has to be enhanced in order to
show the field as a selection criterion. For this purpose, you add the select-option statement to enhancement
point ES_PIQ_SDPRICELIST_EXT1.
REPORT sdpiqpricelist.
CUSTOMER
© 2012 SAP AG. All rights reserved. 17
Now the field from the report user interface has to be linked to the underlying business logic as a selection option.
This is done using the statement "transfer_select_option" in the enhancement point
ES_PIQ_SDPRICELIST_EXT6.
REPORT sdpiqpricelist.
…
START-OF-SELECTION.
The field is added to the output table by simply making sure that the following entry (from the customizing done in
chapter Adding a Field as a Selection Criteria) has flag "Output" set.
CUSTOMER
© 2012 SAP AG. All rights reserved. 18
4.4 Enhancing Price Inquiry API
In order to have the price inquiry API read the field for the selected sold-to parties , add the following entry to the
Customizing table PIQC_PREP_FLD_C in Customizing under Sales and Distribution -> Basic Functions -> Pricing -
> Price Lists -> Price Inquiry -> Define Sources for Communication Structures.
Source type "Database Table Alias" specifies that the price inquiry API should read the field value from
sourcetable/source field KNVV-KVGR1 . It also would be possible to read the value in the price list selection layer
(see chapter Enhancing the Price List Report) and to pass the value into the Price Inquiry API. This could be done
with source type "Head Caller Data".
CUSTOMER
© 2012 SAP AG. All rights reserved. 19
www.sap.com/contactsap
Material Number