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

Develop a Full-Stack CAP Application with Joule

In this tutorial, you will use the Generative AI capabilities of Joule to create a CAP service in SAP Build Code.

Overview

🎓 beginner 30 min. SAP Build CodeBeginnerTutorialSAP Business Application StudioSapui5SAP Mobile ServicesSAP Fiori ElementsSAP Cloud Application Programming ModelSAP Business Technology Platform

You will learn

  • βœ”To leverage the power of Joule in SAP Build Code.
Paola Laufer P Paola Laufer June 15, 2025
Created by February 2, 2025
Contributors

Prerequisites

Prerequisites

Steps

Intro

Let’s create an application for a customer loyalty program. The customer can get bonus points by purchasing products and can redeem these points.

Note: Joule is a Generative AI assistant that will create code for you. The code might be different every time you trigger the prompt, so the examples shown in the tutorial might not be exactly the same as what you see in your system.

Step 1 Create a multi-step CAP application
β€”

  1. Open your Full Stack Node project.

  2. In SAP Business Application Studio, the SAP Build Code development environment, open the digital assistant, Joule, from the activity bar.

    Open Joule
    Open Joule

    If you do not see the icon, click Additional Views and select Joule from the list.

    Find Joule icon
    Find Joule icon

  3. Copy the prompt below.

    Code
    Create a customer loyalty application with sample data and application logic.
  4. At the bottom of the Joule view, select the ‘/cap-gen-app` slash command and then paste the code below in the text field.

    Enter command
    Enter command

  5. Click the arrow

    send arrow
    send arrow
    to send the prompt to Joule.

    Enter Prompt
    Enter Prompt

    Since this is a complex task, Joule divides it into different steps and provides suggestions for the prompts for each step. You can edit these prompts before triggering the generation.

    Enter Prompt
    Enter Prompt

    While Joule suggests certain properties for the entities, let’s edit the prompt to offer a clearer description that aligns better with the data model’s requirements.

  6. Copy the prompt below.

    Code
    Define 4 data entities: Customers, Products, Purchases and Redemptions. 
    Each customer must have the following fields: name, email, 7-digit customer number, total purchase value, total reward points, total redeemed reward points. 
    All fields for each customer should be `integer` except name and email that will be stored as `string`. 
    Each product should have a name, description, and price. 
    Purchases should include the following fields: purchase value, reward points. 
    All fields in Purchases must be `integer`. 
    Redemptions must have 1 field in `integer`: redeemed amount. 
    Each purchase and redemption will be associated to a customer. 
    Each purchase will be associated to a product and is called `selectedProduct`.
    Use associations instead of compositions.
  7. Click

    edit step
    edit step
    to edit step 1 and replace the prompt with the one you just copied.

    edit step1
    edit step1

  8. Click Save.

  9. Click

    run step
    run step
    to run the step and generate the CAP data model.

    run step1
    run step1

    The staging files are generated and are displayed below your prompt. You can view or edit them by clicking on the file name.

    generated code
    generated code

    Note: If you only want to create a data model and service, you can use the /cap-gen-model slash command.

    Let’s edit the sample data to match requirements.

  10. Copy the prompt below.

    Code
    Create sample data with meaningful information. Any phone numbers must be 10 digits long.
    All customer numbers must be 7 digits long and one customer must use the customer number 1200547. 
    No fields may be empty. 
    Total purchase value must be smaller than 10000 not rounded. 
    Both total reward points and total redeemed reward points must not be rounded, must not be identical. and must always sum to one-tenth of the total purchase value for each customer
  11. Click

    edit step
    edit step
    to edit step 2 and replace the prompt with the one you just copied.

    edit step1
    edit step1

  12. Click Save.

  13. Click

    run step
    run step
    to run the step and generate the CAP sample data.

    The CSV files are created and can be opened for review from the Staging Files list.

    generated code
    generated code

    Note: You can also trigger the sample data generation separately using the /cap-gen-data slash command or edit the existing data using the /cap-edit-data slash command.

    Now we will add application logic so that for each purchase, customers receive reward points equal to one-tenth of the purchase price. The purchase value will be added to the customer’s account. Additionally, when customers use reward points, the points should be deducted from their total reward points and added to their total redeemed points.

  14. Copy the prompt below.

    Code
    Implement application logic so that reward points of each purchase will be one tenth of the purchase value. 
    Each purchase value will be added to the total purchase value of the related customer. 
    Each reward point will be added to the total reward points of the related customer. 
    Furthermore, deduct the redemption amount from the customer's total reward points and add that to their total redeemed points.
  15. Click

    edit step
    edit step
    to edit step 3 and replace the prompt with the one you just copied.

    edit step3
    edit step3

  16. Click Save.

  17. Click

    run step
    run step
    to run the step and generate the CAP application logic.

    run step3
    run step3

    The relevant files are created with the required code.

    Note: In an existing project with application logic available, you can use the /cap-app-logic slash command to enhance or modify the logic.

  18. Accept the code.

    accept
    accept

Step 2 Add UI to the Application
+
Step 3 Preview the application (Optional)
+

Resources

Discussion

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

Submit detailed feedback Discuss in Community
Steps
Step 1 of 3
1. Create a multi-step CAP application 2. Add UI to the Application 3. Preview the application (Optional)

Learn more →