Verify Data That Users Enter

Create an order management extension that determines whether a purchase order exists for the purchase order number that the Order Entry Specialist enters in the Purchase Order attribute.

It calls a public view object to get data from Oracle Procurement.

For demonstration purposes, this example hard codes some values, such as HW INTERNAL. Your environment will likely require different variable values.

This topic uses example values. You might need different values, depending on your business requirements.

  1. In the Setup and Maintenance work area, go to the task.

    • Offering: Order Management

    • Functional Area: Orders

    • Task: Manage Order Management Extensions

  2. On the Manage Order Management Extensions page, on the On Start of Submission Request tab, create a new extension.

    Attribute

    Value

    Name

    Verify That the Purchase Order Exists

    Description

    Determine whether a purchase order exists for the purchase order number that the Order Entry Specialist enters in the Purchase Order attribute.

  3. In the Definition area, add code.

    //Import classes for validation exceptions and messages from Oracle Trading Community Architecture.
    import oracle.apps.scm.doo.common.extensions.ValidationException;
    
    def orderType = header.getAttribute("TransactionTypeCode");
    
    //Determine whether the sales order is internal.
    if(orderType != null && orderType.contains("HW INTERNAL")) {
    
      //Determine whether the purchase order exists.
      String poNumber = header.getAttribute("CustomerPONumber");
    
      boolean poExists = false;
      if( poNumber != null ) {
    
    //Get the PVO you need to access purchase orders.
    def poPVO = context.getViewObject("oracle.apps.prc.po.publicView.PurchasingDocumentHeaderPVO");
          
    //Create the view criteria. Use where clause predicates.
    def vc = poPVO.createViewCriteria();
    def vcrow = vc.createViewCriteriaRow();
    vcrow.setAttribute("Segment1", poNumber);
         
    //Query the view object to find a matching row.
    def rowset = poPVO.findByViewCriteriaWithBindVars(vc, 1, new String [0], new String [0]);
          
    //Determine whether a matching row exists.
    poExists = rowset.hasNext();
    }
    
    //If a matching row does not exist, then the purchase order that you entered does not exist. Create a validation error and stop the sales order submit.
      if( !poExists ) {
    throw new ValidationException("ORA_MANAGE_EXTENSIONS",   "DOO_EXT_HW_INTERNAL_PO_REQD", null);
      }    
    }