Extend Extensible Flexfields

Use order management extensions with extensible flexfields as a handy and powerful way to customize your deployment.

Access and Update Extensible Flexfields

You can use any extension point to access or update an extensible flexfield that's on the order header or the order line. To access a flexfield segment, your extension creates a row for a flexfield context. You can then use the getAttribute method and the setAttribute method to read and write to the segment.

For more, see Use Order Management Extensions to Get Values from Extensible Flexfields.

Take Action According to the Value of an Extensible Flexfield

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("VS_Context");
    def effVal = context != null ? context.getAttribute("eligibleforprime") : null;
    if("Y".equals(effVal)) {
      line.setAttribute("OrderedQuantity",0);  
    }
  }
}

If the context doesn't exist and you want to create it, then use getOrCreateContextRow instead of getContextRow. If you use getOrCreateContextRow, then you must also use setAttribute to set the attribute's value on the context instead of getAttribute. For example:

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("VS_Context");
    def effVal = context != null ? context.setAttribute("eligibleforprime") : null;
    if("Y".equals(effVal)) {
      line.setAttribute("OrderedQuantity",0);  
    }
  }
}

Copy Extensible Flexfield Values to Data Values

import oracle.apps.scm.doo.common.extensions.ValidationException;
def poNumber = header.getAttribute("CustomerPONumber");
 
if(poNumber != null && poNumber.equals("TEST_CO2") ){
def docRefs = header.getAttribute("DocumentReferences");
  if (!docRefs.hasNext()){
 throw new ValidationException("We need more time to get the document reference.");
}
while(docRefs.hasNext()) { 
def docRef = docRefs.next();
String docRefType = docRef.getAttribute("DocumentReferenceType");
if(!'COPY_REF_ORDER'.equals(docRefType))continue;
def cntxRow = header.getOrCreateContextRow("HeaderContext1");
cntxRow.setAttribute("_H1AttributeChar2",docRef.getAttribute("DocumentNumber"));                 
}
}

Update the Ship-To Address

This example updates the ship-to address. If the customer relationship type is Single, then set the value of the Ship-To Address according to the value of an extensible flexfield.

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
 
List < Message > messages = new ArrayList < Message > ();
def po = header.getAttribute("CustomerPONumber");
//Condition that specifies when to call the extension. You can can also use an extensible flexfield on the order header.
if (!"TEST_MDF".equals(po))
    return;
     
def line2AddrMap = [: ];
def lines = header.getAttribute("Lines");
 
if (!lines.hasNext()) {
    throw new ValidationException("Order Management hasn't saved the order line details. Save the sales order, then try again.");
}
while (lines.hasNext()) {
    def line = lines.next();
    def lineNo = line.getAttribute("DisplayLineNumber");
    line2AddrMap.put(lineNo, line.getAttribute("ShipToPartySiteIdentifier"));
}
 
lines.reset();
 
while (lines.hasNext()) {
    def line = lines.next();
    def context = line.getContextRow("FulfillLineContext1"); //Add your own extensible flexfield context that identifies the address for the ship-to line that you must copy.
    def copyFromLineNo = context != null ? context.getAttribute("_FL1AttributeChar1") : null; //Update this value with the display line number of the source line.
    if (copyFromLineNo != null && !copyFromLineNo.isEmpty()) {
        line.setAttribute("ShipToPartySiteIdentifier", line2AddrMap.get(copyFromLineNo));
    }
}
 
if (!messages.isEmpty()) {
    ValidationException ex = new ValidationException(messages);
    throw ex;
}

More

Topic Description
Use Extensions to Get Data from Oracle Applications Set the value in a context segment.
Update the Order's Submit Date Use an extensible flexfield to update the order submit date.
Use Extensions to Cancel Order Lines Use an extensible flexfield to cancel order lines in a sales order.
See the Get Extensible Flexfields from Original Sales Order subtopic in Extend Return Orders. Get extensible flexfields from the order line of the original order, then copy it to a return order line,
Extend Order Headers

See these subtopics:

  • Set Extensible Flexfield On Order Header. Set an attribute to the current date and time. Use an extensible flexfield on the order header.
  • Set Extensible Flexfield Values for Hazardous Items. If the HazardousMaterialFlag attribute equals Y, then set the value for attributes that use extensible flexfields on the order header and order lines.
Extend Return Orders

See the Copy Extensible Flexfield from Original Order to an RMA subtopic.

Copy extensible flexfield data from the original order to a return order that includes a return material authorization (RMA).