acumatica
画面ベースのAPIによるレコードのエクスポート
サーチ…
前書き
このトピックでは、Acumatica ERPからScreen-Based API経由でレコードをエクスポートする方法について説明します。 Acumatica ERPのScreen-Based APIは、SOAPインタフェースのみを提供します。開発プラットフォームでSOAP Webサービスのサポートが制限されている場合は、SOAPとRESTの両方のインタフェースを提供するContract-Based APIを検討してください。 Screen-Based APIの詳細については、 Acumatica ERPのドキュメントを参照してください。
備考
このトピックで提供されるすべてのサンプルは、Screen-Based API Wrapperで作成されました。クライアントアプリケーションがAcumatica ERPアプリケーションのUIの変更に依存しないようにするには、 Acumatica ERPのマニュアルに記載されているスクリーンベースのAPIラッパーを使用する必要があります
単一の主キーを持つエントリフォームからのデータのエクスポート
在庫アイテム画面(IN.20.25.00)は、データをエクスポートするAcumatica ERPのデータ入力フォームの中で最も頻繁に使用されるものの1つです。 インベントリIDは、[ 在庫明細]画面の唯一のプライマリキーです。
データ入力フォームからレコードをエクスポートするには、SOAPリクエストは常にServiceCommands.Every[Key]
コマンドで始まらなければなりません。ここで[Key]
は主キー名に置き換えられます。
1つの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();
}
シングルコールアプローチとバッチでのエクスポートの主な違いは2つあります。
シングルコールアプローチでは、 エクスポートコマンドのtopCountパラメータが常に
0
に設定されていましたバッチのレコードをエクスポートするとき、 Filter配列によって補完されたtopCountパラメータが次の結果セットを要求するために、バッチのサイズが設定されます
コンポジット・プライマリ・キーを持つエントリ・フォームからのデータのエクスポート
受注画面(SO.30.10.00)は、複合主キーを持つデータ入力フォームの完全な例です。 受注画面の主キーは、 受注 タイプと受注番号で構成されます。
Sales Orders画面または他のデータ入力フォームから複合Primaryキーを使用してScreen-Based APIを使用してデータをエクスポートする2ステップの推奨戦略:
ステップ1では、以前にAcumatica ERPアプリケーションで作成されたすべてのタイプの注文をリクエストします
2番目のステップは、1つのコールまたはバッチで、各タイプのオーダーを個別にエクスポートすることです
すべての既存の注文をリクエストするには:
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呼び出しでは、 ExportコマンドのtopCountパラメータが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);
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
コマンドで開始する必要があります。このコマンドは、エクスポートするオーダーのタイプを決定します。最初のキー値を設定する値コマンドの後に行くServiceCommands.Every[Key]
コマンド、 [Key]
第2のキーの名前に置き換えられるします。
特定のタイプのレコードをエクスポートするには:
特定のタイプの受注をエクスポートする必要がある場合は、SOAP要求の最初にValue
コマンドを使用して注文のタイプを明示的に定義し、続いてシングルコールアプローチまたはバッチでエクスポートすることができます。
1つの呼び出しで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();
}