機械翻訳について

返品オーダーの延長

オーダー管理拡張を使用して、返品オーダーを管理します。

拡張可能フレックスフィールド値を元の履行明細から返品オーダーにコピー

この例では、拡張可能フレックスフィールドの値を元の履行明細から返品オーダーにコピーします。

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import java.util.logging.Level;
  
Long lineId = 0;
Long headerId = 0;
def lines = header.getAttribute("Lines");
  
while( lines.hasNext() ) {
 def line = lines.next();
    
  String categoryCode = line.getAttribute("TransactionCategoryCode");
    
  if ("RETURN" != categoryCode) continue;
  def docRefs = line.getAttribute("DocumentReferences");
  lineId = 0;
 while(docRefs.hasNext() & lineId == 0) {
  
   def docRef = docRefs.next();
   String docRefType = docRef.getAttribute("DocumentReferenceType");
   if( "ORIGINAL_ORCHESTRATION_ORDER" == docRefType ) {
     // We found the document reference that references the original order.
     // The DocumentSubLineIdentifier attribute identifies the fulfillment line on the original order.
       
     lineId = new Long(docRef.getAttribute("DocumentSubLineIdentifier"));
  
     if(headerId == 0) {
         // The DocumentIdentifier attribute identifies the header of the original order.
         headerId = new Long(docRef.getAttribute("DocumentIdentifier"));
       if (headerId !=0){
           def voRow = getContextHeaderRow(headerId, "HeaderBIEffBComplianceDetailsBIVO");
           def complianceInfo = voRow.getAttribute("_ComplianceInfo");
        
           def context = header.getOrCreateContextRow("ComplianceDetails");
           context.setAttribute("_ComplianceInfo",complianceInfo);
        }
     }
   }
 }
  if ( lineId != 0) {
   // throw new ValidationException(lineId.toString());
    /*
    def oLine = getLine(lineId);
    if (oLine == null) continue;
      
   def Ocontext = oLine.getAttribute("FulfillLineBIEffEFFBIFlattened");
    def oContextRow = Ocontext.first();
        def oattr1 = oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_FulfillLineContext1_EffLineId");
    def oattr = oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_FulfillLineContext1__FL1AttributeNum1");
     */
     
      def voRow = getContextVORow(lineId, "FulfillLineBIEffBPackShipInstructionBIVO");
  def contNum1 = voRow.getAttribute("_PackingInstruction");
 
    def context = line.getOrCreateContextRow("PackShipInstruction");
    context.setAttribute("_PackingInstruction",contNum1);
      //  context.setAttribute("_FL1AttributeNum1",23323);
  
     
      
  }
  else{
  throw new ValidationException("We couldn't find a value.");
    
  }
    
// def effValues = line.getOrCreateContextRow("SODetails");
// effValues.setAttribute("cogs",12);
  
}
  
def Object getLine(Long lineId) {
   
def vo = context.getViewObject("oracle.apps.scm.doo.publicView.analytics.FulfillLinePVO");
  
 Object[] rows = vo.findByKey(lineId, 1);
 def originalFLine = rows[0];
   
 return originalFLine;
}
 
/**
 * Returns a row for the context on the order header.
 * @param contextVOName identifies the name of the context for the virtual object. To get this value, use the context code or look it up in the extensible flexfield archive.
 * under oracle/apps/publicFlex/scm/doo/headerContextsB/analytics/view
 */
Object getContextVORow(Long headerId, String contextVOName) {    
     def contextVO = context.getViewObject("oracle.apps.publicFlex.scm.doo.fulfillLineContextsB.analytics.view." + contextVOName);
     def vc = contextVO.createViewCriteria();
     def vcrow = vc.createViewCriteriaRow();
     vcrow.setAttribute("FulfillLineId", headerId);
     def rowset = contextVO.findByViewCriteria(vc, -1);
     def effRow = rowset.first();
     return effRow;
}
 
