Let us understand how to get costs breakup in standard product costing (CK11N)
SAP Standard product costing process:
Since we are discussing abut technical aspect of costs breakups, we will not go into more functional details, for more functional details you can refer SAP’s product costing documentation. At high level we need to perform below actions to carry out product costing.
- Create material master data
- Create bill of material
- Create workcenter
- Create routing and activities
- Assign activities to workcenter
- Assign cost element to activity
- Assign workcenter to cost center
- Perform KP06, KP26 and KSPI for activity costs.
- Run costing via CK11N (For mass costing run – use CK40N)
- Marking price CK24 – This will update price in material master as future price.
- Release price CK24 – This will update standard price in material master accounting view1.
Note: After the costing run, you can see the costs breakup in CK11N transaction.
How to get costs breakup:
Due to various reasons ( export control, management reporting etc.), we have to provide the break-up of the cost into various categories or a specific cost category. To get the costs breakup, we have to use 2 function modules
- BAPI_COSTESTIMATE_GETLIST – This function module will provide the list of cost estimates performed on material. Recent estimate will be at the top.
- For each estimate received from above function module, call function module BAPI_COSTESTIMATE_ITEMIZATION to get costs breakups until we get the costs.
Demo implementation:
My requirement was to find total cost ( sum of all the elements type ) and value Add ( Sum of element type E and G ). I created a method with material number and plant as input & costs ( total & value add ) as output. Your calculation requirement may vary so you can adjust the calculation part as per your conditions:
METHOD get_product_costs.
*-- Local data declarations
DATA: lt_itemization_list TYPE TABLE OF bapiitemizationlist,
lt_material TYPE TABLE OF bapimateri,
lt_plant TYPE TABLE OF bapiplant,
lt_costestimate_list TYPE TABLE OF bapicolist,
ls_itemization_header TYPE bapiitemizationheader,
ls_return TYPE bapireturn,
ls_itemization_list TYPE bapiitemizationlist,
ls_material TYPE bapimateri,
ls_plant TYPE bapiplant,
ls_costestimate_list TYPE bapicolist,
lv_cost_found TYPE boole_d.
*-- Clear variables
CLEAR: lt_itemization_list,
lt_material,
lt_plant,
lt_costestimate_list,
ls_itemization_header,
ls_return,
ls_itemization_list,
ls_material,
ls_plant,
ls_costestimate_list,
lv_cost_found,
ev_total_cost,
ev_value_add.
IF iv_matnr IS NOT INITIAL AND iv_werks IS NOT INITIAL.
ls_material-sign = 'I'.
ls_material-option = 'EQ'.
ls_material-low = iv_matnr.
APPEND ls_material TO lt_material.
ls_plant-sign = 'I'.
ls_plant-option = 'EQ'.
ls_plant-low = iv_werks.
APPEND ls_plant TO lt_plant.
*-- Get cost estimate lists
CALL FUNCTION 'BAPI_COSTESTIMATE_GETLIST'
IMPORTING
return = ls_return
TABLES
material = lt_material
plant = lt_plant
cost_estimate_list = lt_costestimate_list.
IF ls_return-type EQ 'S'.
*-- Loop through cost estimate and calculate cost with 1st available entry.
LOOP AT lt_costestimate_list INTO ls_costestimate_list.
*-- Clear variables used in loop.
CLEAR: ls_itemization_list,
ls_return,
ev_total_cost,
ev_value_add.
*-- Get Cost Itemization.
CALL FUNCTION 'BAPI_COSTESTIMATE_ITEMIZATION'
EXPORTING
referenceobject = ls_costestimate_list-ref_object
costingnumber = ls_costestimate_list-cstg_num
costingtype = ls_costestimate_list-cstg_type
costingdate = ls_costestimate_list-cstg_date
costingversion = ls_costestimate_list-version
valuationvariant = ls_costestimate_list-vltn_vrnt
enteredmanually = ls_costestimate_list-enter_man
IMPORTING
itemization_header = ls_itemization_header
return = ls_return
TABLES
itemization_list = lt_itemization_list
EXCEPTIONS
OTHERS = 0.
IF ls_return-type EQ 'S'.
*-- Calculate Costs : Category E & G is value added.
LOOP AT lt_itemization_list INTO ls_itemization_list.
lv_cost_found = abap_true.
IF ls_itemization_list-item_category = 'E' OR
ls_itemization_list-item_category = 'G'.
ev_value_add = ev_value_add + ls_itemization_list-ccode_currency_total_value.
ENDIF.
ev_total_cost = ev_total_cost + ls_itemization_list-ccode_currency_total_value.
ENDLOOP.
*-- Just supply price per lot.
IF ls_itemization_header-lotsize IS NOT INITIAL.
ev_value_add = ev_value_add / ls_itemization_header-lotsize.
ev_total_cost = ev_total_cost / ls_itemization_header-lotsize.
ENDIF.
ENDIF.
*-- Come out of loops if cost already calculated.
IF lv_cost_found IS NOT INITIAL.
EXIT.
ENDIF.
ENDLOOP.
ENDIF.
ENDIF.
ENDMETHOD.
I hope you like this post on how to get costs breakup in standard product costing (CK11N). You can write to us in case of any query/suggestion/feedback. Happy learning !