Mar 22, 2020

How to add SD Partner Functions as Characteristics in COPA for Profitability reporting

There are at least 3 different ways to add SD Partner Functions in COPA that I know.


  1. This one is complex and it requires Abap code and enhancements in standard SAP programs. That one is outlined by SAP in OSS Notes (36557, 12682, 32878, 93658). 
  2. Another one is kind of similar to the one that I will recommend, but it does not work in all the cases as the Sales Rep. is not always an SAP employee (PERNR). (This one was described by Paul Ovigele in the SAP Insider blog)
  3. An easy one .... that I have used and developed through the years, that works, it's easy and it requires minimal development (around 15 mins. ). This is the one that I will share with you in this Blog Post ...


To start with we will look at a Sales Order with its Partner Functions
* For confidentialy reason, names and descriptions are masked
Here you can see that we have different Partner Functions in this Sales Order (AG - Sold To, RE Bill To, WE Ship To and a custom one ZE - Sales Representative).

The Sales Representative is a typical Custom Partner Function that SD implementation teams normally create. It is commonly used to calculate commissions, among other things. But from a Profitability Analysis perspective it is also really helpful to be able to calculate how profitable a Sales Rep. is (or his customers). So it is also a common business requirements to have it as a COPA reporting Characteristic.

The SD Partner functions in the Sales Orders can be found in Table VBPA - Sales Document: Partner

As you can see above, in our previous Sales Order, we had ZE - Sales Rep. Partner Function assigned to "Vendor" 35xxx52. We can see the record in the Table VBPA.

Now, if you know a little bit of COPA, you might see where this is going .... With a simple COPA Derivation step, we will read table VBPA (Table lookup) and get the Sales Rep. #.

But .... there is a hick here. How do I create this COPA Characteristic in a way that I will not only have the number, but also the "key description" so I can have the Sales Rep. name in my Profitability reports and not just the number? Otherwise, it will be easy just to get the Sales Rep # into a Custom Characteristic field. But people will need to know what is the name of Sales Rep. 35xxxx52, it is not practical if you have many Reps. like big companies normally have.

This is where we need to do a really small development.

All custom and additional Partner Functions that can be added in COPA, need to be added first in Structure MCPARTUSR (Additional Partners from VBPA).
The right way to do it is by doing an APPEND in this structure right after field PDUMMY. As you can see below, we added 2 fields. The one that we will use is ZSREP_LI


The Field ZSREP_LI is defined with a Check Table and all the right definition same as LFA1-LIFNR as our Sales Rep. has been defined as a Vendor by our SD Team. I have used it before defined as a Customer as a different solution.

This of course cannot be done by a Functional Consultant, it needs to be done by a quilified Abaper.

As you can see below, Structure MCPARTUSR is also an Include of Table PAPARTNER, so the new fields get added to PAPARTNER automatically after saving.


Once this is added to MCPARTUSR, then we can go to create the Custom Characteristc (Tcode KEA5) to be added later to the Operating Concern.



I will create a Characteristic based on Table PAPARTNER that will use my Appended Table MCPARTUSR fields. Ex. WWSRP


Now the added field ZSREP_LI can be used and I will call it WWSRP (In this case the image is slightly difference as this was previously done to taking the screen shoots).

There are other standard partner functions that normally do not come as part of the Operating Concern in COPA and can also be added as Characteristics. Ex. WE - Ship to. You just need to create a Characteristic using KUNWE. Similar process for RE - Bill To. (KUNRE). The difference with the Sales Rep. is that these other are SAP Standard Partner Functions and they all have their own fields and check tables that will give us all the validations and descriptions, not just the code.



Now that the Characteristic has been created, we will add it to the Operating Concern as you would add any other Characteristics.

*** Note: We will not describe this process. We assume that if you are reading this you have the basic COPA knowledge to perform it.

Finally, the Characteristic has been Added to the Operating Concern. But the way it is right now, it will not get filled with any values yet.

We need to build a Characteristic Derivation Step (Tcode KEDR) of the Type Table Lookup for Table VBPA, the one that contains the records that hold the Partner Functions of the Sales Orders.


It is important to take into consideration to have POSNR as '000000' as normally the Partner Functions are at the Header Level. In case your SD design has them at the Line item level, then this will not be a constant. (See Table VBPA displayed previously)
In PARVW you will use GLOBAL-USERTEMP1 and then input RE (SAP Internal denomination for Bill-to) or ZE as per my previous example for Sales Rep.
Then the Target field will be your recently defined COPA Characteristic (Ex, KUNRE, WWSRP, etc.).

This concludes our process to Add a Custom Partner Function in COPA. As you could see it just requires a small Append in a Table that would take a good Abaper, not more than 10/15 minutes. And for sure this is 100% upgrade proof ... !!!


If your Company and/or Project needs to implement this, or any of the functionalities described in my Blog, or advise about them, do not hesitate to reach out to me and I will be happy to provide you my services.

Jan 26, 2020

S/4 HANA Profitability Report creation (COPA)

For COPA - Profitability Analysis purposes, in S/4 HANA the series of "Market Segment" Fiori Apps have replaced the good old fashion Report / Tcode KE30 where we used to build custom reports based on Report Painter technology. Now this is part of the past and we need to use these new "Market Segment" Fiori Apps in order to do Profitability COPA reporting.

