Enterprise Resource Planning Blogs by SAP
Get insights and updates about cloud ERP and RISE with SAP, SAP S/4HANA and SAP S/4HANA Cloud, and more enterprise management capabilities with SAP blog posts.
cancel
Showing results for 
Search instead for 
Did you mean: 
ANKIT_CHAUHAN
Product and Topic Expert
Product and Topic Expert
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:

http://help.sap.com/saphelp_sbo92/helpdata/en/06/2b155358d8ff07e10000000a423f68/content.htm?frameset...

 

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);
16 Comments