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

Inventory Posting in SAP Business One SDK

About Inventory Posting:

Inventory Posting is used to reconcile the item quantities with the Inventory Counting results.

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.

To access this window, from the SAP Business One Main Menu, choose  Inventory  Inventory Transactions Inventory Counting Transactions  Inventory Posting

For more details on Inventory Posting, you can refer to following link:

https://help.sap.com/saphelp_sbo92/helpdata/en/2f/ca149512334ee58fd95c1c9b3af841/content.htm

Using Inventory Posting in SAP Business One SDK:

Inventory Posting is exposed as a service type Object (InventoryPostingsService) in SAP Business One SDK.

Add an Inventory Posting Document using DI API:

SAPbobsCOM.CompanyService oCS = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
SAPbobsCOM.InventoryPostingsService oInventoryPostingsService = oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryPostingsService);
SAPbobsCOM.InventoryPosting oInventoryPosting = oInventoryPostingsService.GetDataInterface(SAPbobsCOM.InventoryPostingsServiceDataInterfaces.ipsInventoryPosting);
oInventoryPosting.CountDate = DateTime.Now;
SAPbobsCOM.InventoryPostingLines oInventoryPostingLines = oInventoryPosting.InventoryPostingLines;
SAPbobsCOM.InventoryPostingLine oInventoryPostingLine = oInventoryPostingLines.Add();
oInventoryPostingLine.ItemCode = "B10000";
oInventoryPostingLine.CountedQuantity = 13;
oInventoryPostingLine.WarehouseCode = "05";
oInventoryPostingLine.BinEntry = 2;
oInventoryPostingLine.Price = 58;
oInventoryPostingLine.UoMCode = "Carton";
oInventoryPostingLine.UoMCountedQuantity = 12;
SAPbobsCOM.InventoryPostingBatchNumber oInventoryPostingBatchNumber = oInventoryPostingLine.InventoryPostingBatchNumbers.Add();
oInventoryPostingBatchNumber.BatchNumber = "B-B1234";
oInventoryPostingBatchNumber.Quantity = 288;
SAPbobsCOM.InventoryPostingParams oInventoryPostingParams = oInventoryPostingsService.Add(oInventoryPosting);

Update an Inventory Posting Document using DI API:

SAPbobsCOM.CompanyService oCS = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
SAPbobsCOM.InventoryPostingsService oInventoryPostingsService = oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryPostingsService);
SAPbobsCOM.InventoryPostingParams oInventoryPostingParams = (SAPbobsCOM.InventoryPostingParams)oInventoryPostingsService.GetDataInterface(SAPbobsCOM.InventoryPostingsServiceDataInterfaces.ipsInventoryPostingParams);
oInventoryPostingParams.DocumentEntry = 1;
SAPbobsCOM.InventoryPosting oInventoryPosting = oInventoryPostingsService.Get(oInventoryPostingParams);
oInventoryPosting.Remarks = "TEST DI API";
oInventoryPostingsService.Update(oInventoryPosting);

Assigned tags

      4 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Andres Ramirez Jaramillo
      Andres Ramirez Jaramillo

      Hello ANKIT CHAUHAN
      How could I export and import via XML, as well as SaveXML and GetBusinessObjectFromXML?
      Thank you

      Andres Ramirez Jaramillo

      Author's profile photo ANKIT CHAUHAN
      ANKIT CHAUHAN
      Blog Post Author

      Hi Andres Ramirez Jaramillo,

      To prepare and debug an XML Payload or to detect the correctness of the XML payload, DI Tool can be used. It lists all DI objects and services supported by the currently selected DI API version. Also, it generates XML sample code for an object schema or a service schema.

      Refer to SAP Note 2057143 for the same.

      Hope it helps!

      Kind regards,

      ANKIT CHAUHAN

      SAP Business One Support

      Author's profile photo Rakesh Singh
      Rakesh Singh

      Hello Ankit,

      Could you further provide code for posting multiple lines.

      When we are posting data with multiple lines, then in SAP it is only showing one line. (only first line items is showing but the line number shows 2)

      So, any code sample with multiple line items would be helpful.

      Author's profile photo ANKIT CHAUHAN
      ANKIT CHAUHAN
      Blog Post Author

      Hi Rakesh Singh,

      Following sample should work:

      SAPbobsCOM.CompanyService oCS = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
      SAPbobsCOM.InventoryPostingsService oInventoryPostingsService = oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryPostingsService);
      SAPbobsCOM.InventoryPosting oInventoryPosting = oInventoryPostingsService.GetDataInterface(SAPbobsCOM.InventoryPostingsServiceDataInterfaces.ipsInventoryPosting);
      oInventoryPosting.CountDate = DateTime.Now;
      SAPbobsCOM.InventoryPostingLines oInventoryPostingLines = oInventoryPosting.InventoryPostingLines;
      SAPbobsCOM.InventoryPostingLine oInventoryPostingLine = oInventoryPostingLines.Add();
      oInventoryPostingLine.ItemCode = "A00003";
      oInventoryPostingLine.CountedQuantity = 596;
      oInventoryPostingLine.WarehouseCode = "01";
      
      oInventoryPostingLine = oInventoryPostingLines.Add();
      oInventoryPostingLine.ItemCode = "A00004";
      oInventoryPostingLine.CountedQuantity = 562;
      oInventoryPostingLine.WarehouseCode = "01";

      Kind regards,

      ANKIT CHAUHAN

      SAP Business One Support