発注書と発注変更のエンタープライズリソース計画への連携

Coupaの発注書と発注変更をエンタープライズリソース計画と連携するための手順。

API設定に関する一般的な考慮事項

制限されたペイロード-フィールドとAPIフィルター

CoupaのAPIは、デフォルトで多くのデータを返します(例えば、関連するオブジェクトの完全なオブジェクト)。 APIリターンペイロードのサイズは非常に大きくなることがあり、その場合所要時間も長くなります。

作業をより効率化するため、Coupaには、オブジェクトのスキーマ全体やすべての関連付けの代わりに、制限されたJSONまたはXMLレスポンスを返すフィールドクエリパラメーターとAPIフィルターが含まれています。 詳細はAPIレスポンスフィルターをご参照ください。

この記事で説明されているユースケース

この文書は、エンタープライズリソースプランニングシステムの発注書番号が、Coupaの発注書番号によって決定されることを前提としています。 この記事では、Coupa発注書をエンタープライズリソース計画に連携するための3つの異なるオプションについて説明します(作成と更新の両方)。

これらのオプションは、Coupaからの連携の監視方法を変更するものです。

  • オプション1:請求書ヘッダーで定義したカスタムフィールドに基づく単純なモニタリング

  • オプション2:連携履歴レコードを使用した高度なモニタリング

  • オプション3: Coupa連携の完全なモニタリングの活用

3つのオプションすべてで、Coupa発注書はエクスポートフラグに基づいてエンタープライズリソース計画にプッシュされます。

発注書連携でエラーが発生した場合は、CoupaのUI上で発注書を手動で修正する必要があります。この操作によりエクスポートフラグがリセットされ、発注書は次回の実行時に再び処理されます。

ヒント:

Coupaサポートに連絡し、変更のたびに最後にエクスポートした発注書をリセットするようオプションを有効にすることができます。 この設定はUIにのみ適用されます。 APIで行われた変更は、エクスポート済みステータスを変更するものではありません。

APIの専用連携と連絡先を作成する

上記のオプション2と3については、次を作成する必要があります。

  1. 実装するAPIオーケストレーションごとの専用連携。

  2. 連携に失敗した場合にアラートが送信される各連携の1つ以上の連携連絡先。

ヒント:

Coupaサポートに連絡し、ドキュメントタイプ別連携履歴へのリンクを有効にするオプションを有効にすることができます。 このオプションでは、設定ページにリンクが追加され、文書タイプごとに完全な連携履歴が表示されます

オプション1:カスタムフィールドに基づく単純なモニタリング

Description

このシナリオでは、各発注書に対して、1つ以上の発注書ヘッダーカスタムフィールドに現在の連携ステータスが追加されます。 Integration Statusという名前のカスタムフィールド cf - integration - status を追加しました。 標準発注書データテーブルを使用し、次のURLでドキュメントの連携ステータスをフォローアップしてください。

https ://<your instance hostname>/order_headers

オーケストレーションダイアグラム

手順/API呼び出しの詳細

手順1

エンタープライズリソース計画で作成/更新するCoupa発注書のリストと詳細を取得します。 選択基準にはエクスポートフラグと発注書ステータスが含まれます。 クエリパラメーターshow_deleted_linesは、エンタープライズリソース計画で発注書の更新を処理するために必要になる場合があります

メソッド

GET

API

https ://<your instance hostname>/api/purchase_orders/

クエリパラメータ

filter =<your API filter name>

offset = 10

exported=false

show_deleted_lines = true *

status [in] =発行済み、キャンセル済み、クローズ済み

サンプルURL

https ://<your instance hostname>/api/purchase_orders? filter =<your API filter name>& offset = 10 & exported = false&show_deleted_lines = true&status [in] = issued, canceled, closed

応答本文のサンプル

注: show_deleted_lines = true クエリパラメータはPO変更用です。

手順2

個々の発注書をエクスポート済みとしてマーク

メソッド

PUT

API

https ://<your instance hostname>/api/purchase_orders/<Purchase Order id>

クエリパラメータ

exported = true

fields = [" id ", "exported "]

サンプルURL

https ://<your instance hostname>/api/purchase_orders/<Purchase Order id>? exported = true&fields =[" id "," exported "]

クエリ本文のサンプル

該当なし*

レスポンス本文のサンプル

{" id ": <Purchase Order id>," exported ": true}
注:

このコールでは、URLに ? exported = true を含めると、ペイロードは必要ありません。 ここでは、エンタープライズリソース計画での発注書の作成/更新が行われます。

ステップ3

レポートのカスタムフィールドを更新する

