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

vmecko
Discoverer

Submitting this week's part of challenge. Please review if it's okay.

vmecko_0-1689156709280.png

Must admit that auto init setup of data files is a nice feature that I didn't know about.

0 Kudos

Nice, I'm glad you learned something new!

stickman_0x00
Explorer

stickman_0x00_2-1689159265036.png

 

stickman_0x00_1-1689159215596.png

Hope my fields are not a problem later on, I am seeing I don't have the exact structure

Add the "par: Integer;" as a property to the Holes entity and you are good 😉

thomas_jung
Developer Advocate
Developer Advocate

2023-07-12_09-23-05.png

I opted to put my testing CSV files into the test\data folder. That way CAP only tries to load them when local testing and not when deploying for real in production. 

Yep, that test folder comes in handy if you don't want to overwrite a production database 😁

dpk_bhat
Advisor
Advisor

Nice work team!
Attaching the screenshots for Week 2 for the CSVs:

dpk_bhat_0-1689170013670.png

 

0 Kudos

Well done

ZhongpinWang
Advisor
Advisor

My submission for the second week. Thanks for offering this challenge!

ZhongpinWang_0-1689176079435.png

 

0 Kudos

Very well done

My submission 2nd week:

romil_agrawal_0-1689184451944.png

 

0 Kudos

Well done

D_Pietroniro
Product and Topic Expert
Product and Topic Expert

My submission for week 2. Thanks for this challenge!

2023-07-12_16-06-12.png

0 Kudos

Well done

MeriemSouissi
Participant

My submission for week 2  ! enjoying the opportunity to learn CAP! thanks @nicoschoenteich 

 

MeriemSouissi_1-1689190991710.png

 

0 Kudos

Well done

choujiacheng
Explorer

choujiacheng_0-1689211406480.png

Hello, attached is the end result. I have added some additional elements from last week's exercise to fit in better to your expectations? Would this be alright?

0 Kudos

Well done Yes, you have full creative freedom 😉

cd_winc
Explorer

Hi,

Thanks for the challenge!

My Week2 submission:

Capture2.PNG

0 Kudos

Well done

PunithKumar
Explorer

Hello
My week 2 submission

PunithKumar_0-1689233864973.png

 

0 Kudos

Well done

narendran_nv
Discoverer

Here's my week-2 submission 😀
narendran_nv_0-1689237216192.png

 

0 Kudos

Well done

UtkanGiray
Explorer

My submission for week 2. Thank you nico for the challenge.

UtkanGiray_0-1689243647033.png

 

0 Kudos

Well done

marcinb
Explorer

hi,
This is my submission for week two!

marcinb_0-1689249237769.png

 

0 Kudos

Well done

MadhavKumar
Explorer

Hi Team,

Sharing here snapshot of Week2 challenge.

MadhavKumar_0-1689260120533.png

 

Thank You

0 Kudos

Well done

alessandraarm
Explorer

Hello!

Here is my submission for week 2:

alessandraarm_0-1689271244838.png

I'm learning a lot with this challenge, it is my first time working with CAP! 😁

 

0 Kudos

Well done

aslan1906
Participant

I guess I won't be able to wait until next Wednesday:)

aslan1906_0-1689302052496.png

 

0 Kudos

Well done

jdm
Explorer

Week 2 submission:

jdm_1-1689305804508.png

Learned how important schema.cds was and how it relates to the data files.

 

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos

Well done

wawowrt
Explorer

Hello @nicoschoenteich 🙂 This is my submission for Week 2.

CAP_Week2.png

Well done

bztoy
Participant

Hi @nicoschoenteich ,

Here is my submission for week#2.

I setup the project both in my local PC and BAS but mainly develop in my local machine.

Below are screen captured of the results in local env.

cap-code-challength-week-02-01.png

cap-code-challength-week-02-02.png

this is BAS dev space under my BTP trial account, the schema is already updated but there is no db/data directory yet.

cap-code-challength-week-02-03.png

I would like to ask you that should I keep tracking the db/data directory via git the same as other source code files or I have to put this dir in the .gitignore then transfer those csv files manually.

Thanks,

Wises

btw, I enjoy learning CAP here together with other community members. this challenge really really helps the CAP beginners.

A big thank to you (Nico), Thomas Jung, other members and also master D.J. Adam for his latest Hands-on episodes about managed association in CAP (I know he is on vacation :p).