Skip to content

Commit 02d9f7e

Browse files
committed
Bring back DB tools and API hub registration
1 parent 151e2e5 commit 02d9f7e

File tree

3 files changed

+41
-80
lines changed

3 files changed

+41
-80
lines changed

-exercises-/02-Deploy/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ In this exercise you will have a look into the data model of the application and
2828

2929
<p align="center"><img width="640" src="res/pic103.png" alt="Console with deployment output"> </p>
3030

31-
<!-- 1.4. Let's take a look into what was deployed. Right-click again on the `db` folder and select `Open HDI container`. This will open up the SAP HANA database explorer.
31+
1.4. Let's take a look into what was deployed. Right-click again on the `db` folder and select `Open HDI container`. This will open up the SAP HANA database explorer.
3232

3333
<p align="center"><img width="640" src="res/pic104.png" alt="Open HDI container"> </p>
3434

@@ -47,7 +47,7 @@ In this exercise you will have a look into the data model of the application and
4747

4848
> The data you see here is maintained in the resource folder `db > src > csv` and was deployed along with the table definitions.
4949
<p align="center"><img width="860" src="res/pic113.png" alt="CSV files in db folder"> </p>
50-
-->
50+
5151

5252
### 2. Run the OData service
5353

-exercises-/03-ConnectService/README.md

Lines changed: 37 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,23 @@ In this exercise you will learn how to add a remote service to your app that fet
1010

1111
## Exercise description
1212

13-
### 1. Setup Mock Server for SAP S/4HANA
13+
### 1. Activate SAP API Business Hub for your user
14+
15+
Navigate to SAP API Business Hub by opening the URL https://api.sap.com in a separate browser tab. Select the `Log On` button and enter the email address and password of your user.
16+
<p align="center"><img width="480" src="res/pic303d.png" alt="Lon on to SAP API Business Hub"> </p>
17+
18+
If this is the first logon with this user, you need to accept the terms of use for SAP API Business hub. Select the two checkboxes and confirm.
19+
<p align="center"><img width="320" src="res/pic308e.png" alt="Lon on to SAP API Business Hub"> </p>
20+
21+
If you don't get to see this screen, this was already done for this user.
22+
23+
### 2. Setup Mock Server for SAP S/4HANA
1424
In case you do not have access to a live SAP S/4HANA system, there is a server that mocks the relevant OData APIs. Follow [these instructions](MockServer/README.md) to set it up.
1525

16-
### 2. Switch to a different start branch
26+
### 3. Switch to a different start branch
1727

1828
For this exercise you have to **switch to another code branch** of the Git repository.
29+
1930
In the Web IDE Git pane click the `+` icon:
2031
<p align="center"><img width="420" src="res/pic301.png" alt="Create local branch"> </p>
2132

@@ -25,85 +36,35 @@ As source branch select `origin/s4bp-start`. The name of the local branch is su
2536
The file explorer always shows the currently active branch:
2637
<p align="center"><img width="330" src="res/pic303a.png" alt="Branch name in explorer"> </p>
2738

28-
### 3. Import S/4HANA service
29-
30-
<!-- 1. **Download the model of the external service from SAP API Business Hub**
31-
32-
Navigate to SAP API Business Hub by opening the URL https://api.sap.com in a separate browser tab. Select the `Log On` button and enter the email address and password of your user.
33-
<p align="center"><img width="480" src="res/pic303d.png" alt="Lon on to SAP API Business Hub"> </p>
34-
35-
In the search field type "OData Service for Business Partner" and press the search icon.
36-
<p align="center"><img width="480" src="res/pic303b.png" alt="API Hub Search"> </p>
37-
38-
On the next screen switch to the "Details" view. Scroll down to select "Download Specification" and then select "EDMX". Store this file to your local machine.
39-
<p align="center"><img width="480" src="res/pic303c.png" alt="Select OData API"> </p> -->
40-
41-
<!-- 1. **Activate SAP Business API Hub for your user**
42-
43-
Navigate to SAP API Business Hub by opening the URL https://api.sap.com in a separate browser tab. Select the `Log On` button and enter the email address and password of your user.
44-
<p align="center"><img width="480" src="res/pic303d.png" alt="Lon on to SAP API Business Hub"> </p>
45-
46-
If this is the first logon with this user, you need to accept the terms of use for SAP API Business hub. Select the two checkboxes and confirm.
47-
<p align="center"><img width="320" src="res/pic308e.png" alt="Lon on to SAP API Business Hub"> </p>
48-
If you don't get to see this screen, this was already done for this user.
49-
50-
2. **Download the model of the external service from SAP API Business Hub**
51-
52-
In the search field type "OData Service for Business Partner" and press the search icon.
53-
<p align="center"><img width="480" src="res/pic303b.png" alt="API Hub Search"> </p>
39+
### 4. Import S/4HANA service
5440

