TB1300 04 DI API Business Objects
TB1300 04 DI API Business Objects
PUBLIC
Business Objects: Topic Objectives
Business objects:
Represent the functionality of SAP Business One application.
Follow appropriate business logic and will not compromise data integrity.
Any data access using business objects is platform and release-independent.
Object:
<Business Object>
Methods:
Add a new Object
+Add
+GetByKey Get the object by key
+Remove Remove the object (if possible)
+SaveXML Save the object as XML file
+Update Update the object
Properties:
+ CardCode Sets or returns the customer or vendor name
Child Objects:
+ Browser Allows navigation/browsing over records
+ UserFields A collection of fields objects, which are user defined fields
+ Document_Lines Represents the line entries of a document
© 2019 SAP SE or an SAP affiliate company. All rights reserved. ǀ PUBLIC 4
Business Objects: Architecture – Child Objects
Object:
<Child Object>
Methods:
+Add Add a new record
+SetCurrentLine Set the current line
+Delete Delete a record (available for most part of objects)
Properties:
…
oBP.CardCode = "C08154711"
oBP.CardName = "James Tiberius Kirk"
oBP.CardType = SAPbobsCOM.BoCardTypes.cCustomer
'…
oOrderDoc.Lines.ItemCode = "A00002"
oOrderDoc.Lines.Quantity = 1
XML Advantages:
Enable exchanging large-scale data between SAP Business One company database and
external systems
Standard
Cheap
Convenient
Simple
Company object
■ oCompany.GetBusinessObjectFromXML (FilePath_OR_XMLString, Index)
■ oCompany.GetXMLelementCount (FilePath_OR_XMLString)
■ oCompany.GetXMLobjectType (FilePath_OR_XMLString, Index)
■ oCompany.GetBusinessObjectXmlSchema (ObjectType)
Business objects
■ oBusinessObject.SaveXML (FilePath_OR_XMLString)
■ oBusinessObject.Browser.ReadXML (FilePath_OR_XMLString)
Use ReadXML to update an existing object
XML export type – specifies the types for exporting data, e.g. to export read-only data
■ oCompany.XmlExportType = SAPbobsCOM.BoXMLExportTypes.xet_ExportImportMode
Method UpdateFromXML
• You can remove sub-object lines from the object via the XML file.
Available for
Items object
BusinessPartners object
Documents object
ProductTrees object
oCompany.XmlExportType = SAPbobsCOM.BoXmlExportTypes.xet_ExportImportMode
iRetVal = oBP.Add()
‘…handle error…
End If
Next ii
Global Transaction
Allows perform several data operations and then a full commit or rollback based on specific criteria
If any of the data operations fails, the global transaction will be rolled-back entirely
Start and end of a global transaction can be managed by using the Company object:
oCompany.StartTransaction()
Boolean oCompany.InTransaction
oCompany.EndTransaction([wf_RollBack / wf_Commit])
Start Transaction
Run a list of
operations on the DB
Challenge
■ There are no DI API data-driven notifications (only FormData events in the UI API – see UI API presentation)
■ Adding SQL triggers at the database level is not permitted!
Solution
■ Enable the Transaction Notification in SAP Business One (Administration > System Initialization > General Setting > Service).
This can be achieved by setting the EnableTransactionNotification property on the CompanyInfo object.
■ Insert the required object to the <companyDB>.CTNS table.
■ Consume the events from SBOCOMMON.SEVT
SAP
■ After handling the events, clean up the entry from SBOCOMMON.SEVT
not e 13 2
04 84
Important remarks:
■ The Integration Framework for SAP Business One can use the SBOCOMMON.SEVT table as well.
The table is cleaned automatically by the EventSender service.