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

nicoschoenteich
Developer Advocate
Developer Advocate
54,871
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 first week of this month's SAP Developer Challenge. This week we are going to learn how to get started with the SAP Cloud Application Programming Model (CAP) and domain modeling. If you haven't read the announcement blog post for this challenge, please head over and do so.
 

The Challenge

 
The objective this week is to build a CAP service, that can track golf rounds. Yes, you read that right – golf rounds ️🏌🏽‍. This is a completely artificial scenario that we made up, but it lends itself pretty well to practice a few basic CAP features.
We have prepared a starter project (link to CodeSandbox below) that already contains the entity "Rounds" and exposes it via a service. It is your job to enrich this existing service.

This is what you have to do to successfully complete this week's challenge:
  1.  Go to the CodeSandbox and fork it. You have to have an account with CodeSandbox and be be signed in to be able to do that.
  2. Work on the project so it represents the following relationships:
        1. The service should track who entered a new round and when it was entered (hint: managed entities).
        2. A round consists of multiple holes. No hole can exists without its "parent" round (hint: compositions vs. associations).
        3. Each hole has a score, representing the number of shots it took a player to get the ball into the hole.
        4. Similarly, each hole has a par of 3, 4, or 5, representing the average amount of shots it takes a professional golfer to get the ball into the hole.
        5. Each hole consists of one or more shots. Similar to rounds and holes, no shot can exists without its "parent" hole (hint: compositions vs. associations).
        6. (Feel free to add more fields to the entities as you see fit.)
  3. Run the dev server using the predefined "dev" task. To do so, click on the little plus icon (+) to open the dev tools and click on "Tasks > dev".
  4. Wait for the server to start. Once done, click on "http://localhost:4004".
  5. Open the metadata of the "browse" service.
  6. Take a screen shot of the metadata and post it into this discussion thread. Hopefully it looks something like this (a few sections collapsed in the screen shot):

metadata.png

 

Resources

 
We have gathered a few helpful resources to get started. Also make sure to inspect the existing code in the starter project and try to understand what it does.


Note: If you encounter issues with your dev server not starting properly, check your cds syntax. Unfortunately, the CodeSandbox doesn't have syntax highlighting for cds and it may not provide clear error messages. One useful approach is to comment out sections of code until the server starts, then gradually uncomment to isolate the problematic line.

Good luck and happy learning!
168 REPLIES 168
Read only

shrinivasan_neelamegam
Developer Advocate
Developer Advocate
22,604

@nicoschoenteich Week 1 challenge, close enough?

CAP result.png

 

Read only

22,603

Sweet! That looks perfect. Good job 💪

Read only

iagoalves
Discoverer
22,599

I think I misunderstood the 4th item But I tried it, what do you guys think?


iagoalves_0-1688569527013.png

 

Read only

22,257

Good job.

And yeah, score and par should be properties of the holes entity, not the shots 😉

Did you go for compositions or associations?

Read only

22,053

associations like:

 

entity Rounds : cuid {
...
holes : Association to many Holes on holes.rounds = $self;
}

entity Holes : cuid {
...
rounds: Association to Rounds;
}


Read only

20,268

Go with compositions instead, as shots shouldn't exists without their "parent" hole. Read more about the difference here: https://cap.cloud.sap/docs/advanced/performance-modeling#compositions-vs-associations

Read only

cguttikonda24
Participant
Read only

22,253

Looks good! Well done.

Read only

Read only

AleMarinho
Product and Topic Expert
Product and Topic Expert
22,021

Hello!

Here is my submission for week 1:

alessandraarm_0-1688584239749.png

😊

Alessandra

 

Read only

20,274

Well done, did you go with a managed entity for the Rounds? Just curious why there is no "modifiedAt" and "modifiedBy"...

Read only

AleMarinho
Product and Topic Expert
Product and Topic Expert
20,262

Hey!

You're right, I completely forgot these fields... 😅. I've updated:

alessandraarm_0-1688736964417.png

Tks! 😁

 

Read only

Former Member
21,925

First time actually giving CAP a try. Is this it?

Afonso_Pimentel_0-1688602346548.png

 

Read only

20,281

You bet this is it! Good job.

Read only

choujiacheng
Explorer
21,890

Hello, attached is the expected output. Is this appropriate for the exercise?

choujiacheng_0-1688608694458.png

 

Read only

Read only

bztoy
Participant
21,709

Hi Nico,

Here is my submission EDMX for Week#1's assignment, hope it is correct :).

 

cap-code-challength-week-01.png

Thanks,

Wises K.

Read only

20,283

It is correct 😉

Read only

Read only

Read only

21,642

Unable to open sandbox . Created a account as well.

shankdeloitte_0-1688635501264.png

 

Read only

20,295

Hm, that's not good. Can you maybe try again? Hope it was just something temporary... Where you able to fork the repository?

Read only

stickman_0x00
Participant
21,591

stickman_0x00_0-1688643601034.png

 

Why do we have score when wee could just see the length of the array of shots?

I think I got everything

Read only

20,294

Because we are just getting started 😉 Curious to see your implementation though!

Read only

21,423

Hi @nicoschoenteich  great idea, thanks for the post. Does this complete week 1 challenge?

benw_0-1688656498091.png

 

Read only

20,293

It does! Good job.

Read only

dhegde
Participant
20,587

My submission for week 1 challenge.  I added some validations using @assert annotations.

@nicoschoenteich does it look good?

dhegde_0-1688695858590.png

 

Read only

20,290

Well done and good idea with add "@assert".

I'm curious, where is the annotation "CatalogService.Rounds/entered_at" coming from?

Read only

18,291

it's here, and I have added "@cds.on.insert: $now;" annotaiton on that field

dhegde_0-1689405112218.png

 

Read only

0 Likes
20,307

Perfect!

Read only

nmkarthikeya
Active Participant
20,501

My submission:

nmkarthikeya_0-1688725673846.png

 

 

Read only

Read only

govardhansahil
Explorer
20,483

Hi @nicoschoenteich ,

Here is my submission for Week 1. Thanks for the challenge.

govardhansahil_1-1688716815410.png

 

Read only

Read only

marcinb
Explorer
20,435

hello!
My submission for week 1:

marcin_barszcz_0-1688721818790.png

 

Read only

Read only

1joandre
Participant
20,390

Hello!

My submission:

1joandre_0-1688725659785.png