55-
On the next screen switch to the "Details" view. Scroll down to select "Download Specification" and then select "EDMX".
56-
<p align="center"><img width="480" src="res/pic303c.png" alt="Select OData API"> </p>
57-
58-
Store this file to your local computer. It will end up in the default Downloads folder. Locate the file `API_BUSINESS_PARTNER.edmx` in the File Explorer and rename it to `ODataServiceforBusinessPartner.edmx`.
59-
-->
60-
61-
3.1 **Import the service model into your project**
62-
63-
3.1.1. On the `srv` folder select `New` > `Data Model from External Service` from the context menu:
41+
4.1. On the `srv` folder select `New` > `Data Model from External Service` from the context menu:
6442
<p align="center"><img width="480" src="res/pic306.png" alt="Data model from external service"> </p>
6543

66-
3.1.2. In the wizard, select `SAP API Business Hub` and enter `business partner` into the search field. If you are asked to logon to API Business Hub, enter your credentials. Select the API `OData Service for Business Partner`and then press `Next`.
44+
4.2. In the wizard, select `SAP API Business Hub` and enter `business partner` into the search field. If you are asked to logon to API Business Hub, enter your credentials. Select the API `OData Service for Business Partner`and then press `Next`.
6745
<p align="center"><img width="640" src="res/pic308b.png" alt="Select the model file"> </p>
6846

69-
3.1.3. **Deselect** the checkbox `Generate Virtual Data Model classes` and press `Finish`.
47+
4.3. **Deselect** the checkbox `Generate Virtual Data Model classes` and press `Finish`.
7048
<p align="center"><img width="480" src="res/pic310.png" alt="Turn off class generation"> </p>
7149

7250
> Java class generation for the data model is not needed in our case, as we will be using precompiled and optimized classes provided by S/4HANA cloud SDK.
7351
74-
3.1.4. Verify in file explorer that the import has generated two service definitions, one in `xml` format, the other in `json` format These can be found in folder `srv` > `external`.
52+
4.4. Verify in file explorer that the import has generated two service definitions, one in `xml` format, the other in `json` format These can be found in folder `srv` > `external`.
7553
<p align="center"><img width="350" src="res/pic311.png" alt="Imported files"> </p>
7654

7755
> While the `xml` file, the so-called `edmx`, is the original model file from API Business Hub, the `json` file is the compiled representation of the model for CDS. It is this `json` file, so-called `cson`, that we will reference from other `cds` source files.
7856
79-
<!-- 3. **Import the service model into your project**
80-
81-
a. Switch back to SAP Web IDE and on the `srv` folder select `New` > `Data Model from External Service` from the context menu:
82-
<p align="center"><img width="480" src="res/pic306.png" alt="Data model from external service"> </p>
83-
84-
b. In the wizard, select `Browse` and find the downloaded model file. Press `Next`.
85-
<p align="center"><img width="640" src="res/pic308a.png" alt="Select the model file"> </p>
86-
87-
c. Deselect the checkbox `Generate Virtual Data Model classes` and press `Finish`.
88-
<p align="center"><img width="480" src="res/pic310.png" alt="Turn off class generation"> </p>
89-
90-
> Java class generation for the data model is not needed in our case, as we will be using precompiled and optimized classes provided by S/4HANA cloud SDK.
91-
92-
d. Verify in file explorer that the import has generated two service definitions, one in `xml` format, the other in `json` format These can be found in folder `srv` > `external`.
93-
<p align="center"><img width="350" src="res/pic311.png" alt="Imported files"> </p>
94-
95-
> While the `xml` file, the so-called `edmx`, is the original model file from API Business Hub, the `json` file is the compiled representation of the model for CDS. It is this `json` file, so-called `cson`, that we will reference from other `cds` source files. -->
9657

97-
### 4. Use external model in flight data and service model
58+
### 5. Use external model in flight data and service model
9859

