Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
cancel
Showing results for 
Search instead for 
Did you mean: 
YatseaLi
Product and Topic Expert
Product and Topic Expert
848

cap-edit-model-guide.jpg

Following the blog post Product Updates for SAP Build Code – July 2024 Edition by @BirgitS. Use Joule to enhance your already existing data models and services is now supported in SAP Build Code, which enables the developers to enhance a specific data model and service back and forth contextually and incrementally. Please go through the blog post above for more details. In this blog post, I would like to showcase this feature with some practical uses.

Introduction to Slash commands of Joule in SAP Build Code

As explained in the product update blog post, we can edit the data model or services with joule icon on the storyboard conveniently.
However, Joule on storyboard can't be activated if you have multiple data model files and service files, and it shows a tip about "you can only edit models or services if you have only one data file and one single service file" as screenshot below. No worry. Joule on Storyboard is essentially invoking a new slash command in Joule.

YatseaLi_0-1722315684233.png

In 2024 July's update, several Slash commands are introduced into Joule in SAP Build Code as screenshot below. A slash command specifies and restricts the intent of the prompt for code generation instead of free-style, and the commands are displayed contextually based on the current opening file or editor.

Slash Commands for Application generation (Initial application generation)

  • /cap-gen-app Generate a CAP application
  • /fiori-gen-app Generate an SAP Fiori element applicaiton

Slash Commands with Specific Intents

  • /cap-edit-model Edit CAP data model (new feature in 2024 July's update)
  • /cap-gen-data Generate CAP sample data
  • /cap-edit-data Edit CAP sample data
  • /cap-app-logic Generate CAP application logic

YatseaLi_1-1722393244161.png                  YatseaLi_1-1722316927109.png

We will focus on the /cap-edit-model slash command, which is the very function triggered by Joule icon on storyboard to edit the data model or service. The rest commands are just the evolution of previous features. 

Enhancing your existing CAP project with Joule in SAP Build Code

In the following scenario, let's assume a new developer Daniel has been assigned to maintain and enhance the customer loyalty management solution, which is initially generated with Joule in SAP Build Code in our previous blog post.

(For an existing CAP project isn't generated with Joule in SAP Build Code, please follow this blog post by MioYasutake to enable the support for existing CAP Projects in SAP Build Code, and note that manual migration of existing business logic are required for generated template of business logic by Joule in SAP Build Code.)

Daniel's needs and daily activities

  • Understand the existing solution, including data models, services and business logic etc.
  • Implement a change request, for example, add phone contact to Customers, which may involve modification of data model, service, business logic, Unit Test and UI adaptation etc.
  • Perform code review
  • Apply best practices of CAP development
  • CI/CD

 Let's address Daniel's needs, and narrow down to enhance data model and services incrementally using slash /cap-edit-model with some practical uses below beyond editing the data model itself, as the rest are covered in our blog post about develop with Joule in SAP Build Code.

  • "Explain me the data model"
    Joule helps with understanding the solution, moreover, the output can also be used as design documentation of data model for future reference.
  • "Add comments to the data model"
    Joule helps to improve the interpret-ability and maintenance. This is a bit tricky as Joule may refuse it, but try to convince it with "yes, you are allowed to do it"
  • "Add a property named 'phoneNo' to 'Customers' entity"
    Joule helps to refine the data model
  • "Review and criticize the code"
    Joule acts as a peer developer for code review
  • "Implement the suggestions"
    Joule help to implement the suggestions from last code review
  • "Apply best practices of CDS data modeling"
    Or simply ask Joule to apply the general best practices of CDS data modeling without explicit code review
  • "Make it production ready"
    Joule help with final check on the data model before production.
  • ...

cds_enhancement_by_joule.jpg

Import note: As the conversation with /cap-edit-model in Joule is contextual, therefore, more token may be used. Be aware of the limited monthly quota of AI requests per user for using Joule. Please make wise use of the tokens. For some explicit code changes, for example, set the length of string, adding a property etc, manual code editing or graphical modelling will be more efficient than Joule.

Demo Video:

Additional Materials

Summary

With this contextual and incremental enhancement capability of existing CDS data model and services, Joule in SAP Build Code is extremely useful and helpful for maintaining and enhancing the existing CAP Data Model and Services with various practical uses beyond editing data model itself, such as code explanation, extracting design documentation, improving code readability, role-based code review, implementing best practices, pre-production check etc.