To test and troubleshoot the ERP Integration of your application, it's beneficial to test the functionality before deploying it. You can test the application in a completely local setup or use the destinations and services in your SAP BTP subaccount to connect to the systems while your application runs locally. A local setup involves running the application within the SAP Business Application Studio, for example, using cds watch, without needing to deploy it.
The goal of local tests is to connect to integrated ERP systems without using destinations. Therefore, you need to adjust the code slightly, as shown below:
-
To edit the development credentials in the package.json file, replace the placeholders
{{b1-hostname}},{{test-user}},{{test-password}}with the information of your ERP test system:"cds": { "requires": { "b1_sbs_v2": { "kind": "odata", "model": "srv/external/b1_sbs_v2", "csrf": true, "csrfInBatch": true, "[development]": { "credentials": { "url": "https://{{b1-hostname}}/b1s/v2", "authentication": "BasicAuthentication", "username": "{{test-user}}", "password": "{{test-password}}" } }, "[production]": { "credentials": { "destination": "b1", "path": "/b1s/v2" } } } } }
-
The Create Project or Create Purchase Order buttons depend on the setup of the destinations. Once you configure the destinations correctly and deploy the application to the SAP BTP Cloud Foundry runtime, the button for creating projects becomes active.
To test this button locally, edit the ERP-specific connector, for example, for SAP S/4HANA Cloud connectorB1.js. In method createConnectorInstance, change the value of connector.isConnectedIndicator to true after the connector instance is created:
const connector = new ConnectorB1(data); connector.isConnectedIndicator = true;
-
Run the command
cds watch --profile developmenton the command line interface. This starts the web application with the above development configuration.
In addition to testing the application in a strictly local setup, you can use a hybrid setup as described in the capire documentation about hybrid testing. Testing in a hybrid setup, runs the application locally (in SAP Business Application Studio), but using services on the SAP BTP, running in the Cloud Foundry runtime and destination definitions on the SAP BTP. This setup behaves more like a productive setup while still offering the flexibility and simplicity of a locally run application. However, testing your application in a hybrid setup requires some configuration in your SAP BTP subaccount and your development environment in SAP Business Application Studio.
-
Create or copy existing destinations used for your ERP integration into your SAP BTP subaccount used for development.
-
For development purposes, use a simple authentication type for the destination, like Basic Authentication.
-
Set up a Cloud Connector that is used to connect to the on-premise destinations.
-
Enable the Cloud Foundry environment:
-
Open the Overview in your SAP BTP subaccount for development.
-
Choose Enable Cloud Foundry.
-
In the enablement dialog, choose the following attributes:
- Environment: Cloud Foundry Runtime (Selected by default and cannot be changed)
- Plan: build-runtime
- Landscape: cf-eu10
- Instance Name: for example
- Org Name: dev
-
Choose Create.
-
-
Check the entitlements of the subaccount for the SAP Destination Service and for the SAP Connectivity Service. In case they are missing, you need to add them.
Note: You do not have to assign any quota/memory to this Cloud Foundry environment.
-
Open your local project in your SAP Business Application Studio instance.
-
Login to your Cloud Foundry space in your development SAP BTP subaccount by using
cf login. -
Set up your local application to connect to the destinations configured in your SAP BTP subaccount:
-
Cloud Destinations:
-
Create a service instance and a service key of the SAP Destination service:
cf create-service destination lite <service-name>
cf create-service-key <service-name> <key-name> -
Bind the SAP Destination service to your local application:
cds bind -2 <service-name>:<key-name>
-
-
On-premise Destinations:
-
Create a service instance and a service key of the SAP Destination service:
cf create-service destination lite <service-name>
cf create-service-key <service-name> <key-name> -
Bind the SAP Destination service to your local application:
cds bind -2 <service-name>:<key-name> -
Create a service instance and a service key of the SAP Connectivity service:
cf create-service connectivity lite <service-name>
cf create-service-key <service-name> <key-name> -
Bind the SAP Connectivity service to your local application with an additional configuration to use the HTTP-Proxy of the SAP Business Application Studio instead of the default HTTP-Proxy (CAP documentation: Hybrid Testing > Overwrite Cloud Service Credentials):
cds bind -2 <service-name>:<key-name> --credentials '{ "onpremise_proxy_host": "127.0.0.1", "onpremise_proxy_http_port": "8887" }'The command
cds bindautomatically creates the file cdsrc-private.json if it does not already exist. In the file, the local bindings of the services are created in the hybrid profile per default. An example of a cdsrc-private.json can look like this:{ "requires": { "[hybrid]": { "destinations": { "binding": { "type": "cf", "apiEndpoint": "<your api endpoint>", "org": "<your org>", "space": "<your space>", "instance": "poetry-slams-destination", "key": "poetry-slams-destination-key", "resolved": false }, "kind": "destinations", "vcap": { "name": "destinations" } }, "connectivity": { "binding": { "type": "cf", "apiEndpoint": "<your api endpoint>", "org": "<your org>", "space": "<your space>", "instance": "poetry-slams-connectivity", "key": "poetry-slams-connectivity-key", "resolved": false, "credentials": { "onpremise_proxy_host": "127.0.0.1", "onpremise_proxy_http_port":"8887" } }, "kind": "connectivity", "vcap": { "name": "connectivity" } } } } }
-
-
-
Set up hybrid-mode in your local application:
-
Usage of credentials of the remote services in your cds configuration (Example: Remote service to SAP Business One in the package.json file):
"requires": { "cds": { "b1_sbs_v2": { "kind": "odata", "model": "srv/external/b1_sbs_v2", "csrf": true, "csrfInBatch": true, "[development]": { "credentials": { "url": "https://{{b1-hostname}}/b1s/v2", "authentication": "BasicAuthentication", "username": "{{test-user}}", "password": "{{test-password}}" } }, "[hybrid]": { "credentials": { "destination": "b1", "path": "/b1s/v2" } }, "[production]": { "credentials": { "destination": "b1", "path": "/b1s/v2" } } } } }
-
Change the default behavior of services, in case they do not need to be tested in hybrid-mode (Example: SAP Audit Log service):
Per default, the SAP Audit Log service is configured to be of kind "audit-log-to-restv2" in a hybrid setup (see CAP Audit Logging Guide). To overwrite this configuration, you can set the following attribute in your cds configuration:
"requires": { "cds": { "[hybrid]": { "audit-log": { "kind": "audit-log-to-console" } } } }
-
-
Start your local application in hybrid-mode:
cds watch --profile hybrid
The information above is specific to the ERP integration. Find additional hints in the tutorials Ensure Code Quality, Test, and Troubleshoot the Application and Test and Troubleshoot Multitenancy.
For more information about hybrid testing, check out the chapter Hybrid Testing in the official CAP documentation.