メソッド

PUT

API

https ://<your instance hostname>/api/purchase_orders/<Purchase Order id>

クエリパラメータ

fields = [" id ", "exported ", {" custom_fields ": {}}]

サンプルURL

https ://<your instance hostname>/api/purchase_orders/<Purchase Order id>? fields = [" id ", "exported ", {" custom_fields ": {}}]

クエリ本文のサンプル

{" custom - fields ":{"<your custom-field name>":"成功: ERPにPOが正しく複製されました"}}

または

{" custom - fields ":{"<your custom-field name>":"エラー: ERPでPOが正しく複製されました"}}

レスポンス本文のサンプル

{" id ": <Purchase Order id>," exported ": true ," custom - fields ":{"<your custom-field name>":"成功: POがERPに正しく複製されました"}}

または

{" id ": <Purchase Order id>," exported ": true ," custom - fields ":{"<your custom-field name>":"エラー:発注書がERPに正しく複製されました"}}

オプション2:連携履歴を使用した高度なモニタリング

Description

このシナリオでは、発注書ごとに次のことを行います。

  • ドキュメントの以前の連携履歴レコードを解決する

  • 連携履歴レコードを作成する

  • エラーが発生した場合に連携連絡先にアラートを送信する

標準発注書連携履歴データテーブルを使用し、ドキュメントの連携ステータスをフォローアップしてください。 これは次の場所で見つけることができます。

https ://<your instance hostname>/integration_history_records/purchase_orders

レスポンスコードのフィルターを使用すると、正常に複製された文書と失敗した文書を区別できます。

オーケストレーションダイアグラム

手順/API呼び出しの詳細

手順1

エンタープライズリソース計画で作成/更新するCoupa発注書のリストと詳細を取得します。 選択基準にはエクスポートフラグと発注書ステータスが含まれます。 クエリパラメーターshow_deleted_linesは、エンタープライズリソース計画で発注書の更新を処理するために必要になる場合があります

メソッド

GET

API

https ://<your instance hostname>/api/purchase_orders/

クエリパラメータ

filter =<your API filter name>

offset = 10

exported=false

show_deleted_lines = true

status [in] = buyer_hold, issued, canceled, closed, soft_closed

サンプルURL

https ://<your instance hostname>/api/purchase_orders? filter =<your API filter name>& offset = 10 & exported = false&show_deleted_lines = true&status [in] = buyer_hold, issued, canceled, closed, soft_closed

応答本文のサンプル

手順2

個々の発注書をエクスポート済みとしてマーク

メソッド

PUT

API

https ://<your instance hostname>/api/purchase_orders/<Purchase Order id>

クエリパラメータ

exported = true

fields = [" id ", "exported "]

サンプルURL

https ://<your instance hostname>/api/purchase_orders/<Purchase Order id>? exported = true&fields =[" id "," exported "]

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

{" id ": <Purchase Order id>," exported ": true}

ここでは、エンタープライズリソース計画での発注書の作成/更新が行われます。

ステップ3 a

未解決の連携履歴レコードを取得する

メソッド

GET

API

https ://<your instance hostname>/api/integration_history_records

クエリパラメータ

resolved = false

document - type = OrderHeader

document - id =<Purchase Order id>

fields = [" id ", "document - id "," status ", "resolved "]

サンプルURL

https ://<your instance hostname>/api/integration_history_records? resolved = false&document - type = OrderHeader&document - id =<Purchase Order id>& fields = [" id ", "document - id "," status ", "resolved "]

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

[{" id ": <Old Integration History Record id>," document - id ": <Purchase Order id>," status ":" Error "," resolved ": false}]

ステップ3 b

以前の連携履歴レコードを解決する

メソッド

PUT

API

https ://<your instance hostname>/api/integration_history_records/<Old Integration History Record id>/resolve

クエリパラメータ

fields = [" id ", "document - id "," status ", "resolved "]

サンプルURL

https ://<your instance hostname>/api/integration_history_records/<Old Integration History Record id>/resolve? fields = [" id ", "document - id "," status ", "resolved "]

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

[{" id ": <Old Integration History Record id>," document - id ": <Purchase Order id>," status ":" Error "," resolved ": true}]

ステップ4 a

連携履歴を作成する(成功)

メソッド

POST

API

https ://<your instance hostname>/api/integration_history_records

クエリパラメータ

fields = [" id ", "document - id "," status "]

サンプルURL

https ://<your instance hostname>/api/integration_history_records? fields = [" id ", "document - id "," status "]

クエリ本文のサンプル

