Skip to Content
Product Information
Author's profile photo ANKIT CHAUHAN

Inventory Opening Balance in SAP Business One SDK

Inventory opening balance (Stock Opening Balance) refers to the financial quantities of your inventory at the beginning of a new financial period.

You can set up inventory opening balance at either of the following points in time:

  • As initial settings, before you have any inventory transactions. This gives you a picture of your inventory from the moment you start to work with SAP Business One.

  • If you were not able to enter inventory opening balances as initial settings, you also can enter the balances later on, when inventory transactions already exist in the application.

To access this Window from the SAP Business One Main Menu, choose Inventory → Inventory Transactions → Inventory Opening Balance

For more information on Inventory Opening Balance, you can refer to following link:

https://help.sap.com/saphelp_sbo92/helpdata/EN/45/2364e69e152b31e10000000a1553f7/content.htm

Inventory Opening Balance in SAP Business One SDK:

Inventory opening balance is exposed as a Service Type Object (InventoryOpeningBalancesService) in SAP Business One SDK. You can use it following ways using DI API:

Create an Inventory Opening Balance Document having Item managed by Batches using DI API:

SAPbobsCOM.InventoryOpeningBalancesService oInventoryOpeningBalancesService = oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryOpeningBalancesService);
SAPbobsCOM.InventoryOpeningBalance oInventoryOpeningBalance = (SAPbobsCOM.InventoryOpeningBalance)oInventoryOpeningBalancesService.GetDataInterface(SAPbobsCOM.InventoryOpeningBalancesServiceDataInterfaces.iobsInventoryOpeningBalance);
SAPbobsCOM.InventoryOpeningBalanceLine oInventoryOpeningBalanceLine;
SAPbobsCOM.InventoryOpeningBalanceBatchNumber oInventoryOpeningBalanceBatchNumber;
oInventoryOpeningBalance.DocumentDate = DateTime.Today;
oInventoryOpeningBalance.PostingDate = DateTime.Today;
oInventoryOpeningBalanceLine = oInventoryOpeningBalance.InventoryOpeningBalanceLines.Add();
oInventoryOpeningBalanceLine.ItemCode = "B10000";
oInventoryOpeningBalanceLine.WarehouseCode = "05";
oInventoryOpeningBalanceLine.OpeningBalance = 2;
oInventoryOpeningBalanceLine.Price = 10;
oInventoryOpeningBalanceLine.OpenInventoryAccount = "110020";
oInventoryOpeningBalanceLine.BinEntry = 2;
oInventoryOpeningBalanceBatchNumber = (SAPbobsCOM.InventoryOpeningBalanceBatchNumber)oInventoryOpeningBalanceLine.InventoryOpeningBalanceBatchNumbers.Add();
oInventoryOpeningBalanceBatchNumber.BatchNumber = "BAT-01";
oInventoryOpeningBalanceBatchNumber.AddmisionDate = DateTime.Today;
oInventoryOpeningBalanceBatchNumber.ExpiryDate = DateTime.Today.AddYears(1);
oInventoryOpeningBalanceBatchNumber.Quantity = 2;
oInventoryOpeningBalancesService.Add(oInventoryOpeningBalance);

Create an Inventory Opening Balance Document having Item managed by Serial Numbers using DI API:

SAPbobsCOM.InventoryOpeningBalancesService oInventoryOpeningBalancesService = oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryOpeningBalancesService);
SAPbobsCOM.InventoryOpeningBalance oInventoryOpeningBalance = (SAPbobsCOM.InventoryOpeningBalance)oInventoryOpeningBalancesService.GetDataInterface(SAPbobsCOM.InventoryOpeningBalancesServiceDataInterfaces.iobsInventoryOpeningBalance);
SAPbobsCOM.InventoryOpeningBalanceLine oInventoryOpeningBalanceLine;
SAPbobsCOM.InventoryOpeningBalanceSerialNumber oInventoryOpeningBalanceSerialNumber;
oInventoryOpeningBalancesService = oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryOpeningBalancesService);
oInventoryOpeningBalance = (SAPbobsCOM.InventoryOpeningBalance)oInventoryOpeningBalancesService.GetDataInterface(SAPbobsCOM.InventoryOpeningBalancesServiceDataInterfaces.iobsInventoryOpeningBalance);
oInventoryOpeningBalance.DocumentDate = DateTime.Today;
oInventoryOpeningBalance.PostingDate = DateTime.Today;
oInventoryOpeningBalanceLine = oInventoryOpeningBalance.InventoryOpeningBalanceLines.Add();
oInventoryOpeningBalanceLine.ItemCode = "S10000";
oInventoryOpeningBalanceLine.WarehouseCode = "05";
oInventoryOpeningBalanceLine.OpeningBalance = 2;
oInventoryOpeningBalanceLine.Price = 10;
oInventoryOpeningBalanceLine.OpenInventoryAccount = "110020";
oInventoryOpeningBalanceLine.BinEntry = 2;
oInventoryOpeningBalanceSerialNumber = (SAPbobsCOM.InventoryOpeningBalanceSerialNumber)oInventoryOpeningBalanceLine.InventoryOpeningBalanceSerialNumbers.Add();
oInventoryOpeningBalanceSerialNumber.ManufacturerSerialNumber = "MAF-02";
oInventoryOpeningBalanceSerialNumber.InternalSerialNumber = "SAN-02";
oInventoryOpeningBalanceSerialNumber.ExpiryDate = DateTime.Today.AddYears(1);
oInventoryOpeningBalanceSerialNumber.Quantity = 1;
oInventoryOpeningBalanceSerialNumber = (SAPbobsCOM.InventoryOpeningBalanceSerialNumber)oInventoryOpeningBalanceLine.InventoryOpeningBalanceSerialNumbers.Add();
oInventoryOpeningBalanceSerialNumber.ManufacturerSerialNumber = "MAF-03";
oInventoryOpeningBalanceSerialNumber.InternalSerialNumber = "SAN-03";
oInventoryOpeningBalanceSerialNumber.ExpiryDate = DateTime.Today.AddYears(1);
oInventoryOpeningBalanceSerialNumber.Quantity = 1;
oInventoryOpeningBalancesService.Add(oInventoryOpeningBalance);

Update an Inventory Opening Balance Document using DI API:

SAPbobsCOM.InventoryOpeningBalancesService oInventoryOpeningBalancesService = oCompany.GetCompanyService().GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryOpeningBalancesService);
SAPbobsCOM.InventoryOpeningBalance oInventoryOpeningBalance = (SAPbobsCOM.InventoryOpeningBalance)oInventoryOpeningBalancesService.GetDataInterface(SAPbobsCOM.InventoryOpeningBalancesServiceDataInterfaces.iobsInventoryOpeningBalance);
SAPbobsCOM.InventoryOpeningBalanceParams oInventoryOpeningBalanceParams = (SAPbobsCOM.InventoryOpeningBalanceParams)oInventoryOpeningBalancesService.GetDataInterface(SAPbobsCOM.InventoryOpeningBalancesServiceDataInterfaces.iobsInventoryOpeningBalanceParams);
oInventoryOpeningBalanceParams.DocumentEntry = 1;
oInventoryOpeningBalance = oInventoryOpeningBalancesService.Get(oInventoryOpeningBalanceParams);
oInventoryOpeningBalance.Remarks = "Inventory Opening Balance Update using DI API";
oInventoryOpeningBalancesService.Update(oInventoryOpeningBalance);

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      Nice One

      Author's profile photo Dhruv Parmar
      Dhruv Parmar

      Nice work, I want to implement same thing but here save as draft not generate document for opening balance. please suggest.