Note: This is all based on the assumption that you are running "Account Based Profitability" as it is the recommended approach today for S/4 HANA. Also my preffered one as per many years of experience running both. (Account vs. Costing based).

Now, on an Account Based model COPA, you run all your Profitability Analysis based on GL Accounts postings. For that, in order to do Profitability reporting / reports, you have to build a Financial Statement Version (FSV) (Hierarchy Type FSVN, in Tcode HRRP_REP).

Once you built your Profitability FSV, you just need to run Tcode HRRP_REP (Step #2 from my previous Blog post) to replicate it.

In order to create your FSV, you need to follow this IMG Path.


Then you will and create you own custom FSV for Profitability Purposes. Ex: YPA2



You will enter a description, a Maintenance Language and an applicable Chart of Accounts for this FSV. All the same as if you were configuring any other FSV as you did in the past for FI purposes.
Then you will click in "Financial Statement Items" to start building your Hierarchies and GL groupings.


This is the Standard SAP Best Practices Contribution Margin report (Profitability). I suggest you take a copy of it and create your own "Z / Y" one as per your specific business requirements.


Once created and saved, you will replicate it with Tcode HRRP_REP (as explained in Step #2 from my previous Blog post).


Note: 

Please do not confuse this FSV for COPA / Profitability with your other FSV that you might have created (or not) for FI purposes (I mean your Financial Statements). These are 2 different things / concepts.
One is for Management and Internal reporting (FSV COPA) and the other for External Financial reporting (FSV FI).
They both use the same config tool, as SAP decided to use this concept for both things; but they are definitively not the same and should not be confused with one another.
Another thing that you might have noticed, is that when you define your FSV options; Functional Area is not flagged in this YPA2 Contribution Margin Report as you do not use Functional Area for Profitability Reporting. In my opinion, Functional Area should only be used for External reporting and not for Management reporting.


If your Company and/or Project needs to implement this, or any of the functionalities described in my Blog, or advise about them, do not hesitate to reach out to me and I will be happy to provide you my services.

Build and use Hierarchies like GL or Cost Center for Profitability (COPA) or other reporting in S/4 HANA Fiori Apps

Now a days in S/4 HANA we have a series of Fiori Apps available for reporting that are replacing the good old fashion S_ALR_xxx reports that we used to use to report on Cost Center, Internal Order, Profit Center and others on actuals/plan. The old reports are still working fine, but they are good for GUI, not for Fiori. (Unless you call the Tcode through Fiori GUI tile)
So now you have Fiori App reports like "Cost Center - Plan/Actual YTD" or COPA "Market Segments" (replacing old fashion KE30) among others that in order for you to use the Cost Center Hierarchy or Profit Center Hierarchy on them, you first need to run a couple of programs to make them available in those Fiori Apps.
These Hierarchies are stored in the back-end as SETs like any other SETs that we used to use in Finance for all sort of needs. In order to be able to have them available for these Fiori Apps, you need to convert them into BW Hierarchies as the Fiori Apps are based on BW Queries and those don't know anything about SETs, they run with Hierarchies.

This is a 2-step process that you need to run every time you do a modification in any of those Hierarchies, so then the changes become available in the Fiori Apps.

Step #1
Tcode: HRY_REPRELEV - Set Report Relevancy for Hierarchies


As you can see in the screen capture, you can use the following Hierarchies 
  • Cost Center Group
  • Cost Element Group
  • Order (Ex Internal Order) Group
  • Profit Center Group
  • Account Group
  • WBS Element Group
  • Functional Area Group 


Once you select the Hierarchy (Set Class) that you want to use, you execute and you get the list of the available ones. In this case "Organizational Unit" is my SAP Best Practices Controlling Area "A000" and all the Groups that come with it. Depending on the Set Class you select, it could mean something different.
Then you activate the "Report Relevant" flag of the lines/lines that you want and SAVE.

Step #2
Tcode: HRRP_REP - FIN Runtime Hierarchy Replicator

This step is required to be able to replicate those previous elements as hierarchies so then the Fiori Apps will be able to use them. Without entering into to many technical details, the Fiori Apps use / show/ consume this as a kind of BW Hierarchies, and this process is required to expose them as such.

You will go, select your Hierarchy ID that you want to replicate, enter a valid from date, and select the "Run settings" for background or foreground. It does not take long to execute, so foreground should not be an issue.


This means that every time you do a change in any of the Hierarchies (GL, Cost Center, Profit Center, Internal Ordes, WBS, etc.) you need to run these 2-Step process so you will have the latest changes available for the Fiori Apps. Without this execution, you will not see the new changes.
This process can also be scheduled to run periodically, but this should only be in a context were you have constant changes.

An small example of an App that would use these hierarchies, "Cost Centers Plan/Actual YTD"


Click in "Cost Center Hierarchy", click "Go"


And you will get the list of Hierarchies that were replicated. (For confidentiality reasons, I am masking the names)


If your Company and/or Project needs to implement this, or any of the functionalities described in my Blog, or advise about them, do not hesitate to reach out to me and I will be happy to provide you my services.