{" document - type ":" OrderHeader "," document - id ": <Purchase Order id>," document - status ":"<Purchase Order status>"," contact - alert - type ":" Functional "," status ":" Success "," integration ":{" code ":"<Customer Integration id>"}," responses ":[{" response - code ":" Success -1234 "," response - message ":" ERPでの統合はうまくいった"}]}

レスポンス本文のサンプル

{" id ": <New Integration History Record id>," document - id ": <Purchase Order id>," status ":"成功"}

ステップ4 b

連携履歴を作成して(エラー)、連携連絡先にアラートを送信する

メソッド

POST

API

https ://<your instance hostname>/api/integration_history_records/create_alert

クエリパラメータ

fields = [" id ", "document - id "," status "]

サンプルURL

https ://<your instance hostname>/api/integration_history_records/create_alert? fields = [" id ", "document - id "," status "]

クエリ本文のサンプル

{" document - type ":" OrderHeader "," document - id ": <Purchase Order id>," document - status ":"<Purchase Order status>"," contact - alert - type ":" Functional "," status ":" Error "," integration ":{" code ":"<Customer Integration id>"}," responses ":[{" response - code ":" Failure - CC "," response - message ":" Line 1: Cost center CA 234 is closed for ordering "},{" response - code ":" Failure - date "," response - message ":" Line 2: Delivery date cannot be in the past "}]}

レスポンス本文のサンプル

{" id ": <New Integration History Record id>," document - id ": <Purchase Order id>," status ":" Error "}

オプション3: Coupa連携の完全なモニタリングの活用

説明

このシナリオでは、次の項目を追跡する連携実行を作成します。

  • 連携のステータス(保留中/開始済み/エラー/成功/失敗)

  • 処理された発注の合計数

  • 成功とエラーの数

  • 連携エラーのリストとそのステータス(解決済みかどうか)

発注書ごとに次のことを行います。

  • ドキュメントの以前の連携履歴レコードを解決する

  • 連携履歴レコードを作成する

  • エラーが発生した場合、連携エラーと連携連絡先へのアラートを作成する

連携のすべての連携実行は、次の場所でモニタリングできます。

https ://<your instance hostname>/integrations/<your integration id>/integration_runs

標準発注書連携エラーデータテーブルを使用し、連携エラーのあるすべての発注書をリストアップします。 これは次の場所にあります。

https ://<your instance hostname>/integration_errors

標準発注書連携履歴データテーブルを使用し、正常に連携されたすべての発注書をリストアップします。 これは次の場所にあります。

https ://<your instance hostname>/integration_history_records/purchase_orders

オーケストレーションダイアグラム

手順/API呼び出しの詳細

手順1

統合実行の作成

メソッド

POST

API

https ://<your instance hostname>/api/integration_runs

クエリパラメータ

該当なし

クエリ本文のサンプル

{" integration ":{" code ":"{{integration_code}}"}}

レスポンス本文のサンプル

{" id ": <Integration Run ID>,...}

手順2

エンタープライズリソース計画で作成/更新するCoupa発注書のリストと詳細を取得します。 選択基準にはエクスポートフラグと発注書ステータスが含まれます。 クエリパラメーターshow_deleted_linesは、エンタープライズリソース計画で発注書の更新を処理するために必要になる場合があります

メソッド

GET

API

https ://<your instance hostname>/api/purchase_orders/

クエリパラメータ

filter =<your API filter name>

offset = 10

exported=false

show_deleted_lines = true

status [in] = buyer_hold, issued, canceled, closed, soft_closed

サンプルURL

https ://<your instance hostname>/api/purchase_orders? filter =<your API filter name>& offset = 10 & exported = false&show_deleted_lines = true&status [in] = buyer_hold, issued, canceled, closed, soft_closed

応答本文のサンプル

ステップ3

インテグレーションの実行を開始する

メソッド

PUT

API

https ://<your instance hostname>/api/integration_runs/<Integration Run ID>/run

クエリパラメータ

該当なし

クエリ本文のサンプル

{" TOTAL_RECORDS ": <Total Number of POs from Step 2>}

レスポンス本文のサンプル

{" id ": <Integration Run ID>,...}

ステップ4

個々の発注書をエクスポート済みとしてマーク

メソッド

PUT

API

https ://<your instance hostname>/api/purchase_orders/<Purchase Order id>

クエリパラメータ

exported = true

fields = [" id ", "exported "]

サンプルURL

https ://<your instance hostname>/api/purchase_orders/<Purchase Order id>? exported = true&fields =[" id "," exported "]

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

{" id ": <Purchase Order id>," exported ": true}

