Product Information
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 →
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);
Hello ANKIT CHAUHAN
How could I export and import via XML, as well as SaveXML and GetBusinessObjectFromXML?
Thank you
Andres Ramirez Jaramillo
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
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.
Hi Rakesh Singh,
Following sample should work:
Kind regards,
ANKIT CHAUHAN
SAP Business One Support