【问题标题】:Exporting Records from Acumatica via SOAP Contract-Based API通过基于 SOAP 合同的 API 从 Acumatica 导出记录
【发布时间】:2018-03-03 09:25:30
【问题描述】:

通过基于 SOAP 合同的 API 从 Acumatica 导出大量数据的推荐方法是什么?

【问题讨论】:

    标签: soap acumatica acumatica-kb


    【解决方案1】:

    从具有单个主键的条目表单中导出数据

    库存项目 屏幕 (IN.20.25.00) 是 Acumatica ERP 用于导出数据的最常用的数据输入形式之一。 Inventory IDStock Items 屏幕上的唯一主键:

    在单个 Web 服务调用中导出所有库存项目:

    using (DefaultSoapClient client = new DefaultSoapClient())
    {
        client.Login(username, password, null, null, null);
        try
        {
            var items = client.GetList(new StockItem());
        }
        finally
        {
            client.Logout();
        }
    }
    

    随着时间的推移,任何 ERP 应用程序中的数据量都趋于增长。如果您将在单个 Web 服务调用中从 Acumatica ERP 实例中导出所有记录,很快您可能会注意到超时错误。增加超时可能是一次性的,但不是很好的长期解决方案。应对这一挑战的最佳选择是分批导出多条记录的库存项目。

    以 10 条记录为单位批量导出库存商品:

    using (DefaultSoapClient client = new DefaultSoapClient())
    {
        client.Login(username, password, null, null, null);
        try
        {
            var items = client.GetList(
                new StockItem
                {
                    RowNumber = new LongSearch
                    {
                        Condition = LongCondition.IsLessThan,
                        Value = 10
                    }
                });
            while (items.Length == 10)
            {
                StockItem filter = new StockItem
                {
                    RowNumber = new LongSearch
                    {
                        Condition = LongCondition.IsLessThan,
                        Value = 10
                    },
                    InventoryID = new StringSearch
                    {
                        Condition = StringCondition.IsGreaterThan,
                        Value = (items[items.Length - 1] as StockItem).InventoryID.Value
                    }
                };
            }
        }
        finally
        {
            client.Logout();
        }
    }
    

    单调用方式和批量导出主要有2个区别:

    • StockItem 实体的RowNumber 属性未在单一调用方法中使用

    • 批量导出记录时,通过传入GetList方法请求下一个结果集的实体的RowNumber属性配置批量大小

    从具有复合主键的条目表单中导出数据

    销售订单屏幕 (SO.30.10.00) 是具有复合主键的数据输入表单的完美示例。 销售订单屏幕上的主键由订单类型订单号组成:

    100条记录批量导出销售订单:

    using (DefaultSoapClient client = new DefaultSoapClient())
    {
        client.Login(username, password, null, null, null);
        try
        {
            var orders = client.GetList(
                new SalesOrder
                {
                    OrderType = new StringReturn(),
                    OrderNbr = new StringReturn(),
                    RowNumber = new LongSearch
                    {
                        Condition = LongCondition.IsLessThan,
                        Value = 100
                    },
                    ReturnBehavior = ReturnBehavior.OnlySpecified
                });
    
            bool sameOrderType = true;
            while (orders.Length > 0 && (orders.Length == 100 || !sameOrderType))
            {
                SalesOrder filter = new SalesOrder
                {
                    RowNumber = new LongSearch
                    {
                        Condition = LongCondition.IsLessThan,
                        Value = 100
                    },
                    OrderType = new StringSearch
                    {
                        Condition = sameOrderType ? StringCondition.Equal : StringCondition.IsGreaterThan,
                        Value = (orders[orders.Length - 1] as SalesOrder).OrderType.Value
                    },
                    OrderNbr = new StringSearch
                    {
                        Condition = StringCondition.IsGreaterThan,
                        Value = sameOrderType ? (orders[orders.Length - 1] as SalesOrder).OrderNbr.Value : string.Empty
                    },
                    ReturnBehavior = ReturnBehavior.OnlySpecified
                };
                orders = client.GetList(filter);
                sameOrderType = orders.Length == 100;
            }
        }
        finally
        {
            client.Logout();
        }
    }
    

    上面的示例演示了如何从 Acumatica ERP 中以 100 条记录为一组导出所有销售订单。我们首先请求从 Acumatica 获得前 100 个销售订单。之后,我们分别导出每种类型的销售订单:您的 SOAP 请求获取下一个相同先前接收类型的订单或下一个订单类型的前 100 个销售订单。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-03-03
      • 1970-01-01
      • 2021-06-21
      • 1970-01-01
      • 2017-05-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多