cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Add-on using DI API vs Service Layer - How to decide?

Thiago_Moura
Explorer
4,627

Hello!

I noticed that a lot of add-ons are made using DI API, as well as Service Layer.

My doubt is: How to decide which one is better to develop an add-on (backend)? What features is important to consider to decide between DI API and Service Layer?

Thank you!

View Entire Topic
AlyShorbagy
Discoverer

Hi Thiago,

There are several factors that can help you in your decision:

Performance: The Service Layer is usually faster than the DI API for most operations because it works directly with the database, reducing overhead. However, this speed advantage may not always be noticeable, especially for small datasets.

Protocol: The DI API uses the COM protocol which is compatible with UI API and Add-On creation, while the Service Layer uses the more modern and widely adopted HTTP/HTTPS protocols. HTTP/HTTPS allows for better integration with modern technologies, such as web-based and cloud-based applications.

Supported Operations: The DI API supports a wider range of operations compared to the Service Layer. However, the Service Layer does cover most of the common operations. If you need to perform operations not supported by the Service Layer, you may need to use the DI API.

Concurrency: The Service Layer supports multi-threading, meaning it can handle multiple requests concurrently. The DI API is single-threaded, which can be a limiting factor for high-concurrency applications.

Complexity: The DI API has a steeper learning curve compared to the Service Layer due to its extensive feature set and lower level of abstraction. If you need to develop an add-on quickly and the Service Layer supports all the operations you need, the Service Layer may be a better choice.

Version of SAP Business One: The Service Layer is only available from SAP Business One 9.1 PL09 and later for SAP HANA only. If you are using an earlier version, or if you're not using SAP HANA, then you will need to use the DI API.

In conclusion, the best choice depends on your specific needs and constraints. If you are developing a web-based or multi-threaded application, or if performance is a crucial factor, the Service Layer may be the better choice. However, if you need to use features not supported by the Service Layer or if you are using an earlier version of SAP Business One, the DI API.

Thanks,

Aly Elshorbagy

Thiago_Moura
Explorer

Perfect, Aly!

I'm very grateful!