Object getContextHeaderRow(Long headerId, String contextVOName) {    
     def contextVO = context.getViewObject("oracle.apps.publicFlex.scm.doo.headerContextsB.analytics.view." + contextVOName);
     def vc = contextVO.createViewCriteria();
     def vcrow = vc.createViewCriteriaRow();
     vcrow.setAttribute("HeaderId", headerId);
     def rowset = contextVO.findByViewCriteria(vc, -1);
     def effRow = rowset.first();
     return effRow;
}

拡張可能フレックスフィールドを当初オーダーから返品オーダーにコピー

この例では、拡張可能フレックスフィールド・データを元のオーダーから返品承認(RMA)を含む返品オーダーにコピーします。

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import java.util.logging.Level;

//Following lines are for applying this extension only to specific cases
String poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null) return;
if (poNumber != "PMC TEST") return;


Long lineId = 0;
Long headerId = 0;

def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
    def line = lines.next();

    //get the category code specified on the line. A category code of RETURN means it is a return line
    String categoryCode = line.getAttribute("TransactionCategoryCode");

    if ("RETURN" != categoryCode) continue;

    //we have a return line. Now let's find the original line
    //we will go through the document references on this line to locate the document reference
    //that identifies the original order line.

    def docRefs = line.getAttribute("DocumentReferences");
    lineId = 0;
    while (docRefs.hasNext() & lineId == 0) {

        def docRef = docRefs.next();
        String docRefType = docRef.getAttribute("DocumentReferenceType");
        if ("ORIGINAL_ORCHESTRATION_ORDER" == docRefType) {
            //We found the document reference that points to the original order.
            //The DocumentSubLineIdentifier attribute is the fulfillline id of the original order fulfillment line

            lineId = new Long(docRef.getAttribute("DocumentSubLineIdentifier"));

            if (headerId == 0) {
                //The DocumentIdentifier attribute is the header id of the original order header
                headerId = new Long(docRef.getAttribute("DocumentIdentifier"));
            }
        }
    }
    /*
     if (lineId != 0) {
       
         //call method getline to get the original line a PVO
         def oLine = getLine(lineId);
         if (oLine == null) continue;
         //Define the context variable that you want to copy value to
         def context1 = line.getOrCreateContextRow("FulfillLineContext1");
         //Define the next context variable that you want to copy value to
         def packShipContext = line.getOrCreateContextRow("PackShipInstruction");
         //Define the next context variable that you want to copy value to
         def itemMaterialContext = line.getOrCreateContextRow("Item Material");
         //get Context form the oldline
         def Ocontext = oLine.getAttribute("FulfillLineBIEffEFFBIFlattened");
         //get to the first row of the context for the original order fulfillment line
         def oContextRow = Ocontext.first();
         //Attribute name will be like DOO_FULFILL_LINES_ADD_INFO_<contextname>_<segmentname>
         //You can download the Flexfield archives and navigate to oracle\apps\scm\doo\processOrder\flex\fulfillLineCategories\view\
         //and look for j_ExtendedDeclarativeprivateVO.xml.  This is where you will find all the flex attribute names in above fashion
         def attr1 = oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_FulfillLineContext1__FL1AttributeNum1");
         context1.setAttribute("_FL1AttributeNum1", attr1);
         context1.setAttribute("_FL1AttributeChar1",oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_FulfillLineContext1__FL1AttributeChar1"));
         context1.setAttribute("_FL1AttributeDate1",oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_FulfillLineContext1__FL1AttributeDate1"));
         itemMaterialContext.setAttribute("lineMaterialSgmt",oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_Item__Material_lineMaterialSgmt"));
         itemMaterialContext.setAttribute("lineMaterialText",oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_Item__Material_lineMaterialText"));
         packShipContext.setAttribute("_PackingInstruction",oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_PackShipInstruction__PackingInstruction"));
     }
    }
    */

    if (headerId != 0) {

        def oHeader = getHeader(headerId)

        if (oHeader == null) continue;
        //get Context from the original header
        def context = oHeader.getAttribute("HeaderBIEffEFFBIFlattened");

        //get to the first row of the context for the original header
        def contextRow = context.first();

        //Attribute name will be like DOO_HEADERS_ADD_INFO_<contextname>_<segmentname>
        //You can download the Flexfield archives and navigate to oracle\apps\scm\doo\processOrder\flex\headerCategories\view\
        //and look for j_ExtendedDeclarativeprivateVO.xml.  This is where you will find all the flex attribute names in above fashion
        def complInfo = contextRow.getAttribute("DOO_HEADERS_ADD_INFO_PMC__Pricing_partyid");

        //Define the context variable that you want to copy value to - header is the header of the return oorder which is currently being worked on
        def complianceDetails = header.getOrCreateContextRow("PMC Pricing");
        complianceDetails.setAttribute("partyid", complInfo);

        /* This SQL will be useful in identifying the correct values to set:

select
fdsb.context_code
,fdsb.segment_code
,fdsb.SEGMENT_IDENTIFIER
from
fnd_df_segments_tl fdst,
fnd_df_segments_b fdsb
where
fdst.APPLICATION_ID = fdsb.APPLICATION_ID and
fdst.ENTERPRISE_ID = fdsb.ENTERPRISE_ID and
fdst.DESCRIPTIVE_FLEXFIELD_CODE = fdsb.DESCRIPTIVE_FLEXFIELD_CODE and
fdst.CONTEXT_CODE = fdsb.CONTEXT_CODE and
fdst.SEGMENT_CODE = fdsb.SEGMENT_CODE and
fdst.language = 'US' and
fdst.descriptive_flexfield_code = 'DOO_HEADERS_ADD_INFO'
order by
fdst.CONTEXT_CODE,
fdsb.SEQUENCE_NUMBER

In this instance the Sql returned

CONTEXT_CODE SEGMENT_CODE SEGMENT_IDENTIFIER

PMC Pricing PartyID     partyid

The value DOO_HEADERS_ADD_INFO_PMC__Pricing_partyid - is derived from :

Context_code = PMC Pricing , note the space is replaced by __
Segment_identifier = partyid

*/


    }
}

