Skip to content

Commit 11ef6e6

Browse files
Merge branch 'sap-tutorials:master' into master
2 parents dec823d + 2adf2c1 commit 11ef6e6

167 files changed

Lines changed: 1818 additions & 8 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

tutorials/abap-extensibility-cbo-rules-create-destination/abap-extensibility-cbo-rules-create-destination.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ primary_tag: topic>abap-extensibility
88
---
99

1010
## Prerequisites
11-
- Custom Business Object must have been created. If not, then follow the tutorials [Create Custom Business Objects in S/4HANA Cloud](group.abap-extensibiliy-cbo-cce-ccl.html).
11+
- Custom Business Object must have been created. If not, then follow the tutorials [Create Custom Business Objects in S/4HANA Cloud](group.abap-extensibiliy-cbo-cce-ccl).
1212
- You must have SAP Cloud Platform account.
1313

1414

tutorials/btp-app-analytics-setup-use/btp-app-analytics-setup-use.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ SAP Fiori elements is a framework that comprises the most commonly used floor pl
3838
1. Speed up development by reducing the amount of front-end code needed to build SAP Fiori apps.
3939
2. Drive UX consistency and compliance with the latest SAP Fiori design guidelines.
4040

41-
SAP Fiori elements for OData version 2 (V2) offers **Analytical list page (ALP)** as a separate floor plan for a unique way to analyze data step by step from different perspectives, to investigate a root cause through drill-down, and to act on transactional content. On the other hand, in SAP Fiori elements for OData V4, the **Analytical List Page (ALP)** is not a separate floor plan, but rather a "flavor" of the **List Report Object Page** floor plan. Hence, we can configure a **List Report Object Page** floor plan in such a way that it can serve as an "ALP flavor" report page.
41+
SAP Fiori elements for OData version 2 (V2) offers **Analytical list page (ALP)** as a separate floor plan for a unique way to analyze data step by step from different perspectives, to investigate a root cause through drill-down, and to act on transactional content. On the other hand, in SAP Fiori elements for OData V4, the **Analytical List Page (ALP)** is not a separate floor plan, but rather a "flavor" of the **List Report Object Page** floor plan. Hence, you can configure a **List Report Object Page** floor plan in such a way that it can serve as an "ALP flavor" report page.
4242

