使用acumatica系统中的webservices API在屏幕Bill And Adjusment中导入金额

我需要使用webservices将Amount Paid的值导入Acumatica ERP系统。 请参阅下面的截图。

在此处输入图像描述

我已经使用参考编号=“1700000016”,DocType =“Bill”,VendorRef =“SV-889-JKT-2”,VendorID =“V000000030”和Amount Paid =“1,250,000”创建了一些代码。 请参阅下面的代码。

sCon.getLogin(username, password, url, context); AP301000Content konten = context.AP301000GetSchema(); //context.AP301000Clear(); List oCmds = new List(); //oCmds.Add(konten.Actions.Insert); //--------------- adding header transaction -----------------// konten.DocumentSummary.Type.Commit = false; konten.DocumentSummary.Type.LinkedCommand = null; oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.Type, Value = "Bill" }); oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.ReferenceNbr, Value = "0000" }); oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.Date, Value = dtDateSV.Text }); oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.VendorRef, Value = "SV-889-JKT-2" }); oCmds.Add(new Value { LinkedCommand = konten.DocumentSummary.Vendor, Value = "V000000030" }); //-------------- adding detail transaction (Based on values in Data Grid )------------- int a = dgvDocDetailSV.Rows.Count; for (int x = 0; x < a; x++) { oCmds.Add(konten.DocumentDetails.ServiceCommands.NewRow); oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.Branch, Value = dgvDocDetailSV.Rows[x].Cells[1].Value.ToString() }); oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.InventoryID, Value = dgvDocDetailSV.Rows[x].Cells[2].Value.ToString() }); oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.JobOrderNbr, Value = dgvDocDetailSV.Rows[x].Cells[3].Value.ToString() }); oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.Quantity, Value = dgvDocDetailSV.Rows[x].Cells[4].Value.ToString() }); oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.UOM, Value = dgvDocDetailSV.Rows[x].Cells[5].Value.ToString() }); oCmds.Add(new Value { LinkedCommand = konten.DocumentDetails.UnitCost, Value = dgvDocDetailSV.Rows[x].Cells[6].Value.ToString() }); } //------ add document in Applications Tab Menu -------// string DocTypePrepayment = "Prepayment"; string RefNbrPrepayment = "1700000015"; oCmds.Add(new Key { ObjectName = konten.Applications.DocTypeDisplayDocType.ObjectName, FieldName = konten.Applications.DocTypeDisplayDocType.FieldName, Value = DocTypePrepayment }); oCmds.Add(new Key { ObjectName = konten.Applications.ReferenceNbrDisplayRefNbr.ObjectName, FieldName = konten.Applications.ReferenceNbrDisplayRefNbr.FieldName, Value = RefNbrPrepayment }); oCmds.Add(new Value { LinkedCommand = konten.Applications.AmountPaid, Value = "1250000" }); //------ save transaction in acumatica -------// oCmds.Add(konten.Actions.Save); var result = context.AP301000Submit(oCmds.ToArray()); 

尝试导入此数据后,我收到一条错误消息。 错误消息是“System.Web.Services.Protocols.SoapException:Server无法处理请求.—> PX.Data.PXException:错误#111:处理字段时发生错误CuryAdjdAmt:对象引用未设置为对象的实例.. —> System.NullReferenceException:对象引用未设置为对象的实例。“ 字段CuryAdjdAmt似乎为null,并且此字段映射到Acumatica System的“应用程序菜单”选项卡中的AmountPaid字段。

请给我参考解决这个问题。 谢谢

看起来调整数据视图委托存在问题,这是由我们在一年前为“帐单和调整”屏幕所做的性能改进引起的。 我已将所有细节转发给Acumatica工程团队进行进一步调查。

作为临时解决方法,您可以为APInvoiceEntry BLC实现扩展,并稍微更改Adjustments数据视图的委托:

 public class APInvoiceEntryExt : PXGraphExtension { [PXCopyPasteHiddenView] public PXSelectJoin, And>>>> Adjustments; public IEnumerable adjustments() { IEnumerable result; bool origIsImport = Base.IsImport; Base.IsImport = false; try { result = Base.Adjustments.Select(); } finally { Base.IsImport = origIsImport; } return result; } } 

通过应用临时解决方法,我可以使用以下命令集更新AmountPaid字段。 鉴于调整数据视图中的复杂程度(因为它必须处理从数据库检索并在运行时创建的记录),当“应用程序”选项卡中有多个文档时,必须使用RowNumber服务命令(屏幕 – 遗憾的是,基于Key类型的API命令无法在“应用程序”选项卡中找到记录。

下面的示例将向Acumatica API发送2个请求: – 第一次调用以从“应用程序”选项卡导出所有记录 – 通过循环返回的数组,您可以确定哪些是需要为AmountPaid设置新值的记录的RowNumbers – 第二次调用,您传递RowNumber并将新值分配给AmountPaid字段

 Screen context = new Screen(); context.CookieContainer = new System.Net.CookieContainer(); context.Url = "http://localhost/AP301000/Soap/AP301000.asmx"; context.Login("admin", "123"); Content billSchema = context.GetSchema(); // 1st call to export all records from the Applications tab billSchema.DocumentSummary.Type.Commit = false; billSchema.DocumentSummary.Type.LinkedCommand = null; var commands = new Command[] { new Value { Value = "Bill", LinkedCommand = billSchema.DocumentSummary.Type }, new Value { Value = "000927", LinkedCommand = billSchema.DocumentSummary.ReferenceNbr }, billSchema.Applications.DocTypeDisplayDocType, billSchema.Applications.ReferenceNbrDisplayRefNbr, billSchema.Applications.Balance }; var applications = context.Submit(commands).ToList(); // end of 1st call to export all records from the Applications tab // 2nd call to set AmountPaid in the Applications tab var cmds = new List(); foreach (var application in applications) { cmds.Add( new Value { Value = applications.IndexOf(application).ToString(), LinkedCommand = billSchema.Applications.ServiceCommands.RowNumber }); cmds.Add( new Value { Value = application.Applications.Balance.Value, LinkedCommand = billSchema.Applications.AmountPaid }); } cmds.Add(billSchema.Actions.Save); context.Submit(cmds.ToArray()); // end of 2nd call to set AmountPaid in the Applications tab