🚀 Using SAP Build Code + Joule with /cap-gen-app for CAP Development
🧠 What is Joule?
Joule is SAP’s generative AI assistant integrated into SAP Build Code and Business Application Studio (BAS). It helps developers build full-stack apps using natural language prompts and streamlines development tasks like data modeling, service generation, and deployment.
🛠️ Step-by-Step: Use /cap-gen-app in Joule
✅ 1. Prepare Your Environment
In BAS, launch a SAP Cloud Business Application dev space with:
💬 2. Run /cap-gen-app: Prompt in Joule
Open Joule from the BAS sidebar and enter:
/cap-gen-app:
Create a CAP model for an online course platform.
Entities:
- Course: title, description, duration, category, instructor (1-to-1)
- Instructor: name, email, department, expertise
- Student: name, email, enrollment date
- Enrollment: student (1-to-1), course (1-to-1), status, enrollment date
Generate 5 sample records for each entity.
⚙️ 3. What Joule Will Do
Joule will automatically:
🚀 4. Deployment (Manual or One-Click)
You can now deploy using the terminal or BAS UI:
cds deploy --to hana
cf push
Or use right-click > Deploy options from BAS if your environment is connected to SAP BTP.
💡 Benefits of Using /cap-gen-app
Feature Value Speed Generate end-to-end CAP projects in seconds Clarity Describe your domain in plain English—Joule handles the technical part Best Practices Outputs clean, production-ready CDS and CAP code HANA Ready Supports .hdbcds deployment and BTP-native app architecture
Here’s a fully generated example CAP project structure and code based on the /cap-gen-app prompt for the online course platform domain.
✅ Joule Availability: BAS vs. Build Code
Recommended by LinkedIn
🔍 Joule Access – SAP Business Application Studio (BAS) vs. SAP Build Code
ℹ️ Note: Joule is available in SAP Business Application Studio (BAS) only when SAP Build Code is enabled within it.
Example CAP Project: Online Course Platform
1. Project structure (simplified)
/course-platform
│
├── package.json
├── cds-config.json
├── srv/
│ └── cat-service.cds
├── db/
│ ├── data/
│ │ ├── courses.csv
│ │ ├── instructors.csv
│ │ ├── students.csv
│ │ └── enrollments.csv
│ └── schema.cds
└── README.md
2. CDS Model (db/schema.cds)
namespace courseplatform;
entity Course {
key ID : UUID;
title : String(100);
description : String(500);
duration : Integer; // duration in minutes
category : String(50);
instructor : Association to Instructor;
}
entity Instructor {
key ID : UUID;
name : String(100);
email : String(100);
department : String(50);
expertise : String(200);
}
entity Student {
key ID : UUID;
name : String(100);
email : String(100);
enrollmentDate : Date;
}
entity Enrollment {
key ID : UUID;
student : Association to Student;
course : Association to Course;
status : String(30);
enrollmentDate : Date;
}
3. Service Definition (srv/cat-service.cds)
using { courseplatform as cp } from '../db/schema';
service CourseService {
entity Courses as projection on cp.Course;
entity Instructors as projection on cp.Instructor;
entity Students as projection on cp.Student;
entity Enrollments as projection on cp.Enrollment;
}
4. Sample Data (CSV files in db/data)
courses.csv
ID,title,description,duration,category,instructor_ID
1,Introduction to AI,Learn the basics of AI,120,Technology,101
2,Advanced JavaScript,Deep dive into JS,180,Programming,102
3,Project Management Essentials,Manage projects efficiently,90,Business,103
4,Creative Writing Workshop,Enhance your writing skills,60,Arts,104
5,Data Science 101,Intro to data science,150,Technology,101
instructors.csv
ID,name,email,department,expertise
101,Dr. Alice Smith,alice.smith@example.com,Technology,Artificial Intelligence
102,John Doe,john.doe@example.com,Programming,JavaScript, TypeScript
103,Mary Johnson,mary.johnson@example.com,Business,Project Management
104,Laura White,laura.white@example.com,Arts,Creative Writing
105,Mark Lee,mark.lee@example.com,Technology,Data Science
students.csv
ID,name,email,enrollmentDate
201,Kevin Brown,kevin.brown@example.com,2024-01-10
202,Sarah Wilson,sarah.wilson@example.com,2024-02-15
203,Michael Green,michael.green@example.com,2024-03-20
204,Emma Davis,emma.davis@example.com,2024-04-05
205,Oliver Miller,oliver.miller@example.com,2024-04-25
enrollments.csv
ID,student_ID,course_ID,status,enrollmentDate
301,201,1,Active,2024-01-12
302,202,2,Completed,2024-02-20
303,203,3,Active,2024-03-25
304,204,4,Pending,2024-04-07
305,205,5,Active,2024-04-27
Disclaimer: This article is intended for quick learning and introductory purposes only. For complete and detailed information, please refer to the official SAP documentation and resources.