07-19-2023 9:24 AM - edited 08-02-2023 2:14 PM
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 third week of this month's SAP Developer Challenge. This week we are going to learn how to use event handlers with the SAP Cloud Application Programming Model.
After moving to the SAP Business Application Studio and adding some sample data to our application last week, it's now time to explore some more features and capabilities of the SAP Cloud Application Programming Model. One of those is event handling, which will be our focus for this week.
Let's say we would like to enhance our application by automatically populating a new data field for the entity Holes. We would like to know what score a player scored on a hole, but not as a number, rather as one of the following strings: "birdie", "par", "bogey" (and a few more, see table below). These terms are frequently used in golf to describe the score a player scored on a hole in relation to the hole's par (par = expected score from a professional player). Let's say it took the player 4 shots to get the ball into the hole on a par 4 - that is a par. If it took the player only 3 shots on that same hole - that would be a birdie. See the table below for all mappings.
The described requirement is a perfect use case for event handling in CAP. As described in the documentation, calculated fields should be pre-calculated whenever a new entry is written into the database (instead of calculating on every read operation). This means we need a custom event handler for the CREATE operation on the Holes entity.
This is what you have to do to successfully complete this week's challenge:
1. Create a new property result: String; in the schema definition of the Holes entity. This is where we will store "par", "birdie", "bogey" etc..
Score in relation to par | String |
score - par = -3 | albatross |
score - par = -2 | eagle |
score - par = -1 | birdie |
score - par = 0 | par |
score - par = +1 | bogey |
score - par = +2 | double bogey |
score - par = +3 | triple bogey |
score = 1 | hole in one |
POST http://localhost:4004/browse/Holes
Content-Type: application/json
{
"score": 3,
"par": 4
}
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.
Good luck and happy learning!
07-25-2023 11:38 AM
07-26-2023 11:12 AM
07-25-2023 12:10 PM
07-26-2023 11:12 AM
07-25-2023 5:02 PM
07-26-2023 11:12 AM
07-26-2023 8:15 AM
07-26-2023 11:12 AM
07-26-2023 8:15 AM
07-26-2023 11:12 AM
07-26-2023 11:41 AM
07-31-2023 9:57 AM
07-26-2023 2:43 PM
07-31-2023 9:56 AM
07-26-2023 11:15 PM
07-31-2023 9:56 AM
07-27-2023 7:33 AM
07-31-2023 9:55 AM
07-28-2023 5:16 AM
07-31-2023 9:55 AM
07-28-2023 11:50 PM
07-31-2023 9:55 AM
07-29-2023 10:31 PM
07-31-2023 9:55 AM
07-30-2023 2:16 PM
07-31-2023 9:54 AM
07-31-2023 4:40 AM
Hi Nico,
Here is my submission:
but why the request doesn't work for
07-31-2023 9:54 AM
08-01-2023 9:14 AM
08-02-2023 9:57 AM
08-01-2023 10:09 AM
08-02-2023 9:57 AM
08-05-2023 10:17 AM