SAP K_DOCUMENT_COSTS_POSTING Function Module for Primary costs planning: updating the created document
K_DOCUMENT_COSTS_POSTING is a standard k document costs posting SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Primary costs planning: updating the created document processing and below is the pattern details for this FM, showing its interface including any import and export parameters, exceptions etc. there is also a full "cut and paste" ABAP pattern code example, along with implementation ABAP coding, documentation and contribution comments specific to this or related objects.
See here to view full function module documentation and code listing for k document costs posting FM, simply by entering the name K_DOCUMENT_COSTS_POSTING into the relevant SAP transaction such as SE37 or SE38.
Function Group: KAPL
Program Name: SAPLKAPL
Main Program: SAPLKAPL
Appliation area: K
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update: 1

Function K_DOCUMENT_COSTS_POSTING pattern details
In-order to call this FM within your sap programs, simply using the below ABAP pattern details to trigger the function call...or see the full ABAP code listing at the end of this article. You can simply cut and paste this code into your ABAP progrom as it is, including variable declarations.CALL FUNCTION 'K_DOCUMENT_COSTS_POSTING'"Primary costs planning: updating the created document.
EXPORTING
EPSKZ = "
KOKRS = "
* TOTALS_UPDATE = 'X' "
TABLES
* ITCOBK = "
* ITCOSPRU = "
* ITCOSPA_DEL = "
* ITCOSSA_DEL = "
* ITCOEJA = "
* ITCOKA = "
* ITCOKAU = "
* ITCOKP = "
* ITCOKPU = "
* ITCOKS = "
* ITCOKSU = "
* ITCOSPR = "
IMPORTING Parameters details for K_DOCUMENT_COSTS_POSTING
EPSKZ -
Data type: TKA07-EPSKZOptional: No
Call by Reference: No ( called with pass by value option)
KOKRS -
Data type: COBK-KOKRSOptional: No
Call by Reference: No ( called with pass by value option)
TOTALS_UPDATE -
Data type: TKA07-EPSKZDefault: 'X'
Optional: Yes
Call by Reference: No ( called with pass by value option)
TABLES Parameters details for K_DOCUMENT_COSTS_POSTING
ITCOBK -
Data type: COBKOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOSPRU -
Data type: RKSTAOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOSPA_DEL -
Data type: COSPA_KEYOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOSSA_DEL -
Data type: COSSA_KEYOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOEJA -
Data type: COEJAOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOKA -
Data type: COKAOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOKAU -
Data type: RKSTAOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOKP -
Data type: COKPOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOKPU -
Data type: RKSTAOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOKS -
Data type: COKSOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOKSU -
Data type: RKSTAOptional: Yes
Call by Reference: No ( called with pass by value option)
ITCOSPR -
Data type: COSPROptional: Yes
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for K_DOCUMENT_COSTS_POSTING Function Module
The ABAP code below is a full code listing to execute function module POPUP_TO_CONFIRM including all data declarations. The code uses the original data declarations rather than the latest in-line data DECLARATION SYNTAX but I have included an ABAP code snippet at the end to show how declarations would look using the newer method of declaring data variables on the fly. This will allow you to compare and fully understand the new inline method. Please note some of the newer syntax such as the @DATA is not available until a later 4.70 service pack (SP8), which i why i have stuck to the origianl for this example.| DATA: | ||||
| lv_epskz | TYPE TKA07-EPSKZ, " | |||
| lt_itcobk | TYPE STANDARD TABLE OF COBK, " | |||
| lt_itcospru | TYPE STANDARD TABLE OF RKSTA, " | |||
| lt_itcospa_del | TYPE STANDARD TABLE OF COSPA_KEY, " | |||
| lt_itcossa_del | TYPE STANDARD TABLE OF COSSA_KEY, " | |||
| lv_kokrs | TYPE COBK-KOKRS, " | |||
| lt_itcoeja | TYPE STANDARD TABLE OF COEJA, " | |||
| lt_itcoka | TYPE STANDARD TABLE OF COKA, " | |||
| lv_totals_update | TYPE TKA07-EPSKZ, " 'X' | |||
| lt_itcokau | TYPE STANDARD TABLE OF RKSTA, " | |||
| lt_itcokp | TYPE STANDARD TABLE OF COKP, " | |||
| lt_itcokpu | TYPE STANDARD TABLE OF RKSTA, " | |||
| lt_itcoks | TYPE STANDARD TABLE OF COKS, " | |||
| lt_itcoksu | TYPE STANDARD TABLE OF RKSTA, " | |||
| lt_itcospr | TYPE STANDARD TABLE OF COSPR. " |
|   CALL FUNCTION 'K_DOCUMENT_COSTS_POSTING' "Primary costs planning: updating the created document |
| EXPORTING | ||
| EPSKZ | = lv_epskz | |
| KOKRS | = lv_kokrs | |
| TOTALS_UPDATE | = lv_totals_update | |
| TABLES | ||
| ITCOBK | = lt_itcobk | |
| ITCOSPRU | = lt_itcospru | |
| ITCOSPA_DEL | = lt_itcospa_del | |
| ITCOSSA_DEL | = lt_itcossa_del | |
| ITCOEJA | = lt_itcoeja | |
| ITCOKA | = lt_itcoka | |
| ITCOKAU | = lt_itcokau | |
| ITCOKP | = lt_itcokp | |
| ITCOKPU | = lt_itcokpu | |
| ITCOKS | = lt_itcoks | |
| ITCOKSU | = lt_itcoksu | |
| ITCOSPR | = lt_itcospr | |
| . " K_DOCUMENT_COSTS_POSTING | ||
ABAP code using 7.40 inline data declarations to call FM K_DOCUMENT_COSTS_POSTING
The below ABAP code uses the newer in-line data declarations. This allows you to see the coding differences/benefits of the later inline syntax. Please note some of the newer syntax below, such as the @DATA is not available until 4.70 EHP 8.| "SELECT single EPSKZ FROM TKA07 INTO @DATA(ld_epskz). | ||||
| "SELECT single KOKRS FROM COBK INTO @DATA(ld_kokrs). | ||||
| "SELECT single EPSKZ FROM TKA07 INTO @DATA(ld_totals_update). | ||||
| DATA(ld_totals_update) | = 'X'. | |||
Search for further information about these or an SAP related objects