Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

SAP Developer Challenge - SAP Cloud Application Programming Model (Week 2)

nicoschoenteich
Developer Advocate
Developer Advocate

Please note that this challenge is closed. The deadline for receiving a badge upon successful completion has passed. Check out this new challenge for the month of August.

Welcome to the second week of this month's SAP Developer Challenge. This week we are going change development environments and move to the SAP Business Application Studio. Additionally, we will add some sample data to our project using the @sap/cds-dk (command line client and development toolkit).

If you haven't read the announcement blog post for this challenge, please head over and do so. This week's challenge builds on top of last week's challenge, which you should have completed before starting with this one.

The Challenge

After getting started with the SAP Cloud Application Programming Model in a CodeSandbox last week, we now want to move to a new development environment, that is dedicated to development on the SAP Business Technology Platform and is a better fit for purpose - the SAP Business Application Studio. You might have noticed that the CodeSandbox didn't provide syntax highlighting or code completion for CDS, which is one of many benefits of moving to the SAP Business Application Studio.

 
This is what you have to do to successfully complete this week's challenge:
 
1. You need access to an account on SAP Business Technology Platform. If you don't have one yet, check out these tutorials on how to get an account on SAP BTP to try out Free Tier service plans or how to get a free account on SAP BTP Trial.
2. If you don't already have access to the SAP Business Application Studio, check out this tutorial on how to set up SAP Business Application Studio for development.
3. Once you have access, create a new dev space of type "Full Stack Cloud Application". This dev space will have all necessary tooling preinstalled.
 
Screenshot 2023-07-11 at 22.45.21.png
 
You can alternatively also complete this week's challenge in any other development environment, for example VS Code or a terminal (any (n)vim users? 😁), although we highly recommend to try out the SAP Business Application Studio. Using the SAP Business Application Studio (or VS Code) allows you to use the SAP CDS Language Support extension. Additionally, any other dev environment than the SAP Business Application Studio would require to install Node.js and the @sap/cds-dk (command line client and development toolkit) manually.
 
4. Open a new terminal (Menu > Terminal > New Terminal).
5. Create a new directory for your CAP application inside the projects/ directory using the command mkdir projects/cap-developer-challenge (basix UNIX commands).
6. Open the newly created directory (Menu > File > Open Folder ... > /home/user/projects/cap-developer-challenge/).
7. Open a new terminal session (Menu > Terminal > New Terminal).
8. You can now make use of the CDS project generator by running the command cds init (documentation). You will see how this creates a sample application. Now is also a good time to run cds help and explore the capabilities of the CDS cli.
9. You can now manually copy over the db/schema.cds and srv/cat-service.cds files from last week's CodeSandbox.
 
At this point you can of course also use a source code control system like GitHub to share the project between to environments. We will skip this step here for brevity. Please let us know in the comments, if you are interested in a "Getting started with Git" tutorial. Always use a source code control system when working on productive projects.
 
10. You can now start the dev server using the command cds watch in the terminal.
11. Add some initial data to your application (hint: providing initial data).
12. Take a screenshot of your development environment. Make sure it shows the db/data/ directory with its content and at least one open CSV file. It should look something like this:
 
Screenshot 2023-07-11 at 22.44.28.png
 

Resources

We have gathered a few helpful resources for this week's challenge. Feel free to use the comments sections if you have question or need help.

 
131 REPLIES 131

Well done I am glad you are enjoying the challenge!

You can keep your db/data/ for git, no need to put it in the .gitignore, but be aware that when eventually deploying to SAP BTP, these files would always overwrite whatever is currently in the database. This is why this technique of providing initial data should only be used for entity that don't change at runtime. If you do want to provide data during dev time that does change at runtime, put it in test/data/. This way it will only be used at dev time.

0 Kudos

Noted with thanks for the answer and the explanation how to handle these 2 kinds of entity. I have done it already  😊😊

I will also try to use composition like below which is requires another mapping csv file. 

holes : Composition of many {
  key hold : Association to Holes;
  score : Integer;

 }

I am not sure if I understand this correctly or not but It seems like this can help to reduce redundant data in target entity (like some common attributes in entity Holes).

Let's learn CAP 😎

1joandre
Participant

Hello team!

Attaching the screenshots for Week 2 

 

1joandre_1-1689330550500.png

 

0 Kudos

Well done

catalinfeidi
Participant

catalinfeidi
Participant

Week 2, done as well! 🙂golf week 2.png

0 Kudos

Well done

catalinfeidi
Participant

I have been generating the data files structure automatically via Terminal Command: cds add data

GOLF WEEK 2 V1.png

0 Kudos

Well done

v-tryputsina
Product and Topic Expert
Product and Topic Expert

0 Kudos

Well done

govardhansahil
Explorer

Hi @nicoschoenteich 

Here is my submission for week 2. Thanks for the challenge!

govardhansahil_0-1689339293405.png

 

0 Kudos

Well done

GRABLERE
Product and Topic Expert
Product and Topic Expert

0 Kudos

Well done

Afonso_Pimentel
Explorer

This is my submission:

Afonso_Pimentel_0-1689345836404.png

I had to change a few things on the schema, apparently it was not right from the start, but now it is.

0 Kudos

Well done

former_member150823
Product and Topic Expert
Product and Topic Expert

here's my solution for week 2 challenge

radubigu_0-1689363256016.png

 

0 Kudos

Well done

satya-dev
Participant

done!!

satyadev_0-1689364075694.png

 

0 Kudos

gitrepo link 

0 Kudos

Well done

nmkarthikeya
Active Participant

Hello, hope this is okay?

nmkarthikeya_0-1689402940519.png

 

0 Kudos

Well done

dhegde
Participant

Here is my submission for Week 2.  I generated test data by first generating .csn file and then using CDS CDS Generator extension.  

If I saved the .csn file under db/ directory (same as that of schema.cds), then I was getting a "duplciate artifact found.." error.  So, after generating data, I deleted the .csn file.  Is that common?  

dhegde_0-1689424234293.png

Thank you

Dhananjay

Well done

There is no need to generate a .csn file for creating test data. The most convenient way is probably the command "cds add data".

0 Kudos

I tried that first but it added only an empty test data file with just column names.  With .csn I could generate also some data.  May be I missed something with "cds add data".  will check.  Thanks for the hint. 👍

MarcelloUrbani
Active Contributor

Silly SSO didn't allow me to run BAS, did it in vscode

MarcelloUrbani_0-1689500997262.png

 

0 Kudos

Well done

JohnPaulLiberal
Explorer

Hi All!

My submission for this week's challenge:

JohnPaulLiberal_0-1689517281583.png

As I mainly develop on my local machine, I also did the challenge using vs. code:

JohnPaulLiberal_1-1689517690469.png

Thanks for this challenge, @nicoschoenteich.



 



0 Kudos

Well done

MioYasutake
Active Contributor

My week 2 submission.

miyasuta_0-1689538781330.png

 

0 Kudos

Well done

ajos
Explorer

0 Kudos

Well done

My submission for Week-2 Challenge. Please check and let me know if this is fine.

santoshmurmu_0-1689583158510.png

 

0 Kudos

Well done

cguttikonda24
Participant

@nicoschoenteich 2nd week submission.

cguttikonda24_0-1689591181325.png

 

0 Kudos

Well done

ajay_soreng
Developer Advocate
Developer Advocate

Hi @nicoschoenteich , 

Thanks for the challenge, it is really nice to bump into small hurdles/errors thrown by the tool and learn fixing them.  Please find this weeks submission. 

Screenshot 2023-07-17 at 5.24.08 PM.png