cancel
Showing results for 
Search instead for 
Did you mean: 

SAP CAP BAS - Call BAPI via OData

gadirov
Participant
0 Kudos

Dear SAP experts,

since I plan to call a BAPI from SAP ERP backend via my CAP ( = Cloud Application Programming Model) application on SCP, I wanted to ask you what approach might be the best. We plan to expose the BAPI via OData Service which we want to call from our CDS function/event handlers. Possibly you have some examples or recommendations about the best approach. So far, I only noticed that there are some tutorials with Java examples and couldn´t find an example without java.

Thank you in advance.

thomas.jung dj.adams mariusobert

Best regards

Rufat

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate

Well first of all this is exactly something we will show at TechEd in two weeks during the developer keynote https://blogs.sap.com/2020/11/19/sap-teched-developer-keynote-dk100-the-story/

You can import the EDMX ($metadata XML response) directly into a CAP project with the cds import command:

CAP will even mock the service locally and use CSV files for mock data.

CAP uses the Cloud SDK behind the scenes to call these services

You can then use CAP CQL to write SQL like queries against the imported external service and CAP will convert those to the OData HTTP Requests.

Attila
Active Participant
0 Kudos

Hello Thomas, ( thomas.jung )

I'd like also ask for some tip complementing this topic.

I am doing some research how-to realize OData v2 batch / changeset processing by CAP calling an ECC system through BTP Destination (Service).

https://answers.sap.com/questions/13627510/sending-batch-requests-from-cap.html

I am not sure, that I should use the SAP Cloud SDK directly, or can I use the CAP as entry point, to be able to send a batch request with multiple changesets . Of course convenient changeset response parsing is a point to consider (like getting out the http status code and in case of error ECC backend messages).

I know we have the feature with proper batch and response handling in the Cloud SDK, but in case I can keep my programming "CAP only", it would be very clean and more simple from DevOps perspective.

Thank You in Advance
Best regards
Attila

thomas_jung
Developer Advocate
Developer Advocate

attila.berencsi

CAP does use the SAP Cloud SDK internally and uses it for extensive functionality to consume remote services. I'd suggest the following help document on the subject: capire - Consuming Services (cloud.sap)

Attila
Active Participant
0 Kudos

Thank You Thomas,
I will pull the trigger through CAP with some debugging to see how batches are managed, and we will see.
Attila

Answers (1)

Answers (1)

gadirov
Participant
0 Kudos

Hi thomas.jung ,

thank you very much for your quick response! I will absolute participate in the TechEd Sessions, thx for letting me know about it. Indeed, the EDMX import is a feasible way to consume external services and I already tried it out with Northwind and API Business Hub OData which worked. However, since we´ll have to integrate with SAP ERP OnPremise backend, we have to take the IDOC processing into account. It would be great to know how or if the CPI for SOAP/REST and IDOC can be called via CAP? That would be good to know, because SAP usually uses IDOCS in the ERP scenario for goods movements and FI postings.

Best regards

Rufat

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

>would be great to know how or if the CPI for SOAP/REST and IDOC can be called via CAP

CAP can call a plain REST service as well. When you define your external services in the package.json in CAP you can use kind: rest in addition to kind: odata. I'd suggest reading more in the Generic HTTP Client section of the SAP Cloud SDK: https://sap.github.io/cloud-sdk/docs/js/features/connectivity/generic-http-client