Discover how to use the Profitability Analysis (CO-PA) valuation enhancement to lock posting periods against changes in CO-PA data. See also how this solution helps meet Sarbanes-Oxley compliance for internal controls on CO-PA reporting.
Key Concept
Valuation is a key capability of costing-based Profitability Analysis (CO-PA) that the system uses to automatically fill value fields based on several available methods of calculation. Valuation with material cost estimates allows you to add the fixed and variable cost-of-goods-manufactured of the products sold in billing documents that are transferred to CO-PA. Valuation using the condition technique allows you to use conditions and costing sheets to calculate estimated values needed for analyzing profitability that are not captured at the time of the original source document posting, such as sales commissions or freight costs. You can implement your own valuation logic with custom-defined ABAP program routines. The custom-defined routine known as the CO-PA valuation enhancement is explained here to demonstrate one innovative use.
Usually in a productive SAP ERP system, the G/L administrator ensures that only the current financial posting period is open for posting, while all other posting periods are closed. At the end of a posting period, the period is closed, and the next posting period is opened. An exception to this rule occurs during the time frame of the financial closing activities, when both the prior and current posting periods are open. This period-locking concept is a fundamental capability of any accounting system to prevent transactions from posting to past and future periods. It provides users of financial data an assurance of consistency and integrity of the reported data that they can use for comparative analysis and decision making.
Companies often use CO-PA to support sales quantity reporting by segment in their public financial disclosures. Companies are increasingly applying Sarbanes-Oxley rules for internal controls to all areas of financial reporting, even management reporting, such as that offered by CO-PA. Based on feedback SAP Consulting received from customers on Sarbanes-Oxley-related audits of their SAP systems, an internal control risk for CO-PA data has been exposed. Because SAP Development has not yet provided a fix in the standard system to address the gap through a Support Package, I developed the following CO-PA enhancement for a customer to satisfy its auditors for Sarbanes-Oxley compliance. I’ll explain the CO-PA valuation enhancement, beginning with four customizing steps. Then I’ll show you some programming you’ll need so you can lock your CO-PA data. I set up my examples within an SAP ERP Central Component (ECC) 6.0 IDES solution using operating concern IDEA; however, the same solution is applicable in R/3.
Before I explain the valuation enhancement, I’ll look into a couple of different ways you can lock or unlock posting periods, and how they relate to my process.
Lock or Unlock Posting Periods
With transaction OB52 in the G/L, you maintain permitted posting period data. You can specify which posting periods are open by company code using a posting period variant. You can elect, for example, to have customer and vendor accounts open, but asset accounts closed. It is possible to further separate the opened and closed posting periods by G/L account intervals. You can even open and close posting periods only for specific users with inclusion of the authorization group field.
Independent from the G/L, you can lock (close) or unlock (open) posting periods in the Controlling (CO) applications. You maintain the CO period lock in transaction OKP1 and store its data in table KAPS. It delineates setting period locks by controlling area and fiscal year, and by actual data and plan versions. Within any of these options, you can lock or unlock different business processes by posting period.
Though you can lock posting periods in your SAP system using transactions OB52 and OKP1, a few known gaps exist in Profitability Analysis (CO-PA). In the standard system, transaction OB52 is not relevant to the CO applications, including CO-PA data. Transaction OKP1 only provides the capability to lock or unlock certain types of CO-PA-related postings, including assessments and settlements into CO-PA, activity and template allocations, repostings, and top-down distributions. The CO period lock transaction OKP1 does not, however, prevent postings from the following transactions available within costing-based CO-PA:
- Manually created line items (KE21N)
- Transfer of external data (KEFC)
- Periodic valuation (KE27)
For companies that do not use these functions, a simple solution for locking these types of postings is to disallow authorization to these transaction codes. However, companies that require these transaction codes, without the ability to lock the posting periods, need to ensure that their profitability data is secure, accurate, and reliable — that it does not change after the posting period is intended to be closed.
Furthermore, a recent trend resulting from Sarbanes-Oxley compliance audits is a finding in material weakness concerning the inability to completely lock the posting period against changes to CO-PA data. Now I’ll discuss my CO-PA valuation enhancement that can help solve this problem.
CO-PA Valuation Enhancement
An enhancement is a callout from an SAP standard program made at a predefined point, known as a user exit, provided for making custom additions to the standard SAP processing logic. The enhancement framework is useful because it allows customization of the programming environment without changing SAP Repository Objects, which is otherwise known as a core modification. You have to be careful with enhancements so as to minimize the risk and cost of system development. Enhancements are not typically affected by upgrading to a new release.
You need to activate the standard CO-PA valuation enhancement, in which you call the function modules that you need to determine if the posting periods are open. If the function returns that the posting period is open, then the CO-PA transactions are permitted. If the functions determine that the posting period is not open, then the system produces a standard SAP error message. The enhancement checks both whether the CO period is unlocked and whether the FI posting period is open. However, you could easily adapt the solution depending on your requirements to use either the FI or the CO period lock tables to determine if postings are allowed.
I detail the steps for customizing now. First, follow menu path SAP menu > Tools > Customizing > IMG> SPRO > SAP Reference IMG or use transaction ORKE.
- Step 1. Establish a valuation strategy for valuation of actual data
- Step 2. Create separate sequence steps for each user exit
- Step 3. Assign the valuation strategies you created in the first step to one or more points of valuation and for each record type used in your SAP system
- Step 4. Define an SAP enhancement project
Step 1. Establish a valuation strategy for valuation of actual data. You can use transaction KE4U or follow menu path Profitability Analysis > Master Data > Valuation > Valuation Strategies > Define and Assign Valuation Strategies (Figure 1). For flexibility, you should use separate strategies for online (001) and periodic (002) valuations.

