SAP FCO_COGS_GET_ACTIVE_VERSION Function Module for Get active version for cost estimate
FCO_COGS_GET_ACTIVE_VERSION is a standard fco cogs get active version SAP function module available within SAP R/3 or S/4 Hana systems, depending on your version and release level. It is used for Get active version for cost estimate 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 fco cogs get active version FM, simply by entering the name FCO_COGS_GET_ACTIVE_VERSION into the relevant SAP transaction such as SE37 or SE38.
Function Group: FCO_SFIN_SPLIT_UTIL
Program Name: SAPLFCO_SFIN_SPLIT_UTIL
Main Program: SAPLFCO_SFIN_SPLIT_UTIL
Appliation area:
Release date: N/A
Mode(Normal, Remote etc): Normal Function Module
Update:

Function FCO_COGS_GET_ACTIVE_VERSION 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 'FCO_COGS_GET_ACTIVE_VERSION'"Get active version for cost estimate.
EXPORTING
* I_MATERIAL = "Material Number - short
* I_PSPNR = "Valuated Sales Order Stock WBS Element
I_PLANT = "Plant
I_SALES_ORDER = "Sales Order Number
I_SALES_ORDER_ITEM = "Item Number in Sales Order
I_VALUATION_TYPE = "Valuation Type
I_SPECIAL_STOCK_IND = "Special Stock Indicator
I_POSTING_DATE = "Posting Date in the Document
I_VALUATION_SPECIAL_STOCK = "Valuation of Special Stock
* I_MATERIAL_EXT = "Material Number - MATNR40 in case of S4H
IMPORTING
E_COST_COMP_STRUCTURE = "Cost Component Structure
E_KEKO_KEY = "Product Costing - Header Data
CHANGING
* CTS_VALUTYP_PR_COST_KEY = "Get cost calculation key for all relevant valuation views
EXCEPTIONS
FAILED = 1 MATERIAL_MISSING = 2
IMPORTING Parameters details for FCO_COGS_GET_ACTIVE_VERSION
I_MATERIAL - Material Number - short
Data type: MATNR18Optional: Yes
Call by Reference: No ( called with pass by value option)
I_PSPNR - Valuated Sales Order Stock WBS Element
Data type: ACCIT-MAT_PSPNROptional: Yes
Call by Reference: No ( called with pass by value option)
I_PLANT - Plant
Data type: ACCIT-WERKSOptional: No
Call by Reference: No ( called with pass by value option)
I_SALES_ORDER - Sales Order Number
Data type: ACCIT-KDAUFOptional: No
Call by Reference: No ( called with pass by value option)
I_SALES_ORDER_ITEM - Item Number in Sales Order
Data type: ACCIT-KDPOSOptional: No
Call by Reference: No ( called with pass by value option)
I_VALUATION_TYPE - Valuation Type
Data type: ACCIT-BWTAROptional: No
Call by Reference: No ( called with pass by value option)
I_SPECIAL_STOCK_IND - Special Stock Indicator
Data type: ACCIT-SOBKZOptional: No
Call by Reference: No ( called with pass by value option)
I_POSTING_DATE - Posting Date in the Document
Data type: ACCIT-BUDATOptional: No
Call by Reference: No ( called with pass by value option)
I_VALUATION_SPECIAL_STOCK - Valuation of Special Stock
Data type: ACCIT-KZBWSOptional: No
Call by Reference: No ( called with pass by value option)
I_MATERIAL_EXT - Material Number - MATNR40 in case of S4H
Data type: ACCIT-MATNROptional: Yes
Call by Reference: No ( called with pass by value option)
EXPORTING Parameters details for FCO_COGS_GET_ACTIVE_VERSION
E_COST_COMP_STRUCTURE - Cost Component Structure
Data type: KEKO-ELEHKOptional: No
Call by Reference: No ( called with pass by value option)
E_KEKO_KEY - Product Costing - Header Data
Data type: CKIKEKOKEYOptional: No
Call by Reference: No ( called with pass by value option)
CHANGING Parameters details for FCO_COGS_GET_ACTIVE_VERSION
CTS_VALUTYP_PR_COST_KEY - Get cost calculation key for all relevant valuation views
Data type: FCOYS_VALUTYP_PR_COST_KEYOptional: Yes
Call by Reference: No ( called with pass by value option)
EXCEPTIONS details
FAILED - Active version could not be determined
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
MATERIAL_MISSING - Either IV_MATERIAL or IV_MATERIAL_EXT has to be set
Data type:Optional: No
Call by Reference: No ( called with pass by value option)
Copy and paste ABAP code example for FCO_COGS_GET_ACTIVE_VERSION 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_failed | TYPE STRING, " | |||
| lv_i_material | TYPE MATNR18, " | |||
| lv_e_cost_comp_structure | TYPE KEKO-ELEHK, " | |||
| lv_cts_valutyp_pr_cost_key | TYPE FCOYS_VALUTYP_PR_COST_KEY, " | |||
| lv_i_pspnr | TYPE ACCIT-MAT_PSPNR, " | |||
| lv_i_plant | TYPE ACCIT-WERKS, " | |||
| lv_e_keko_key | TYPE CKIKEKOKEY, " | |||
| lv_material_missing | TYPE CKIKEKOKEY, " | |||
| lv_i_sales_order | TYPE ACCIT-KDAUF, " | |||
| lv_i_sales_order_item | TYPE ACCIT-KDPOS, " | |||
| lv_i_valuation_type | TYPE ACCIT-BWTAR, " | |||
| lv_i_special_stock_ind | TYPE ACCIT-SOBKZ, " | |||
| lv_i_posting_date | TYPE ACCIT-BUDAT, " | |||
| lv_i_valuation_special_stock | TYPE ACCIT-KZBWS, " | |||
| lv_i_material_ext | TYPE ACCIT-MATNR. " |
|   CALL FUNCTION 'FCO_COGS_GET_ACTIVE_VERSION' "Get active version for cost estimate |
| EXPORTING | ||
| I_MATERIAL | = lv_i_material | |
| I_PSPNR | = lv_i_pspnr | |
| I_PLANT | = lv_i_plant | |
| I_SALES_ORDER | = lv_i_sales_order | |
| I_SALES_ORDER_ITEM | = lv_i_sales_order_item | |
| I_VALUATION_TYPE | = lv_i_valuation_type | |
| I_SPECIAL_STOCK_IND | = lv_i_special_stock_ind | |
| I_POSTING_DATE | = lv_i_posting_date | |
| I_VALUATION_SPECIAL_STOCK | = lv_i_valuation_special_stock | |
| I_MATERIAL_EXT | = lv_i_material_ext | |
| IMPORTING | ||
| E_COST_COMP_STRUCTURE | = lv_e_cost_comp_structure | |
| E_KEKO_KEY | = lv_e_keko_key | |
| CHANGING | ||
| CTS_VALUTYP_PR_COST_KEY | = lv_cts_valutyp_pr_cost_key | |
| EXCEPTIONS | ||
| FAILED = 1 | ||
| MATERIAL_MISSING = 2 | ||
| . " FCO_COGS_GET_ACTIVE_VERSION | ||
ABAP code using 7.40 inline data declarations to call FM FCO_COGS_GET_ACTIVE_VERSION
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 ELEHK FROM KEKO INTO @DATA(ld_e_cost_comp_structure). | ||||
| "SELECT single MAT_PSPNR FROM ACCIT INTO @DATA(ld_i_pspnr). | ||||
| "SELECT single WERKS FROM ACCIT INTO @DATA(ld_i_plant). | ||||
| "SELECT single KDAUF FROM ACCIT INTO @DATA(ld_i_sales_order). | ||||
| "SELECT single KDPOS FROM ACCIT INTO @DATA(ld_i_sales_order_item). | ||||
| "SELECT single BWTAR FROM ACCIT INTO @DATA(ld_i_valuation_type). | ||||
| "SELECT single SOBKZ FROM ACCIT INTO @DATA(ld_i_special_stock_ind). | ||||
| "SELECT single BUDAT FROM ACCIT INTO @DATA(ld_i_posting_date). | ||||
| "SELECT single KZBWS FROM ACCIT INTO @DATA(ld_i_valuation_special_stock). | ||||
| "SELECT single MATNR FROM ACCIT INTO @DATA(ld_i_material_ext). | ||||
Search for further information about these or an SAP related objects