cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAP identify runtime environment / system

T1mey
Participant
0 Kudos

Hi @all,

I have an action in my CAP application which is triggering a call to an external application.

The logic is using the destination service to connect to the target system.

const myApi = await cds.connect.to("MYDESTINATION");

The payload I need to send to the destination differs from runtime environment (or destination URL).

Means JSON payload (and the ID's inside it) on DEV, QA and PROD system (speparate BTP subaccounts) differs.

So I need to add a logic which is able to identify the system (or maybe the URL of the destination) to be able to prepare the right payload.

Is there any standard way to get this information?

Accepted Solutions (1)

Accepted Solutions (1)

maheshpalavalli
Active Contributor
0 Kudos

If the data that you want to send is rarely changed and if you want to bound it to the cap application in all subaccounts and not to the destination, you can try using user-defined variables and read them inside your cap application like shown by mariusobert

https://blogs.sap.com/2020/07/23/cloud-native-lab-1-7-ways-to-define-environment-variables/

Answers (1)

Answers (1)

gregorw
Active Contributor
0 Kudos

I don't get your issue here. Your CAP App should be deployed in 3 different subaccounts DEV, QA and PROD which then provide the same destination name, but this connection is pointing to the correspoinding backend systems. Each deployment of your app has it's own HDI Container. So your payload should already be different due to the separated persistency.

T1mey
Participant
0 Kudos

I will do an example. The destination will stay the same for DEV QA and PROD.

I need to prepare a JSON which must be send via destination service to the configured backend. The JSON will contain ID's and strings which will differ depending on the system and not persisted in my database. Persisting them could be a solution.

So on DEV the JSON looks like { guid: "123" }, for QA { guid: "129" }

I need to find a way to destingish based on the system the app is running on.

gregorw
Active Contributor
0 Kudos

I would suggest a customizing Entity with a Fiori Elements UI that is only accessible for Admins.