cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Cannot add row without complete selection of batch / serial numbers SBO 8.8

former_member221339
Participant
0 Kudos
5,245

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member

Hello

You would like to import items with batches or items with serials?

This code is importing items with serials.

Hereby an expample for each cases


'bacthes

        oDoc.Lines.BatchNumbers.SetCurrentLine(0)
        oDoc.Lines.BatchNumbers.BatchNumber = "1"
        oDoc.Lines.BatchNumbers.Quantity = 1
        oDoc.Lines.BatchNumbers.Add()
        oDoc.Lines.BatchNumbers.SetCurrentLine(1)
        oDoc.Lines.BatchNumbers.BatchNumber = "2"
        oDoc.Lines.BatchNumbers.Quantity = 1
        oDoc.Lines.BatchNumbers.Add()
        ' here you should apply condition: sum of batch qty = oDoc.Lines.Quantity -this completes the selection
        oDoc.Lines.Add()

'serials
       
        oDoc.Lines.SerialNumbers.SetCurrentLine(0)
        ' Use the correct line for selection of serial numbers:
        ' I have the settings "None" -> Systemserialnumber will be used
        ' query: SELECT T0.[SriUniqFld] FROM OADM T0
        oDoc.Lines.SerialNumbers.SystemSerialNumber = "1"
        'oDoc.Lines.SerialNumbers.ManufacturerSerialNumber = "1"
        'oDoc.Lines.SerialNumbers.InternalSerialNumber = "1"
        oDoc.Lines.SerialNumbers.Add()
        oDoc.Lines.SerialNumbers.SetCurrentLine(0)
        oDoc.Lines.SerialNumbers.SystemSerialNumber = "2"
        'oDoc.Lines.SerialNumbers.ManufacturerSerialNumber = "2"
        'oDoc.Lines.SerialNumbers.InternalSerialNumber = "2"
        oDoc.Lines.SerialNumbers.Add()
        ' here you should apply condition: count of serialnumer lines = oDoc.Lines.Quantity

Regards

János

former_member221339
Participant
0 Kudos

Hi Janos

It's batch numbers

That worked and thanks

I was being silly and using serial numbers and not batchnumbers for some reason !

Thanks again

Regards Andy

Answers (1)

Answers (1)

gabriel-20206
Discoverer
0 Kudos

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;