on 2010 Aug 24 10:22 AM
Hi
I have written some code to import a goods receipt po document in SAP 8.8
When the item is a batch number I get the message 'Cannot add row without complete selection of batch / serial numbers'
This is my code -
doc.Lines.SerialNumbers.SetCurrentLine(0)
doc.Lines.SerialNumbers.InternalSerialNumber = batchno
doc.Lines.SerialNumbers.ExpiryDate = CDate(bbdate2)
doc.Lines.SerialNumbers.ReceptionDate = CDate(Now.Date)
Can anyone see what is wrong please ?
Many thanks
Regards Andy
Request clarification before answering.
I have the same error tring to remove batch and serial numbers in the Inventory Postings document and before many tests witch a friend we realized that have a logic between the CountedQuantity field in lines and the Quantity field in the batch or serial sub object.
The logic is, if you want to add a new batch or serial you need to set the field CountedQuantity for exemplo 1 number major than the quantity in stock, and add the batch or serial with te quantity that you added (in case of batch you add the quantity in field quantity, and serial you add the multiple serial numbers corresponding of the quantity).
And if you want to remove batch or serial you need to set CountedQuantity with the reduced quantity and fill the arrays of batch or serial with negative values, thats calls the SAP that you want to remove quantities from stock.
Example in Service Layer:
// removing serial
{
"CountDate": "2024-12-11T00:00:00Z",
"BranchID": 1,
"U_P1_OWNER": 15,
"InventoryPostingLines": [
{
"LineNumber": 1,
"Remarks": "REF100037; R002; R003; R004",
"ItemCode": "IT101",
"WarehouseCode": "01",
"Price": 1,
"CountedQuantity": 3,
"InventoryPostingSerialNumbers": [
{
"InternalSerialNumber": "R007",
"Quantity": -1
}
]
}
]
}
// adding serial
{
"CountDate": "2024-12-11T00:00:00Z",
"BranchID": 1,
"U_P1_OWNER": 15,
"InventoryPostingLines": [
{
"LineNumber": 1,
"Remarks": "REF100037; R002; R003; R004",
"ItemCode": "IT101",
"WarehouseCode": "01",
"Price": 1,
"CountedQuantity": 3,
"InventoryPostingSerialNumbers": [
{
"InternalSerialNumber": "R007",
"Quantity": 1
}
]
}
]
}
Example in DI API:
SAPbobsCOM.CompanyService oCS = (SAPbobsCOM.CompanyService)oCompany.GetCompanyService();
SAPbobsCOM.InventoryPostingsService oInventoryPostingsService = (InventoryPostingsService)oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryPostingsService);
SAPbobsCOM.InventoryPosting oInventoryPosting = (InventoryPosting)oInventoryPostingsService.GetDataInterface(SAPbobsCOM.InventoryPostingsServiceDataInterfaces.ipsInventoryPosting);
oInventoryPosting.CountDate = "YOUR DATE";
oInventoryPosting.BranchID = "YOUR BRANCH";
SAPbobsCOM.InventoryPostingLines oInventoryPostingLines = oInventoryPosting.InventoryPostingLines;
SAPbobsCOM.InventoryPostingLine oInventoryPostingLine = oInventoryPostingLines.Add();
oInventoryPostingLine.ItemCode = "YOUR ITEM CODE";
oInventoryPostingLine.WarehouseCode = "YOUR WAREHOUSE";
oInventoryPostingLine.Price = 1; //exemple price
oInventoryPostingLine.CountedQuantity = 3; //exemple count
// removing serial
SAPbobsCOM.InventoryPostingSerialNumber serialNumber = oInventoryPostingLine.InventoryPostingSerialNumbers.Add();
serialNumber.InternalSerialNumber = item.Lote;
serialNumber.Quantity = -1;
// adding serial
SAPbobsCOM.InventoryPostingSerialNumber serialNumber = oInventoryPostingLine.InventoryPostingSerialNumbers.Add();
serialNumber.InternalSerialNumber = item.Lote;
serialNumber.Quantity = 1;
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
60 | |
9 | |
8 | |
6 | |
5 | |
4 | |
3 | |
3 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.