2016 Nov 24 1:12 PM - edited 2024 Feb 03 6:33 PM
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
Request clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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???
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
116 | |
7 | |
6 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.