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
20,750

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
10,808

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
10,699

Nice, I'm glad you learned something new!

stickman_0x00
Participant
10,787

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

10,701

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

thomas_jung
Developer Advocate
Developer Advocate
10,715

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. 

10,701

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

dpk_bhat
Product and Topic Expert
Product and Topic Expert
10,709

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

dpk_bhat_0-1689170013670.png

 

0 Kudos
10,701

Well done

ZhongpinWang
Product and Topic Expert
Product and Topic Expert
10,677

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

ZhongpinWang_0-1689176079435.png

 

0 Kudos
10,632

Very well done

10,592

My submission 2nd week:

romil_agrawal_0-1689184451944.png

 

0 Kudos
10,560

Well done

D_Pietroniro
Product and Topic Expert
Product and Topic Expert
10,564

My submission for week 2. Thanks for this challenge!

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

0 Kudos
10,560

Well done

MeriemSouissi
Participant
10,543

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

 

MeriemSouissi_1-1689190991710.png

 

0 Kudos
9,850

Well done

choujiacheng
Explorer
10,446

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
9,850

Well done Yes, you have full creative freedom 😉

cd_winc
Explorer
10,382

Hi,

Thanks for the challenge!

My Week2 submission:

Capture2.PNG

0 Kudos
9,854

Well done

PunithKumar
Explorer
10,333

Hello
My week 2 submission

PunithKumar_0-1689233864973.png

 

0 Kudos
9,854

Well done

narendran_nv
Explorer
10,322

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

 

0 Kudos
9,862

Well done

UtkanGiray
Explorer
10,288

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

UtkanGiray_0-1689243647033.png

 

0 Kudos
9,865

Well done

marcinb
Explorer
10,270

hi,
This is my submission for week two!

marcinb_0-1689249237769.png

 

0 Kudos
9,869

Well done

MadhavKumar
Explorer
10,221

Hi Team,

Sharing here snapshot of Week2 challenge.

MadhavKumar_0-1689260120533.png

 

Thank You

0 Kudos
9,870

Well done

alessandraarm
Explorer
10,134

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
9,870

Well done

AslanCakirdogan
Participant
9,991

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

aslan1906_0-1689302052496.png

 

0 Kudos
9,870

Well done

jdm
Explorer
9,973

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
9,872

Well done

wawowrt
Explorer
9,884

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

CAP_Week2.png

9,877

Well done

bztoy
Participant
9,869

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).