bw2:sbo_sl_v26

This is an old revision of the document!


SAP Business One Service Layer using Bizweaver v2.6 and higher

Accessing SAP Business One using the Service Layer is a two-step process. The first step (Login) responds with two cookies. These cookies are then used in any subsequent web service calls in the current processing cycle.

Accessing SAP Business One via the Service Layer is available for HANA on v9.3 only. It is available for both HANA and SQL Server beginning with SAP Business One v10 PL02.

The difference in Bizweaver v2.6 is that a Service Layer global connection can be used to manage much of the detail work. Configuring a Service Layer global connection is described here.

Login Step

  • Select SAP Service Layer in the “Select Service” drop-down list.
  • Select Authenticate in the next drop-down to the right.
  • Select the Authentication Required checkbox.
  • Select your previously defined Service Layer connection in the “Select Connection” drop-down.
  • Click the Validate Login link to confirm that your connection is working. If the response is not True, check your connection information and try again.

Interact With Data Steps

Once the workflow has completed a successful login, the remaining steps will use the Interact With Data option.

  • Select SAP Service Layer in the “Select Service” drop-down list.
  • Select Interact With Data in the next drop-down to the right.
    • No other information is needed in this section as the log-in step has provided the needed credentials.
  • Select an action from the four options

Query

  • Query - This will only select (read) data from the selected object
    • In the Record ID field, you can enter the primary key for the Object for Orders it would be DocNum
    • Selecting any of the Feilds in the “Name Column” will filter results to select only those fields when querying. The Feilds can be seen in the textbox below Text in the box can be modified.
    • When you select fields and save when the tool is reentered, it will only show the selected fields.
      • To select more fields, refresh the object list and select or remove fields as needed.
    • When Query is selected, and fields are selected to limit the query, and you switch to another option, it will clear the query limitations, and the fields need to be unselected and reselected to limit the query again.

Add Record

  • Add Record - This will add new records to SAP.
    • Select Refresh Object List to populate the object list.
    • Select the desired object from the list
    • Enter the relevant variable or data in the “Value” field
    • Lines - when adding lines, you have to select the relevant option in the field list for Orders it is DocumentLines
      • To add lines, the databuilder is needed to format the data into JSON. Once the data is built, it can be entered into the Value column for the lines. See example below

Note the lack of array name. The service layer tool will add the array name, so the only thing needed is the array data. Add Cumulative data from the data builder step to Values field

  • When you select fields and save when the tool is reentered, it will only show the selected fields.
  • To select more fields, refresh the object list and select or remove fields as needed

Patch

  • Patch is used to update a record in SAP.
    • Enter the record id that needs updating.
    • Select the fields that need to be updated.
    • Enter the values for the selected fields.
  • When updating records in SAP it is best to update the whole record as opposed to doing a target update. As in most cases, SAP Service Layer will overwrite data in the record instead of adding it to the end.

Delete

  • Delete will delete the indicated record id.

More information on the various objects and methods is available on your HANA server using this URL in a browser on your network.

https://<YourServerName>:50000

Working with the Service Layer

Information on sending data through the Service Layer is found here.

Sample Building JSON for SAP Business One Service Layer

Workflow

This workflow builds two sections of a JSON structure for an SAP Business One sales order. The sections are the header and the rows. Each section consists of a SQL statement to gather the needed information and the DataBuilder to format the information. Once the pieces are constructed, the output is sent to the SAP Service Layer API in the WebService step. Other APIs will work in a similar manner.

Create Main DataBuilder Step

This should always contain the first items of the data structure.

  1. Enter a workflow step name.
  2. Select the data source from the Datasource Object drop-down list.
  3. Select the desired data structure type to be created (JSON or XML).
  4. Leave the “Add as an array” checkbox cleared unless you know that the top-level object needs to be any array. This is uncommon.
  5. Select the “Top-level element” checkbox, assuming this is the top level (header) node of the structure.
    1. This option causes the “CumulativeData” step-variable to be cleared before starting to build a new structure.
  6. Enter the name of the top-level object.
    1. The requirements of the receiving API will determine this.
    2. In some cases, a top-level object name is not used; e.g. SAP Service Layer and BigCommerce.
      1. If a top-level object name is not used, leave the field blank.
  7. Create a row for each value to be included in the structure.
  8. Enter the output field name values in the right-side grid.
    1. The Field Name value will need to exactly match (including case) the value the API is expecting.
  9. Select the field type from the drop-down list.
  10. Press <F4> to get a list of variables from the associated Datasource Object and select the appropriate value.

Continue this process for all desired fields in the top-level object.

The data structure being built is displayed in the left-side panel as elements are added. The data structure cannot be altered in this area. The display is for information only.

Create the Lower-Level DataBuilder Step(s)

This will be the next section in the expected data structure. The process is the same as described in the “Main DataBuilder” step.

For objects such as a set of rows, the display will only display a single entry. However, all data received as input will be included when the workflow executes.

In most cases the lower-level sections will need to be marked as an array. The “Add as an array” checkbox should be selected. However, always check your API documentation to verify this. At the same time, the “Top-level Element” checkbox should remain cleared.

When creating lower-level section that may have more than one entry (i.e. an array), be sure to put the DataBuilder tool within a Loop. As each record is read from the input it is added to the bottom of the array being constructed. Not using a loop will result in an incorrect data structure.

All objects other than the main one will require an Object Name. This must exactly match (including case) what is expected by the API.

Reference Lower-level Objects in the Main DataBuilder Step

Once the DataBuilder steps for the lower-level objects have been created, they can be referenced in the main DataBuilder step. This is what causes the entire data structure to be created when the workflow is executed.

  1. Click the “Field Type” drop-down in the main DataBuilder step. The names of the lower-level objects are displayed in addition to the standard field type values.
  2. Select the desired object.
    1. The Field Name and Value are automatically filled in.
    2. The lower-level object is displayed in the left-side data structure.

Here is the resulting JSON that is sent in the API call.

{
"CardCode": "C20000",
"DocDueDate": "20190313",
"DocumentLines": [
{
"ItemCode": "A00001",
"Quantity": 9,
"LineTotal": 33.75
},
{
"ItemCode": "A00001",
"Quantity": 7,
"LineTotal": 105
}
],
"AddressExtension": [
{
"CItyB": "New York"
}
]
}

Reference the Output of the Main DataBuilder Step in the API Call

The output of the main DataBuilder step is used in the API call. This is done by using the “CumulativeData” variable from the Main DataBuilder step. An example is shown in the image below.

bw2/sbo_sl_v26.1613075778.txt.gz · Last modified: 2021/02/11 15:36 by akoehler