This is an old revision of the document!
This document discusses the Bizweaver tools used for integration with SAP Business One (SAP Business One).
This document is intended for developers of Bizweaver workflows. The integration process also requires a reasonable knowledge of SAP Business One functionality.
The following documents contain additional information that may be helpful with the development of Bizweaver workflows.
The discussions in this document assume that you are using either DI Server or DI API to communicate with SAP Business One in a SQL Server environment. These tools can also be used in a HANA environment but with some limitations. New functionality beginning in SAP Business One v9.2 may not be supported with DI Server or DI API.
For HANA environments Third Wave is recommending the use of the SAP Business One Service Layer. This is a web service-based set of APIs that support integration activities. Unfortunately, this approach is only available for HANA environments. The Service Layer is supported in Bizweaver via the Web Service tool. Information on using the Service Layer integration will be provided in a separate document.
There are two Bizweaver tools that are used for integration with SAP Business One: Mapper and SBO Update. These tools are specific to SAP Business One and are not used for any other purpose.
To illustrate the SAP Business One integration process, we will use the following workflow. In this case, the source data is coming from database tables that are associated with a Versago form. (Versago is a Web/Mobile portal application from Third Wave). However, the same principals apply for any data source (e.g. flat files, etc.).
The basic process is:
The Mapper tool is used to connect the incoming data columns to the appropriate value in SAP Business One.
An SAP Business One “object” is the document or transaction to be created. In this example we will create a Sales Order.
The list of objects will be slightly different based on the DI connection being used. When DI API is being used, the object name starts with “o”, where DI Server does not. Using Sales Orders as an example:
Double-click on the object name to continue.
The “command” is the action you wish to take. The most commonly used options are Add, Update, Close, and Cancel.
Double-click on the command to continue.
The “Object Components” are the elements of the document or transaction that will be used. Most SAP Business One objects have multiple components and you must know which ones are appropriate for your application. In most cases, you will need “Documents” and “Document_Lines” at a minimum. “Documents” is the header information and “Document_Lines” is the information in the rows grid in SAP Business One.
Double-click on the desired object component to select it.
In the following image, “Documents” and “Document_Lines” have been selected.
“Mapping” is the process of defining which SAP Business One values are to be updated from which values are provided as input. It is accomplished by using drag-and-drop to link source data values to the corresponding SAP Business One value.
The SBO Update tool handles the communication between Bizweaver and the SAP Business One DI. This is the step that updates SAP Business One.
To avoid possible DI issues, dates being passed into SAP Business One should use the YYYYMMDD format. The SQL function used to convert a date value to this format is:
CONVERT(VARCHAR,FieldName,112) AS [AliasName]
where FieldName is the column to be converted and AliasName is the name to be used on output.
For example:
CONVERT(VARCHAR,DocDate,112) AS [DocDate]
At first glance, it might appear that header data and row data should be two separate data sets. This is not the case. Each incoming record must contain all needed columns for both the header and the row.
This is where the ‘Create new record for …” options come into play. Assume you have ten records for an order, each representing an order row. This means that the source record ID, customer code, etc. are presented ten times, once on each row.
To avoid creating ten orders, one for each row, we use the “Change of value” option. This option ensures that a header record is created only when the specified key record value in the incoming data changes.
At the same time, the rows typically use the “Every record” option. This means that a row record is created for each incoming row; but within the designated header value. Note, however, that in some cases the “Change on value” option for rows may use a specific value. See Appendix D for an example of this type of usage.
When transactions are created in SAP Business One through the DI, certain values are handled just like they are in the SAP Business One application. Examples:
“Enumerators” are the values that are passed to SAP Business One to represent a certain value when using an application interface like Data Transfer Workbench (DTW) or DI Server. A different value may be passed to the interface depending on the tool being used.
The following table shows many of the common values that may be used in Bizweaver workflows.
Value is what should be used when mapping a transaction using Bizweaver.
| Enumerator | Description | Value | Member Name | DB Value |
|---|---|---|---|---|
| BoActivities | Conversation | 0 | cn_Conversation | C |
| Meeting | 1 | cn_Meeting | M | |
| Task | 2 | cn_Task | T | |
| Other | 3 | cn_Other | E | |
| Note | 4 | cn_Note | P | |
| Campaign | 5 | cn_Campaign | N | |
| boAddressType | ShipTo | 0 | bo_ShipTo | S |
| BillTo | 1 | bo_BillTo | B | |
| BoCardTypes | Customer | 0 | cCustomer | C |
| Supplier | 1 | cSupplier | S | |
| Lead | 2 | cLid | L | |
| BoDocumentTypes | Items | 0 | dDocument_Items | I |
| Service | 1 | dDocument_Service | S | |
| BoMsgPriorities | Low | 0 | pr_Low | L |
| Medium | 1 | pr_Normal | M | |
| High | 2 | pr_High | H | |
| BoProductionOrderStatus | Planned | 0 | boposPlanned | P |
| Released | 1 | boposReleased | R | |
| Closed | 2 | boposClosed | L | |
| Cancelled | 3 | biposCancelled | C | |
| BoRcptTypes | Customer | 0 | rCustomer | C |
| Supplier | 2 | rSupplier | S | |
| Account | 1 | rAccount | A | |
| BoYesNoEnum | No | 0 | tNO | N |
| Yes | 1 | tYES | Y | |
| CancelStatusEnum | Yes | 0 | csYes | Y |
| No | 1 | csNo | N | |
| Cancellation Document | 2 | csCancellation | C | |
| BoDurations | Minutes | 0 | dur_Minuts | M |
| Hours | 1 | dur_Hours | H | |
| Days | 2 | dur_Days | D | |
| BoCardCompanyTypes | Company | 0 | cCompany | C |
| Private | 1 | cPrivate | P | |
| Government | 2 | cGovernment | G | |
| LineStatusTypeEnum | Open | 0 | lst_Open | O |
| Closed | 1 | lst_Closed | C | |
| BoSvcContractStatus | Approved | 0 | scs_Approved | A |
| Frozen | 1 | scs_Frozen | F | |
| Draft | 2 | scs_Draft | D | |
| Terminated | 3 | scs_Terminated | T | |
| BoSubPeriodTypeEnum | Year | 0 | spt_Year | Y |
| Quarters | 1 | spt_Quarters | Q | |
| Months | 2 | spt_Months | M | |
| Days | 3 | spt_Days | D | |
| GetGLAccountByEnum | General | 0 | gglab_General | ? |
| Warehouse | 1 | gglab_Warehouse | ? | |
| Item Group | 2 | gglab_ItemGroup | A | |
| boOpSales | Customer Opportunity | 1 | C | |
| boOpPurchasing | Purchasing Opportunity | 2 | S | |
| boDocSpecialLineType | Text Lines | 0 | dslt_Text | T |
| Subtotal Lines | 1 | dslt_Subtotal | S | |
| batToWarehouse | “To” transfer | 1 | ||
| batFromWarehouse | “From” transfer | 2 |
As an example, assume you want to create a Service-type Sales Order. An Item-type order is created by default. To create the Service-type order you will pass a value of 1 into the Mapper for the field “DocType.”
More information on enumerators is found in the “REF DI” help file provided by SAP Business One as part of the SAP Business One SDK. Contact Third Wave support or your Third Wave consultant if you need assistance locating this file.
The information DI Server uses in the Bizweaver Mapper and SBO Update tools is obtained from SAP Business One schema files. These files contain information about the various data objects that are available, what actions can be performed on each object, and the data elements of each object. Bizweaver DI Server connections interact with SAP Business One to create its own version of these files.
From time to time it may be necessary to update these files. This generally happens automatically when a Mapper step is opened. If the files need to be updated, Bizweaver will appear to “pause” for several seconds. A progress bar is displayed while the update is executing. When the progress bar disappears, you will be able to continue working.
See SBO Schemas for more information.
Bizweaver will create DI Server schemas for SAP Business One User Defined Objects (UDO). For this process to work the UDO name assigned in the registration process cannot contain any spaces. If you have followed the instructions above and still don’t see the UDO, this is the first place to check.
Be sure to follow the manual update process described above after making this change.
The SAP Business One DI handles Business Partner Contacts and Addresses in a rather odd manner. It is not possible to simply add a new contact or address. Nor is it possible to simply update a single existing contact or address record. Instead, you must retrieve ALL appropriate records for the Business Partner. This can be done with a UNION statement in the source SQL.
Note that in both cases the function is an UPDATE, not an Add. This is a bit confusing since you are adding a new record. But you are updating the master record. The DI process takes care of figuring out which child records are additions, and which are updates.
The Bizweaver File Writer tool can be used to create a file to be used for transaction processing tracking. A common use of this type of file is to capture error information when a transaction in SAP Business One is being created.
The Custom Output File Writer option must be used to create this type of file. In this example, we are using all three sections of the custom output. The Body section of the file contains the response from the SAP Business One DI.
The values that are used in the Body section are shown below. Press F4 to get a list of all available variables.
SBO Key: WorkFlow(DI_ServiceCall).Get({RetKey})
PassFail: WorkFlow(DI_ServiceCall).Get({VALUE})
Type: WorkFlow(DI_ServiceCall).Get({RetType})
Message: WorkFlow(DI_ServiceCall).Get({MESSAGE})
Following is the output to the file based on the setup described here. The mapping was deliberately done incorrectly to illustrate the output from SAP Business One. Note that {RetKey} is blank, {Value} is “N” and {Type} is blank since the posting failed. {Message} describes the issue as it came from the SAP Business One DI.
This is the Header section Service Call for: C20000 File written at 2016-03-01 09:56:06.220 This is the Body section ===== RetKey: Value: N Type: Message: Error Code: -5002, Error Message: Subject is not specified in service call [OSCL.subject] =========== This is the Footer section
An additional workflow step could also be added to email this file to someone as an alert that a problem occurred.
A Versago form can be configured to allow the user to upload files as part of the transaction. It is possible, using Bizweaver, to use these files to create attachments in SAP Business One. The following section describes this process for two scenarios.
Note: the SAP Business One object (Business Partner, Document, etc.) must exist before attachments can be applied.
Bizweaver uses the folder C:\ProgramData\Bizweaver\SBOAttachments as a temporary work area during the processing of attachments. Confirm that this folder exists before starting. It can be created manually if it does not exist.
Uploaded files are stored in a table named TWBS_VGO_FormAttachments. This table is automatically created by the Versago process in whatever database is referenced by the form. The name of the table is fixed, and cannot be changed.
There are three columns in the table that are key to retrieving the file data and passing it to SAP Business One. These columns are: FormId, RecordId, FileName, and FileContent.
FileName is the name of the file when it was uploaded. No references to the source folder are captured since they are not relevant.
FileContent is the actual data from the file, stored as a binary record. The information in this field cannot be used without some process to convert it back to its original format.
FileName and FileContent are used in the mapping into SAP Business One.
FormId is the identifying number of the Versago form. You can find this information on the “Form Creation”tab on the from maintenance function is Versago.
RecordId is the primary key value (record ID) of the record in Versago that was created when the file was uploaded. There may be multiple records in TWBS_VGO_FormAttachments for each RecordId.
The Versago record reference by RecordId must contain some information that will allow you to reference the object in SAP Business One where the attachment will be added. In the following Example 1, the value is a Business Partner code. In Example 2, the value is the unique ID assigned to an SAP Business One Marketing document (Purchase Order, in this case) when the order is created. This link is required, but the method of obtaining the value can be accomplished in different ways. The discussion of how this is done in Versago is outside the scope of this document.
The folder that holds attachments for SAP Business One is defined in Administration > System Initialization > General Settings >
In this example, a Versago form has a field that captures a Business Partner code in its record. It also allows a user to upload associated files.
This is a very simple example to illustrate the process. In most cases you will need to add additional logic to obtain the correct record set.
SELECT t0.Id FROM TWBS_VGO_FormAttachments t0 WHERE t0.ObjectID = 11
SELECT t0.recordid, t1.CardCode, t0.Filename, t0.FileContent FROM TWBS_VGO_FormAttachments t0 INNER JOIN Attachments_BP t1 ON t0.RecordID = t1.vgoRecNum WHERE t0.Id = WorkFlow(SQLCommand_getProcessList).Get({FIELD_Id})
In this example, a Versago form is used to capture information to create a Purchase Order in SAP Business One. The order is created in SAP Business One, and then the attachments are associated with the new order.
SELECT DocEntry, CardCode FROM OPOR WHERE DocEntry = 'WorkFlow(SBOUpdate_PO).Get({RetKey})'
SELECT t0.Id FROM TWBS_VGO_FormAttachments t0 WHERE t0.ObjectID = 12 AND RecordId = WorkFlow(SQLCommand_getOrderList).Get({FIELD_vgoRecNum})
SELECT t0.Id, t0.Filename, t0.FileContent, WorkFlow(SQLCommand_getDocEntry).Get({FIELD_DocEntry}) AS [DocEntry], 'Test' AS [NumAtCard] FROM TWBS_VGO_FormAttachments t0 WHERE t0.Id = WorkFlow(SQLCommand_getAttachList).Get({FIELD_ID})
Files on disk (as opposed to files uploaded into Versago as described in Appendix F) can also be added as SAP Business One attachments. The process consists of identifying the file to be “attached,” mapping it into SAP Business One, and posting the attachment.
the SAP Business One object (Business Partner, Document, etc.) must exist before attachments can be applied.
The file to be attached must be identified as a Bizweaver Variable in the workflow. This will typically be done using a File Operations-Get step. The results of the “get” are then identified in a subsequent Variable step.
This is a technical process and should not be attempted by anyone not familiar with T-SQL stored procedures. Contact TWBS support if you need assistance.
SQL Server OLE Automation must be enabled to use this function. Information on doing this can be found by searching the Third Wave Knowledge Base for “OLE”.
The following SQL Stored Procedure illustrates how a Bizweaver workflow can be initiated from SAP Business One. The values for Bizweaver_Server:Port need to reflect your Bizweaver server name and port number. NN in “pTaskID” is the Bizweaver workflow ID. The pArguments values will need to be adjusted based on your workflow.
CREATE PROCEDURE [dbo].[Call_BWO] @DocEntry INT AS DECLARE @object AS INT, @url VARCHAR(5000) SELECT @url = 'http:%%//%%Bizweaver_Server:Port/BWService/api/workflow/InvokeWorkFlow?pTaskID=NN&pStartAfter=0&pArguments={DocEntry:' + '"' + CAST(@DocEntry AS VARCHAR) + '"}' EXEC sp_OACreate 'MSXML2.XMLHTTP', @object OUT; EXEC sp_oamethod @object, 'open', NULL, 'get', @url EXEC sp_oamethod @object, 'send' EXEC sp_oadestroy @object