0
我嘗試使用下面的代碼來創建基於現有SalesOrder新SalesInvoice:Dynamics GP的Web服務:SalesInvoice創作與單位分配
SalesInvoice invoice = new SalesInvoice();
invoice.DocumentTypeKey = new SalesDocumentTypeKey { Type = SalesDocumentType.Invoice };
invoice.CustomerKey = originalOrder.CustomerKey;
invoice.BatchKey = originalOrder.BatchKey;
invoice.Terms = new SalesTerms { DiscountTakenAmount = new MoneyAmount { Value = 0, Currency = "USD", DecimalDigits = 2 }, DiscountAvailableAmount = new MoneyAmount { Value = 0, Currency = "USD", DecimalDigits = 0 } };
invoice.OriginalSalesDocumentKey = originalOrder.Key;
List<SalesInvoiceLine> lineList = new List<SalesInvoiceLine>();
for (int i = 0; i < originalOrder.Lines.Length; i++)
{
SalesInvoiceLine line = new SalesInvoiceLine();
line.ItemKey = originalOrder.Lines[i].ItemKey;
line.Key = new SalesLineKey { LineSequenceNumber = originalOrder.Lines[i].Key.LineSequenceNumber; }
SalesLineLot lot = new SalesLineLot();
lot.LotNumber = originalOrder.Lines[i].Lots[0].LotNumber;
lot.Quantity = new Quantity { Value = 2200 };
lot.Key = new SalesLineLotKey { SequenceNumber = originalOrder.Lines[i].Lots[0].Key.SequenceNumber };
line.Lots = new SalesLineLot[] { lot };
line.Quantity = new Quantity { Value = 2200 };
lineList.Add(line);
}
invoice.Lines = lineList.ToArray();
DynamicsWS.CreateSalesInvoice(invoice, DynamicsContext, DynamicsWS.GetPolicyByOperation("CreateSalesInvoice", DynamicsContext));
在執行時,我收到以下錯誤:
SQL Server Exception: Operation expects a parameter which was not supplied.
而且從異常控制檯動態的更詳細的異常:
Procedure or function 'taSopLotAuto' expects parameter '@I_vLNITMSEQ',
which was not supplied.
經過Google的大量挖掘之後,我發現了一些事情。
- 'taSopLotAuto'是銷售訂單處理組件中的eConnect過程,它嘗試自動填充批次。我不希望批量自動填充,這就是爲什麼我嘗試在代碼中手動填充它們的原因。我還將CreateSalesInvoice策略從GP批次自動執行修改爲GP Web服務用戶手動批次執行,但這並未改變調用哪個eConnect過程。
- 「@I_vLNITMSEQ」是指LineSequenceNumber。 LineSequenceNumber和SequenceNumber(Lot本身)必須匹配。在我的情況下,它們都是默認值:16384.這個參數不僅在上面的代碼中設置,而且它也出現在服務器試圖處理的SOAP消息中 - 幾乎「沒有提供」。
我可以創建一個沒有問題的發票無條件訂單項,但如果我添加訂單項則失敗。我不明白爲什麼我收到一個錯誤的參數顯然存在。
有關如何通過Dynamics GP 10.0 Web Services成功創建SalesInvoice的任何想法?
我還需要做出的CreateSalesInvoice政策的一個額外的變化,以自動創建垃圾箱阻止它。這與@mhommedn建議的代碼結合解決了這個問題。謝謝。 –