Application Development and Automation 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: 
Read only

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

nicoschoenteich
Developer Advocate
Developer Advocate
24,045

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
Read only

vmecko
Discoverer
12,559

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.

Read only

0 Kudos
12,450

Nice, I'm glad you learned something new!

Read only

stickman_0x00
Participant
12,538

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

Read only

12,452

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

Read only

thomas_jung
Developer Advocate
Developer Advocate
12,466

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. 

Read only

12,452

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

Read only

dpk_bhat76
Product and Topic Expert
Product and Topic Expert
12,460

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

dpk_bhat_0-1689170013670.png

 

Read only

0 Kudos
12,452

Well done

Read only

ZhongpinWang
Product and Topic Expert
Product and Topic Expert
12,428

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

ZhongpinWang_0-1689176079435.png

 

Read only

0 Kudos
12,383

Very well done

Read only

12,343

My submission 2nd week:

romil_agrawal_0-1689184451944.png

 

Read only

0 Kudos
12,311

Well done

Read only

D_Pietroniro
Product and Topic Expert
Product and Topic Expert
12,315

My submission for week 2. Thanks for this challenge!

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

Read only

0 Kudos
12,311

Well done

Read only

MeriemSouissi
Participant
12,294

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

 

MeriemSouissi_1-1689190991710.png

 

Read only

0 Kudos
11,601

Well done

Read only

choujiacheng
Explorer
12,197

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?

Read only

0 Kudos
11,601

Well done Yes, you have full creative freedom 😉

Read only

cd_winc
Explorer
12,133

Hi,

Thanks for the challenge!

My Week2 submission:

Capture2.PNG

Read only

0 Kudos
11,605

Well done

Read only

PunithKumar
Explorer
12,084

Hello
My week 2 submission

PunithKumar_0-1689233864973.png

 

Read only

0 Kudos
11,605

Well done

Read only

narendran_nv
Explorer
12,073

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

 

Read only

0 Kudos
11,613

Well done

Read only

UtkanGiray
Explorer
12,039

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

UtkanGiray_0-1689243647033.png

 

Read only

0 Kudos
11,616

Well done

Read only

marcinb37
Explorer
12,021

hi,
This is my submission for week two!

marcinb_0-1689249237769.png

 

Read only

0 Kudos
11,620

Well done

Read only

MadhavKumar25
Explorer
11,972

Hi Team,

Sharing here snapshot of Week2 challenge.

MadhavKumar_0-1689260120533.png

 

Thank You

Read only

0 Kudos
11,621

Well done

Read only

alessandraarm
Explorer
11,885

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! 😁

 

Read only

0 Kudos
11,621

Well done

Read only

AslanCakirdogan
Participant
11,742

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

aslan1906_0-1689302052496.png

 

Read only

0 Kudos
11,621

Well done

Read only

jdm
Explorer
11,724

Week 2 submission:

jdm_1-1689305804508.png

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

 

Read only

nicoschoenteich
Developer Advocate
Developer Advocate
0 Kudos
11,623

Well done

Read only

wawowrt
Explorer
11,635

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

CAP_Week2.png

Read only

11,628

Well done

Read only

bztoy
Participant
11,620

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