Stock Transfer Part 2

Batch managed items can be transferred between warehouses and bins by including the BatchNumbers property in the StockTransfers API post request. The BatchNumbers property is an array of batch numbers. Listing 1 below shows an example JSON object that contains an item with a single batch. Notice that the quantity specified for the batch number object is equal to the quantity at the item level.

Listing 1

{
    FromWarehouse: "From Warehouse code",
    StockTransferLines: [
        {
            WarehouseCode: "Target Warehouse Code",
            ItemCode: "v100001",
            Quantity: 5,
            BatchNumbers: [
                {
                    BaseLineNumber: 0,
                    Quantity: 5,
                    BatchNumberProperty: "BN0001"

                }
            ]
        }
    ]
}

The BaseLineNumber property of the batch object refers to the index position of the current item contained within the StockTransferLines array. In the example above, the StockTransferLines array contains a single item with the index position 0. This position is used as the BaseLineNumber value for batch objects.

As mentioned, the BatchNumbers property allows you to specify an array of batch number objects. The quantities for each batch object must sum up to the total quantity at the item level as shown in listing 2 below.

Listing 2

{
    FromWarehouse: "From Warehouse code",
    StockTransferLines: [
        {
            WarehouseCode: "Target Warehouse Code",
            ItemCode: "v100001",
            Quantity: 10,
            BatchNumbers: [
                {
                    BaseLineNumber: 0,
                    Quantity: 5,
                    BatchNumberProperty: "BN0001"

                },
                {
                    BaseLineNumber: 0,
                    Quantity: 5,
                    BatchNumberProperty: "BN0002"

                }
            ]
        }
    ]
}

The final code sample below shows how to transfer multiple items with multiple batch numbers. Notice how the BaseLineNumber value for each item relates to the items index position.

Listing 3

{
    FromWarehouse: "From Warehouse code",
    StockTransferLines: [
        {
            WarehouseCode: "Target Warehouse Code",
            ItemCode: "v100001",
            Quantity: 10,
            BatchNumbers: [
                {
                    BaseLineNumber: 0,
                    Quantity: 5,
                    BatchNumberProperty: "BN0001"

                },
                {
                    BaseLineNumber: 0,
                    Quantity: 5,
                    BatchNumberProperty: "BN0002"

                }
            ]
        },
        {
            WarehouseCode: "Target Warehouse Code",
            ItemCode: "v100002",
            Quantity: 5,
            BatchNumbers: [
                {
                    BaseLineNumber: 1,
                    Quantity: 5,
                    BatchNumberProperty: "BN0003"

                }
            ]
        }
    ]
}

SAP Business One

HANA DB

Rust

Java

Node.js