def Object getLine(Long lineId) {

    def vo = context.getViewObject("oracle.apps.scm.doo.publicView.analytics.FulfillLinePVO");

    Object[] rows = vo.findByKey(lineId, 1);
    def originalFLine = rows[0];

    return originalFLine;
}

def Object getHeader(Long headerId) {
    def vo = context.getViewObject("oracle.apps.scm.doo.publicView.analytics.HeaderPVO");

    Object[] rows = vo.findByKey(headerId, 1);
    def originalHeader = rows[0];
    return originalHeader;
}

void debug(String msg) {
    header.setAttribute("ShippingInstructions", header.getAttribute("ShippingInstructions") + ", " + msg);
}

元の順序からの値の取得

返品オーダーには、一部のオーダー明細属性の元のオーダーの値が含まれていません。 たとえば、返品明細には販売実績または購買オーダー番号の元の値は含まれません。 拡張機能を使用して、元のオーダー明細から値を取得できます。 このトピックの次の例では、返品承認(RMA)を使用するときに、元のオーダーから値を取得します。

元のオーダーからオーダー・タイプを取得

この例では、元の販売オーダーからオーダー・タイプを取得し、それを使用して返品オーダーのオーダー・タイプの値を設定します。

// Extension : DefaultOrderTypeFromOrigOrder
//
//===========================================================
import oracle.apps.scm.doo.common.extensions.ValidationException;

// Go through all the order lines. We're interested in return lines. As soon as we find a return line, we will use the document
// reference on the line to try to locate the original order.
def lines=header.getAttribute("Lines");

while (lines.hasNext()) {

    def line=lines.next();

    // Get the line type specified on the line. A line type code of ORA_RETURN means its a return line.
    String lineTypeCode=line.getAttribute("TransactionLineTypeCode");

    if ("ORA_RETURN"==lineTypeCode) {
        // We have a return line. Now let's find the original order.
        // We will go through the document references on this line to locate the document reference
        // that identifies the original order.
        def docRefs=line.getAttribute("DocumentReferences");

        while (docRefs.hasNext()) {
            def docRef=docRefs.next();
            String docRefType=docRef.getAttribute("DocumentReferenceType");

            if ("ORIGINAL_ORCHESTRATION_ORDER"==docRefType) {
                // We found the document reference that points to the original order.
                // The DocumentIdentifier attribute is the header id of the original order.
                Long headerId=new Long(docRef.getAttribute("DocumentIdentifier"));
                // Call the getOrderType method to get the order type of the original order using a PVO
                String orderTypeCode=getOrderType(headerId);

                debug("Original Order Order Type: "+ orderTypeCode);

                // If order type isn't null, set it on the current order, else use a validation exception.
                if (orderTypeCode !=null) {
                    header.setAttribute("TransactionTypeCode", orderTypeCode);
                    break;
                }

                else {
                    throw new ValidationException("Order type isn't specified on the original order.");
                }
            }
        }
    }
}

