cancel
Showing results for 
Search instead for 
Did you mean: 

How to Run an ABAP Cloud Destination Locally in a SAP CAP Project?

fabi2295
Explorer
173

Aqui está o post atualizado em inglês:


How to Run an ABAP Cloud Destination Locally in a SAP CAP Project?

Context

I am working on a SAP CAP project with a hybrid configuration, and I need to connect to an ABAP Cloud destination locally. The destination is properly configured, and I can reach it using curl.

Destination Configuration (package.json - hybrid profile)

Sensitive details are replaced with ***:

{
  "requires": {
    "[hybrid]": {
      "auth": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "https://api.cf.***.hana.ondemand.com",
          "org": "***",
          "space": "dev",
          "instance": "teste-auth",
          "key": "teste-auth-key",
          "resolved": false
        },
        "kind": "xsuaa-auth",
        "vcap": {
          "name": "auth"
        }
      },
      "destinations": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "https://api.cf.***.hana.ondemand.com",
          "org": "***",
          "space": "dev",
          "instance": "teste-destination",
          "key": "teste-destination-key",
          "resolved": false
        },
        "kind": "destinations",
        "vcap": {
          "name": "destinations"
        }
      },
      "connectivity": {
        "binding": {
          "type": "cf",
          "apiEndpoint": "https://api.cf.***.hana.ondemand.com",
          "org": "***",
          "space": "dev",
          "instance": "teste-connectivity",
          "key": "teste-connectivity-key",
          "resolved": false
        },
        "kind": "connectivity",
        "vcap": {
          "name": "connectivity"
        }
      },
      "API_PESSOAS": {
        "credentials": {
          "destination": "abap-cloud-default_abap-trial-***",
          "forwardAuthToken": false
        }
      }
    }
  }
}

curl Test

When running the following command:

curl -v abap-cloud-default_abap-trial-***.dest

I get a successful response (HTTP 200), confirming that the destination is reachable:

{"@odata.context":"$metadata","value":[{"name":"ZC_PESSOAS","url":"ZC_PESSOAS"}]}

Issue with cds watch --profile hybrid

However, when I try to run cds watch --profile hybrid to connect from CAP to the ABAP Cloud destination, I receive the following error:

Error during request to remote service: Failed to load destination. 
Caused by: No user token (JWT) has been provided. 
This is strictly necessary for 'OAuth2UserTokenExchange'.

External Service Connection Code

This is how I am executing the external connection:

try {
  const ExternalPessoas = await cds.connect.to('API_PESSOAS');
  return await ExternalPessoas.run(req.query);
} catch (error) {
  LOG.error(error);
}

Works Fine in Deployed Version

When deployed to SAP BTP, the destination works correctly, and I receive the expected response:

{
  "@odata.context": "$metadata#Pessoas",
  "@odata.metadataEtag": "W/\"20250311171855\"",
  "value": [
    {
      "Cpf": "12345678911",
      "Nome": "Fabricio",
      "Idade": 29,
      "SAP__Messages": []
    }
  ]
}

Question

  • How can I correctly authenticate and run this ABAP Cloud destination locally in my SAP CAP project using the hybrid profile?
  • Is there a way to pass the necessary JWT token in local development?
  • Do I need to configure something extra in my XSUAA or connectivity settings to make it work?

Any insights or suggestions would be greatly appreciated! 🚀

View Entire Topic
rotem_puterman-sobe
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi,
If you are using SAP Business Application Studio for developing your application I suggest you to use the Run Configuration panel to create appropriate configuration to test your application with live data from your destination (and also possibly connect to XSUAA service instance for authentication). 
See documentation here: https://help.sap.com/docs/bas/developing-business-applications-using-productivity-tools/testing-appl...

Make sure that your devspace is of type "Full-Stack Application Using Productivity Tools" which allows you working with Run Configuration tool in addition to more tools which are designed to enhance your productivity while developing CAP applications. 

Thanks,
Rotem