Figure 1
Transaction KE4U valuation strategy
Step 2. Create separate sequence steps for each user exit. To do this, select the Valuation strategy step in the dialog structure from Figure 1, then click on the Details screen (Figure 2). You use exit number U01 to check if the FI posting period is open and exit number U02 to check if the CO posting period is unlocked. The exit names chosen here are not fixed by SAP. You can define them with any name you desire. Additionally, you can elect to use either one or both of these exits, as mentioned previously.

Figure 2
Transaction KE4U valuation strategy details
Step 3. Assign the valuation strategies you created in the first step to one or more points of valuation and for each record type used in your SAP system. From the same screen as shown in Figure 1, go to the Assignment of valuation strategy screen (Figure 3). Valuation 01 in the PV (point of valuation) column represents an online posting, for example, from a manual CO-PA line item posting (transaction KE21N) or from external data transfer (transaction KEFC). Valuation 02 represents a periodic posting, for example, from use of the periodic valuation (transaction KE27).

Figure 3
Figure 3 Transaction KE4U assignment of valuation strategy
Step 4. Define an SAP enhancement project. You can use transaction CMOD or follow menu path SAP menu > Tools > ABAP Workbench > Utilities > Enhancements > Project Management. In my example project, I used ZCOPAVAL, which follows the convention of naming custom developments with a leading Z to distinguish customization from SAP-delivered objects. Within this step, you need to take three actions.
1. Mark the button next to the Enhancement Assignment sub-object and click on the Change button. On the screen that follows, enter COPA0002 in the Enhancement column. SAP provides this enhancement for programming customer-specific requirements within CO-PA valuation.
2. Click on the Components button and observe that several standard function modules are included in enhancement COPA0002 (Figure 4). In this example, you use function EXIT_SAPLKEAB_001, which is used for valuating actual data. The other exits shown in Figure 4 include exit 002 for valuation of plan data, exit 003 for valuation using conditions, and exit 004 for valuation with material cost estimates. For more information, see the documentation for enhancement COPA0002 by pressing Control+F4.

Figure 4
Standard function modules in COPA0002
3. Double-click on the first line and navigate to the function builder (transaction SE37) for function module EXIT_SAPLKEAB_001 (Figure 5). Observe that the function has four import parameters, four export parameters, and provides exception handling for messages. The function also has a standard delivered include statement to call program ZXKKEU03. You can put customer-specific coding for the enhancement in this program. Double-click on the ZXKKEU03 program to continue to the ABAP Editor (transaction SE38).