/**
* Returns the order type of the indicated order.
*/
String getOrderType(Long headerId) {
    debug("finding order by headerId: "+ headerId);

    def vo=context.getViewObject("oracle.apps.scm.doo.publicView.analytics.HeaderPVO");

    Object[] rows=vo.findByKey(headerId, 1);
    def originalHeader=rows[0];

    return originalHeader.getAttribute("OrderTypeCode");

void debug(String msg) {
// Print a debug message. This code appends the string passed in as parameter to the shipping instructions attribute.
// To avoid performance problems, you must comment out this debug statement in your production environment.
   header.setAttribute("ShippingInstructions", header.getAttribute("ShippingInstructions") + msg + "\n");
}

元のオーダーから購買オーダーを取得

この例では、元のオーダーのオーダー・ヘッダーおよびオーダー明細から購買オーダー詳細を取得し、それらを返品オーダーおよび返品オーダー明細にコピーします。

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import java.util.logging.Level;
Long lineId = 0;
Long headerId = 0;
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
  def line = lines.next();
  String categoryCode = line.getAttribute("TransactionCategoryCode");

  if ("RETURN" != categoryCode) continue;
    def docRefs = line.getAttribute("DocumentReferences");
    lineId = 0;
    while (docRefs.hasNext() & lineId == 0) {
      def docRef = docRefs.next();
      String docRefType = docRef.getAttribute("DocumentReferenceType");

      if ("ORIGINAL_ORCHESTRATION_ORDER" == docRefType) {
        // We found the document reference that points to the original order.
        // The DocumentSubLineIdentifier attribute is the fulfillline id of the original order fulfillment line.
        lineId = new Long(docRef.getAttribute("DocumentSubLineIdentifier"));

        if (headerId == 0) {
          // The DocumentIdentifier attribute is the header id of the original order header.
          headerId = new Long(docRef.getAttribute("DocumentIdentifier"));
        }
      }
  }
  if (lineId != 0) {
    // throw new ValidationException(lineId.toString());
    def oLine = getLine(lineId);

    if (oLine == null) continue;
      def oLinePO = oLine.getAttribute("FulfillLineCustomerPoNumber");
      def oHeaderPO = oLine.getAttribute("HeaderCustomerPoNumber");
      line.setAttribute("CustomerPONumber", oLinePO);
      header.setAttribute("CustomerPONumber", oHeaderPO);
    } else {
        throw new ValidationException("Value not found");
  }
}
  def Object getLine(Long lineId) {
  def vo = context.getViewObject("oracle.apps.scm.doo.publicView.analytics.FulfillLinePVO");
  Object[] rows = vo.findByKey(lineId, 1);
  def originalFLine = rows[0];
  return originalFLine;
}

当初オーダーからの拡張可能フレックスフィールドの取得

この例では、元のオーダーのオーダー明細から拡張可能フレックスフィールドを取得し、それを返品オーダー明細にコピーします。

