cancel
Showing results for 
Search instead for 
Did you mean: 

DI API (JCO) Development Environment

0 Kudos

Hello all,

my company is migrating to SAP Business One and I need to start understanding how to interact with SAP with DI API.

First I saw that the preferred languages to do this were C# and VB and that there was a Java connector (which I would like to use):

- Can the connection be made with other languages? If yes, which ones and how?

- Is there any difference between using C# and Java, is there anything possible with one that would not be possible with the other?

What is the normal development environment like for developers when they want to develop?

- Do they have to have an SAP client installed on their machines to develop?

- If not, how do you set up the development environment to use DI API?

- Is .jar sufficient outside the SAP client to make the connection?

Thank you for your reading and your answers

ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi guillaumehanotel,

Here is a Java program to make a company connection in SAP Business One:

import com.sap.smb.sbo.api.ICompany;
import com.sap.smb.sbo.api.SBOCOMConstants;
import com.sap.smb.sbo.api.SBOCOMUtil;
import com.sap.smb.sbo.api.SBOErrorMessage;


public class SBOClient {


    public static void main(String[] args) {
        ICompany datasource = SBOCOMUtil.newCompany();
        datasource.setCompanyDB("testDB");
        datasource.setDbUserName("dbUserName");
        datasource.setDbPassword("dbPassword");
        datasource.setServer("Server");
        datasource.setUserName("username");
        datasource.setPassword("pwd");
	datasource.setLicenseServer("LicenseServer:30000");
        datasource.setDbServerType(SBOCOMConstants.BoDataServerTypes_dst_MSSQL2017);
        datasource.setUseTrusted(Boolean.FALSE);
        datasource.setLanguage(SBOCOMConstants.BoSuppLangs_ln_German);
            
        int rc = datasource.connect();


        if(rc != 0) {
            SBOErrorMessage errMsg = datasource.getLastError();
            System.out.println("ErrorCode: " + errMsg.getErrorCode());
            System.out.println("ErrorMessage: " + errMsg.getErrorMessage());
        }


        if(datasource != null && datasource.isConnected()) {
            datasource.disconnect();
        }
        System.exit(0);
    }
}

Also, refer to the following link: https://wiki.scn.sap.com/wiki/display/Snippets/JCO+for+dummies?original_fqdn=wiki.sdn.sap.com

Hope it helps!

Kind regards,

ANKIT CHAUHAN

SAP Business One Support

Accepted Solutions (0)

Answers (3)

Answers (3)

maik_delly
Active Contributor

Hi John,

since nobody answered, I try to..

You can establish a B1 DI API connection by using all kind of languages. Basically you need to be able to call COM objects. This said, almost all information / help / documentation is .NET C# and some VB.NET. I hardly have seen Java related content.

To be able to develop you have to install B1 SDK on your development machine. You also would need access to a B1 installation - best practise: install B1 locally but remote server is also working.

From your description it is not clear what you want to achieve/do, but my best guess is that you want to create some kind of interface to interact with business objects. If so, I would suggest to have a look into Service Layer, it is a REST API connector for B1, providing almost all DI API functionality.

best regards,

Maik

MHollender
Explorer
0 Kudos

Hi John!

If you are migrating to a recent version, you can use the Service Layer, not DI. It is faster and more reliable, it was available for HANA for a while and for SQL from 10 PL02. My general impression is that the DI is slowly getting deprecated and the SL is the future.

With the Service Layer you have a generic ODATA / JSON web service that you can access from any programming language. No client installation or anything needed.

What you need to consider that there is essentially two kind of development:

- when you have to add forms, buttons, functionality to be directly accessed by the user in the B1 client. This is done with the SDK and I don't knowm much about this, this is traditionally done in C# or VB and via the DI, but there are these new Fiori widgets or what that are HTML5 and can call the Service Layer, I don't know much about this

- If you are writing data to B1 from an external program or source, this is when the SL comes really handy. You could also take a look at the Integration Framework.

So to sum it up, if you do not have to directly modify the client by adding buttons or stuff like that into it, but accessing B1 from an external program, the SL is a better choice than the DI.

0 Kudos

Thank you very much Ankit !

Is there any chance that someone would be able to answer my questions in my first message ?

Thank you