4343
[DONE]
4444
[ACCORDION-END]
@@ -50,7 +50,7 @@ Create a new service for Analytics as given in [Create a CAP-Based Application](
5050

5151
2. Open the folder `templates`.
5252

53-
3. Copy the file `risk-analysis-service.cds` from `templates/create-ui-fiori-elements-analytics/srv` to the `srv` folder of your app.
53+
3. Copy the file `risk-analysis-service.cds` from `templates/analytics/srv` to the `srv` folder of your app.
5454

5555
The content of the file looks like this:
5656

@@ -84,7 +84,7 @@ Create a new service for Analytics as given in [Create a CAP-Based Application](
8484

8585
!![RisksAnalysis Entity](entity_riskAnalysis.png)
8686

87-
5. Copy the latest `sap.ui.riskmanagement-Risks.csv` file from `templates/create-ui-fiori-elements-analytics/db/data` and replace the existing file in the `db/data` folder of your app.
87+
5. Copy the latest `sap.ui.riskmanagement-Risks.csv` file from `templates/analytics/db/data` and replace the existing file in the `db/data` folder of your app.
8888

8989
This `.csv` file has a large number of records for analytical purposes.
9090

@@ -104,7 +104,7 @@ Create a new service for Analytics as given in [Create a CAP-Based Application](
104104

105105
> Why not use the Analytical List Page floor plan?
106106

107-
> Although we are using SAP Fiori elements for OData V4, you will notice that there is still a floor plan **Analytical List Page** in the previous screen. However, it is due to be removed from the Fiori Generator UI, so we are not going to use it for this tutorial.
107+
> Although you are using SAP Fiori elements for OData V4, you will notice that there is still a floor plan **Analytical List Page** in the previous screen. However, it is due to be removed from the Fiori Generator UI, so you are not going to use it for this tutorial.
108108

109109
3. Choose **Next**.
110110

@@ -251,7 +251,7 @@ The application is now generated and in a few seconds you can see it in the `app
251251
}
252252
```
253253

254-
3. Copy the file `risks-analysis-service-ui.cds` from `templates/create-ui-fiori-elements-analytics/srv` to the `srv` folder of your app.
254+
3. Copy the file `risks-analysis-service-ui.cds` from `templates/analytics/srv` to the `srv` folder of your app.
255255

256256
[DONE]
257257
[ACCORDION-END]
@@ -472,7 +472,7 @@ Similarly, other charts like **Line Chart for Visual Filters** can be added.
472472
[ACCORDION-END]
473473
---
474474
[ACCORDION-BEGIN [Step 9: ](Add your app to the launch page)]
475-
Let us add the `Risk Analysis` application to the launch page where we already have the `Risks` and `Mitigations` apps.
475+
Let us add the `Risk Analysis` application to the launch page where you already have the `Risks` and `Mitigations` apps.
476476

477477
1. Open the file `launchpage.html` in `app` folder of your application.
478478

@@ -524,4 +524,4 @@ The result of this tutorial can be found in the [`analytics`](https://github.com
524524

525525

526526
[ACCORDION-END]
527-
---
527+
---
107 KB
Loading
162 KB
Loading
65 KB
Loading
Lines changed: 224 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,224 @@
1+
---
2+
auto_validation: true
3+
time: 20
4+
tags: [ tutorial>advanced, tutorial>free-tier, software-product>sap-integration-suite, software-product>sap-cloud-integration, software-product>sap-api-management, software-product>sap-business-technology-platform ]
5+
primary_tag: software-product>sap-api-management
6+
parser: v2
7+
author_name: Mariajose Martinez
8+
author_profile: https://github.com/mariajosesap
9+
---
10+
# Configure SAP API Management policies to avoid CORS issues and generate an API Key
11+
<!-- description --> Learn how to set up API Management policies to avoid CORS issues when calling the API endpoint from SAP AppGyver, also you'll learn how to apply security policies to enable the API consumption via an API Key.
12+
13+
## Prerequisites
14+
15+
- You have a SAP BTP account or trial account with access to the SAP Integration Suite.
16+
- You have completed the previous tutorial [Send SMS using SAP Cloud Integration while consuming a Twilio API](btp-integration-suite-integral-cpi-urlencoded).
17+
18+
19+
## You will learn
20+
21+
- How to set up API Management policies to avoid CORS issues when calling the API endpoint.
22+
- How to apply security policies to enable the API consumption via an API Key.
23+
24+
### Set up the policy to avoid CORS issues
25+
26+
1. Go to your SAP API Portal (in the main SAP Integration Suite portal).
27+
28+
2. Create an API and select URL. Here you're going to paste your IFlow endpoint from past tutorials. Give it a name: `APIBestRunDemo`. Give it a path: `/https/salesOrder`, and service type `REST`.
29+
30+
![Create the API](create_api.png)
31+
32+
3. After creating it, go to the Proxy Endpoint tab and add the following in this order, and save it:
33+
34+
![Add the route rules](route_rules.png)
35+
36+
4. Now, go to Policies (if it doesn't show up in the top-right of your screen, click on the 3 dots).
37+
38+
Here you'll add the required policies to avoid CORS issues while calling this API from SAP AppGyver and configure the API Key policy later on.
39+
40+
5. On the Edit Mode, start adding the Policies as followed:
41+
42+
In the PostFlow inside the Proxy Endpoint configuration, add an `Assign Message` policy as an `OutgoingResponse` and name it `setCORS`. Like this:
43+
44+
![Add the route rules](create_set_cors_policy.png)
45+
46+
6. Copy and paste this script (read message on line 5):
47+
48+
<!-- cpes-file db/schema.cds -->
49+
```XML
50+
<!-- This policy can be used to create or modify the standard HTTP request and response messages -->
51+
<AssignMessage async="false" continueOnError="false" enabled="true" xmlns='http://www.sap.com/apimgmt'>
52+
<Add>
53+
<Headers>
54+
<!-- Set up this header, however if you come across to this error: " 'Access-Control-Allow-Origin' header contains multiple values, but only one is allowed when executing the test on AppGyver ", then remove it and try it again: <Header name="Access-Control-Allow-Origin">*</Header> -->
55+
<Header name="Access-Control-Allow-Headers">set-cookie, origin, accept, maxdataserviceversion, x-csrf-token, authorization, dataserviceversion, accept-language, x-http-method, content-type, X-Requested-With, apikey</Header>
56+
<Header name="Access-Control-Max-Age">3628800</Header>
57+
<Header name="Access-Control-Allow-Methods">GET, PUT, POST, DELETE</Header>
58+
<Header name="Access-Control-Expose-Headers">set-cookie, x-csrf-token, x-http-method</Header>
59+
</Headers>
60+
</Add>
61+
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
62+
<AssignTo createNew="false" type="response">response</AssignTo>
63+
</AssignMessage>
64+
```
65+
>Note: notice that you're already adding "apikey" as a header in the policy.
66+
67+
You should look it like this:
68+
69+
![CORS Policy](set_cors_policy.png)
70+
71+
7. In the ProxyEndpoint click on `+` to add one. Name it `preflight` and in the condition string paste: `request.verb == "OPTIONS"`. Like this:
72+
73+
![Preflight Condition String](preflight.png)
74+
75+
This is all you need to avoid CORS issues when calling our API from SAP AppGyver.
76+
77+
### Create a Key Value Map for your SAP Cloud Integration Credentials
78+
79+
1. Before adding the needed policies, create first a Key Value Map with your CPI credentials (to access the Cloud Integration Platform API endpoint). You will need this credential to reference it in the API Key Policy.
80+
81+
Go to Configure (click on the tool icon) -> go to the `Key Value Maps` tab and create one.
82+
83+
84+
![Create a Key Value Map](key_value_map.png)
85+
86+
2. Put `CPICredentials` as the name and declare your CPI credentials (username and password). Check the `Encrypt Key Value Map` box.
87+
88+
89+
90+
![Create a Key Value Map](create_cpi_credentials.png)
91+
92+
### Add the Verify API Key Policy
93+
94+
Go back to your API policies.
95+
96+
In the TargetEndpoint, add 3 policies in the PreFlow.
97+
98+
1. Add a Key Value Map Operations policy, name it and leave it as a Incoming Request. This is needed to get the CPI Credentials created before, as a Key Value Map. Like this:
99+
100+
![Create a Key Value Map](key_value_policy.png)
101+
102+
Copy and Paste this script (you will be referencing 'CPICredentials' with the mapIdentifier parameter):
103+
104+
<!-- cpes-file db/schema.cds -->
105+
```XML
106+
<KeyValueMapOperations mapIdentifier="CPICredentials" continueOnError="false" enabled="true" xmlns="http://www.sap.com/apimgmt">
107+
<!-- Read parameter with key "username" and assign its value to private variable BasicAuthUsername-->
108+
<Get assignTo="private.BasicAuthUsername" index='1'>
109+
<Key><Parameter>username</Parameter></Key>
110+
</Get>
111+
<!-- Read parameter with key "password" and assign its value to private variable BasicAuthPassword-->
112+
<Get assignTo="private.BasicAuthPassword" index='1'>
113+
<Key><Parameter>password</Parameter></Key>
114+
</Get>
115+
<Scope>environment</Scope>
116+
</KeyValueMapOperations>
117+
```
118+
Like this:
119+
120+
![Set up the Key Value Map Policy](setup_key_value_policy.png)
121+
122+
2. Add a Basic Authentication policy, name it and leave it with the `IncomeRequest` stream. Like this:
123+
124+
![Add a Basich Authentication Policy](basic_authentication_policy.png)
125+
126+
Copy and paste this script:
127+
128+
<!-- cpes-file db/schema.cds -->
129+
```XML
130+
<BasicAuthentication async='true' continueOnError='false' enabled='true' xmlns='http://www.sap.com/apimgmt'>
131+
<!-- Operation can be Encode or Decode -->
132+
<Operation>Encode</Operation>
133+
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
134+
<!-- for Encode, User element can be used to dynamically populate the user value -->
135+
<User ref='private.BasicAuthUsername'></User>
136+
<!-- for Encode, Password element can be used to dynamically populate the password value -->
137+
<Password ref='private.BasicAuthPassword'></Password>
138+
139+
<!-- Assign to is used to assign the encoded value of username and password to a variable. This should not be used if the operation is Decode -->
140+
<AssignTo createNew="true">request.header.Authorization</AssignTo>
141+
</BasicAuthentication>
142+
```
143+
144+
You should look it like this:
145+
146+
![Set up a Basich Authentication Policy](setup_basic_authentication_policy.png)
147+
148+
3. Add a API Key verification policy to request the API Key every time the API is called (you'll later need to create the API Product and subscribe to the application to get the API Key). Add the `Verify API Key` policy, same in the PreFlow. Like this:
149+
150+
![Set up a Basich Authentication Policy](setup_basic_authentication_policy.png)
151+
152+
<!-- cpes-file db/schema.cds -->
153+
```XML
154+
<!--Specify in the APIKey element where to look for the variable containing the api key-->
155+
<VerifyAPIKey async='true' continueOnError='false' enabled='true'
156+
xmlns='http://www.sap.com/apimgmt'>
157+
<APIKey ref='request.header.ApiKey'/>
158+
</VerifyAPIKey>
159+
```
160+
161+
This should be the first policy to be triggered. Make sure it is set it up as the first one (you can change the order with the arrows in the top-right). Like this:
162+
163+
![Set up Verify API Key Policy](setup_verify_api_key.png)
164+
165+
4. Click on Update, Save and Deploy your API project.
166+
167+
![Deploy your API](deploy_api.png)
168+
169+
### Create an API Product and Subscribe to the Application
170+
171+
1. Now you need to create the API Product. Go to the pencil icon (develop), click on the `Products` tab and create one. Put this name to your Product `APIBestRunDemoProduct`.
172+
173+
![Create an API Product](create_product.png)
174+
175+
3. Reference your API to your Product.
176+
177+
![Reference your API](reference_your_api.png)
178+
179+
4. Publish your Product, click on `Publish`.
180+
181+
5. Then, go to the API Business Hub Enterprise portal.
182+
183+
![Publish you Product](publish_api.png)
184+
185+
You should be able to see it in your SAP API Business Hub:
186+
187+
![API Product](API_product.png)
188+
189+
6. Enter the API product and subscribe it by creating a new Application:
190+
191+
![Create API Application](create_api_application.png)
192+
193+
Name it `APIBestRunDemoApplication`, like this:
194+
195+
![Create API Application](create_api_application_name.png)
196+
197+
198+
7. Here's where you can get your API Key, crucial to authenticate to this API endpoint when consuming its service.
199+
200+
![Create API Application](api_key.png)
201+
202+
Now you've successfully created policies to avoid CORS issues and enable an API Key to authenticate and consume your API endpoint from SAP Integration Suite.
203+
204+
### Add additional tasks into your Integration Flow
205+
206+
Right now, as following the whole exercises, the IFlow is returning us the SMS message sent by consuming the Twilio API. But for the purpose of the exercise with SAP AppGyver, you're going to use as the return message, mainly the receipt URL when the payment transaction is successfully done with Stripe. For this, you need to save this message in the IFlow and retrieve it at the end of the IFlow.
207+
208+
Remember the previous tutorial about "Set up Write, Filter and Get Tasks in the Integration Flow…" for filtering the payment data and later calling the SAP C4C OData service? well, you are going to do the same, but in this case to retrieve the receipt URL from the Stripe request response.
209+
210+
1. Go back to SAP Cloud Integration and to your Integration Flow. Add a Write task after the Stripe Connector request reply, and configure the task as following:
211+
212+
![Add a Write Task](write_task.png)
213+
214+
2. And now add a Get task at the end of the IFlow to retrieve this returned message:
215+
216+
![Add a Get Task](get_task.png)
217+
218+
Save and deploy your IFlow.
219+
220+
Now, it's time to set up the integration with SAP AppGyver. Check out the next and final tutorial of this series: [Integrate SAP AppGyver with SAP Integration Suite](btp-integration-suite-integral-appgyver).
221+
222+
### Check your knowledge
223+
224+
### One more time, check your knowledge
305 KB
Loading
76.4 KB
Loading
190 KB
Loading
102 KB
Loading

0 commit comments

Comments
 (0)