import oracle.apps.scm.doo.common.extensions.ValidationException;
import oracle.apps.scm.doo.common.extensions.Message;
import java.util.logging.Level;
Long lineId = 0;
Long headerId = 0;
def lines = header.getAttribute("Lines");
while (lines.hasNext()) {
    def line = lines.next();

    String categoryCode = line.getAttribute("TransactionCategoryCode");

    if ("RETURN" != categoryCode) continue;
    def docRefs = line.getAttribute("DocumentReferences");
    lineId = 0;
    while (docRefs.hasNext() & lineId == 0) {
        def docRef = docRefs.next();
        String docRefType = docRef.getAttribute("DocumentReferenceType");
        if ("ORIGINAL_ORCHESTRATION_ORDER" == docRefType) {
            // We found the document reference that references the original order.
            // The DocumentSubLineIdentifier attribute identifies the fulfillment line in the original order.

            lineId = new Long(docRef.getAttribute("DocumentSubLineIdentifier"));
            if (headerId == 0) {
                // The DocumentIdentifier attribute identifies the header in the original order.
                headerId = new Long(docRef.getAttribute("DocumentIdentifier"));
            }
        }
    }
    if (lineId != 0) {
        // throw new ValidationException(lineId.toString());
        def oLine = getLine(lineId);
        if (oLine == null) continue;

        def Ocontext = oLine.getAttribute("FulfillLineBIEffEFFBIFlattened");
        def oContextRow = Ocontext.first();
        def oattr1 = oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_FulfillLineContext1_EffLineId");
        def oattr = oContextRow.getAttribute("DOO_FULFILL_LINES_ADD_INFO_FulfillLineContext1__FL1AttributeNum1");

        def context = line.getOrCreateContextRow("FulfillLineContext1");
        context.setAttribute("_FL1AttributeNum1", oattr);
    } else {
        throw new ValidationException("Value not found");

    }
}
def Object getLine(Long lineId) {

    def vo = context.getViewObject("oracle.apps.scm.doo.publicView.analytics.FulfillLinePVO");
    Object[] rows = vo.findByKey(lineId, 1);
    def originalFLine = rows[0];

    return originalFLine;
}

返品時にビジネス・ユニットが当初オーダーのビジネス・ユニットと一致することを確認

import oracle.apps.scm.doo.common.extensions.ValidationException;
 
/*
def poNumber = header.getAttribute("CustomerPONumber");
if (poNumber == null || !("VS_BU_TEST".equals(poNumber))) {
  return;
}
*/
 
Set<Long> referencedReturnLinesHeaderIds = null;
 
def lines = header.getAttribute("Lines");
while( lines.hasNext() ) {
 
  def line = lines.next();
 
  def categoryCode = line.getAttribute("TransactionCategoryCode");
  if (categoryCode == null || !(categoryCode.equals("RETURN"))) {
    continue;
  }
 
  def docRefs = line.getAttribute("DocumentReferences");
  Long headerId = null;
  while(docRefs.hasNext()) {
 
    def docRef = docRefs.next();
    String docRefType = docRef.getAttribute("DocumentReferenceType");
    if( "ORIGINAL_ORCHESTRATION_ORDER".equals(docRefType) ) {
      if (referencedReturnLinesHeaderIds == null) {
        referencedReturnLinesHeaderIds = new HashSet<Long>();
      }
      headerId = new Long(docRef.getAttribute("DocumentIdentifier"));
      if (!(referencedReturnLinesHeaderIds.contains(headerId))) {
        referencedReturnLinesHeaderIds.add(headerId);
      }
      break;
    }
  }
}
 
if (referencedReturnLinesHeaderIds != null && referencedReturnLinesHeaderIds.size()>0) {
 
  def buId = header.getAttribute("BusinessUnitIdentifier");
 
  def vo = context.getViewObject("oracle.apps.scm.doo.publicView.analytics.HeaderPVO");
  def vc = vo.createViewCriteria();                                                             
 
  def vcrow = vc.createViewCriteriaRow();
  Object inQuery = " in " + referencedReturnLinesHeaderIds;
  inQuery = inQuery.replace('[', '(');
  inQuery = inQuery.replace(']', ')');
  vcrow.setAttribute("HeaderId", inQuery);
 
  def rowset = vo.findByViewCriteria(vc, -1);
  def row = null;
  if(rowset.hasNext()){
    row = rowset.next();
    def returnBuId = row.getAttribute("BUBusinessUnitId");
    if (returnBuId != buId) {
      throw new ValidationException("The request failed. Make sure the business unit of this return order matches the business unit on the original order, then resubmit your sales order. ");
    }
  }
}