從具有複合主鍵的輸入表單匯出資料
銷售訂單螢幕(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();
}