Dear SAPLearners, in this blog post we will learn about KONV SD pricing data model changes and new table PRCD_ELEMENTS in S/4 HANA.
This blog post is part of S/4 HANA technical tutorials, you can find all tutorials here.
Firstly, we all know that SD pricing results are stored in the KONV table for sales business documents such as sales order and we have been using this table in custom code SELECT queries etc..
In S/4 HANA system, SAP has reviewed this table and new changes were implemented. When you are moving to S/4 HANA system from ECC, these changes to be followed and custom code is modified accordingly.
Lets see these changes in detail
1. New table PRCD_ELEMENTS
A new database table called PRCD_ELEMENTS is introduced to replace the KONV table to store all SD document conditions. It is of type Transparent table.
The data is no longer stored in the KONV table. You need to use new table PRCD_ELEMENTS in custom code to SELECT pricing conditions.
2. CDS view V_KONV
Further to the table and a new ABAP CDS view V_KONV is also available to get the price conditions. CDS view V_KONV can be used in custom CDS views.
In addition to the CDS view, an API is also available to Get, Update and Delete the pricing conditions.
3. New API
The factory class CL_PRC_RESULT_FACTORY is used to retrieve the pricing data.
Following methods are provided within the API to read, write and delete the data.
|GET_PRICE_ELEMENT_DB||Get price elements from DB|
|GET_PRICE_ELEMENT_DB_BY_KEY||Get price elements from DB by semantic key|
|SAVE_PRICE_ELEMENT_DB||Save price elements on DB|
|DELETE_PRICE_ELEMENT_DB_BY_KEY||Delete price element from DB by semantic key (one document)|
|DELETE_PRICE_ELEMENT_DB||Delete price elements from DB (multiple documents)|
|DELETE_PRICE_ELEMENTS_DB||Delete list of dedicated price elements (multiple documents)|
Now you know quite a bit about data model changes to KONV. Its time to see the how we can migrate our custom code to S/4 HANA system compatible.
Here is the old code from ECC system to get SD pricing conditions.
SELECT knumv kposn stunr zaehk kappl kschl kdatu FROM konv INTO TABLE lt_konv WHERE knumv = vbak-knumv.
Now lets look at the new code
Using PRCD_ELEMENTS table:
"new table PRCD_ELEMENTS SELECT knumv kposn stunr zaehk kappl kschl kdatu FROM prcd_elements INTO TABLE lt_konv WHERE knumv = vbak-knumv.
With V_KONV CDS view:
" CDS view SELECT knumv kposn stunr zaehk kappl kschl kdatu FROM v_konv INTO TABLE lt_konv WHERE knumv = vbak-knumv.
Using factory class CL_PRC_RESULT_FACTORY:
TRY. cl_prc_result_factory=>get_instance( )->get_prc_result( )->get_price_element_db_by_key( EXPORTING iv_knumv = vbak-knumv IMPORTING et_prc_element_classic_format = hkonv ). CATCH cx_prc_result. "implement suitable error handling ENDTRY. "or other alternative way TRY. cl_prc_result_factory=>get_instance( )->get_prc_result( )->get_price_element_db( EXPORTING it_selection_attribute = VALUE #( ( fieldname = 'KNUMV' value = komk-knumv ) ) IMPORTING et_prc_element_classic_format = hkonv ). CATCH cx_prc_result. "implement suitable error handling ENDTRY.
Like wise, now lets look at DDIC enhancements to KONV table.
4. DDIC enhancements
At some times we need to enhance KONV table with custom fields catering to the customer requirements. This is usually achieved using append structure to the database table KONV
In S/4 HANA system, you should NOT append directly to PRCD_ELEMENTS table.
Instead add append structure to the new structure PRCS_ELEMENTS_DATA which is included in database table PRCD_ELEMENTS.
Subsequently to PRCD_ELEM_DRAFT which is included in database table PRCD_ELEM_DRAFT(used to temporarily store pricing results as a draft prior to save)
Similarly ABAP CDS view V_KONV can also be used to get pricing data, therefore it is necessary to enhance the CDS view.
Click here to know how you can extend a CDS view with custom fields.
Congrats!!! 👍 you have successfully KONV SD pricing data model changes in S/4 HANA.
Please feel free to comment and let us know your feedback. Subscribe for more updates
If you liked it, please share it! Thanks!
Click here to join our channel and stay updated with the latest tutorials and updates.