Skip to Content
Technical Articles
Author's profile photo Mayumi Lacerda Blak

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.

 

 

Assigned Tags

      19 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Madhu Vadlamani
      Madhu Vadlamani

      Hi Mayumi,

      Nice Blog.

      Regards,

      Madhu.

      Author's profile photo Yoel Tovi
      Yoel Tovi

      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.

      Author's profile photo Mayumi Lacerda Blak
      Mayumi Lacerda Blak
      Blog Post Author

      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

      Author's profile photo Michael Wilk
      Michael Wilk

      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!

      Author's profile photo Mayumi Lacerda Blak
      Mayumi Lacerda Blak
      Blog Post Author

      Hello Michael,

      The screenshots are added for the steps you mentioned.

      Kind regards

      Mayumi

      Author's profile photo natalia podvoyskaya
      natalia podvoyskaya

      Hi Mayumi,

       

      thanks a lot for sharing the information!

      I have a questions, in order to add CO-PA characteristics to standard Fiori report (for exampl, Market segment), do you also need to follow such a long path or is there a simpler way to do it?

      Author's profile photo Mayumi Lacerda Blak
      Mayumi Lacerda Blak
      Blog Post Author

      Hi Natalia!

      Yes, you need to follow the same steps but using the views from the Market Segment Virtual Data Model.

      Although it's a Margin Analysis App, Market Segment comes only with the standard, "not user defined" characteristics.

      There is already a request opened in SAP Influence Portal for this topic, let's hope they add COPA WW characteristics in the app Custom Fields and Logic, it will be super.

      Kind regards,

      Mayumi

      Author's profile photo GIANLUCA TACCONE
      GIANLUCA TACCONE

      Hi Mayumi,

       

      thanks a lot for sharing this.

      Very Useful!

      Best

      Gianluca

      Author's profile photo Arpitha Shet
      Arpitha Shet

      Hi Mayumi,

      Thank you for sharing this it was very useful.

      I followed the same approach to add few fields and when moved the changes to Quality system it ended with errors. Do you have any idea what could it be ? All the views were activated I am not sure what would have caused it into error.

      Below is the error :

      DDL Source ZC_GLLINEITEMSQ0001 could not be activated
      (E- The column mvgr1 is unknown )
      (Package: ZCOPA, SW-Comp: HOME, Appl-Comp: FI)
      DDL Source ZE_JOURNALENTRYITEM could not be activated
      (E- The column mvgr1_pa is unknown )
      (Package: ZCOPA, SW-Comp: HOME, Appl-Comp: FI)
      DDL Source ZI_GLACCOUNTLINEITEMCUBE could not be activated
      (E- The component mvgr1 does not exist or is not active )

      Thank you,

      Arpitha

      Author's profile photo Mayumi Lacerda Blak
      Mayumi Lacerda Blak
      Blog Post Author

      Hello Arpita!

       

      It seems to be a problem in COPA configuration, not in the CDS extension.

      Did you transport the COPA characteristic MVGR1_PA to Quality system? Did you check if this field is in ACDOCA in Quality?

      kind regards

      Mayumi

      Author's profile photo Arpitha Shet
      Arpitha Shet

      Hello Mayumi,

      Just checked acdoca in Quality system and i cant find field MVGR1_PA , But the field is available in Dev. Just checked with FI consultant and Characteristics were not moved to Quality. Will reimport my changes once COPA characteristics are moved to Quality

      Thank you so much for you inputs, really appreciate!

      Kind Regards,
      Arpitha

      Author's profile photo Mayumi Lacerda Blak
      Mayumi Lacerda Blak
      Blog Post Author

      you need to run the program FCO_ADD_COPA_FIELD_TO_ACDOCA in SE38, after that the field will be added to ACDOCA.

      inform the operating concern and run in background.

      You will need to get the details with your functional consultant.

       

      kind regards

      Mayumi

      Author's profile photo sachin shinde
      sachin shinde

      Hello Mayumi,

      How can I add Sales Document Type in the report ? Sales Document field is already there.

      Extension is only for ACDOCA.

      Appreciate your help.

      Thanks,

      Sachin

      Author's profile photo Mayumi Lacerda Blak
      Mayumi Lacerda Blak
      Blog Post Author

      Hello Sachin,

      To add Sales Document Type is more simple than COPA fields.

      You can extend, for example , I_ACTUALPLANJRNLENTRYITEMCUBE by making association to

      I_SALESDOCUMENT, where the link will be on the field SALESDOCUMENT (then get the field

      SALESDOCUMENTTYPE).

      You can do it using the app "Custom CDS Views", or directly in Eclipse.

       

      kind regards

      Mayumi

      Author's profile photo sachin shinde
      sachin shinde

      Hi Mayumi,

      Thank you for your reply. It is very useful.

      I did the same way however it doesn't bring 'Text' for the fields even if I_SalesDocumentBasic is associated with I_SalesDocumentType.

      In extension, added below lines

      "association [0..1] to I_SalesDocument on $projection.salesdocument = I_SalesDocument.SalesDocument"

      @ObjectModel.foreignKey.association: 'I_SalesDocument'
      _SalesDocument.SalesDocumentType as SalesDocumentType,

      //associations

      ,I_SalesDocument

      Sales%20Doc%20type

      I tried linking using '_SalesDocument' instead '$projection', but getting error that 'SalesDocument' is missing from the field list.

      "association [0..1] to I_SalesDocument on _SalesDocument.salesdocument = I_SalesDocument.SalesDocument"

      Please let me know if anything missing.

      Thank you.

      Regards,

      Sachin

      Author's profile photo Mayumi Lacerda Blak
      Mayumi Lacerda Blak
      Blog Post Author

      Hi Sachin,

      You cannot make an association from an associated view, so in this case, to get the sales document type description, you will need to:

      1. Create a new data definition from I_Salesdocument associated to I_SALESDOCUMENTTYPETEXT to get SALESDOCUMENTTYPENAME field.

       

      2. Associate your primary view (e.g I_ACTUALPLANJRNLENTRYITEMCUBE) to the new Data definition created on step 1, to get the Sales document type text.

       

      kind regards

      Mayumi

      Author's profile photo sachin shinde
      sachin shinde

      Thank you Mayumi.

      Able to see description now.

       

      Regards,

      Sachin

      Author's profile photo Mohamad Akkad
      Mohamad Akkad

      Hello Mayumi,

      great blog, which helped us to extend a SAP standard cds view (A_SupplierInvoice), so we have our extension fields in the OData response and finally in our app. With the same OData service (API_SUPPLIERINVOICE_PROCESS_SRV/A_SupplierInvoice) we can also create a journal entry, but without the values of our extension fields.
      Do you know what needs to be done, so that the extension fields value will be saved in ACDOCA? Is it possible without creating an own OData service?

      Thanks & kind regards,

      Firas

      Author's profile photo bharath rajamanickam
      bharath rajamanickam

      Hello Mayumi,

      How can i add custom fields of I_PROFITCENTER into the I_MatrixCnsldtnFndnEnhcdCube & C_CnsldtnRpt40Q.

      VDM CDS
      consumption  view C_CNSLDTNRPT40Q
      composite interface view I_MatrixCnsldtnFndnEnhcdCube
      basic interface view E_CnsldtnGroupJrnlEntryItem
      ACDOCU
      I_ProfitCenter
      E_ProfitCenter
      database table CEPC

      Finally I am trying to execute the RSRT - 2CIMCFNDNENHANCUBE/2CCSRPT40Q.

       

      Thanks & Regards

      Bharath