New table PRCD_ELEMENTS in S/4HANA

0
27840

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.

Introduction

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 in SAP ECC.

With SAP 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. The data is no longer stored in the KONV table and you need to use new table PRCD_ELEMENTS in custom code to SELECT pricing conditions.

New table PRCD ELEMENTS in S4 HANA

2. CDS view V_KONV

In addition to the PRCD_ELEMENTS table and a new ABAP CDS view V_KONV is also available to get the price conditions in SAP S/4HANA. CDS view V_KONV can be used in custom CDS views.

CDS View V KONV in S4 HANA

Along with the CDS view, a class-based API is available to get, update and delete the pricing conditions in SAP.

3. New API – CL_PRC_RESULT_FACTORY

The factory class CL_PRC_RESULT_FACTORY is used to retrieve the pricing data. Following class methods are provided within the API to read, write and delete the data.

GET_PRICE_ELEMENT_DBGet price elements from DB
GET_PRICE_ELEMENT_DB_BY_KEYGet price elements from DB by semantic key
SAVE_PRICE_ELEMENT_DBSave price elements on DB
DELETE_PRICE_ELEMENT_DB_BY_KEYDelete price element from DB by semantic key (one document)
DELETE_PRICE_ELEMENT_DBDelete price elements from DB (multiple documents)
DELETE_PRICE_ELEMENTS_DBDelete 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/adjust the custom code from SAP ECC to S/4 HANA.

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!