Skip to Content

Problem in SAPbobsCOM.InventoryPosting with batches on 9.2 version

Hi all,

We have an integration app, that creates InventoryPosting documents into SAP based on warehouse counting results sent from an external system.

The process has worked fine in version 9.1 although items were non-batch managed.

After customer has upgrade to version 9.2 we need to count also batch items, and we are getting the error "Cannot add row without complete selection of batch/serial numbers"...

Based on documentation and SAP standard behavior, when we add batch item counting, we do the following:

- we only add InventoryPostingLine.Add() lines for batchs with qty difference

- if a batch qty difference exists, we add it with InventoryPostingBatchNumbers

- in the item line, we post the total qty counted for all item batches

Here is a simple test to get this error:

- In SAP, Item A001 has 2 batches AAA and BBB with 10 UN each

- After counting, batch BBB has only 6 UN; batch AAA has 0 counted qty

- Our code adds a SAPbobsCOM.InventoryPosting document and executes the following sequence:

- it adds a SAPbobsCOM.InventoryPostingLine.Add() for item A001

- then it adds a InventoryPostingBatchNumbers.Add() for batch AAA with dif qty 10

- then it adds a InventoryPostingBatchNumbers.Add() for batch BBB with dif qty 4

- finally it sets the line CountedQuantity to 6

- when it adds the inventory counting, we get the above error

What is the problem with this process? We tried different combinations but cant figure out how to add the Inventory posting on SAP...

Thanks

Manuel Dias

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    Dec 23, 2016 at 02:55 AM
    ,

    Hi Manuel,
    The below works for me :

            private static void CreatePosting(SAPbobsCOM.Company oC)
            {
                SAPbobsCOM.CompanyService oCS = oC.GetCompanyService();
                SAPbobsCOM.InventoryPostingsService oPS = oCS.GetBusinessService(SAPbobsCOM.ServiceTypes.InventoryPostingsService) as SAPbobsCOM.InventoryPostingsService;
                SAPbobsCOM.InventoryPosting oP = oPS.GetDataInterface(SAPbobsCOM.InventoryPostingsServiceDataInterfaces.ipsInventoryPosting) as SAPbobsCOM.InventoryPosting;
                SAPbobsCOM.InventoryPostingParams oPP = null;
    
    
                SAPbobsCOM.InventoryPostingLine oPL = oP.InventoryPostingLines.Add();
                oPL.ItemCode = "B10001";
                oPL.WarehouseCode = "01";
                oPL.CountedQuantity = 6;
    
    
    
    
                SAPbobsCOM.InventoryPostingBatchNumber oPLB = oPL.InventoryPostingBatchNumbers.Add();
                oPLB.BaseLineNumber = 1;
                oPLB.Location = "01";
                oPLB.BatchNumber = "B1234";
                oPLB.Quantity = -10;
    
    
                oPLB = oPL.InventoryPostingBatchNumbers.Add();
                oPLB.BaseLineNumber = 1;
                oPLB.Location = "01";
                oPLB.BatchNumber = "C1234";
                oPLB.Quantity = -4;
    
    
                String sXML = oP.ToXMLString();
                try
                {
                    oPP = oPS.Add(oP);
                    System.Console.WriteLine("Posted " + oPP.DocumentNumber.ToString());
                }
                catch (Exception Ex)
                {
                    System.Console.WriteLine(Ex.Message);
                }
            }
    

    Note the batch quantity are negative if you have less counted qty.
    My scenario : Item Code =B1001, Existing SAP Record QTY = Batch 'B1234' = 10 + Batch 'C1234' = 10
    Counted Qty = Batch 'B1234' = 0 + Batch 'C1234' = 6

    Regards

    Edy

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 22, 2016 at 01:22 AM

    Hi Manuel,

    Are you adding inventory counting or inventory posting ? Sorry, a bit confused because your post mixes the two terms.
    Your logic should be correct for posting object, not for counting object.
    Or you can try creating counting document, then create the posting object based on the counting document.

    Regards

    Edy

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 22, 2016 at 03:40 PM

    Hi Edy,

    I meant a inventory posting document, not a inventory counting document: our customer wanted to post the counting differences directly, when the external system sends the final count results.

    In the end, if we can't figure out the problem, we can analyze the alternative way you suggest: first post the inventory counting and immediately next, copy it to inventory posting...

    However, either our inventory posting algorithm is wrong or the DI-API has a bug...

    Thanks,

    mdias

    Add comment
    10|10000 characters needed characters exceeded

  • Dec 26, 2016 at 04:29 PM

    Hi Edy,

    Thanks for the example.

    It allowed us to realize the problem was related to another issue: the inventory posting was sent several days after the physical counting which lead to different stock figures in SAP since the posting algorythm takes into account the current SAP stock figures, thus originating the typical "Cannot add row without complete selection of batch/serial numbers" error...

    mdias

    Add comment
    10|10000 characters needed characters exceeded