> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nekt.com/llms.txt
> Use this file to discover all available pages before exploring further.

# SAP Business One as a data source

> Bring sales and purchasing documents, payments, journal entries, business partners, items and stock from SAP Business One to Nekt.

SAP Business One is the ERP from SAP for small and midsize companies, covering sales, purchasing, inventory, banking and accounting. This connector reads your company through the **SAP Business One Service Layer**, the official REST API of SAP Business One (versions 9.3 and 10.0, on SQL Server or SAP HANA). It brings sales and purchasing documents with their lines and installments, incoming and outgoing payments with the documents they settled, journal entries, business partners, items with prices and stock per warehouse, and the main setup tables (chart of accounts, warehouses, cost centers, payment terms and others).

<Note>
  The connector only reads data. It signs in to the Service Layer, reads the selected objects and signs out. It never creates, changes or cancels anything in SAP Business One.
</Note>

## Before you start

The Service Layer runs on your SAP Business One server (or at your SAP partner's cloud). Ask your IT team or SAP partner to:

1. **Make the Service Layer reachable from the internet for Nekt.** Nekt connects to it over HTTPS, by default on port 50000 (for example `https://sap.yourcompany.com:50000/b1s/v2`). Open the firewall or port forwarding for Nekt's IP addresses, or publish the Service Layer through a reverse proxy. Contact Nekt support to get the IP addresses.
2. **Create a user for Nekt** (recommended) with read access to the objects you want to sync, under **Administration > System Initialization > Authorizations > General Authorizations**. Business partners, items, sales and purchasing documents, incoming and outgoing payments, journal entries and the setup tables each have their own authorization.
3. **Check the TLS certificate.** The SAP installation creates a self-signed certificate for the Service Layer. Nekt verifies certificates by default, so a certificate issued by a trusted authority for the address you give Nekt is recommended. If that is not possible, see **Verify TLS Certificate** below.

## Configuring SAP Business One as a Source

In the [Sources](https://app.nekt.ai/sources) tab, click on the "Add source" button located on the top right of your screen. Then, select the SAP Business One option from the list of connectors.

Click **Next** and you'll be prompted to add your access.

### 1. Add account access

The following configurations are available:

* **Service Layer URL**: The address of your Service Layer as Nekt reaches it over the internet, ending in `/b1s/v2` (or `/b1s/v1` on versions older than 10.0). For example: `https://sap.yourcompany.com:50000/b1s/v2`. Only HTTPS addresses are accepted.

* **Company Database**: The database name of the company to read, as shown in the **Database Name** column of the company selection screen (for example `SBO_MYCOMPANY`), not the company's display name.

* **User Name** and **Password**: The SAP Business One user the connector signs in with.

* **Start Date**: (Optional, advanced) Only read records created or changed on or after this date (documents, business partners, items) or posted on or after it (payments, journal entries). Leave it empty to read the whole history. For companies with many years of data, setting a start date is recommended: the first load of journal entries alone can take hours.

* **Lookback Days**: (Optional, advanced) Days re-read before the last sync position on every incremental run, to catch changes saved late. Default: 2.

* **Page Size**: (Optional, advanced) Records requested per call to the Service Layer. Default: 100. Lower it if your Service Layer times out on documents with many lines.

* **Verify TLS Certificate**: (Optional, advanced) On by default. Turn it off only if your Service Layer still uses the self-signed certificate created by the SAP installation and you cannot replace it. The connection stays encrypted, but Nekt can no longer confirm it is talking to your server, and every sync logs a warning.

When you click **Next**, Nekt signs in to the Service Layer once to check the URL, company and credentials.

### 2. Select streams

Choose which data streams you want to sync. For faster extractions, select only the streams that are relevant to your analysis. You can select entire groups of streams or pick specific ones.

> Tip: The stream can be found more easily by typing its name.

Select the streams and click **Next**.

### 3. Configure data streams

Customize how you want your data to appear in your catalog. Select the desired layer where the data will be placed, a folder to organize it inside the layer, a name for each table (which will effectively contain the fetched data) and the type of sync.

* **Layer**: choose between the existing layers on your catalog. This is where you will find your new extracted tables as the extraction runs successfully.
* **Folder**: a folder can be created inside the selected layer to group all tables being created from this new data source.
* **Table name**: we suggest a name, but feel free to customize it. You have the option to add a **prefix** to all tables at once and make this process faster!
* **Sync Type**: you can choose between INCREMENTAL and FULL\_TABLE.
  * Incremental: every time the extraction happens, we'll get only the new data, which is good if, for example, you want to keep every record ever fetched.
  * Full table: every time the extraction happens, we'll get the current state of the data, which is good if, for example, you don't want to have deleted data in your catalog.

<Tip>
  Keep a document and its lines (and installments) on the same sync type. If the lines are set to FULL\_TABLE while the document is INCREMENTAL, the connector reads the whole document history on every run to keep the lines table complete, and logs a warning.
</Tip>

Once you are done configuring, click **Next**.

### 4. Configure data source

Describe your data source for easy identification within your organization, not exceeding 140 characters.

To define your [Trigger](https://docs.nekt.com/runs/scheduling-and-triggers), consider how often you want data to be extracted from this source. This decision usually depends on how frequently you need the new table data updated (every day, once a week, or only at specific times).

Optionally, you can define some additional settings:

* Configure Delta Log Retention and determine for how long we should store old states of this table as it gets updated. Read more about this resource [here](https://docs.nekt.com/get-started/core-concepts/resource-control).
* Determine when to execute an [Additional Full Sync](https://docs.nekt.com/get-started/core-concepts/types-of-sync#additional-full-sync). This will complement the incremental data extractions, ensuring that your data is completely synchronized with your source every once in a while. A periodic full sync is useful here: it refreshes business partner balances and item quantities, picks up edits to older payments and journal entries, and removes lines deleted from open orders and quotations.

Once you are ready, click **Next** to finalize the setup.

### 5. Check your new source

You can view your new source on the [Sources](https://app.nekt.ai/sources) page. If needed, manually trigger the source extraction by clicking on the arrow button. Once executed, your data will appear in your Catalog.

<Warning>For you to be able to see it on your [Catalog](https://app.nekt.ai/catalog), you need at least one successful source run.</Warning>

## How data is kept up to date

* **Documents, business partners and items** are read by their last update date (`update_date`). The last synced day and the lookback days before it are always read again.
* **Documents that change status later** (an order closed by a delivery, an invoice paid, cancelled or reopened) are covered even when SAP does not change their update date: every run lists the open documents with a light request and reads again the ones that opened or closed since the previous run. For invoices, credit memos and down payments it also reads again the ones whose paid amount changed (partial payments).
* **Orders, quotations and other documents copied into new documents** are read again when a later document is created from them (for example, a partial delivery of an open order changes the order's open quantities and line status). The connector reads again the source document named on the lines of each new or changed document, in the same run when possible, otherwise on the next run. Only the document streams you selected are refreshed this way.
* **Payments and journal entries** have no update date in the Service Layer. New ones are read by their internal number; payments cancelled after they were synced are detected and read again. Other edits to payments and journal entries made after they were synced (remarks, references, user-defined fields, payment block, due dates of journal entry lines) only reach your tables on a full sync.
* **Setup tables, item prices and stock per warehouse** are read in full on every run, so they always show the current values.
* If the user loses access to an object, or the Service Layer keeps failing, the run fails with a message saying what to fix. It never finishes successfully with data missing.

<Tip>
  A line removed from an open order or quotation in SAP stays in the lines table, because tables are updated by key. Documents and their lines and installments carry `extracted_at`, the moment the connector read them: keep only lines whose `extracted_at` equals the `extracted_at` of their document (join on `doc_entry`). For example: `SELECT l.* FROM order_lines l JOIN orders o ON o.doc_entry = l.doc_entry AND o.extracted_at = l.extracted_at`.
</Tip>

<Note>
  Balances on business partners (`current_account_balance` and the open balances) and quantities on items (`quantity_on_stock` and similar) change with every transaction without changing the record's update date. In incremental syncs they show the value of the last time the record itself changed. Use `item_warehouse_stock` for current stock, and open invoices for current receivables.
</Note>

# Streams and Fields

## Available streams

The table below lists every stream, its **slug** (the exact identifier to pass when creating the source via API) and a short description.

| Stream | Slug | Description |
| - | - | - |
| Sales Quotations | `quotations` | Sales quotations (Sales - A/R > Sales Quotation). |
| Sales Quotation Lines | `quotation_lines` | Lines of sales quotations. |
| Sales Orders | `orders` | Sales orders (Sales - A/R > Sales Order). |
| Sales Order Lines | `order_lines` | Lines of sales orders. |
| Deliveries | `delivery_notes` | Sales deliveries (Sales - A/R > Delivery). |
| Delivery Lines | `delivery_note_lines` | Lines of deliveries. |
| Returns | `returns` | Sales returns (Sales - A/R > Return). |
| Return Lines | `return_lines` | Lines of returns. |
| A/R Invoices | `invoices` | A/R invoices (Sales - A/R > A/R Invoice). |
| A/R Invoice Lines | `invoice_lines` | Lines of A/R invoices. |
| A/R Invoice Installments | `invoice_installments` | Installments (due dates and amounts) of A/R invoices. |
| A/R Credit Memos | `credit_notes` | A/R credit memos. |
| A/R Credit Memo Lines | `credit_note_lines` | Lines of A/R credit memos. |
| A/R Credit Memo Installments | `credit_note_installments` | Installments of A/R credit memos. |
| A/R Down Payments | `down_payments` | A/R down payment requests and invoices. |
| A/R Down Payment Lines | `down_payment_lines` | Lines of A/R down payments. |
| A/R Down Payment Installments | `down_payment_installments` | Installments of A/R down payments. |
| Purchase Orders | `purchase_orders` | Purchase orders (Purchasing - A/P > Purchase Order). |
| Purchase Order Lines | `purchase_order_lines` | Lines of purchase orders. |
| Goods Receipt POs | `purchase_delivery_notes` | Goods receipt POs. |
| Goods Receipt PO Lines | `purchase_delivery_note_lines` | Lines of goods receipt POs. |
| Goods Returns | `purchase_returns` | Goods returns to vendors. |
| Goods Return Lines | `purchase_return_lines` | Lines of goods returns. |
| A/P Invoices | `purchase_invoices` | A/P invoices (Purchasing - A/P > A/P Invoice). |
| A/P Invoice Lines | `purchase_invoice_lines` | Lines of A/P invoices. |
| A/P Invoice Installments | `purchase_invoice_installments` | Installments (due dates and amounts) of A/P invoices. |
| A/P Credit Memos | `purchase_credit_notes` | A/P credit memos. |
| A/P Credit Memo Lines | `purchase_credit_note_lines` | Lines of A/P credit memos. |
| A/P Credit Memo Installments | `purchase_credit_note_installments` | Installments of A/P credit memos. |
| A/P Down Payments | `purchase_down_payments` | A/P down payment requests and invoices. |
| A/P Down Payment Lines | `purchase_down_payment_lines` | Lines of A/P down payments. |
| A/P Down Payment Installments | `purchase_down_payment_installments` | Installments of A/P down payments. |
| Incoming Payments | `incoming_payments` | Payments received from customers (Banking > Incoming Payments). |
| Incoming Payment Documents | `incoming_payment_invoices` | Documents each incoming payment settled (invoices, credit memos, journal entries). |
| Outgoing Payments | `vendor_payments` | Payments made to vendors (Banking > Outgoing Payments). |
| Outgoing Payment Documents | `vendor_payment_invoices` | Documents each outgoing payment settled. |
| Journal Entries | `journal_entries` | Journal entries (Financials > Journal Entry), including the ones created by documents. |
| Journal Entry Lines | `journal_entry_lines` | Debit and credit lines of journal entries. |
| Business Partners | `business_partners` | Customers, vendors and leads, with addresses, contacts and tax IDs. |
| Items | `items` | Item master data. |
| Item Prices | `item_prices` | Price of every item in every price list. |
| Item Stock per Warehouse | `item_warehouse_stock` | Quantity in stock, committed and ordered of every item in every warehouse. |
| Chart of Accounts | `chart_of_accounts` | G/L accounts. |
| Warehouses | `warehouses` | Warehouses. |
| Item Groups | `item_groups` | Item groups. |
| Sales Employees | `sales_persons` | Sales employees and their commission. |
| Payment Terms | `payment_terms_types` | Payment terms. |
| Profit Centers | `profit_centers` | Profit centers (cost centers). |
| Distribution Rules | `distribution_rules` | Distribution rules used to allocate costs and revenues to profit centers. |
| Projects | `projects` | Projects. |
| Business Partner Groups | `business_partner_groups` | Customer and vendor groups. |
| Business Places | `business_places` | Business places (branches). |
| Price Lists | `price_lists` | Price lists. |

## Fields by stream

Every stream has the standard fields of its SAP Business One object (several hundred on documents, business partners and items), named in snake\_case: `DocTotal` becomes `doc_total`, `CardCode` becomes `card_code`. Dates come as `YYYY-MM-DD` (the business date in SAP, with no time zone), times as `HH:MM:SS` text, amounts as decimal numbers, and SAP enumerations keep their SAP values (for example `tYES`/`tNO`, `bost_Open`/`bost_Close`). Two fields are common to all streams:

* `user_fields` - Your company's user-defined fields (UDFs, the fields whose names start with `U_`) as a JSON object, for example `{"U_Segment": "Retail"}`.
* `other_fields` - Fields returned by the Service Layer that have no column of their own (for example fields added in newer SAP Business One versions), as a JSON object.

Nested objects and lists (addresses, tax details, batch numbers and similar) are stored as JSON text. The main fields of each group of streams are listed below.

<AccordionGroup>
  <Accordion title="Sales and purchasing documents (quotations, orders, deliveries, returns, invoices, credit memos, down payments)">
    One row per document. Primary key: `doc_entry`. Incremental key: `update_date`.

    * `doc_entry` - Internal key of the document
    * `doc_num` - Document number shown in SAP Business One
    * `series` - Numbering series of the document
    * `doc_date`, `doc_due_date`, `tax_date` - Posting, due and document dates
    * `card_code`, `card_name` - Customer or vendor
    * `doc_total`, `doc_total_fc`, `doc_total_sys` - Document total in local, foreign and system currency
    * `vat_sum` - Tax amount
    * `paid_to_date` - Amount already paid or cleared
    * `doc_currency`, `doc_rate` - Currency and exchange rate
    * `document_status` - Open or closed (`bost_Open`, `bost_Close`)
    * `cancelled`, `cancel_status` - Whether the document was cancelled
    * `sales_person_code` - Sales employee (see `sales_persons`)
    * `payment_group_code` - Payment terms (see `payment_terms_types`)
    * `bpl_id_assigned_to_invoice`, `bpl_name` - Business place (branch)
    * `sequence_code`, `sequence_serial`, `series_string`, `sequence_model` - Nota Fiscal numbering (Brazil)
    * `tax_extension`, `address_extension` - Tax, transport and address details (JSON)
    * `comments`, `num_at_card` - Remarks and the customer's or vendor's reference number
    * `creation_date`, `update_date`, `update_time` - When the document was created and last updated
    * `extracted_at` - When the connector read the document (shared with its lines and installments)
  </Accordion>

  <Accordion title="Document lines (quotation_lines, order_lines, invoice_lines and the other *_lines streams)">
    One row per line. Primary key: `doc_entry` + `line_num`.

    * `doc_entry`, `line_num` - Document and line number
    * `item_code`, `item_description` - Item
    * `quantity`, `price`, `unit_price`, `discount_percent` - Quantity, price and discount
    * `line_total` - Line total before tax
    * `warehouse_code` - Warehouse
    * `account_code` - G/L account
    * `costing_code` to `costing_code5`, `project_code` - Distribution rules (cost centers) and project
    * `tax_code`, `tax_total` - Tax code and amount
    * `line_status` - Open or closed
    * `base_type`, `base_entry`, `base_line` - Document the line was copied from (for example the order of an invoice line)
    * `cfop_code`, `ncm_code`, `cst_for_pis`, `cst_for_cofins`, `cst_for_ipi` - Brazilian tax codes
    * `update_date` - Last update date of the document the line belongs to
    * `extracted_at` - When the connector read the line's document: lines whose value differs from their document's were removed in SAP
  </Accordion>

  <Accordion title="Document installments (invoice_installments and the other *_installments streams)">
    One row per installment. Primary key: `doc_entry` + `installment_id`.

    * `doc_entry` - Document
    * `installment_id` - Installment number
    * `due_date` - Due date of the installment
    * `total`, `total_fc` - Installment amount in local and foreign currency
    * `percentage` - Share of the document total
    * `payment_ordered` - Whether the installment was already included in a payment run
  </Accordion>

  <Accordion title="Incoming and outgoing payments">
    One row per payment. Primary key: `doc_entry`. Incremental key: `doc_entry` (new payments get higher numbers).

    * `doc_entry`, `doc_num` - Internal key and number of the payment
    * `doc_date`, `due_date`, `tax_date` - Posting, due and document dates
    * `card_code`, `card_name` - Customer or vendor
    * `cash_sum`, `transfer_sum`, `check_account`, `transfer_account` - Amounts and accounts by payment method
    * `doc_currency`, `doc_rate` - Currency and exchange rate
    * `cancelled` - Whether the payment was cancelled
    * `payment_checks`, `payment_credit_cards`, `payment_accounts` - Payment method details (JSON)
    * `bplid`, `bpl_name` - Business place (branch)
  </Accordion>

  <Accordion title="Documents settled by payments (incoming_payment_invoices, vendor_payment_invoices)">
    One row per settled document. Primary key: `payment_doc_entry` + `line_num`.

    * `payment_doc_entry` - The payment (join to `doc_entry` of the payment stream)
    * `doc_entry` - The settled document; its type is in `invoice_type` (for example `it_Invoice` for an A/R invoice)
    * `installment_id` - Installment of the settled document
    * `sum_applied`, `applied_fc`, `applied_sys` - Amount applied
    * `discount_percent`, `total_discount` - Cash discount
  </Accordion>

  <Accordion title="Journal entries and lines">
    `journal_entries`: one row per entry, primary and incremental key `jdt_num` (the transaction number). `journal_entry_lines`: one row per line, primary key `jdt_num` + `line_id`.

    * `jdt_num` - Transaction number
    * `reference_date`, `due_date`, `tax_date` - Posting, due and document dates
    * `memo`, `reference`, `reference2`, `reference3` - Remarks and references
    * `original_journal`, `original`, `base_reference` - Transaction that created the entry (for example an A/R invoice)
    * `project_code` - Project
    * Lines: `account_code`, `short_name`, `debit`, `credit`, `fc_debit`, `fc_credit`, `contra_account`, `costing_code` to `costing_code5`, `bplid`, `line_memo`
  </Accordion>

  <Accordion title="Business partners">
    One row per business partner. Primary key: `card_code`. Incremental key: `update_date`.

    * `card_code`, `card_name`, `card_foreign_name` - Code and names
    * `card_type` - Customer, vendor or lead
    * `group_code` - Group (see `business_partner_groups`)
    * `federal_tax_id` - Federal tax ID
    * `phone1`, `email_address`, `city`, `county`, `country` - Contact data
    * `pay_terms_grp_code`, `price_list_num`, `sales_person_code` - Default payment terms, price list and sales employee
    * `credit_limit`, `current_account_balance` - Credit limit and balance
    * `bp_addresses`, `contact_employees`, `bp_fiscal_tax_id_collection`, `bp_bank_accounts` - Addresses, contacts, tax IDs (CNPJ, CPF and state registration in Brazil) and bank accounts (JSON)
    * `create_date`, `update_date` - When the record was created and last updated
  </Accordion>

  <Accordion title="Items, item prices and stock per warehouse">
    `items`: one row per item, primary key `item_code`, incremental key `update_date`. `item_prices`: primary key `item_code` + `price_list`. `item_warehouse_stock`: primary key `item_code` + `warehouse_code`.

    * `item_code`, `item_name`, `foreign_name` - Code and names
    * `items_group_code` - Item group (see `item_groups`)
    * `inventory_item`, `sales_item`, `purchase_item` - Item type flags
    * `inventory_uom`, `sales_unit`, `purchase_unit` - Units of measure
    * `ncm_code` - NCM code (Brazil)
    * `valid`, `frozen` - Active and blocked flags
    * Prices: `price_list`, `price`, `currency`
    * Stock: `warehouse_code`, `in_stock`, `committed`, `ordered`, `minimal_stock`, `maximal_stock`, `standard_average_price`
  </Accordion>

  <Accordion title="Setup tables">
    Read in full on every run. Primary keys: `chart_of_accounts.code`, `warehouses.warehouse_code`, `item_groups.number`, `sales_persons.sales_employee_code`, `payment_terms_types.group_number`, `profit_centers.center_code`, `distribution_rules.factor_code`, `projects.code`, `business_partner_groups.code`, `business_places.bplid`, `price_lists.price_list_no`.

    * Chart of accounts: `code`, `name`, `account_type`, `active_account`, `father_account_key`, `balance`, `acct_currency`
    * Payment terms: `group_number`, `payment_terms_group_name`, `number_of_additional_days`, `number_of_installments`
    * Profit centers and distribution rules: `center_code`, `center_name`, `in_which_dimension`, `factor_code`, `factor_description`
  </Accordion>
</AccordionGroup>

## Troubleshooting

| Message | What to do |
| - | - |
| The Service Layer host could not be found / Could not connect to the Service Layer | Check the Service Layer URL and that the Service Layer is reachable from the internet for Nekt's IP addresses (firewall or port forwarding of port 50000). |
| Could not open a secure (HTTPS) connection | The Service Layer's certificate could not be verified. Install a certificate issued by a trusted authority, or turn off **Verify TLS Certificate**. |
| SAP Business One refused to sign in | Check the Company Database (database name, not display name), User Name and Password, and that the user is not locked and has a license. |
| The SAP Business One user of this connection cannot read... | Give the user read authorization to the listed objects (Administration > System Initialization > Authorizations > General Authorizations), or deselect their streams. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.