Skip to Content
0
May 29, 2020 at 09:33 AM

Exception in execution of Bapi using SAP Cloud SDK 3.18

38624 Views

Hello All,

I am trying to execute the Bapi present in on-Premise SAP system from my cloud application. Below is the sample code which I am using:

@RequestMapping(value="/costCenters", method = RequestMethod.GET, produces ="application/json")
  private CostCenter getCostCenterDetails() throws RequestExecutionException{

  final Destination destination =DestinationAccessor.getDestination("ErpQueryEndpoint");
    final BapiRequestResult resultCostCenterDetail = new BapiRequest("BAPI_COSTCENTER_GETLIST1")
            .withExporting("CONTROLLINGAREA", "BAPI0012_1-CO_AREA", "0001")
            //.withExporting("COSTCENTER", "BAPI0012_1-COSTCENTER", chosenCostCenter.getId())
            .withImportingFields("COSTCENTERDETAIL", "BAPI0012_CCOUTPUTLIST").end()
            .withTableAsReturn("BAPIRET2")
            .execute(destination);
    return resultCostCenterDetail.get("COSTCENTERDETAIL").getAsObject().as(CostCenter.class);
  }

ErpQueryEndpoint is http destination defined in cloud platform. Screenshot attached here. While i am trying to run the end point /costCenters, It is giving me below exception:

There was an unexpected error (type=Internal Server Error, status=500).
com.sap.cloud.sdk.cloudplatform.thread.exception.ThreadContextExecutionException: org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.sap.cloud.sdk.s4hana.connectivity.rfc.exception.RemoteFunctionException: com.sap.cloud.sdk.s4hana.connectivity.exception.AccessDeniedException: 403 Forbidden. Failed to establish a trusted connection to the ERP. This may be caused by a misconfiguration of the SAP Cloud Connector or a misconfiguration of the trust certificate. Response body: Access denied to resource /sap/bc/srt/scs_ext/sap/7BAPI_COSTCENTER_GETLIST1 on system /systemurlhere:8000. In case this was a valid request, ensure to expose the resource correctly in your cloud connector. Headers: content-type: text/plain; charset=utf-8, content-length: 203.

This destination I can access on cloud foundry and on cloud connector as well. Could you please help me on how can I resolve this issue.

Attachments

destination.png (24.8 kB)