99-
4.1. **Update CDS**
60+
5.1. **Update CDS**
10061

10162
After the import we need to make the CDS build system aware of the new model. On the project node in the tree, select `Build CDS` from the context menu.
10263
<p align="center"><img width="480" src="res/pic313a.png" alt="Build CDS"> </p>
10364

10465
> In future versions of Web IDE this step will no longer be necessary.
10566
106-
4.2. **Remove comments in file `db/index.cds`**
67+
5.2. **Remove comments in file `db/index.cds`**
10768

10869
Remove the comment markers from all lines. After selecting all lines, you can use the `Toggle Line Comment` command from the editor context menu, or hit `Ctrl+/`
10970

@@ -122,7 +83,7 @@ The file explorer always shows the currently active branch:
12283
> - We will use this `Customers` table/entity to cache business partner records that we have retrieved from S/4HANA. We not only do this for performance reasons, but also because we can conveniently join and query over both 'local' and 'remote' data sets.
12384
> 4. Finally, in line `31-33` the `Bookings` entity is extended by an association to the `Customers` table from above. By storing the customer ID with each booking, we link `Bookings` with `Customers` records.
12485
125-
4.3. **Remove comments in file `srv/booking-service.cds`**
86+
5.3. **Remove comments in file `srv/booking-service.cds`**
12687

12788
- In line `9` to enable the `excluding` clause.
12889
> Here we remove properties `CustomerName` and `EmailAddress` from the service, since they are now available through our new `Customer` entity.
@@ -135,15 +96,15 @@ The file explorer always shows the currently active branch:
13596
After you save the file, CDS auto build should now successfully compile our CDS model.
13697
Should there still be errors shown in `db/index.cds`, close the editors and refresh the browser page.
13798

138-
4.4. **Build and deploy to the database**
99+
5.4. **Build and deploy to the database**
139100

140101
The model is now ready to be compiled and deployed to SAP HANA. Use the `Build` command on the `db` folder to do this.
141102
<p align="center"><img width="480" src="res/pic319.png" alt="Deploy to database"> </p>
142103

143104
There should be a success message in console view for the deploy operation:
144105
<p align="center"><img width="480" src="res/pic320.png" alt="Success message"> </p>
145106

146-
4.5. **Inspect the service**
107+
5.5. **Inspect the service**
147108

148109
Re-start the OData service:
149110
<p align="center"><img width="480" src="res/pic321.png" alt="Run Java app"> </p>
@@ -154,18 +115,18 @@ The file explorer always shows the currently active branch:
154115
Using URL `.../BookingService/Bookings` you can see that our sample data (in the `db/src/csv` folder) already makes use of `Customer_ID` and stores the link to a (artificial) customer number `1` in the booking.
155116
<p align="center"><img width="480" src="res/pic326c.png" alt="Customer ID filled"> </p>
156117

157-
<!-- 5. **Browse the database**
118+
5.6. **Browse the database**
158119

159120
On the `db` folder, select `Open HDI Container`, which will lead you to the deployed tables.
160121
Click on the `Tables` item in the tree.
161122
<p align="center"><img width="480" src="res/pic326a.png" alt="Browse the database"> </p>
162123

163-
> Note that there is a new table `..._CUSTOMERS` for the `Customers` entity. Also, in table `..._BOOKINGS` you can see a new column `CUSTOMER_ID` holding the foreign key to the `CUSTOMERS` table. In the next section you will see how this new table is filled with data from S/4HANA. -->
124+
> Note that there is a new table `..._CUSTOMERS` for the `Customers` entity. Also, in table `..._BOOKINGS` you can see a new column `CUSTOMER_ID` holding the foreign key to the `CUSTOMERS` table. In the next section you will see how this new table is filled with data from S/4HANA.
164125
165126

166-
### 5. Call S/4 in the Java code
127+
### 6. Call S/4 in the Java code
167128

168-
5.1. **Change `CustomersRemoteHandler.java`**:
129+
6.1. **Change `CustomersRemoteHandler.java`**:
169130

170131
Locate the file `CustomersRemoteHandler.java` in folder `srv/src/main/java/com/sap/cloudsamples/spaceflight/`.
171132
To enable reading a single customer record, add a comment in line `31` and remove the comment from line `32`:
@@ -176,7 +137,7 @@ The file explorer always shows the currently active branch:
176137

