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: guides/integration/data-federation.md
+29-20Lines changed: 29 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,11 +4,11 @@ CAP applications can integrate and federate data from multiple external data sou
4
4
{.abstract}
5
5
6
6
7
-
## Introduction
7
+
## Introduction & Motivation
8
8
9
9
Displaying external data in lists commonly requires fast access to that data. Relying on live calls to remote services per row is clearly not an option, as that would lead to poor performance, excessive load on server, and a nightmare regarding resilience. Instead, we somehow need to ensure that all required data is available locally, so that it can be accessed fast and reliably by UIs, using good old SQL JOINs.
10
10
11
-
For example, we saw the need for that already in the [CAP-level Service Integration](calesi.md#coding-required) guide, where the `Customer` field in the travel requests list is populated from the remote S/4 Business Partner service, but missing when running the services separately:
11
+
For example, we saw the need for that already in the [CAP-level Service Integration](calesi.md#integration-logic-required) guide, where the `Customer` field in the travel requests list is populated from the remote S/4 Business Partner service, but missing when running the services separately:
12
12
13
13
1. First run these commands **in two separate terminals**:
14
14
@@ -80,16 +80,28 @@ In addition, when we again look into the log output, we see some bulk requests l
80
80
```
81
81
</span>
82
82
83
-
In the xtravels app we accomplished that with a simple, yet quite effective data replication solution, which automatically replicates data as follows...
83
+
84
+
## Get The XTravels Sample
85
+
86
+
In the [`@capire/xtravels`](https://github.com/capire/xtravels) app we accomplished that with a simple, yet quite effective data replication solution, which automatically replicates data as documented below.
87
+
88
+
Clone the project from GitHub and open it in VS Code to follow along:
Tag [consumption views](calesi#consumption-views) with the `@federated` annotation, to express your intent to have that data federated, i.e. in close access locally, for example:
98
+
Tag [consumption views](calesi#consumption-views) with the `@federated` annotation, to express your intent to have that data federated, i.e. in close access locally. For example, we did so in out consumption view for S/4 Business Partners:
89
99
90
-
```cds :line-numbers=4
100
+
::: code-group
101
+
```cds :line-numbers=4 [apis/capire/s4.cds]
91
102
@federated entity Customers as projection on S4.A_BusinessPartner { ... }
@@ -98,7 +110,7 @@ Tag [consumption views](calesi#consumption-views) with the `@federated` annotati
98
110
99
111
## Generic Implementation
100
112
101
-
Here's the complete code, placed infile `srv/data-federation.js`:
113
+
Here's the complete code, as found in[`srv/data-federation.js`](https://github.com/capire/xtravels/blob/main/srv/data-federation.js):
102
114
103
115
::: code-group
104
116
```js:line-numbers [srv/data-federation.js]
@@ -155,7 +167,7 @@ Let's have a closer look at this code, which handles these main tasks:
155
167
> We work with **database-agnostic** and **protocol-agnostic** [CQL queries](../../cds/cql) both for interacting with the local database as well as for querying remote services. In effect, we got a fully generic solution for replication, i.e., it works for**_any_** remote service that supports OData, or HCQL.
156
168
157
169
158
-
### Test Drive Locally
170
+
## Test Drive Locally
159
171
160
172
Let's see the outcome in action: to activate the above data federation code, edit `srv/server.js` file and uncomment the single line of code in there like this:
161
173
@@ -216,16 +228,13 @@ Finally, open the Fiori UI in the browser again, and see that customer data from
216
228

0 commit comments