on 10-14-2016 12:58 PM - last edited on 02-03-2024 6:43 PM by postmig_api_4
My item master contains a couple of items for which I cannot reliably add a Goods Receipt via DI API in SAP Business One 9.0 PL9. The resulting error message is cryptic and doesn't seem applicable. I think there must be some nuance of creating a Goods Receipt that I don't understand. Here is code showing all the steps I take. What am I missing?
public void AddGoodsReceipt(
SAPbobsCOM.Company company,
string receivedItemCode,
string warehouseCode,
double standardCost,
double receivedQuantity,
string referenceDoc
) {
var grh = company.GetBusinessObject( SAPbobsCOM.BoObjectTypes.oInventoryGenEntry ) as SAPbobsCOM.Documents;
grh.DocDate = DateTime.Today;
grh.Reference1 = referenceDoc;
grh.JournalMemo = "GR:" + referenceDoc;
grh.Comments = "Goods Receipt: " + referenceDoc;
var grl = grh.Lines;
grl.ItemCode = receivedItemCode;
grl.UnitPrice = standardCost;
grl.Quantity = receivedQuantity;
grl.WarehouseCode = warehouseCode;
grl.Add();
if ( grh.Add() != 0 ) {
// Here we fail.
// The error code is: -5011
// The error message is: [IGN1.WhsCode][line:1], 'Invalid Account Code'
// The receivedItemCode refers to an item whose GLMethod is "Item Group" (not Warehouse)
// The same group is used for other item-group-managed items for which this code works!
// In other words, there doesn't seem to be a difference in the configuration of items
// which do work versus items which don't. So it makes me think some step is missing
// in the code above.
}
}
Hi Charles,
Have you checked the GL Accounts settings?
Here is a similar problem: https://archive.sap.com/discussions/thread/3617365 but with Inventory Transfer.
I'm not an accountant but here are my settings on a demo database:
Good luck.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Charles,
Try check this link:
https://archive.sap.com/discussions/thread/3187695
Maybe it's your problem.
Kind Regards,
Diego Lother
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.
I just tried in the Business One Client and get the same result. I can successfully add a Goods Receipt for a quantity of 1. But if I try to add one for a quantity of 2, the add fails and the little red bar at the bottom of the screen displays the same error I reported above, but slightly more verbosely: [Goods Receipt - Rows - Warehouse Code][line: 1] , 'Invalid Account Code' [Message 173-9]
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem seems to be related to quantity. If I have a quantity of 1, the Goods Receipt will be created. A quantity of 2 or more fails. This sounds crazy, but I've reproduced it several times this afternoon. For quantity to affect a Goods Issue would make sense, because you may not be able to issue more than the quantity in inventory. But how could quantity possibly affect a Goods Receipt?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Charles,
Did you try reproduce this situation in SAP B1 client?
Because SAP loads automatically account code for the line of your goods receipt, but if the account code is not defined, I believe that you need provide this information. Try too in this case set an account code in the property AccountCode in the line of your object.
Hope it helps.
Kind Regards,
Diego Lother
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you, Diego. In fact my item group does have both Inventory Offset accounts defined, so this isn't the problem. I should have mentioned in my original post that I can indeed create Goods Receipts for these items in the client. That's what leads me to believe the issue is a problem in my code rather than a configuration error in SAP.
User | Count |
---|---|
103 | |
12 | |
11 | |
6 | |
5 | |
4 | |
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.