Order Managementの拡張機能を使用した拡張可能フレックスフィールドからの値の取得
getOrCreateContextRowメソッドを使用して、新しいデータを追加したり、フレックスフィールドを介してデータを更新します。 getContextRowを使用して、すでに追加したデータを取得します。
拡張機能を使用して拡張可能フレックスフィールドから値を取得する場合、拡張の動作は、使用するメソッドおよび拡張に指定したコンテキストが存在するかどうかによって異なります。
メソッド | コンテキストが存在しない場合 |
---|---|
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);
}
}
}