供应商常用标准表及常用查询

供应商头表:ap_suppliers
供应商地点表:ap_supplier_sites_all
供应商联系人表:ap_supplier_contacts
采购订单头表:po_headers_all
采购订单行表:po_lines_all
发运表:po_line_locations_all
分配表:po_distributions_all
采购员:po_agents_v
采购申请头表:po_requisition_headers_all
采购申请行表:po_requisition_lines_all
采购申请分配:po_req_distributions_all
采购接收头表:rcv_shipment_headers
采购接收行表:rcv_shipment_lines
采购接收事务处理表:rcv_transactions
销售订单头表:oe_order_headers_all
销售订单行表:oe_order_lines_all
销售订单头,行类型:oe_transaction_types_tl
发运事务处理表:wsh_delivery_details
交货表:wsh_delivery_assignments
物料搬运单头表:mtl_txn_request_headers
物料搬运单行表:mtl_txn_request_lines
物料:MTL_SYSTEM_ITEMS_B
批次:mtl_lot_numbers
货位:MTL_ITEM_LOCATIONS
单位:MTL_UNITS_OF_MEASURE_VL
子库存:mtl_secondary_inventories
物料类别:mtl_item_categories
类别属性:mtl_categories_b
事物处理:mtl_material_transactions
事务处理来源类型:mtl_txn_source_types
事务处理类型:mtl_transaction_types
事务处理批次:MTL_TRANSACTION_LOT_NUMBERS
事务处理序列:mtl_serial_numbers
库存组织视图:org_organization_definitions
库存组织基表:HR_ALL_ORGANIZATION_UNITS
库存期间表:org_acct_periods
现有量:mtl_onhand_quantities_detail
离散任务表:wip_discrete_jobs
离散任务名称表:wip_entities
工单物料需求:wip_requirement_operations
工序表:wip_operations
移动事务处理:wip_move_transactions
资源事务处理表:wip_transactions
BOM清单父项目:bom_bill_of_materials
BOM清单构成项目:bom_inventory_components
装配件状态表:bom_assembly_comments
部门代码对应表:bom_departments
资源代码对应表 :bom_resources  
工艺路线细节之资源表 :bom_operation_resources
工艺路线:bom_operational_routings
标准操作表:bom_standard_operations
标准操作资源表:bom_std_op_resources
BOM替代件表:bom_substitute_components
客户基表:HZ_PARTIES
客户的账户层:HZ_CUST_ACCOUNTS
客户地点:HZ_CUST_ACCT_SITES_ALL
客户地点用途表:HZ_CUST_SITE_USES_ALL
客户地点基表:HZ_PARTY_SITES
地点地址表:HZ_LOCATIONS
销售人员:JTF_RS_RESOURCE_EXTNS_VL,需关联JTF_RS_SALESREPS
销售价目表头:qp_secu_list_headers_v
销售价目表行:qp_list_lines_v

供应商银行信息