Figure 5
Function module EXIT_SAPLKEAB_001
Programming Conventions in Program ZXKKEU03
Within CO-PA exit program ZXKKEU03, you need to follow a few standard programming conventions.
First, begin by defining a work area such as the CO-PA line item table CE1XXXX where XXXX is equal to the key (IDEA) of the operating concern:
data: line_item_IDEA like CE1IDEA.
Because the enhancement is active system-wide, use the case-endcase method to
restrict the program logic by operating concern:
case ERKRS. "Operating Concern when IDEA. endcase.
You need to do this in the event that your SAP system has more than one
operating concern. Within this section, pass the imported data from the
function module to the work area:
line_item_IDEA = EP_Source.
It is also a good idea to use the case-endcase technique to separate
the coding for each particular exit that you will use in your system:
case EXIT_NR. “Exit number declared in t-code. KE4U when U01. …………….......
……..when U02. endcase.
Now I show you the specific source code that you need within the exit U01 to check if the FI posting period is open based on the posting date of the CO-PA document:
***************************************************************** *Lock is based on FI Posting Period Control tr. OB52 when ‘U01’. “CO-PA valuation strategy tr. KE4U call function ‘G_PERIOD_ALLOWED_CHECK’ EXPORTING account_type = ‘+’ “Account Type company = line_item_IDEA-bukrs “Company Code period = line_item_IDEA-perde “Posting Period record_type = ‘0’ “Record Type year = line_item_IDEA-gjahr “Fiscal Year EXCEPTIONS period_not_allowed = 1 not_authorized = 2 OTHERS = 3. if sy-subrc = 0. “Period open elseif sy-subrc = 1. “Period closed raise VALUATION_ERROR. endif.
Note
This function is checking for the permitted posting periods in table T001B using a constant for record type equal to 0, the account type +, the specific company code, the document posting period, and the document fiscal year. Account type + is a wildcard meaning it is valid for all account types.
Here is the specific source code that you need within the exit U02 to check if the CO period lock is active in table KAPS based on the CO area, version, business transaction, and the posting date of the CO-PA document. In this example, I’m using a constant for version 000 and another constant KTDA for the business transaction COPA: TOP-DOWN: Actuals in transaction OKP1:
***************************************************************** * Lock is based on CO Period
Lock tr. OKP1 ***************************************************************** data: c_vrgng
like rkcsp-vrgng. data: c_versi like ce1idea-versi. data: l_period_open type c. c_vrgng
= ‘KTDA’. c_versi = ‘000’. WHEN ‘U02’. “CO-PA valuation strategy tr. KE4U call
function ‘K_PERIOD_LOCK_CHECK’ EXPORTING id_kokrs = line_item_IDEA-kokrs “Controlling Area
id_versn = c_versi “Version id_vrgng = c_vrgng “Business Transaction id_date_from =
line_item_IDEA-budat “Posting date from id_date_to = line_item_IDEA-budat “Posting date to
IMPORTING ed_message = l_period_open EXCEPTIONS others = 1. if l_period_open is initial. “lock
exists message e806(ki) WITH c_vrgng line_item_IDEA-kokrs line_item_IDEA-gjahr line_item_IDEA-
perde raising VALUATION_ERROR. else. endif.
You need to end the program by passing the work area back to the export structure of the function module:
EP_Target = line_item_IDEA.
From transaction CMOD described in step 4, be sure the project you defined is activated. In the attributes screen, ensure that the Project Status field displays Active.
With these steps complete, I will now show you the effect of adding message logic within the valuation enhancement. Figure 6 shows an example that demonstrates from a manual CO-PA line item (transaction KE21N) the raising of error message GU501 from FI. Error message KI 806 from CO looks similar to this screen.

Figure 6
Transaction KE21N with error GU501
Be aware of an unintended consequence of the CO enhancement. When you make a manual posting to an unlocked posting period, a new pop-up message KI812 notifies you that the system has found open posting periods. Users simply have to press enter to pass through this informational message to save their data.

Jeffrey Holdeman
Jeffrey Holdeman joined the SAP BusinessObjects Regional Implementation Group (RIG) for Enterprise Performance Management (EPM) in 2007. He works as a product specialist in SAP BusinessObjects Profitability and Cost Management and SAP BusinessObjects Planning and Consolidation. In March 2009, he celebrated with his customer the first ever go-live on SAP BusinessObjects Planning and Consolidation, version for SAP NetWeaver. Previously, Jeff worked for 10 years at SAP America, Inc. as a principal applications consultant where he was a key contributor and impact player in the success of nine customer SAP ERP/BW go-lives, including all aspects of project lifecycles. He is a nationally known expert in CO-PA and was the past national practice leader for SEM. Jeff has an MBA degree from The Ohio State University and a BS cum laude degree with high honors in finance from Butler University.
You may contact the author at jeffrey.holdeman@sap.com.
If you have comments about this article or publication, or would like to submit an article idea, please contact the editor.