ここでは、エンタープライズリソース計画での発注書の作成/更新が行われます。

ステップ5 a

未解決の連携履歴レコードを取得する

メソッド

GET

API

https ://<your instance hostname>/api/integration_history_records

クエリパラメータ

resolved = false

document - type = OrderHeader

document - id =<Purchase Order id>

fields = [" id ", "document - id "," status ", "resolved "]

サンプルURL

https ://<your instance hostname>/api/integration_history_records? resolved = false&document - type = OrderHeader&document - id =<Purchase Order id>& fields = [" id ", "document - id "," status ", "resolved "]

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

[{" id ": <Old Integration History Record id>," document - id ": <Purchase Order id>," status ":" Error "," resolved ": false}]

ステップ5 b

以前の連携履歴レコードを解決する

メソッド

PUT

API

https ://<your instance hostname>/api/integration_history_records/<Old Integration History Record id>/resolve

クエリパラメータ

fields = [" id ", "document - id "," status ", "resolved "]

サンプルURL

https ://<your instance hostname>/api/integration_history_records/<Old Integration History Record id>/resolve? fields = [" id ", "document - id "," status ", "resolved "]

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

[{" id ": <Old Integration History Record id>," document - id ": <Purchase Order id>," status ":" Error "," resolved ": true}]

ステップ6 a

未解決の連携エラーレコードを取得する

メソッド

GET

API

https ://<your instance hostname>/api/integration_errors

クエリパラメータ

resolved = false

document - type = OrderHeader

document - id =<Purchase Order id>

サンプルURL

https ://<your instance hostname>/api/integration_errors? resolved = false&document - type = OrderHeader&document - id =<Purchase Order id>

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

[{" id ": <Old Integration Error Record id>," document - type ":" OrderHeader "," document - id ": <Purchase Order id>," status ":" Error "," resolved ": false...}]

ステップ6 b

以前の連携履歴レコードを解決する

メソッド

PUT

API

https ://<your instance hostname>/api/integration_errors/<Old Integration Error Record id>/resolve

クエリパラメータ

該当なし

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

[{" id ": <Old Integration Error Record id>," document - id ": <Purchase Order id>," status ":" Error "," resolved ": true...}]

ステップ7 a

連携履歴の作成する(成功) 連携実行を参照する必要があります

メソッド

POST

API

https ://<your instance hostname>/api/integration_history_records

クエリパラメータ

fields = [" id ", "document - id "," status "]

サンプルURL

https ://<your instance hostname>/api/integration_history_records? fields = [" id ", "document - id "," status "]

クエリ本文のサンプル

{" document - type ":" OrderHeader "," document - id ": <Purchase Order id>," document - status ":"<Purchase Order status>"," contact - alert - type ":" Functional "," status ":" Success "," integration ":{" code ":"<Customer Integration id>"}," integration - run ":{" id ":<Integration Run ID>}," responses ":[{" response - code ":" Success -1234 "," response - message ":" ERPでの統合はうまくいきました"}]}

レスポンス本文のサンプル

{" id ": <New Integration History Record id>," document - id ": <Purchase Order id>," status ":"成功"}

ステップ7 b

連携エラーを作成して連携の連絡先にアラートを送信。連携実行を参照する必要があります

メソッド

POST

API

https ://<your instance hostname>/api/integration_errors/create_alert

クエリパラメータ

該当なし

クエリ本文のサンプル

{" document - type ":" OrderHeader "," document - id ": <Purchase Order id>," document - status ":"<Purchase Order status>"," contact - alert - type ":" Functional "," status ":" Error "," integration - run - id ":"<Integration Run ID>"," responses ":[{" response - code ":" Failure - CC "," response - message ":" Line 1: Cost center CA 234 is closed for ordering "},{" response - code ":" Failure - date "," response - message ":" Line 2: Delivery date cannot be in the past "}]}

レスポンス本文のサンプル

{" id ": <New Integration Error Record id>," document - id ": <Purchase Order id>," status ":"エラー"...}

手順8

連携実行を正常に終了

メソッド

PUT

API

https ://<your instance hostname>/api/integration_runs/<Integration Run ID>/success

クエリパラメータ

該当なし

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

{" id ": <Integration Run ID>," status ":" successful "...}

連携実行中に一般的な障害が発生した場合。

ステップx

連携実行の失敗を報告

メソッド

PUT

API

https ://<your instance hostname>/api/integration_runs/<Integration Run ID>/fail

クエリパラメータ

該当なし

クエリ本文のサンプル

該当なし

レスポンス本文のサンプル

{" id ": <Integration Run ID>," status ":" failed "...}