Oracle EBS:SQL 失效一揽子PO协议

1.查询一揽子PO:

这里要注意的是:不同的付款条件,币种,税率,都会可能产生一张新的一揽子PO协议


select pla.PO_LINE_ID,
       pla.PO_HEADER_ID,
       pla.ITEM_ID,
       msib.SEGMENT1 ITEM_CODE,
        pla.UNIT_PRICE,
       pla.ITEM_DESCRIPTION,
       pla.START_DATE,
       pla.EXPIRATION_DATE,
       pla.CANCEL_FLAG,
       pla.CLOSED_CODE,
       pha.PO_HEADER_ID,
       pha.VENDOR_ID,
       pha.VENDOR_SITE_ID,
       pha.TERMS_ID,
       pla.TAX_CODE_ID
  from PO_LINES_ALL pla, PO_HEADERS_ALL pha,MTL_SYSTEM_ITEMS_B msib
where nvl(pla.closed_code, 'OPEN') != 'FINALLY CLOSED'
   and nvl(pla.CANCEL_FLAG, 'N') = 'N'
   and pla.PO_HEADER_ID=pha.PO_HEADER_ID
   and nvl(pha.closed_code, 'OPEN') != 'FINALLY CLOSED'
   and nvl(pha.CANCEL_FLAG,'N')='N'
   and pha.ENABLED_FLAG='Y'
   and pha.TYPE_LOOKUP_CODE = 'BLANKET'
   and msib.INVENTORY_ITEM_ID=pla.ITEM_ID



2.通过查找对应的ID,失效对应的价格,我这里好像少了付款条件跟币种,税率这几个条件,


procedure SetPriceExpireDate(P_ITEM_CODE        IN VARCHAR2,
                               P_VENDOR_CODE      IN VARCHAR2,
                               P_VENDOR_SITE_CODE IN VARCHAR2,
                               P_ORG_ID           IN VARCHAR2,
                               v_retval           out number) is
  begin
    Update PO_LINES_ALL pla
       set pla.EXPIRATION_DATE = sysdate
     where pla.ITEM_ID = GetItemID(P_ITEM_CODE, P_ORG_ID)
       and pla.ORG_ID = P_ORG_ID
       and nvl(pla.cancel_flag, 'N') = 'N'
       and nvl(closed_code, 'OPEN') != 'FINALLY CLOSED'
       and exists
     (select *
              from PO_HEADERS_ALL pha
             where pha.PO_HEADER_ID = pla.PO_HEADER_ID
               and pha.TYPE_LOOKUP_CODE = 'BLANKET'
               and pha.VENDOR_ID = GetVendorID(P_VENDOR_CODE)
               and pha.VENDOR_SITE_ID =
                   GetVendorSiteID(P_VENDOR_SITE_CODE, P_ORG_ID));
  
    v_retval := 1;
    COMMIT;
  
  EXCEPTION
    WHEN OTHERS THEN
      v_retval := 0;
    
  end SetPriceExpireDate;



3.辅助的几个函数


Function GetVendorID(P_Vendor_Code IN VARCHAR2) RETURN NUMBER as
    v_vendor_id number;
  
  begin
  
    select pv.VENDOR_ID
      into v_vendor_id
      from po_vendors pv
    
     where pv.SEGMENT1 = P_Vendor_Code;
  
    return v_vendor_id;
  
  end;

  Function GetVendorSiteID(P_Vendor_SITE_CODE IN VARCHAR2,
                           P_ORG_ID           IN NUMBER) RETURN NUMBER as
    v_vendor_site_id number;
  begin
    select pvsa.VENDOR_SITE_ID
      into v_vendor_site_id
      from PO_VENDOR_SITES_ALL pvsa
     where pvsa.VENDOR_SITE_CODE = P_Vendor_SITE_CODE
       and pvsa.ORG_ID = P_ORG_ID;
  
    return v_vendor_site_id;
  
  end;

  FUNCTION GetItemID(P_ITEM_CODE IN VARCHAR2, P_ORG_ID IN NUMBER)
    RETURN NUMBER as
  
    v_item_id number;
  
  begin
    select msib.INVENTORY_ITEM_ID
      into v_item_id
      from MTL_SYSTEM_ITEMS_B msib
    
     where msib.SEGMENT1 = P_ITEM_CODE
       AND msib.ORGANIZATION_ID = P_ORG_ID;
  
    return v_item_id;
  
  end;

 

posted @ 2012-01-09 11:46  我不卖豆腐  阅读(677)  评论(0编辑  收藏  举报