177138
> If you are curious, you can take a look into the `CustomersReplicator` class to see how we call the business partner OData service using the S/4HANA Cloud SDK.
178139
179-
5.2. **Verify the code works**
140+
6.2. **Verify the code works**
180141

181142
a. Run the Java application:
182143
<p align="center"><img width="480" src="res/pic321.png" alt="Run Java app"> </p>
@@ -193,9 +154,9 @@ The file explorer always shows the currently active branch:
193154

194155
> Whenever we get or query the `CustomersRemote` entity, a new remote call is made. In the next section we will cache the retrieved customer records.
195156
196-
### 6. Prepare storing S/4 customers in the local database
157+
### 7. Prepare storing S/4 customers in the local database
197158

198-
6.1. **Adjust `BookingsHandler.java`**
159+
7.1. **Adjust `BookingsHandler.java`**
199160

200161
Remove the line comments in line `75`:
201162
<p align="center"><img width="640" src="res/pic315.png" alt="Call fetchAndSaveCustomer"> </p>
@@ -205,37 +166,37 @@ The file explorer always shows the currently active branch:
205166

206167
Save the file.
207168

208-
6.2. **Run the service again**
169+
7.2. **Run the service again**
209170

210171
<p align="center"><img width="480" src="res/pic321.png" alt="Run Java app"> </p>
211172

212173
> Now, for each new booking created, the respective customer record is going to be fetched and saved to the local database.
213174
214175
To create a booking, we need a UI, though. Let's do this real quick in the next section.
215176

216-
### 7. Create bookings for S/4 customers
177+
### 8. Create bookings for S/4 customers
217178

218-
7.1. **Adjust the UI**
179+
8.1. **Adjust the UI**
219180

220181
The UI can be adapted when adding/changing Fiori annotations to CDS models. Remove the line comments for the section marked in the following figures. Also, remove the lines marked with `REMOVE`.
221182
<p align="center"><img width="480" src="res/pic327.png" alt="Change Customers annotations"> </p>
222183
<p align="center"><img width="480" src="res/pic328.png" alt="Change Bookings annotations"> </p>
223184
<p align="center"><img width="480" src="res/pic329.png" alt="Change Bookings annotations"> </p>
224185
<p align="center"><img width="480" src="res/pic330.png" alt="Change Bookings line item annotation"> </p>
225186

226-
7.2. **Run the UI within SAP Web IDE**
187+
8.2. **Run the UI within SAP Web IDE**
227188

228189
<p align="center"><img width="600" src="res/pic331.png" alt="Open run configuration"> </p>
229190

230191
<p align="center"><img width="600" src="res/pic332.png" alt="Enable run with local metadata"> </p>
231192

232193
<p align="center"><img width="700" src="res/pic333.png" alt="Query bookings"> </p>
233194

234-
7.3. **Create a new booking for an S/4 customer:**
195+
8.3. **Create a new booking for an S/4 customer:**
235196

236197
<p align="center"><img width="700" src="res/pic334.png" alt="Create booking"> </p>
237198

238-
7.4. **Check that this S/4 customer has been persisted (cached) in the database**
199+
8.4. **Check that this S/4 customer has been persisted (cached) in the database**
239200

240201
<p align="center"><img width="700" src="res/pic335.png" alt="Query Customers entity"> </p>
241202

-exercises-/04-Reuse/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ For this exercise you have to switch to branch `reuse-start` of the Git reposito
7878
As usual, use the `Build` menu on the `db` folder.
7979
<p align="center"><img width="480" src="res/11.png" alt="Build database module"> </p>
8080

81-
<!-- 6. Browse database
81+
2.7. Browse the database
8282

8383
- Open database explorer:
8484
<p align="center"><img width="320" src="res/12.png" alt="index.cds"> </p>
@@ -87,7 +87,7 @@ For this exercise you have to switch to branch `reuse-start` of the Git reposito
8787

8888
<p align="center"><img width="640" src="res/13.png" alt="index.cds"> </p>
8989

90-
These are admin data from `node_modules/@sap/cds/common.cds`, which we inherit through `node_modules/spaceflight-model/db/common.cds`. -->
90+
These are admin data from `node_modules/@sap/cds/common.cds`, which we inherit through `node_modules/spaceflight-model/db/common.cds`.
9191

9292
2.6. Restart the Java application
9393

0 commit comments

Comments
 (0)