Product Information
Inventory Counting in SAP Business SDK
About Inventory Counting:
Inventory counting (also known as Stock Taking/Stock Counting) helps you to keep track of your inventory.
Inventory counting is crucial to any company that manages an inventory, be it perpetual or periodic. By matching the actual inventory to the quantities saved in the database, companies can adjust existing inventory records, detect unusual or unacceptable discrepancies, and improve inventory management.
After creating an Inventory Counting document to record the counting results, you must post the inventory changes to effect the adjustments in the system. For this, you need to create an Inventory Posting document based on the Inventory Counting document.
For more details on Inventory Counting, you can refer to following link:
Using Inventory Counting in SAP Business One SDK:
Inventory Counting is exposed as a service type Object (InventoryCountingsService) in SAP Business One SDK.
Add an Inventory Counting Document using DI API:
SAPbobsCOM.CompanyService oCS = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
SAPbobsCOM.InventoryCountingsService oICS = oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryCountingsService);
SAPbobsCOM.InventoryCounting oIC = oICS.GetDataInterface(SAPbobsCOM.InventoryCountingsServiceDataInterfaces.icsInventoryCounting);
DateTime dt = DateTime.Now;
oIC.CountDate = DateTime.Now;
SAPbobsCOM.InventoryCountingLines oICLS = oIC.InventoryCountingLines;
SAPbobsCOM.InventoryCountingLine oICL = oICLS.Add();
oICL.ItemCode = "A00001";
oICL.CountedQuantity = 4;
oICL.WarehouseCode = "01";
oICL.Counted = SAPbobsCOM.BoYesNoEnum.tYES;
SAPbobsCOM.InventoryCountingParams oICP = oICS.Add(oIC);
Update an Inventory Counting Document using DI API:
SAPbobsCOM.CompanyService oCS = oCompany.GetCompanyService();
SAPbobsCOM.InventoryCountingsService oICS = (SAPbobsCOM.InventoryCountingsService)oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryCountingsService);
SAPbobsCOM.InventoryCountingParams oICP = (SAPbobsCOM.InventoryCountingParams)oICS.GetDataInterface(SAPbobsCOM.InventoryCountingsServiceDataInterfaces.icsInventoryCountingParams);
oICP.DocumentEntry = 1;
SAPbobsCOM.InventoryCounting oIC = oICS.Get(oICP) as SAPbobsCOM.InventoryCounting;
SAPbobsCOM.InventoryCountingLine line = oIC.InventoryCountingLines.Item(0);
line.CountedQuantity = 2;
oICS.Update(oIC);
Remove the lines/rows from an Inventory Counting Document using DI API:
SAPbobsCOM.CompanyService oCS = SBOCompany.GetCompanyService();
SAPbobsCOM.InventoryCountingsService oICS = (SAPbobsCOM.InventoryCountingsService)oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryCountingsService);
SAPbobsCOM.InventoryCountingParams oICP = (SAPbobsCOM.InventoryCountingParams)oICS.GetDataInterface(SAPbobsCOM.InventoryCountingsServiceDataInterfaces.icsInventoryCountingParams);
SAPbobsCOM.InventoryCountingLine oICl;
oICP.DocumentEntry = 1;
SAPbobsCOM.InventoryCounting oIC = oICS.Get(oICP) as SAPbobsCOM.InventoryCounting;
int i = 0;
while ((i < oIC.InventoryCountingLines.Count))
{
oICl = oIC.InventoryCountingLines.Item(i);
if ((oICl.CountedQuantity == 0))
{
oIC.InventoryCountingLines.Remove(i);
}
i = (i + 1);
}
oICS.Update(oIC);
Close an Inventory Counting Document using DI API:
SAPbobsCOM.CompanyService oCS = SBOCompany.GetCompanyService();
SAPbobsCOM.InventoryCountingsService oICS = (SAPbobsCOM.InventoryCountingsService)oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryCountingsService);
SAPbobsCOM.InventoryCountingParams oICP = (SAPbobsCOM.InventoryCountingParams)oICS.GetDataInterface(SAPbobsCOM.InventoryCountingsServiceDataInterfaces.icsInventoryCountingParams);
SAPbobsCOM.InventoryCountingLine oICl;
oICP.DocumentEntry = 1;
SAPbobsCOM.InventoryCounting oIC = oICS.Get(oICP) as SAPbobsCOM.InventoryCounting;
oICS.Close(oICP);
Dear Ankit,
Thank you, Its very useful
Dear Ankit,
Is there an option to save inventory counting as draft? Or is it only possible via SAP B1 Client?
Kind Regards,
Atilla
Hello Aniket,
InventoryCountingsService is available in Di Server ? Please update
Regards,
Rahul Jain
Hi Rahul Jain,
Yes, you can use InventoryCountingsService in DI Server.
Kind regards,
ANKIT CHAUHAN
SAP Business One Support