cancel
Showing results for 
Search instead for 
Did you mean: 

How to implement ODATA on Bapi?

04-28-2025 10:38 AM
walkerist79 Participant
3279 views 3 comments
0 Likes
SAP Managed Tags
Subscribe

I'm new with ODATA. I have created a BAPI, CDS Views and want to use them together. Can I consume or implement ODATA on Bapi or is it the other way around? Is it possible to implement it using RAP?

 

0 Likes

Accepted Solutions (0)

Answers (2)

Answers (2)

CLTGravesen
Active Participant

Hello @walkerist79 ,

Without more information, it is a bit difficult to answer your question fully.

If my answer is not helpful, maybe you can add some information about your CDS view, the BADI and what you were hoping to achieve?

But I can give you some general pointers.

Is it possible to consume a BAPI in a CDS View?

In general: No. The CDS views are created to be "Database Agnostic", meaning that they have to work on some MySQL server as well as a HANA server, so including ABAP code is not supported directly in the view. 

Again, it comes down to what your BADI does. If the logic can be replicated in a CDS view with the functions available, you might as well 'do it again'. However, I imagine that if it could, you wouldn't be asking 🙂 

Is it possible to consume a BAPI in an OData service? 

Absolutely! 
If you are building your OData service from scratch, you can do pretty much anything, including a 'select' from your CDS view. 

You can follow this guide: How to create or Building a Custom SAP Gateway Service OData with SEGW.

Is it possible to implement using RAP?

Again, absolutely! 
If you are new to RAP, I recommend you just start from the top of the official documentation, but the chapter on "Developing Actions" might be closer to what you are looking for. 
Here, you can define custom actions, and can implement them as you see fit in an ABAP class and consume your BADI, while still reading your CDS views. 

 

Conclusion

Well, it depends on what you want. 
Consuming a BADI in a CDS view is not supported, however there are ways to combine them. Either with a custom OData Project, or through RAP.  However of these are looong ways around, if you are just starting out with either.

So, if it's for a client, I would suggest you do your best to replicate the functionality with the standard CDS library. If it is just for fun / learning, it depends on how much of a challenge you are in for. 
An OData project is - arguably - easier to start, but RAP is a powerful framework, if you can get your head around it. 

Hope this helps 🙂

Sandra_Rossi
Active Contributor
0 Likes
Typo: "BADI" (Business Add-In) is not BAPI (Business API).
NooruBohra
Active Participant
0 Likes

If you have a custom entity then you can go with Unmanaged implementation and can call released API instead of BAPI.
If you want to use ABAP then you can create a project in SEGW, get your CDS' reference in project and override the create method. There you can write the BAPI Code.