Order Managementの拡張機能を使用した拡張可能フレックスフィールドからの値の取得
getOrCreateContextRowメソッドを使用して、新しいデータを追加したり、フレックスフィールドを介してデータを更新します。 getContextRowを使用して、すでに追加したデータを取得します。
getOrCreateContextRow("context code")
またはgetAttribute("API name")
を使用します。ここで、context code
は拡張可能フレックスフィールドのコンテキスト・コードの名前、API name
はメソッドの呼出しに使用するAPI (アプリケーション・プログラミング・インタフェース)の名前です:
エンティティ |
コードで使用する値 |
親 |
すべてのイベントでの読取り |
保存中または発行リクエストの開始中の書込み |
送信リクエストの終了時の書込み |
---|---|---|---|---|---|
オーダー・ヘッダーの拡張可能フレックスフィールド |
該当なし |
ヘッダー |
Yes |
Yes |
Yes |
履行明細の拡張可能フレックスフィールド |
該当なし |
ライン |
Yes |
Yes |
Yes |
拡張機能を使用して拡張可能フレックスフィールドから値を取得する場合、拡張の動作は、使用するメソッドおよび拡張に指定したコンテキストが存在するかどうかによって異なります。
メソッド | コンテキストが存在しない場合 |
---|---|
getContextRow("EFFContextName") | このメソッドは新しいコンテキストを作成しません。 |
getorCreateContextRow("EFFContextName") | このメソッドは、新規コンテキストを作成します。 |
このコードを使用するとします。
import oracle.apps.scm.doo.common.extensions.ValidationException;
def poNumber = header.getAttribute("CustomerPONumber");
if (poNumber != null && poNumber.equals("test")) {
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
def line = lines.next();
def context = line.getOrCreateContextRow("My_Context");
def effVal = context.getAttribute("eligibleforprime");
// throw new ValidationException("Eff value effVal:: "+effVal);
if (effVal.equals("Y")) {
line.setAttribute("OrderedQuantity", 0);
}
}
}
説明
getOrCreateContextRow("My_Context")
は、My_Contextという名前のコンテキストを検出しようとします。 そのコンテキストが存在しない場合は、拡張によって作成されます。
getOrCreateContextRowを使用して、新しいデータを追加したり、販売オーダーのフレックスフィールドを介してデータを更新します。
販売オーダーのフレックスフィールドを介してすでに追加したデータのみを取得する必要がある場合は、getOrCreateContextRowのかわりにgetContextRowを使用します。 たとえば:
import oracle.apps.scm.doo.common.extensions.ValidationException;
def poNumber = header.getAttribute("CustomerPONumber");
if (poNumber != null && poNumber.equals("test")) {
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
def line = lines.next();
def context = line.getContextRow("My_Context");
if (context == null) {
return; // if we don't find a context, then don't create one.
}
def effVal = context.getAttribute("eligibleforprime");
// throw new ValidationException("Eff value effVal:: "+effVal);
if (effVal.equals("Y")) {
line.setAttribute("OrderedQuantity", 0);
}
}
}
コンテキストが存在することを確認
getOrCreateContextRowを使用する場合は、コンテキストが存在することを確認する必要があります。 次のコードを使用すると仮定します:
def cntxRow = header.getOrCreateContextRow("HeaderContext1");
cntxRow.setAttribute("_H1AttributeChar2", docRef.getAttribute("DocumentNumber"));
コンテキストが存在しない場合は、空のレコードを作成します。
getContextRowは、コンテキストが存在しない場合、null
を返します。 これを使用して、アクションを実行する前にnull条件をテストできます。 たとえば:
def context = line.getContextRow("VS_Context");
def effVal = context != null ? context.getAttribute("eligibleforprime") : null;
if("Y".equals(effVal)) {
// Do something here.
}
コンテキストに1つの拡張を使用
コンテキストの移入には、1つの拡張のみを使用します。 これを行うには、複数の拡張子を使用しないでください。 次のような拡張機能があるとします:
梱包ノート拡張の設定
def notes = line.getOrCreateContextRow("Line Level Notes");
notes.setAttribute("packNote", "Packing Instructions 22");
出荷ノート拡張の設定
def notes = line.getOrCreateContextRow("Line Level Notes");
notes.setAttribute("shipNote", "Shipping Instructions 11");
明細レベル・ノート・コンテキストを複数の拡張に移入すると、パフォーマンスに影響する可能性があります。 かわりに、1つの拡張子のみを使用します:
梱包および出荷ノート拡張の設定
def notes = line.getOrCreateContextRow("Line Level Notes");
notes.setAttribute("packNote", "Packing Instructions 22");
notes.setAttribute("shipNote", "Shipping Instructions 11");