Enterprise Resource Planning Blogs by Members
Gain new perspectives and knowledge about enterprise resource planning in blog posts from community members. Share your own comments and ERP insights today!
cancel
Showing results for 
Search instead for 
Did you mean: 
rasmuswulff_jensen
Active Contributor
16,309
One of the first thing you learn when you learn the SAP Business One SDK is how to make a DI-API. But if you learned this many years ago and never look at the recent samples in the SDK Help I will claim there is a good chance that you are doing it ”wrong”.

Let's have a closer look at the DI-API connection properties.

On the Company object we have the following 10 Properties dealing with the connection:

  1. Server

  2. CompanyDB

  3. DbServerType

  4. Username

  5. Password

  6. Language

  7. LicenseServer

  8. UseTrusted

  9. DbUsername

  10. DbPassword


So since there are 10 Properties you might think you need to set all 10 of them, but this is not true. You actually only need to set the first 5 of them (6 if you want the error messages in other languages than English)... rest are not needed and are only there for backward compatibility.

OK, you might already know this but you are setting the rest “just in case”... well, that is actually a really bad idea and here is why.

The first reason off cause is you might by mistake set one of the properties wrong leading to a connection error, but even if everything is set correct there are actually bad side-effects.

Let's see a sample of that:



If everything is right you will of cause get a result back of 0 (no error code).

But let us explore a scenario where the user "TEST" is locked



 

With our above code, we get this good error message telling us what is wrong:



 

Lets now explore the same issue in a scenario where you set the DbUsername and DbPassword in addition to the above code (or some of the other fields like many people do out there because of the "more is better mentality")

Well, "more is not better", is actually worse despite the data being right. Here is the result:



Gone are the nice clear error message of "User is Locked" and are replaced with the generic and frankly rather unhelpful -4008 error code "Login SLD Fail, make sure the Server, Company and user Credentials are correct" ... Good luck finding that the real issue is actually a locked user!

 

So when you do DI-API Connections "less is better"


 

But wait: How can I be sure you are correct?

Well, just have a simple look at the DTW Login Screen from SAP



It has exactly the 6 mentioned properties, meaning if they do not ask for more so shouldn't you!

 

If you want in general to learn more about the different DI-API Error codes and what they mean, this is a great resource on how to troubleshoot

 

 
5 Comments
Labels in this area