Skip to Content
Technical Articles

Extending CDS view with COPA field including Key and Text

Motivation to write this blog:

With SAP S/4HANA, FICO consultants are facing a lot of challenges, especially when we talk about reports. As report painter is not a recommended option (as they do not read the universal journal tables), and with the constant improvements on Analytics solutions, Finance and Management Accounting consultants are being challenged to become more technical to achieve independency on implementing reports.

After a lot of research and help from some experts and Community contributors (Masaaki Arai, Stephen Offenbacker, Loucas Stylianou), I finally had success on extending an app exactly the way I needed. So, I decided to share this experience with whoever is facing with the same scenario.

Introduction:

In SAP S/4HANA with COPA account based, when new COPA characteristics are created and added to ACDOCA and ACDOCP table, they are not automatic added to Fiori reports/CDS views.

Unfortunately, COPA fields are not part of the scope of the app “Custom Fields and Logic”, which would turn our lives much easier. SAP note 2453614 details the different scenarios for extending fields, including COPA characteristics.

The example I will use is the App “Journal Entry Analyzer”, and 4 new COPA characteristics already configured in KEA5/KEA0 and added to ACDOCA and ACDOCP.

 

 

The steps bellow should be considered:

 

  1. Identify the Consumption view (DDL Source)
  2. Map the underlying views according to the Virtual Data Model
  3. Create Text views to be added to the extension (to display key and text on the app) – Eclipse
  4. Extend the mapped CDS views – Eclipse

 

  1. Identify the Consumption view 

There are several ways to identify the DDL Source of an app, but in my case, I found it using table DDDDLSRT, filling the description of the app (language EN):

Journal Entry Analyzer DDL Source = C_GLLINEITEMSQ0001

 

  1. Map the underlying views according to the Virtual Data Model

 

Virtual Data Models are represented by the following levels:

The logic is that we need to map the CDS views until de Basic Interface views, and then identify which Extension View is available.

*There are great blogs explaining the concept of Virtual Data Models on SAP Community.

I used the app View Browser to identify the underlying views:

In this app, inform the Consumption view, and click on it, to get the details:

 

The tab “Cross Reference” displays de underyling view from the Composite view, that is I_GLAccountLineItemCube. At this moment, keep the Alias name which will be used in the extension:

 

When clicking on the Composite view name, its details are displayed. Go to “Cross Reference” tab and a list of basic views will be displayed. Scroll down until you find the extension view (in this case E_JournalentryItem). Keep the Name and Alias to use in the extension.

Click on the Extension view name to see its details and go to Cross Reference tab. You will see that E_JournalEntryItem is an Include view for the basic view I_JournalEntryItem, and its directly related to table ACDOCA. Keep the Alias Name to use in the extension.

 

 

 

The mapping will be like that:

 

 

  1. Create Text views to be added to the extension (to display key and text on the app) – Eclipse

 

Now we will jump from Fiori to Eclipse. The first thing is to create text views, that will be used in the CDS extensions to display on the app both KEY and TEXT values.

 

*Prerequisite: Eclipse installed, package created in se80 and added to “Favorites” as below:

 

Create new Data Definition:

 

Define View that will select the text from the text table of the COPA characteristic. In this example, the characteristic WW002 has the text table T25A0, as previously defined in KEA5. For each characteristic, create views the same way as below, but selecting from the respective text table (also defined in KEA5).

Ex:

Then you need to create a second view selecting the characteristic from the check table (in this example, table T2500), with an association to the text view, using the same “key” field. Also, do the same for the other characteristics.

 

After activating the text views, you are now able to start the extension:

 

4. Extend the CDS views – Eclipse

Click on the package > Core data Services > Data Definitions > New data definition

You will extend the mapped CDS views from the bottom to the top. So, start with the Extension view E_JournalEntryItem:

The associations will bring the text for each characteristic. The fields will be extended with the prefix “ZE_”, and the ALIAS “Persistence” must be used according to selected from View Browser.

The annotation @ObjectModel.foreignKey.association: ‘ZV_WW001_PA’ must be added above each extension line, to get the field foreign key.

The associated views must be declared as bellow, before the “}”.

As you can see, I did not get the text from characteristic W004_pa, so I will only have the key from this field available on the report.

 

After activating the Extension of the basic view, the append structure is displayed on the DDL Source (se11):

Query Browser:

Next, define a new view to extend the Composite view I_GLAccountLineItemCube:

The same associations must be done to get the texts.

The Alias “_Extension” must be used to extend the fields in this composite view.

After activating, fields are added to Composite view (Query Browser):

Se11:

Finally, you need to extend the Consumption view. Create new data definition:

 

For the Consumption View, you need to just add the relevant annotations above the extension of each field. To get the text, the annotation @AnalyticsDetails.query.display: #TEXT must be added. For other annotations you can check SAP Documentation.

 

Result: 

Finally, when you activate the Consumption view extension, the fields will be available on the report, with KEY and TEXT available for selection:

 

The Field that was not extended with text, will have only the key available for selection:

Same report in Analysis for office (this print is in Portuguese):

Fields available with key and text:

 

Conclusion:

The more knowledge a functional consultant gets from CDS views, the easier their lives will be in a SAP S/4HANA implementation.

 

On the next blog post I will show an extension of a Plan/Actual CDS view, which has some tricky differences.

 

 

4 Comments
You must be Logged on to comment or reply to a post.
  • Thank you Mayumi for this well explained and informative post.

    A question: in step 4, is the code in eclipse generated automatically as a results of your selection or do you have to actually type in the code?

    Personally, I feel functional consultants are driven to be much more technically capable under S/4HANA environment, which is not what I prefer doing.

    BTW, I believe it is possible to create report painter reports using by creating a library for ACDOCT.

     

    Cheers and thanks again,

    Yoel.

    • Hi Yoel,

       

      Yes, all the Eclipse steps I did manually. The extensions are not generated automatically.

      You are right, we are being “forced” to become more technical…but i’m enjoying it. 🙂

      Thanks for the ACDOCT tip!

       

      Cheers!

      Mayumi

  • Great blog, thank you Mayumi!

     

    It would be great if you could include a screenshot for the last step (“Finally, you need to extend the Consumption view. Create new data definition:”).

    Thank you!