on 08-24-2016 4:04 AM
Hi Guys,
I am having an issue when posting Delivery Notes or Stock Transfers with Serial tracked items via Service Layer.
I am using SAP Business One For Hana 9.2 PL02.
The error received from Service Layer response is:
{
"error" : {
"code" : -10,
"message" : {
"lang" : "en-us",
"value" : "1470000838 - Invalid \"SerialAndBatchNumbersBaseLine\"; specify a valid \"SerialAndBatchNumbersBaseLine\""
}
}
}
I have followed the SCN Support Note https://launchpad.support.sap.com/#/notes/0001937920 but still having the issue.
It happens even when posting a Delivery Note or Stock Transfer with only one serial on it.
I ensure the SerialAndBatchNumbersBaseLine value is correct so I still do not get it why the error.
Please find below Test Code I am using to debug this issue:
* Test Code For Delivery Notes:
Document oDeliveryNote = new SAPB1HanaServiceLayer.SAPB1.Document();
oDeliveryNote.DocType = "dDocument_Items";
oDeliveryNote.CardCode = "C30000";
DocumentLine oLine = null;
oLine = new DocumentLine();
oLine.ItemCode = "A00006";
oLine.Quantity = 1;
SerialNumber Ser = new SerialNumber();
Ser.BaseLineNumber = 0;
Ser.InternalSerialNumber = "A6-000338";
Ser.Quantity = 1;
oLine.SerialNumbers.Add(Ser);
DocumentLinesBinAllocation BinAlloc = new DocumentLinesBinAllocation();
BinAlloc.BaseLineNumber = 0;
BinAlloc.BinAbsEntry = 74;
BinAlloc.Quantity = 1;
BinAlloc.SerialAndBatchNumbersBaseLine = 0;
oLine.DocumentLinesBinAllocations.Add(BinAlloc);
oDeliveryNote.DocumentLines.Add(oLine);
* Test Code For Stock Transfers:
StockTransfer oStockTransfer = new SAPB1HanaServiceLayer.SAPB1.StockTransfer();
oStockTransfer.Comments = "Jose Joya Test Transfers Serials via SAP1 Service Layer";
oStockTransfer.FromWarehouse = "01";
StockTransferLine oLine = null;
oLine = new StockTransferLine();
oLine.ItemCode = "A00006";
oLine.Quantity = 1;
oLine.FromWarehouseCode = "01";
StockTransferLinesBinAllocation BinLocFrom = new StockTransferLinesBinAllocation();
BinLocFrom.BinActionType = "2";
BinLocFrom.BinAbsEntry = 74;
BinLocFrom.Quantity = 1;
BinLocFrom.SerialAndBatchNumbersBaseLine = 0;
oLine.WarehouseCode = "01";
StockTransferLinesBinAllocation BinLocTo = new StockTransferLinesBinAllocation();
BinLocTo.BinActionType = "1";
BinLocTo.BinAbsEntry = 75;
BinLocTo.Quantity = 1;
BinLocTo.SerialAndBatchNumbersBaseLine = 0;
oLine.StockTransferLinesBinAllocations.Add(BinLocFrom);
oLine.StockTransferLinesBinAllocations.Add(BinLocTo);
oStockTransfer.StockTransferLines.Add(oLine);
.
.
.
Could someone please assist?
Posting Delivery Notes And Transfer Documents without Batch/Serial Tracked items works well. The issue happens only when using tracked items.
Hi Jose,
Please comment the follow lines in the RebuildComplexValue function in ServiceLayerService.cs
There are some special logic to handle 0 value here before sending the request to Service Layer.
The current logic is ignore the property having value as zero. Simply, zero is quite special in B1, some times it is just like a null value by default for some property.
In your case, we shouldn't use this piece of logic for we intend to set the BaseLine as 0.
for example.
BaseLine = 0;
private ODataComplexValue RebuildComplexValue(ODataComplexValue source)
{
ODataComplexValue newVal = new ODataComplexValue();
newVal.TypeName = source.TypeName;
List<ODataProperty> complexSons = source.Properties.ToList();
//Filter to get new list
List<ODataProperty> filteredSons = new List<ODataProperty>();
foreach (ODataProperty prop in complexSons)
{
PropertyType retType = GetPropertyType(prop);
switch (retType)
{
case PropertyType.SimpleEdmx:
{
if (null != prop.Value)
{
if (prop.Value.GetType().Name == "Int32")
{
//Check the value now.
bool bInclude = false;
try
{
//TODO: You cannot simply do this, potential bugs there maybe.
//Use your own logics the determine if need to ignore ZEORs or not.
int val = Convert.ToInt32(prop.Value);
bInclude = (0 != val);
}
catch (Exception)
{
}
if (bInclude)
filteredSons.Add(prop);
}
else
filteredSons.Add(prop);
}
}
break;
case PropertyType.ComplexType:
{
//Recursively
ODataComplexValue comx = RebuildComplexValue((ODataComplexValue)prop.Value);
if (comx.Properties.Count() > 0)
{
prop.Value = comx;
filteredSons.Add(prop);
}
}
break;
case PropertyType.Collection:
{
ODataCollectionValue coll = RebuildCollectionValue((ODataCollectionValue)prop.Value);
List<ODataComplexValue> listSubs = (List<ODataComplexValue>)coll.Items;
if (listSubs.Count > 0)
{
prop.Value = coll;
filteredSons.Add(prop);
}
}
break;
default:
break;
}
}
//Re-Assign sons
newVal.Properties = filteredSons;
return newVal;
}
Kind Regards, Yatsea
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Yatsea,
I comment out the lines in the RebuildComplexValue function in ServiceLayerService.cs as per your suggestion.
Still receiving same error:
{
"error" : {
"code" : -10,
"message" : {
"lang" : "en-us",
"value" : "1470000838 - Invalid \"SerialAndBatchNumbersBaseLine\"; specify a valid \"SerialAndBatchNumbersBaseLine\""
}
}
}
Any other suggestion?
Hi Jose,
Please kindly set a break point on the line of.
if (null != prop.Value)
And check if it comes through there.
eventually, the code should be equivalent to this, make sure filteredSons.Add(prop) is still there. This is the only trick. The reason is still BaseLine = 0 isn't included into the body. Please assure you comment it right.
case PropertyType.SimpleEdmx:
{
if (null != prop.Value)
{
filteredSons.Add(prop);
}
}
break;
In addition, you also use fiddler tool to check what is the exact body send to Service Layer.
Download Fiddler Web Debugging Tool for Free by Telerik
And you also can try to use Postman in GoogleChrome to post the correct payload to test if it works in SL. Mostlikey, it works. The problem is only in WCF project, where we don't include the propeorty with an integer zero value
Kind Regards, Yatsea
User | Count |
---|---|
108 | |
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.