Skip to Content
0
Jul 08, 2019 at 08:10 PM

SAP B1 9.3 Service Layer: 1st line always fails for Issues from Production and Stock transfer

920 Views Last edit Jul 09, 2019 at 04:45 PM 4 rev

When generating Issue from Production using Service Layer based on existing Production Order the first line from production order always fails with the error:

System.Data.Services.Client.DataServiceRequestException: An error occurred while processing this request. ---> System.Data.Services.Client.DataServiceClientException: {
"error" : {
"code" : -10,
"message" : {
"lang" : "en-us",
"value" : "Quantity falls into negative inventory [DocumentLines.ItemCode][line: 1]"
}
}
}

Note, for some reason it shows [line: 1], while single line documents normally would show [line: 0].

I created a simple BOM with only 2 lines and a simple Production Order, when creating issues from production using C# (via Service Layer) Second line generates correct document, while first line always throws an above Exception. I tried creating a new production order and switched those items around and the item that had error now generates issue from production while the first item on the BOM generates the error.

Running through debug I can see that Document only has 1 line and after checking base document for unique identifiers all appear to be set correctly for both items, yet item on the first line of production always fails to post via Service Layer. Quantities in warehouse are exceeding the amounts we trying to issue by thousands.

These are the reference fields I map:

line.BaseEntry = 160; //matches document absolute entry of base production order
line.BaseLine = 0; // first line on the production lineNum and VisOrder are both 0
line.BaseType = 202; //202 for production order

When I use those same parameters with line.BaseLine = 1; (for the second item) it generates the document as expected.

Any idea if there is a workaround or a fix? That same process works for both items via DI API and issue seems to be isolated to service layer.

Similar problem happens when trying to create transfer based on transfer request when passing baseLine 0 it blows up with the following error:

System.Data.Services.Client.DataServiceRequestException: An error occurred while processing this request. ---> System.Data.Services.Client.DataServiceClientException: {
"error" : {
"code" : -10,
"message" : {
"lang" : "en-us",
"value" : "Enter a valid value in \"Whse\" field [Mensagem 0-0]"
}
}
}

This happens for any item as long as it is on the first line of transfer request or production order.

Any advice or a solution to this is appreciated.