Skip to Content
0

SAP 9 PL09 Inventory Posting with batch numbers

Nov 24, 2016 at 01:12 PM

152

avatar image

Good morning,
does someone has got some code about using InventoryPostingService with batch numbers?

In every manner I do that I've got always the same error (cause for sap b1 there's not sufficient quantity selected in batches).

Thank you in advance

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

10 Answers

Pedro Magueija Nov 24, 2016 at 01:59 PM
0

Hi Alessandro,

Can you post the code you are using so we can check what might be the issue?

Pedro Magueija

LinkedIn | Twitter | Blog

Share
10 |10000 characters needed characters left characters exceeded
Alessandro D'Amico Nov 24, 2016 at 02:49 PM
0
                        SAPbobsCOM.InventoryPostingLine Line = oDoc.InventoryPostingLines.Add();
                        Line.ItemCode = ItemCode;
                        Line.WarehouseCode = MagaDec;
                        Line.CountedQuantity = Quantity;
                        InventoryPostingBatchNumber mybatch = CurrentLine.InventoryPostingBatchNumbers.Add();
                        mybatch.BatchNumber = Quantity;
                        mybatch.Quantity = Math.Abs(UsedQty);

The "real" code is very complicated (because is inserted in a more big context), but the poc in the code is what I do. I think the question is: what's the quantity to put in the batchnumber? What about the sign?

It's also important to known that I made all controls about batch quantity and so on, but whichever way the problem remain the same.

Share
10 |10000 characters needed characters left characters exceeded
Pedro Magueija Nov 24, 2016 at 04:03 PM
0

Hi Alessandro,

Usually these "collections" such as batch/serial and even items, already have a row ready to use. When you invoke .Add() at the beginning without using this "default" row, you are effectively creating one more row, leaving the default empty.

Business One will then attempt to use the information there are throw some errors.

Move the .Add() to after setting the Batch information.

You're also assigning the quantity to the BatchNumber

mybatch.BatchNumber = Quantity;

Perhaps that's an error as well.

Pedro Magueija

LinkedIn | Twitter | Blog

Share
10 |10000 characters needed characters left characters exceeded
Alessandro D'Amico Nov 24, 2016 at 04:14 PM
0

Thank you Pedro,

I know that thing but it seems in this case it's not so, but I'm going to try it, anyway.

I'll let you know asap if it is only a problem related to this.
Share
10 |10000 characters needed characters left characters exceeded
Alessandro D'Amico Nov 24, 2016 at 04:21 PM
0

Hi,

I get the document in XML format and there's no a blank batchnumber/quantity.

So I think it's not an error due to the position of the "Add()" method. I also checked the presence of an "item(0)" in the object, but it doesn't exist.

So at this point: is this a bug in DI???

Share
10 |10000 characters needed characters left characters exceeded
Pedro Magueija Nov 25, 2016 at 08:21 AM
0

Hi Alessandro,

I've tried this as well and it fails (on 9.1 and 9.2). I'd say you're right and there is something wrong with the DI API.

You'll have to open a ticket with SAP.

Could you let us know what the reply from SAP is?

Note: this seems to be reproducible from the client.

Pedro Magueija

LinkedIn | Twitter | Blog

Share
10 |10000 characters needed characters left characters exceeded
Alessandro D'Amico Nov 25, 2016 at 10:36 AM
0

Hi Pedro,

only one (ehm...two) more things:

1) Can you post the complete proof of concept of the code you used to reproduce the issue?
2) You say that this is reproducible by client. If I'm not wrong in my test all works fine by client.

Thank you.

Share
10 |10000 characters needed characters left characters exceeded
Pedro Magueija Nov 25, 2016 at 11:33 AM
0

Hi Alessandro,

Here is the code that fails for me:

var companyService = company.GetCompanyService();
var postingSrv = companyService.GetBusinessService(ServiceTypes.InventoryPostingsService) as InventoryPostingsService;

var posting = postingSrv.GetDataInterface(InventoryPostingsServiceDataInterfaces.ipsInventoryPosting) as InventoryPosting;

var line = posting.InventoryPostingLines.Add();
line.ItemCode = "B90123";
line.CountedQuantity = 1;
line.WarehouseCode = "01";

var batch = line.InventoryPostingBatchNumbers.Add();
batch.BatchNumber = "B90001";
batch.Quantity = 1;

var results = postingSrv.Add(posting);

Here is the same attempt in the client:

Note: if you use the Create button and create a new batch, it works.

Perhaps this is where we should read the documentation on Inventory Posting (from a functional perspective)?

Pedro Magueija

LinkedIn | Twitter | Blog


ivpost-add.png (267.3 kB)
Show 2 Share
10 |10000 characters needed characters left characters exceeded

Hi Pedro,

Can I see your Inventory Posting screen above, I wonder why the total selected quantity is -1.
The create button should be used if your current inventory is less than the counted quantity.
But then again, the error message is pointing to line 2.

Regards
Edy

0

Hi Edy,

Yeah, I found that weird too, and even weirder is that if you create a batch rather than use an existing one, it works.

One more thing I didn't type -1, I actually typed 1 and then pressed '>'. That's when it becomes -1.

Do you have the same issue?

Pedro Magueija

LinkedIn | Twitter | Blog

0
Alessandro D'Amico Nov 25, 2016 at 01:44 PM
0

Thank you so much Pedro,
I'm going to open a ticket to SAP (it's really the first for me about DI...).

I think it's very important to understand if this is a bug or something else.

I'll post here the result.

Bye.

Share
10 |10000 characters needed characters left characters exceeded
Edy Simon Nov 30, 2016 at 02:11 AM
0

Hi All,

After checking with my manager,

Turns out this is the correct design.
In the inventory posting screen, The batch selection is the batch that you don't have in your stock instead of the batch you have.
Example, Item A, in your inventory you still have Batch1 - Qty 1 and Batch2 Qty1.
When you do inventory posting, let's say counted quantity is 1 only and the correct physical batch in your WHS is Batch1.
Your batch selection criteria is Batch2-Qty 1 (The batch that you don't have and need to adjust)
If your counted qty is equal to your inventory qty, then you don't need to select the batch.

Regards
Edy

Share
10 |10000 characters needed characters left characters exceeded