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);
}
}
}