從具有單個主鍵的輸入表單匯出資料

庫存產品螢幕(IN.20.25.00)是最常用的資料輸入表單 Acumatica ERP 的匯出資料之一。庫存 ID庫存專案螢幕上唯一的主鍵 : StackOverflow 文件

要從資料輸入表單匯出記錄,你的 SOAP 請求必須始終以 ServiceCommands.Every[Key] 命令開頭,其中 [Key] 將替換為主鍵名稱。

要在單個 Web 服務呼叫中匯出所有庫存專案:

Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaERP/Soap/IN202500.asmx";
context.Login(username, password);
try
{
    Content stockItemsSchema = PX.Soap.Helper.GetSchema<Content>(context);
    Field lastModifiedField = new Field
    {
        ObjectName = stockItemsSchema.StockItemSummary.InventoryID.ObjectName,
        FieldName = "LastModifiedDateTime"
    };
    var commands = new Command[]
    {
        stockItemsSchema.StockItemSummary.ServiceCommands.EveryInventoryID,
        stockItemsSchema.StockItemSummary.InventoryID,
        stockItemsSchema.StockItemSummary.Description,
        stockItemsSchema.GeneralSettingsItemDefaults.ItemClass,
        stockItemsSchema.GeneralSettingsUnitOfMeasureBaseUnit.BaseUnit,
        lastModifiedField
    };
    var items = context.Export(commands, null, 0, false, false);
}
finally
{
    context.Logout();
}

隨著時間的推移,任何 ERP 應用程式中的資料量都會增加。如果你要在單個 Web 服務呼叫中匯出 Acumatica ERP 例項中的所有記錄,很快就會發現超時錯誤。增加超時可能是一次性但不是很好的長期解決方案。解決此挑戰的最佳選擇是分批匯出多個記錄的庫存專案。

要分批匯出 10 個記錄的庫存專案:

Screen context = new Screen();
context.CookieContainer = new System.Net.CookieContainer();
context.Url = "http://localhost/AcumaticaERP/Soap/IN202500.asmx";
context.Login(username, password);
try
{
    Content stockItemsSchema = PX.Soap.Helper.GetSchema<Content>(context);
    Field lastModifiedField = new Field
    {
        ObjectName = stockItemsSchema.StockItemSummary.InventoryID.ObjectName,
        FieldName = "LastModifiedDateTime"
    };
    var commands = new Command[]
    {
        stockItemsSchema.StockItemSummary.ServiceCommands.EveryInventoryID,
        stockItemsSchema.StockItemSummary.InventoryID,
        stockItemsSchema.StockItemSummary.Description,
        stockItemsSchema.GeneralSettingsItemDefaults.ItemClass,
        stockItemsSchema.GeneralSettingsUnitOfMeasureBaseUnit.BaseUnit,
        lastModifiedField
    };
    var items = context.Export(commands, null, 10, false, false);

    while (items.Length == 10)
    {
        var filters = new Filter[]
        {
            new Filter
            {
                Field = stockItemsSchema.StockItemSummary.InventoryID,
                Condition = FilterCondition.Greater,
                Value = items[items.Length - 1][0]
            }
        };
        items = context.Export(commands, filters, 10, false, false);
    }
}
finally
{
    context.Logout();
}

單一呼叫方法與批量匯出之間存在兩個主要差異:

  • **** 在單次呼叫方法中, Export 命令的 topCount 引數始終設定為 0

  • 批量匯出記錄時,通過由 Filter 陣列補充的 topCount 引數配置批量大小以請求下一個結果集 ****