You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: -exercises-/02-Deploy/README.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ In this exercise you will have a look into the data model of the application and
28
28
29
29
<palign="center"><imgwidth="640"src="res/pic103.png"alt="Console with deployment output"> </p>
30
30
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.
Copy file name to clipboardExpand all lines: -exercises-/03-ConnectService/README.md
+37-76Lines changed: 37 additions & 76 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,12 +10,23 @@ In this exercise you will learn how to add a remote service to your app that fet
10
10
11
11
## Exercise description
12
12
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
+
<palign="center"><imgwidth="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
+
<palign="center"><imgwidth="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
14
24
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.
15
25
16
-
### 2. Switch to a different start branch
26
+
### 3. Switch to a different start branch
17
27
18
28
For this exercise you have to **switch to another code branch** of the Git repository.
29
+
19
30
In the Web IDE Git pane click the `+` icon:
20
31
<palign="center"><imgwidth="420"src="res/pic301.png"alt="Create local branch"> </p>
21
32
@@ -25,85 +36,35 @@ As source branch select `origin/s4bp-start`. The name of the local branch is su
25
36
The file explorer always shows the currently active branch:
26
37
<palign="center"><imgwidth="330"src="res/pic303a.png"alt="Branch name in explorer"> </p>
27
38
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.
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.
<!-- 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.
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:
64
42
<palign="center"><imgwidth="480"src="res/pic306.png"alt="Data model from external service"> </p>
65
43
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`.
67
45
<palign="center"><imgwidth="640"src="res/pic308b.png"alt="Select the model file"> </p>
68
46
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`.
70
48
<palign="center"><imgwidth="480"src="res/pic310.png"alt="Turn off class generation"> </p>
71
49
72
50
> 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.
73
51
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`.
> 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.
78
56
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`.
> 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. -->
96
57
97
-
### 4. Use external model in flight data and service model
58
+
### 5. Use external model in flight data and service model
98
59
99
-
4.1. **Update CDS**
60
+
5.1. **Update CDS**
100
61
101
62
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.
> In future versions of Web IDE this step will no longer be necessary.
105
66
106
-
4.2. **Remove comments in file `db/index.cds`**
67
+
5.2. **Remove comments in file `db/index.cds`**
107
68
108
69
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+/`
109
70
@@ -122,7 +83,7 @@ The file explorer always shows the currently active branch:
122
83
> - 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.
123
84
> 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.
124
85
125
-
4.3. **Remove comments in file `srv/booking-service.cds`**
86
+
5.3. **Remove comments in file `srv/booking-service.cds`**
126
87
127
88
- In line `9` to enable the `excluding` clause.
128
89
> 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:
135
96
After you save the file, CDS auto build should now successfully compile our CDS model.
136
97
Should there still be errors shown in `db/index.cds`, close the editors and refresh the browser page.
137
98
138
-
4.4. **Build and deploy to the database**
99
+
5.4. **Build and deploy to the database**
139
100
140
101
The model is now ready to be compiled and deployed to SAP HANA. Use the `Build` command on the `db` folder to do this.
141
102
<palign="center"><imgwidth="480"src="res/pic319.png"alt="Deploy to database"> </p>
142
103
143
104
There should be a success message in console view for the deploy operation:
@@ -154,18 +115,18 @@ The file explorer always shows the currently active branch:
154
115
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.
155
116
<palign="center"><imgwidth="480"src="res/pic326c.png"alt="Customer ID filled"> </p>
156
117
157
-
<!-- 5. **Browse the database**
118
+
5.6. **Browse the database**
158
119
159
120
On the `db` folder, select `Open HDI Container`, which will lead you to the deployed tables.
160
121
Click on the `Tables` item in the tree.
161
122
<palign="center"><imgwidth="480"src="res/pic326a.png"alt="Browse the database"> </p>
162
123
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.
164
125
165
126
166
-
### 5. Call S/4 in the Java code
127
+
### 6. Call S/4 in the Java code
167
128
168
-
5.1. **Change `CustomersRemoteHandler.java`**:
129
+
6.1. **Change `CustomersRemoteHandler.java`**:
169
130
170
131
Locate the file `CustomersRemoteHandler.java` in folder `srv/src/main/java/com/sap/cloudsamples/spaceflight/`.
171
132
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:
176
137
177
138
> 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.
> Now, for each new booking created, the respective customer record is going to be fetched and saved to the local database.
213
174
214
175
To create a booking, we need a UI, though. Let's do this real quick in the next section.
215
176
216
-
### 7. Create bookings for S/4 customers
177
+
### 8. Create bookings for S/4 customers
217
178
218
-
7.1. **Adjust the UI**
179
+
8.1. **Adjust the UI**
219
180
220
181
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`.
0 commit comments