要使用API进行Acumatica Bill Of Materials(BOM)的归档,您可以使用Acumatica ERP的Web服务API。
以下是一个使用C#代码示例的解决方案:
using System;
using Acumatica.RESTClient;
using Acumatica.RESTClient.Api;
using Acumatica.RESTClient.Client;
using Acumatica.RESTClient.Model;
class Program
{
    static void Main(string[] args)
    {
        // 设置连接参数
        Configuration config = new Configuration
        {
            BasePath = "https://your-acumatica-instance.com/entity/Default/19.200.001",
            Username = "your-username",
            Password = "your-password",
            Company = "your-company"
        };
        // 创建BOM归档请求
        BOMMaintApi bomApi = new BOMMaintApi(config);
        BOMMaint bomMaint = new BOMMaint()
        {
            Number = new StringValue { Value = "BOM000001" }, // BOM编号
            ToplevelAssembledQty = new DecimalValue { Value = 1 }, // 最高级别的组装数量
            FinancialSettings = new FinancialSettings { SalesAccount = new StringValue { Value = "SALES_ACCOUNT" } }, // 财务设置
            Details = new BOMComponent[]
            {
                new BOMComponent
                {
                    InventoryID = new StringValue { Value = "ITEM00001" }, // 子件物料编号
                    QtyReq = new DecimalValue { Value = 2 }, // 所需数量
                    ScrapFactor = new DecimalValue { Value = 0.1m } // 损耗系数
                },
                new BOMComponent
                {
                    InventoryID = new StringValue { Value = "ITEM00002" },
                    QtyReq = new DecimalValue { Value = 3 },
                    ScrapFactor = new DecimalValue { Value = 0.2m }
                }
            }
        };
        try
        {
            // 调用API进行BOM归档
            bomApi.Put(bomMaint.Number.Value, bomMaint);
            Console.WriteLine("BOM archived successfully.");
        }
        catch (Exception ex)
        {
            Console.WriteLine("Error archiving BOM: " + ex.Message);
        }
    }
}
请注意,您需要替换代码中的以下信息:
BasePath:替换为您的Acumatica实例的URL。Username:替换为您的Acumatica用户名。Password:替换为您的Acumatica密码。Company:替换为您的Acumatica公司名称。Number:替换为要归档的BOM的编号。ToplevelAssembledQty:替换为BOM的最高级别组装数量。FinancialSettings:替换为适用的财务设置。Details:替换为BOM的组件信息。这个示例代码将使用提供的参数归档BOM。如果成功,它将在控制台上显示"BOM archived successfully."。如果出现错误,它将在控制台上显示"Error archiving BOM: ",后跟错误消息。