从具有复合主键的输入表单导出数据
销售订单屏幕(SO.30.10.00)是具有复合主键数据输入形式的一个很好的例子。销售订单屏幕上的主键由订单类型和订单号组成 :
建议的两步策略,通过基于屏幕的 API 从销售订单屏幕或任何其他数据输入表单中导出数据和复合主键:
-
在第 1 步,你需要先前在 Acumatica ERP 应用程序中创建的所有类型的订单
-
第二步是通过一次通话或批量独立地输出每种类型的订单
要求所有类型的现有订单:
Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaERP/Soap/SO301000.asmx";
context.Login(username, password);
try
{
Content orderSchema = PX.Soap.Helper.GetSchema<Content>(context);
var commands = new Command[]
{
orderSchema.OrderSummary.ServiceCommands.EveryOrderType,
orderSchema.OrderSummary.OrderType,
};
var types = context.Export(commands, null, 1, false, false);
}
finally
{
context.Logout();
}
在上面的 SOAP 调用中,请注意设置为 1
的 Export 命令的 topCount 参数。此请求的目的仅是获取先前在 Acumatica ERP 应用程序中创建的所有类型的订单,而不是导出数据。 ****
要批量导出每种类型的记录:
Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaERP/Soap/SO301000.asmx";
context.Login(username, password);
try
{
Content orderSchema = PX.Soap.Helper.GetSchema<Content>(context);
var commands = new Command[]
{
orderSchema.OrderSummary.ServiceCommands.EveryOrderType,
orderSchema.OrderSummary.OrderType,
};
var types = context.Export(commands, null, 1, false, false);
for (int i = 0; i < types.Length; i++)
{
commands = new Command[]
{
new Value
{
LinkedCommand = orderSchema.OrderSummary.OrderType,
Value = types[i][0]
},
orderSchema.OrderSummary.ServiceCommands.EveryOrderNbr,
orderSchema.OrderSummary.OrderType,
orderSchema.OrderSummary.OrderNbr,
orderSchema.OrderSummary.Customer,
orderSchema.OrderSummary.CustomerOrder,
orderSchema.OrderSummary.Date,
orderSchema.OrderSummary.OrderedQty,
orderSchema.OrderSummary.OrderTotal
};
var orders = context.Export(commands, null, 100, false, false);
while (orders.Length == 100)
{
var filters = new Filter[]
{
new Filter
{
Field = orderSchema.OrderSummary.OrderNbr,
Condition = FilterCondition.Greater,
Value = orders[orders.Length - 1][1]
}
};
orders = context.Export(commands, filters, 100, false, false);
}
}
}
finally
{
context.Logout();
}
上面的示例演示了如何从 100 个记录的批次中导出 Acumatica ERP 的所有销售订单。要独立导出每种类型的销售订单,你的 SOAP 请求必须始终以 Value
命令开头,该命令确定要导出的订单类型。用于设置第一个键值的 Value 命令执行 ServiceCommands.Every[Key]
命令后,其中 [Key]
将替换为第二个键的名称。
要导出特定类型的记录:
如果你需要导出特定类型的销售订单,则可以在 SOAP 请求开始时使用 Value
命令显式定义订单类型,然后是单个调用方法或批量导出。
要在一次调用中导出 IN 类型的所有销售订单 :
Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaERP/Soap/SO301000.asmx";
context.Login(username, password);
try
{
Content orderSchema = PX.Soap.Helper.GetSchema<Content>(context);
var commands = new Command[]
{
new Value
{
LinkedCommand = orderSchema.OrderSummary.OrderType,
Value = "IN"
},
orderSchema.OrderSummary.ServiceCommands.EveryOrderNbr,
orderSchema.OrderSummary.OrderType,
orderSchema.OrderSummary.OrderNbr,
orderSchema.OrderSummary.Customer,
orderSchema.OrderSummary.CustomerOrder,
orderSchema.OrderSummary.Date,
orderSchema.OrderSummary.OrderedQty,
orderSchema.OrderSummary.OrderTotal
};
var orders = context.Export(commands, null, 0, false, false);
}
finally
{
context.Logout();
}