0% found this document useful (0 votes)
13 views12 pages

TB1300 07 DI API Java Connector

tb sap sdk

Uploaded by

ICE MAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views12 pages

TB1300 07 DI API Java Connector

tb sap sdk

Uploaded by

ICE MAN
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

TB 1300 - SAP Business One SDK

Data Interface API – Java Connector


May, 2023

PUBLIC
Java Connector: Topic Objectives

After completing this topic, you will be able to:


▪ Describe how to use and troubleshoot the Java Connector (JCo)

Public 2
Java Connector: Architecture

Client Server
JAVA application
…can deal with COM
(For DI API only!) SBO-Common

Observer.dll
SAP Business One
Java Connector

DI API Interface
(SAPbobsCOM.dll)

Implementation
(OBServerDLL.dll) Company
Company
Company

Public 3
Java Connector: Details

Main Java classes


▪ java.lang.Object
▪ java.lang.Throwable
▪ com.sap.smb.sbo.api.SBOCOMUtil

Package hierarchy
▪ com.sap.smb.sbo.api
▪ com.sap.smb.sbo.util
▪ com.sap.smb.sbo.wrapper

Difference to DI API
▪ Create new object - “new<Object name>”
▪ com.sap.smb.sbo.util

to add new records are created using “new<Object name>” of the SBOCOMUtil class instead of using ICompany object’s
“getBusinessObject”!

E.g. newBusinessPartners must be used when you want to add a business partner!

Public 4
Java Connector: Installation

The JCo always connects to latest version of the DI API


Public 5
Java Connector: Usage

Add sboapi.jar and sbowrapper.jar in the JAVA application

Public 6
Java Connector: Example
Connect to the Company

import com.sap.smb.sbo.api.*;
……
company = SBOCOMUtil.newCompany();
company.setServer("(local)");
company.setUseTrusted(new Boolean(true));
company.setCompanyDB("SBODemoSK");
company.setUserName("manager");
company.setPassword("manager");
……
rc = company.connect();
if (rc == 0) { System.out.println("Connected!");
} else { errMsg = company.getLastError();
System.out.println("Failed: "+ errMsg.getErrorMessage()+ " "+ errMsg.getErrorCode());
}
return rc;

Public 7
Java Connector: Example
Add a Business Partner

import com.sap.smb.sbo.api.*;
public static IBusinessPartners bp;
……
bp = SBOCOMUtil.newBusinessPartners(cmp);
bp.setCardCode("JCO1");
bp.setCardName("JCO Test1");
bp.setCardType(Integer.valueOf(0));
rc = bp.add();

Public 8
Java Connector: Example
Update a Sales Order

import com.sap.smb.sbo.api.*;
public static IDocuments order;
……
order = SBOCOMUtil.getDocuments(cmp, Integer.valueOf(17), Integer.valueOf(138));
order.setComments("JCO test1");
rc = order.update();

Public 9
Java Connector: Example
RecordSet

import com.sap.smb.sbo.api.*;
ICompany com = null;
IRecordset RecSet = null;
String FldName, String FldVal;
Object index;
String sQueryItemList1 = "Select * From OITM";
RecSet = SBOCOMUtil.runRecordsetQuery(conn.company,sQueryItemList1);
int Count = RecSet.getFields().getCount().intValue();
while (RecSet.isEoF().equals(new Boolean(false))) {
for (i = 0; i < Count; i++) {
index = new Integer(i);
FldName = RecSet.getFields().item(index).getName();
FldVal = String.valueOf(RecSet.getFields().item(index).getValue());
RecSet.moveNext();
}
}

Public 10
Java Connector: Troubleshooting

Test the issue in DI API first to identify, whether the issue is caused by the DI API

▪ If the issue cannot be reproduced in DI API, then the issue is caused by the Java Connector

▪ If the issue CAN be reproduced in DI API, then it’s a common issue for JCO and DI API

SAP Notes
1313297 : How to use SAP Business One Java Connector (JCO)
2550515 : How to Use getDataInterface Through JCO

Public 11
Thank you.
Contact information:

© 2023 SAP SE or an SAP affiliate company. All rights reserved. See Legal Notice on www.sap.com/legal-notice for use terms, disclaimers, disclosures, or restrictions related to SAP Materials for general audiences.

You might also like