SELECT Asp.Vendor_Id                   AS 供应商id
      ,Asp.Vendor_Name                 AS 供应商名称
      ,Asp.Segment1                    AS 供应商编号
      ,Asp.Vendor_Type_Lookup_Code     AS 供应商类型
      ,Asp.Start_Date_Active           AS 供应商起始日期
      ,Asp.Enabled_Flag                AS 供应商启用标识
      ,Asp.End_Date_Active             AS 供应商终止日期
      ,Asp.Party_Id
      ,Ieb.Ext_Bank_Account_Id
      ,Ieb.Bank_Party_Id
      ,Ieb.Bank_Name                   AS 银行
      ,Ieb.Bank_Branch_Name            AS 分行
      ,Ieb.Branch_Party_Id             AS 分行id
      ,Ieb.Bank_Account_Id
      ,Ieb.Bank_Account_Number         AS 银行账户
      ,Ieb.Primary_Acct_Owner_Party_Id AS 账户主要责任人id
      ,Ieb.Primary_Acct_Owner_Name     AS 账户主要责任人
      ,
       
       Iao.End_Date     AS 账户责任人终止日期
      ,Iao.Primary_Flag AS 账户主要责任人标识
      ,
       
       Ieb.Start_Date AS 银行起始日期
      ,Ieb.End_Date AS 银行终止日期
      ,(SELECT t.Start_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行起始日期
      ,(SELECT t.End_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行终止日期
      ,
       
       Iep.Payee_Party_Id
      ,Iep.Payment_Function
      ,
       
       Iep.Party_Site_Id
      ,NULL              AS 地址名称
      ,NULL              AS 地址是否有效
      ,
       
       Ass.Org_Id AS 业务实体id
      ,(SELECT t.Description
          FROM Fnd_Flex_Values_Vl  t
              ,Fnd_Flex_Value_Sets s
         WHERE 1 = 1
           AND t.Flex_Value_Set_Id = s.Flex_Value_Set_Id
           AND s.Flex_Value_Set_Name = 'XXX-COMPANY'
           AND t.Flex_Value = (SELECT Substr(Hou.Short_Code, 4)
                                 FROM Hr_Operating_Units Hou
                                WHERE Hou.Organization_Id = Ass.Org_Id)
           AND t.Enabled_Flag = 'Y'
           AND SYSDATE < Nvl(t.End_Date_Active, SYSDATE + 1)) AS 业务实体名称
      ,(SELECT Hou.Date_From
          FROM Hr_Organization_Units Hou
         WHERE Hou.Organization_Id = Ass.Org_Id) AS 业务实体生效日期
      ,(SELECT Hou.Date_To
          FROM Hr_Organization_Units Hou
         WHERE Hou.Organization_Id = Ass.Org_Id) AS 业务实体失效日期
      ,
       
       Ass.Vendor_Site_Id
      ,Ass.Vendor_Site_Code AS 地点名称
      ,Ass.Inactive_Date    AS 地点失效日期
      ,
       
       Uses.Instrument_Payment_Use_Id
      ,Uses.Ext_Pmt_Party_Id
      ,Uses.Instrument_Id
      ,Uses.Payment_Function
      ,Uses.Start_Date                AS 银行账户起始日期
      ,Uses.End_Date                  AS 银行账户终止日期
      ,ieb.eft_swift_code
      ,ieb.branch_number 分行编号

  FROM Ap_Suppliers            Asp
      ,Iby_Ext_Bank_Accounts_v Ieb
      ,Iby_External_Payees_All Iep
      ,Iby_Pmt_Instr_Uses_All  Uses
      ,Iby_Account_Owners      Iao
      ,Ap_Supplier_Sites_All   Ass
 WHERE 1 = 1
   AND Iep.Ext_Payee_Id = Uses.Ext_Pmt_Party_Id
   AND Iep.Payment_Function = 'PAYABLES_DISB'
   AND Uses.Instrument_Id = Ieb.Ext_Bank_Account_Id
   AND Iep.Payee_Party_Id = Asp.Party_Id
   AND Iep.Party_Site_Id IS NULL
   AND Iep.Supplier_Site_Id IS NULL
   AND Iep.Org_Id IS NULL
   AND Asp.Vendor_Type_Lookup_Code = 'EMPLOYEE'
   AND Ass.Vendor_Id = Asp.Vendor_Id
   AND Uses.Instrument_Type = 'BANKACCOUNT'
   AND Iao.Account_Owner_Party_Id = Asp.Party_Id
   AND Iao.Ext_Bank_Account_Id(+) = Ieb.Ext_Bank_Account_Id
   AND Asp.Vendor_Name = '&VENDOR_NAME'

UNION ALL
--VENDOR
--第一层(供应商关联银行)
SELECT Asp.Vendor_Id                   AS 供应商id
      ,Asp.Vendor_Name                 AS 供应商名称
      ,Asp.Segment1                    AS 供应商编号
      ,Asp.Vendor_Type_Lookup_Code     AS 供应商类型
      ,Asp.Start_Date_Active           AS 供应商起始日期
      ,Asp.Enabled_Flag                AS 供应商启用标识
      ,Asp.End_Date_Active             AS 供应商终止日期
      ,Asp.Party_Id
      ,Ieb.Ext_Bank_Account_Id
      ,Ieb.Bank_Party_Id
      ,Ieb.Bank_Name                   AS 银行
      ,Ieb.Bank_Branch_Name            AS 分行
      ,Ieb.Branch_Party_Id             AS 分行id
      ,Ieb.Bank_Account_Id
      ,Ieb.Bank_Account_Number         AS 银行账户
      ,Ieb.Primary_Acct_Owner_Party_Id AS 账户主要责任人id
      ,Ieb.Primary_Acct_Owner_Name     AS 账户主要责任人
      ,
       
       Iao.End_Date     AS 账户责任人终止日期
      ,Iao.Primary_Flag AS 账户主要责任人标识
      ,
       
       Ieb.Start_Date AS 银行起始日期
      ,Ieb.End_Date AS 银行终止日期
      ,(SELECT t.Start_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行起始日期
      ,(SELECT t.End_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行终止日期
      ,
       
       Iep.Payee_Party_Id
      ,Iep.Payment_Function
      ,
       
       Iep.Party_Site_Id
      ,NULL              AS 地址名称
      ,NULL              AS 地址是否有效
      ,
       
       Iep.Org_Id AS 业务实体id
      ,NULL       AS 业务实体名称
      ,NULL       AS 业务实体生效日期
      ,NULL       AS 业务实体失效日期
      ,
       
       Iep.Supplier_Site_Id
      ,NULL
      ,NULL
      ,
       
       Uses.Instrument_Payment_Use_Id
      ,Uses.Ext_Pmt_Party_Id
      ,Uses.Instrument_Id
      ,Uses.Payment_Function
      ,Uses.Start_Date                AS 银行账户起始日期
      ,Uses.End_Date                  AS 银行账户终止日期
      ,ieb.eft_swift_code
      ,ieb.branch_number 分行编号
--,Ieb.*
  FROM Ap_Suppliers            Asp
      ,Iby_Ext_Bank_Accounts_v Ieb
      ,Iby_External_Payees_All Iep
      ,Iby_Account_Owners      Iao
      ,Iby_Pmt_Instr_Uses_All  Uses
 WHERE 1 = 1
   AND Iep.Ext_Payee_Id = Uses.Ext_Pmt_Party_Id
   AND Iep.Payment_Function = 'PAYABLES_DISB'
   AND Uses.Instrument_Id = Ieb.Ext_Bank_Account_Id
   AND Iep.Payee_Party_Id = Asp.Party_Id
   AND Iep.Party_Site_Id IS NULL
   AND Iep.Supplier_Site_Id IS NULL
   AND Iep.Org_Id IS NULL
   AND Asp.Vendor_Type_Lookup_Code = 'VENDOR'
   AND Uses.Instrument_Type = 'BANKACCOUNT'
   AND Iao.Account_Owner_Party_Id = Asp.Party_Id
   AND Iao.Ext_Bank_Account_Id(+) = Ieb.Ext_Bank_Account_Id
      
   AND Asp.Vendor_Name = '&VENDOR_NAME'

UNION ALL

--第二层(地址关联银行)
SELECT Asp.Vendor_Id   AS 供应商id
      ,Asp.Vendor_Name AS 供应商名称
      ,
       
       Asp.Segment1                    AS 供应商编号
      ,Asp.Vendor_Type_Lookup_Code     AS 供应商类型
      ,Asp.Start_Date_Active           AS 供应商起始日期
      ,Asp.Enabled_Flag                AS 供应商启用标识
      ,Asp.End_Date_Active             AS 供应商终止日期
      ,Asp.Party_Id
      ,Ieb.Ext_Bank_Account_Id
      ,Ieb.Bank_Party_Id
      ,Ieb.Bank_Name                   AS 银行
      ,Ieb.Bank_Branch_Name            AS 分行
      ,Ieb.Branch_Party_Id             AS 分行id
      ,Ieb.Bank_Account_Id
      ,Ieb.Bank_Account_Number         AS 银行账户
      ,Ieb.Primary_Acct_Owner_Party_Id AS 账户主要责任人id
      ,Ieb.Primary_Acct_Owner_Name     AS 账户主要责任人
      ,
       
       Iao.End_Date     AS 账户责任人终止日期
      ,Iao.Primary_Flag AS 账户主要责任人标识
      ,
       
       Ieb.Start_Date AS 银行起始日期
      ,Ieb.End_Date AS 银行终止日期
      ,(SELECT t.Start_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行起始日期
      ,(SELECT t.End_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行终止日期
      ,
       
       Iep.Payee_Party_Id
      ,Iep.Payment_Function
      ,
       
       Iep.Party_Site_Id
      ,(SELECT Hps.Party_Site_Name
          FROM Hz_Party_Sites Hps
         WHERE Iep.Party_Site_Id = Hps.Party_Site_Id
              --AND HPS.STATUS='A'
           AND EXISTS (SELECT 1
                  FROM Hz_Party_Sites     Hps
                      ,Hz_Party_Site_Uses Purchase
                      ,Hz_Party_Site_Uses Pay
                 WHERE Hps.Party_Site_Id = Purchase.Party_Site_Id
                   AND Hps.Party_Site_Id = Pay.Party_Site_Id
                   AND Purchase.Site_Use_Type = 'PURCHASING'
                   AND Pay.Site_Use_Type = 'PAY')) AS 地址名称
      ,Decode((SELECT Hps.Status
                FROM Hz_Party_Sites Hps
               WHERE Iep.Party_Site_Id = Hps.Party_Site_Id
                    --AND HPS.STATUS='A'
                 AND EXISTS (SELECT 1
                        FROM Hz_Party_Sites     Hps
                            ,Hz_Party_Site_Uses Purchase
                            ,Hz_Party_Site_Uses Pay
                       WHERE Hps.Party_Site_Id = Purchase.Party_Site_Id
                         AND Hps.Party_Site_Id = Pay.Party_Site_Id
                         AND Purchase.Site_Use_Type = 'PURCHASING'
                         AND Pay.Site_Use_Type = 'PAY'))
             ,'A'
             ,'有效'
             ,'无效') AS 地址是否有效
      ,
       
       Iep.Org_Id
      ,NULL       AS 业务实体
      ,NULL       AS 业务实体生效日期
      ,NULL       AS 业务实体失效日期
      ,
       
       Iep.Supplier_Site_Id
      ,NULL
      ,NULL
      ,
       
       Uses.Instrument_Payment_Use_Id
      ,Uses.Ext_Pmt_Party_Id
      ,Uses.Instrument_Id
      ,Uses.Payment_Function
      ,Uses.Start_Date                AS 银行账户起始日期
      ,Uses.End_Date                  AS 银行账户终止日期
      ,ieb.eft_swift_code
      ,ieb.branch_number 分行编号

  FROM Ap_Suppliers            Asp
      ,Iby_Ext_Bank_Accounts_v Ieb
      ,Iby_External_Payees_All Iep
      ,Iby_Account_Owners      Iao
      ,Iby_Pmt_Instr_Uses_All  Uses

 WHERE 1 = 1
   AND Iep.Ext_Payee_Id = Uses.Ext_Pmt_Party_Id
   AND Iep.Payment_Function = 'PAYABLES_DISB'
   AND Uses.Instrument_Id = Ieb.Ext_Bank_Account_Id
   AND Iep.Payee_Party_Id = Asp.Party_Id
   AND Iep.Party_Site_Id IS NOT NULL
   AND Iep.Supplier_Site_Id IS NULL
   AND Iep.Org_Id IS NULL
   AND Asp.Vendor_Type_Lookup_Code = 'VENDOR'
   AND Uses.Instrument_Type = 'BANKACCOUNT'
   AND Iao.Account_Owner_Party_Id = Asp.Party_Id
   AND Iao.Ext_Bank_Account_Id(+) = Ieb.Ext_Bank_Account_Id
   AND Asp.Vendor_Name = '&VENDOR_NAME'

UNION ALL

--第三层(地址-业务实体关联银行)
SELECT Asp.Vendor_Id   AS 供应商id
      ,Asp.Vendor_Name AS 供应商名称
      ,
       
       Asp.Segment1                    AS 供应商编号
      ,Asp.Vendor_Type_Lookup_Code     AS 供应商类型
      ,Asp.Start_Date_Active           AS 供应商起始日期
      ,Asp.Enabled_Flag                AS 供应商启用标识
      ,Asp.End_Date_Active             AS 供应商终止日期
      ,Asp.Party_Id
      ,Ieb.Ext_Bank_Account_Id
      ,Ieb.Bank_Party_Id
      ,Ieb.Bank_Name                   AS 银行
      ,Ieb.Bank_Branch_Name            AS 分行
      ,Ieb.Branch_Party_Id             AS 分行id
      ,Ieb.Bank_Account_Id
      ,Ieb.Bank_Account_Number         AS 银行账户
      ,Ieb.Primary_Acct_Owner_Party_Id AS 账户主要责任人id
      ,Ieb.Primary_Acct_Owner_Name     AS 账户主要责任人
      ,
       
       Iao.End_Date     AS 账户责任人终止日期
      ,Iao.Primary_Flag AS 账户主要责任人标识
      ,
       
       Ieb.Start_Date AS 银行起始日期
      ,Ieb.End_Date AS 银行终止日期
      ,(SELECT t.Start_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行起始日期
      ,(SELECT t.End_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行终止日期
      ,
       
       Iep.Payee_Party_Id
      ,Iep.Payment_Function
      ,
       
       Iep.Party_Site_Id
      ,(SELECT Hps.Party_Site_Name
          FROM Hz_Party_Sites Hps
         WHERE Iep.Party_Site_Id = Hps.Party_Site_Id
              --AND HPS.STATUS='A'
           AND EXISTS (SELECT 1
                  FROM Hz_Party_Sites     Hps
                      ,Hz_Party_Site_Uses Purchase
                      ,Hz_Party_Site_Uses Pay
                 WHERE Hps.Party_Site_Id = Purchase.Party_Site_Id
                   AND Hps.Party_Site_Id = Pay.Party_Site_Id
                   AND Purchase.Site_Use_Type = 'PURCHASING'
                   AND Pay.Site_Use_Type = 'PAY')) AS 地址名称
      ,Decode((SELECT Hps.Status
                FROM Hz_Party_Sites Hps
               WHERE Iep.Party_Site_Id = Hps.Party_Site_Id
                    --AND HPS.STATUS='A'
                 AND EXISTS (SELECT 1
                        FROM Hz_Party_Sites     Hps
                            ,Hz_Party_Site_Uses Purchase
                            ,Hz_Party_Site_Uses Pay
                       WHERE Hps.Party_Site_Id = Purchase.Party_Site_Id
                         AND Hps.Party_Site_Id = Pay.Party_Site_Id
                         AND Purchase.Site_Use_Type = 'PURCHASING'
                         AND Pay.Site_Use_Type = 'PAY'))
             ,'A'
             ,'有效'
             ,'无效') AS 地址是否有效
      ,
       
       Iep.Org_Id
      , (SELECT TRIM(Substr(Hou.Name, 4))
           FROM Hr_Organization_Units Hou
          WHERE Hou.Organization_Id = Iep.Org_Id)
       --AND SYSDATE BETWEEN NVL(HOU.DATE_FROM,SYSDATE-1) AND NVL(HOU.DATE_TO,SYSDATE+1)
        AS 业务实体
      ,(SELECT Hou.Date_From
          FROM Hr_Organization_Units Hou
         WHERE Hou.Organization_Id = Iep.Org_Id) AS 业务实体生效日期
      ,(SELECT Hou.Date_To
          FROM Hr_Organization_Units Hou
         WHERE Hou.Organization_Id = Iep.Org_Id) AS 业务实体失效日期
      ,
       
       Iep.Supplier_Site_Id
      ,NULL                 AS 地点
      ,NULL                 AS 地点失效日期
      ,
       
       Uses.Instrument_Payment_Use_Id
      ,Uses.Ext_Pmt_Party_Id
      ,Uses.Instrument_Id
      ,Uses.Payment_Function
      ,Uses.Start_Date                AS 银行账户起始日期
      ,Uses.End_Date                  AS 银行账户终止日期
      ,ieb.eft_swift_code
      ,ieb.branch_number 分行编号

  FROM Ap_Suppliers            Asp
      ,Iby_Ext_Bank_Accounts_v Ieb
      ,Iby_External_Payees_All Iep
      ,Iby_Account_Owners      Iao
      ,Iby_Pmt_Instr_Uses_All  Uses

 WHERE 1 = 1
   AND Iep.Ext_Payee_Id = Uses.Ext_Pmt_Party_Id
   AND Iep.Payment_Function = 'PAYABLES_DISB'
   AND Uses.Instrument_Id = Ieb.Ext_Bank_Account_Id
   AND Iep.Payee_Party_Id = Asp.Party_Id
   AND Iep.Party_Site_Id IS NOT NULL
   AND Iep.Supplier_Site_Id IS NULL
   AND Iep.Org_Id IS NOT NULL
   AND Uses.Instrument_Type = 'BANKACCOUNT'
   AND Asp.Vendor_Type_Lookup_Code = 'VENDOR'
   AND Iao.Account_Owner_Party_Id = Asp.Party_Id
   AND Iao.Ext_Bank_Account_Id(+) = Ieb.Ext_Bank_Account_Id
      
   AND Asp.Vendor_Name = '&VENDOR_NAME'

UNION ALL

--第四层(地点关联银行)
SELECT Asp.Vendor_Id   AS 供应商id
      ,Asp.Vendor_Name AS 供应商名称
      ,
       
       Asp.Segment1                    AS 供应商编号
      ,Asp.Vendor_Type_Lookup_Code     AS 供应商类型
      ,Asp.Start_Date_Active           AS 供应商起始日期
      ,Asp.Enabled_Flag                AS 供应商启用标识
      ,Asp.End_Date_Active             AS 供应商终止日期
      ,Asp.Party_Id
      ,Ieb.Ext_Bank_Account_Id
      ,Ieb.Bank_Party_Id
      ,Ieb.Bank_Name                   AS 银行
      ,Ieb.Bank_Branch_Name            AS 分行
      ,Ieb.Branch_Party_Id             AS 分行id
      ,Ieb.Bank_Account_Id
      ,Ieb.Bank_Account_Number         AS 银行账户
      ,Ieb.Primary_Acct_Owner_Party_Id AS 账户主要责任人id
      ,Ieb.Primary_Acct_Owner_Name     AS 账户主要责任人
      ,
       
       Iao.End_Date     AS 账户责任人终止日期
      ,Iao.Primary_Flag AS 账户主要责任人标识
      ,
       
       Ieb.Start_Date AS 银行起始日期
      ,Ieb.End_Date AS 银行终止日期
      ,(SELECT t.Start_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行起始日期
      ,(SELECT t.End_Date
          FROM Iby_Ext_Bank_Branches_v t
         WHERE t.Branch_Party_Id = Ieb.Branch_Party_Id) AS 分行终止日期
      ,
       
       Iep.Payee_Party_Id
      ,Iep.Payment_Function
      ,Iep.Party_Site_Id
      ,(SELECT Hps.Party_Site_Name
          FROM Hz_Party_Sites Hps
         WHERE Iep.Party_Site_Id = Hps.Party_Site_Id
              --AND HPS.STATUS='A'
           AND EXISTS (SELECT 1
                  FROM Hz_Party_Sites     Hps
                      ,Hz_Party_Site_Uses Purchase
                      ,Hz_Party_Site_Uses Pay
                 WHERE Hps.Party_Site_Id = Purchase.Party_Site_Id
                   AND Hps.Party_Site_Id = Pay.Party_Site_Id
                   AND Purchase.Site_Use_Type = 'PURCHASING'
                   AND Pay.Site_Use_Type = 'PAY')) AS 地址名称
      ,Decode((SELECT Hps.Status
                FROM Hz_Party_Sites Hps
               WHERE Iep.Party_Site_Id = Hps.Party_Site_Id
                    --AND HPS.STATUS='A'
                 AND EXISTS (SELECT 1
                        FROM Hz_Party_Sites     Hps
                            ,Hz_Party_Site_Uses Purchase
                            ,Hz_Party_Site_Uses Pay
                       WHERE Hps.Party_Site_Id = Purchase.Party_Site_Id
                         AND Hps.Party_Site_Id = Pay.Party_Site_Id
                         AND Purchase.Site_Use_Type = 'PURCHASING'
                         AND Pay.Site_Use_Type = 'PAY'))
             ,'A'
             ,'有效'
             ,'无效') AS 地址是否有效
      ,
       
       Iep.Org_Id
      , (SELECT TRIM(Substr(Hou.Name, 4))
           FROM Hr_Organization_Units Hou
          WHERE Hou.Organization_Id = Iep.Org_Id)
       --AND SYSDATE BETWEEN NVL(HOU.DATE_FROM,SYSDATE-1) AND NVL(HOU.DATE_TO,SYSDATE+1)
        AS 业务实体
      ,(SELECT Hou.Date_From
          FROM Hr_Organization_Units Hou
         WHERE Hou.Organization_Id = Iep.Org_Id) AS 业务实体生效日期
      ,(SELECT Hou.Date_To
          FROM Hr_Organization_Units Hou
         WHERE Hou.Organization_Id = Iep.Org_Id) AS 业务实体失效日期
      ,
       
       Iep.Supplier_Site_Id
      ,(SELECT Ass.Vendor_Site_Code
          FROM Ap_Supplier_Sites_All Ass
         WHERE Ass.Vendor_Site_Id = Iep.Supplier_Site_Id
           AND Ass.Purchasing_Site_Flag = 'Y'
           AND Ass.Pay_Site_Flag = 'Y') AS 地点
      ,(SELECT Ass.Inactive_Date
          FROM Ap_Supplier_Sites_All Ass
         WHERE Ass.Vendor_Site_Id = Iep.Supplier_Site_Id
           AND Ass.Purchasing_Site_Flag = 'Y'
           AND Ass.Pay_Site_Flag = 'Y') AS 地点失效日期
      ,
       
       Uses.Instrument_Payment_Use_Id
      ,Uses.Ext_Pmt_Party_Id
      ,Uses.Instrument_Id
      ,Uses.Payment_Function
      ,Uses.Start_Date                AS 银行账户起始日期
      ,Uses.End_Date                  AS 银行账户终止日期
      ,ieb.eft_swift_code
      ,ieb.branch_number 分行编号

  FROM Ap_Suppliers            Asp
      ,Iby_Ext_Bank_Accounts_v Ieb
      ,Iby_External_Payees_All Iep
      ,Iby_Account_Owners      Iao
      ,Iby_Pmt_Instr_Uses_All  Uses

 WHERE 1 = 1
   AND Asp.Vendor_Type_Lookup_Code = 'VENDOR'
      
   AND Iep.Ext_Payee_Id = Uses.Ext_Pmt_Party_Id
   AND Iep.Payment_Function = 'PAYABLES_DISB'
   AND Uses.Instrument_Id = Ieb.Ext_Bank_Account_Id
   AND Iep.Payee_Party_Id = Asp.Party_Id
   AND Iep.Party_Site_Id IS NOT NULL
   AND Iep.Supplier_Site_Id IS NOT NULL
   AND Iep.Org_Id IS NOT NULL
   AND Uses.Instrument_Type = 'BANKACCOUNT'
   AND Iao.Account_Owner_Party_Id = Asp.Party_Id
   AND Iao.Ext_Bank_Account_Id(+) = Ieb.Ext_Bank_Account_Id
      
   AND Asp.Vendor_Name = '&VENDOR_NAME';

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值