SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Enhance an ABAP Core Data Services (CDS) View in ABAP On-Premise

Add features like value help, aggregations, and calculated fields to an existing CDS view

Overview

🎓 beginner 60 min. ABAP DevelopmentBeginnerSAP Netweaver 7.5

You will learn

  • โœ”How to add value help using a filter
  • โœ”How to add textual information using associations
  • โœ”How to concatenate two elements, using a built-in function for CDS
  • โœ”How to convert currencies using a built-in function for CDS
  • โœ”How to use grouping and aggregation
  • โœ”How to create an object page
  • โœ”How to create a parent-child hierarchy in your business object
  • โœ”How to add a CASE statement
Unknown U Unknown March 21, 2023
Created by March 21, 2023
Contributors

Prerequisites

Steps

Intro

You can then use some of these features in productive development to make your applications more powerful and more user-friendly. By the end of this tutorial, your application should look like this.

fep-final-enhance
fep-final-enhance
step13c-fep-CASE
step13c-fep-CASE

You can see the code at the end of this tutorial. Throughout the tutorial, objects name include a suffix, such as XXX. Always replace this with your group number or initials.


Step 1 Add value help
โ€”

To make the input fields more useful, you will now add input value help to the field AgencyID.

  1. Specify the source of the value help. This works a bit like a join: You need to point to an entity, and field common to both the entity and your CDS view. In this case, you will point to AgencyID in the CDS entity /DMO/I_Agency. Add the following annotation to your field AgencyID.

    CDS
    @Consumption.valueHelpDefinition: [{  entity: {name: '/DMO/I_Agency', element: 'AgencyID'}  }]
  2. You also need to expose this second entity in the OData service. To do this, add the entity /DMO/I_Agency to your service definition, so the complete definition looks like this:

    CDS
    @EndUserText.label: 'Service exposes Travel Data 005'
    define service Z_EXPOSE_TRAVEL_005 {
      expose Z_C_TRAVEL_DATA_005 as Travel;
      expose /DMO/I_Agency as Agency;
    }
  3. Format, save, and activate both CDS view and service definition ( Shift+F1, Ctrl+S, Ctrl+3 ).

  4. Refresh your Fiori Elements preview and choose value help for the input field AgencyID.

    step13a-choose-value-help
    step13a-choose-value-help

  5. Now the value help appears. Enter the country key DE and choose Go. Only German agencies appear on the list.

    step13b-german-agencies
    step13b-german-agencies

  6. Repeat this step for CustomerID:

    CDS
    @Consumption.valueHelpDefinition: [{entity: {name: '/DMO/I_Customer', element: 'CustomerID' }}]
  7. Also, expose this entity in the service definition:

    CDS
    expose /DMO/I_Customer as Customer;
Step 2 Add text associations
+
Step 3 Merge two fields
+
Step 4 Add currency conversion
+
Step 5 Add aggregation and grouping
+
Step 6 Test aggregation and grouping
+
Step 7 Check code
+
Step 8 Test yourself
+
Step 9 Create object page
+
Step 10 Create CDS entity for booking
+
Step 11 Specify hierarchy
+
Step 12 Add annotations
+
Step 13 Create metadata extension for Z_I_BOOKING_XXX
+
Step 14 Add association from Travel to Booking
+
Step 15 Add Booking information to object page
+
Step 16 Add association from Booking to Connection
+
Step 17 Add CASE statement
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 18
1. Add value help 2. Add text associations 3. Merge two fields 4. Add currency conversion 5. Add aggregation and grouping 6. Test aggregation and grouping 7. Check code 8. Test yourself 9. Create object page 10. Create CDS entity for booking 11. Specify hierarchy 12. Add annotations 13. Create metadata extension for Z_I_BOOKING_XXX 14. Add association from Travel to Booking 15. Add Booking information to object page 16. Add association from Booking to Connection 17. Add CASE statement 18. More Information

Learn more →