SDK Interview Questions : Part 1
In this part, we have listed SDK Questions and answers.
Question 1: What are the two main parts of the SAP B1 SDK?
- UI API (User Interface API): This is used to access, create, and modify the user interface of SAP Business One. Its primary DLL is SAPbouiCOM.dll.
- DI API (Data Interface API): This is used for working with the business data and objects of SAP Business One, such as adding or updating business partners, sales orders, or invoices. Its primary DLL is SAPbobsCOM.dll.
Question 2: What is the "Company" object in the DI API and what is its purpose?
The Company object represents a connection to a specific SAP Business One database. Its primary uses include
- Connecting to and disconnecting from a company database
- Accessing all DI API business objects, such as Business Partners or Items.
- Managing database transactions
Question 3: How do you develop a custom form using the SAP B1 SDK?
The standard way to develop a custom form is by using the SAP Business One Studio, which is an add-on provided by SAP.
Question 4: What is BubbleEvent and how is it used in an event handler?
BubbleEvent is a boolean property within an event's parameter (pVal). When set to False, it stops the event from propagating further to the standard SAP Business One application logic. This is crucial for customizing or blocking default behavior, such as preventing a user from closing a form or saving an invalid record.
Question 5: How do you execute a custom SQL query in the SAP B1 SDK?
To execute a SQL query, you must use the Recordset object from the DI API. You would first instantiate the Recordset object, then use its DoQuery method, passing your SQL string as an argument. This is used for reading data directly from database tables, which can be much faster than using business objects for retrieval.
string getDocEntry1 = "SELECT * FROM <table>";
SAPbobsCOM.Recordset rec1 = (SAPbobsCOM.Recordset)SBOMain.oCompany.GetBusinessObject(BoObjectTypes.BoRecordset);
rec1.DoQuery(getDocEntry1);
Question 6: Explain the function of EventFilters and why they are important for performance.
EventFilters are used to specify which UI events your add-on is interested in processing. By default, if no filters are set, all UI events trigger and are sent to your add-on, which can negatively impact performance. Using EventFilters ensures that only the relevant events are captured and handled, which significantly improves the add-on's efficiency and responsiveness. .
SAPbouiCOM.EventFilters filters = new SAPbouiCOM.EventFilters();
Question 7: What is the difference between DI API and DI Server? When would you use one over the other?
- DI API: A COM-based interface that runs locally on the client machine and is best suited for add-ons that need to react to client-side events or modify the user interface. It has full access to UI API functionality
- DI Server: A SOAP-based web service that runs on the server. It is ideal for high-volume or heavy-duty operations that run in the background without a user interface, such as batch updates, integrations with other systems, or web applications. It provides better performance and scalability for server-side tasks through connection pooling
Question 8: How would you update a UDF (User-Defined Field) on an existing document like a Sales Order?
- Connect to the Company object via the DI API.
- Instantiate the appropriate business object, such as Documents with BoObjectTypes.oOrders.
- Retrieve the specific document by its key using the GetByKey method.
- Access the UserFields property of the object's GeneralService
- Set the value of your specific UDF.
- Call the Update method on the document to save the changes
- Check for any errors after the update and handle them gracefully.
Question 9: Explain the different types of DataSources available in the UI API.
The UI API has three types of data sources.
- DBDataSources: Represents a connection to a specific database table. It's used to bind UI controls directly to database fields.
- UserDataSources: Represents a temporary, in-memory data source. It is used for handling data that is not yet committed to the database or for fields that are not tied directly to a database column.
- DataTables: Represents a temporary table in memory that can be populated with data, including the results of SQL queries. It provides advanced data manipulation capabilities for UI controls like Matrix and is not tied to a specific business object.
Question 10: How do you handle database transactions within the SDK, and why is it important
The SAP Business One Data Interface (DI) API supports two primary types of transactions.
- Single Transactions
- Definition: A single transaction involves a series of operations on one or more business objects that are committed to the database as a single, atomic unit.
- Mechanism: By default, each call to a DI API method for adding, updating, or deleting a business object can be treated as a single transaction, or you can manually commit them if they are not part of a global transaction.
- Example: Adding a new customer or creating an invoice for a specific order would be examples of single transactions, especially if they are not part of a larger global transaction.
-
Global Transactions
- Definition: Global transactions are a more comprehensive mechanism to group multiple, related operations into one logical unit of work, guaranteeing that all operations succeed or fail together.
- Initiation: You start a global transaction using the StartTransaction() method of the Company object.
- Atomic Operation: All changes made to business objects after StartTransaction() are held until EndTransaction() is called.
- Failure Handling: If any operation within a global transaction fails, the entire transaction is automatically rolled back, ensuring the database remains in a consistent state.
- Ending: A global transaction is explicitly ended with the EndTransaction() method.
- Benefits: This high level of database isolation ensures that other transactions cannot interfere with the operations within the global transaction, preventing data corruption.
- Example: A complex scenario where you need to create a sales order, its corresponding delivery, and then the invoice based on that delivery, all as one atomic process, would benefit from a global transaction. Handling transactions is important for maintaining data integrity. It ensures that a sequence of database operations is treated as a single, atomic unit. If any part of the sequence fails, the entire set of changes can be rolled back, preventing partial or inconsistent data from being saved.