plsql ebs 工作中的简单笔记

工作流中给系统界面发送消息:

  PROCEDURE wf_notify(p_sender       IN VARCHAR2 DEFAULT 'SYSADMIN',
                      p_receiver     IN VARCHAR2,
                      p_subject      IN VARCHAR2,
                      p_content_text IN VARCHAR2);



  PROCEDURE wf_notify(p_sender       IN VARCHAR2 DEFAULT 'SYSADMIN',---发送者
                      p_receiver     IN VARCHAR2,--接收人
                      p_subject      IN VARCHAR2,
                      p_content_text IN VARCHAR2) IS
    PRAGMA AUTONOMOUS_TRANSACTION;
    v_notification_id wf_notifications.notification_id%TYPE;
  BEGIN
    v_notification_id := wf_notification.send(role     => p_receiver,
                                              msg_type => 'CS_MSGS',
                                              msg_name => 'EXPANDED_FYI_MSG',
                                              due_date => SYSDATE,
                                              priority => 1);
  
    wf_notification.setattrtext(nid    => v_notification_id,
                                aname  => '#FROM_ROLE',
                                avalue => p_sender);
  
    wf_notification.setattrtext(nid    => v_notification_id,
                                aname  => 'OBJECT_TYPE',
                                avalue => p_subject);
  
    wf_notification.setattrtext(nid    => v_notification_id,
                                aname  => 'SENDER',
                                avalue => p_sender);
  
    wf_notification.setattrtext(nid    => v_notification_id,
                                aname  => 'MESSAGE_TEXT',
                                avalue => p_content_text);
  
    wf_notification.denormalize_notification(nid => v_notification_id);
    dbms_transaction.commit;
  EXCEPTION
    WHEN OTHERS THEN
      dbms_transaction.rollback;
  END wf_notify;

begin
  fnd_global.apps_initialize(user_id      => 234969,
                             resp_id      => 51737,
                             resp_appl_id => 50201);
end;

begin
  dbms_output.put_line(fnd_global.user_name);
  cux_ws_bip_pub_pkg.wf_notify('SYSADMIN',fnd_global.user_name,'请求异的信息','CESHI.................');
end;

将org_id和code链接到一起
select hou.short_code from hr_operating_units hou where hou.organization_id=2084;

清理卡死的程序:

select va.sid,va.OBJECT from v$access va where object like '%CUX_WS_BIP_TBGYS_PKG%';
SELECT * FROM dba_ddl_locks t WHERE t.name = 'CUX_WS_BIP_TBGYS_PKG';
SELECT * FROM V$DB_OBJECT_CACHE WHERE name='CUX_WS_BIP_TBGYS_PKG' AND LOCKS!='0';
select * FROM dba_ddl_locks where name =upper('CUX_WS_BIP_TBGYS_PKG');
select t.sid, t.serial# from v$session t where t.sid  in (4534,8595);
alter system kill session '4534,43139'; 
alter system kill session '8595,23529'; 

查询供应商地址蒲信息:
在这里插入图片描述

SELECT *
  FROM (select hps.party_site_id,
               hps.party_site_name as address_name,
               'CURRENT' as status,
               hzl.address1 as loc_address1,
               hzl.address2 as loc_address2,
               hzl.address3 as loc_address3,
               hzl.city as loc_city,
               hzl.county as loc_county,
               hzl.state as loc_state,
               hzl.province as loc_province,
               hzl.postal_code as loc_postal_code,
               hzl.country as loc_country,
               fvl.territory_short_name as country_name,
               hzl.address4 as loc_address4,
               email.email_address,
               phone.phone_area_code || ' ' || phone.phone_number AS phone_number,
               fax.phone_area_code || ' ' || fax.phone_number AS fax_number,
               decode(POS_UTIL_PKG.IS_ADDR_CCR(1.0, '', hps.party_site_id),
                      'T',
                      'removeInActiveImage',
                      'removeActiveImage') as remove_image,
               'mngSites' as edit_image,
               -1 as address_request_id,
               decode(pay.site_use_type, 'PAY', 'Y', 'N') as pay_flag,
               decode(pur.site_use_type, 'PURCHASING', 'Y', 'N') as pur_flag,
               decode(rfq.site_use_type, 'RFQ', 'Y', 'N') as rfq_flag,
               'TCA' as address_type,
               hzl.address1 || ' , ' || hzl.address2 || ' , ' ||
               hzl.address3 || ' , ' || hzl.address4 || ' , ' || hzl.city ||
               ' , ' || hzl.county || ' , ' || hzl.STATE || ' , ' ||
               hzl.province || ' , ' || hzl.postal_code || ' , ' ||
               fvl.territory_short_name as address_detail_int,
               'SourceSystemEnabled' as source_system_switcher,
               POS_SUPP_CONTACT_PKG.get_address_purpose_string(hps.party_site_id,
                                                               'APPROVED') AS purpose
          from hz_party_sites     hps,
               hz_locations       hzl,
               fnd_territories_vl fvl,
               hz_contact_points  email,
               hz_contact_points  phone,
               hz_contact_points  fax,
               hz_party_site_uses pay,
               hz_party_site_uses pur,
               hz_party_site_uses rfq
         where hps.status = 'A'
           and hps.party_id = 7345--:1 --and hps.created_by_module like 'POS%' 
           and hzl.COUNTRY = fvl.TERRITORY_CODE
           and email.owner_table_id(+) = hps.party_site_id
           and email.owner_table_name(+) = 'HZ_PARTY_SITES'
           and email.status(+) = 'A'
           and email.contact_point_type(+) = 'EMAIL'
           and email.primary_flag(+) = 'Y'
           and phone.owner_table_id(+) = hps.party_site_id
           and phone.owner_table_name(+) = 'HZ_PARTY_SITES'
           and phone.status(+) = 'A'
           and phone.contact_point_type(+) = 'PHONE'
           and phone.phone_line_type(+) = 'GEN'
           and phone.primary_flag(+) = 'Y'
           and fax.owner_table_id(+) = hps.party_site_id
           and fax.owner_table_name(+) = 'HZ_PARTY_SITES'
           and fax.status(+) = 'A'
           and fax.contact_point_type(+) = 'PHONE'
           and fax.phone_line_type(+) = 'FAX'
           and hps.location_id = hzl.location_id
           and pay.party_site_id(+) = hps.party_site_id
           and pur.party_site_id(+) = hps.party_site_id
           and rfq.party_site_id(+) = hps.party_site_id
           and pay.status(+) = 'A'
           and pur.status(+) = 'A'
           and rfq.status(+) = 'A'
           and nvl(pay.end_date(+), sysdate) >= sysdate
           and nvl(pur.end_date(+), sysdate) >= sysdate
           and nvl(rfq.end_date(+), sysdate) >= sysdate
           and nvl(pay.begin_date(+), sysdate) <= sysdate
           and nvl(pur.begin_date(+), sysdate) <= sysdate
           and nvl(rfq.begin_date(+), sysdate) <= sysdate
           and pay.site_use_type(+) = 'PAY'
           and pur.site_use_type(+) = 'PURCHASING'
           and rfq.site_use_type(+) = 'RFQ'
           and not exists
         (select 1
                  from pos_address_requests par, pos_supplier_mappings psm
                 where psm.party_id = hps.party_id
                   and psm.mapping_id = par.MAPPING_ID
                   and party_site_id = hps.party_site_id
                   and request_status = 'PENDING'
                   and request_type in ('UPDATE', 'DELETE'))
        UNION ALL
        select hps.party_site_id,
               hps.party_site_name as address_name,
               decode(par.request_type,
                      'UPDATE',
                      'CHANGED',
                      'DELETE',
                      'CHANGED') as status,
               hzl.address1 as loc_address1,
               hzl.address2 as loc_address2,
               hzl.address3 as loc_address3,
               hzl.city as loc_city,
               hzl.county as loc_county,
               hzl.state as loc_state,
               hzl.province as loc_province,
               hzl.postal_code as loc_postal_code,
               hzl.country as loc_country,
               fvl.territory_short_name as country_name,
               hzl.address4 as loc_address4,
               email.email_address,
               phone.phone_area_code || ' ' || phone.phone_number AS phone_number,
               fax.phone_area_code || ' ' || fax.phone_number AS fax_number,
               'removeInActiveImage' as remove_image,
               decode(par.request_type,
                      'UPDATE',
                      'mngSites',
                      'DELETE',
                      'mngSitesDisabled') as edit_image,
               par.address_request_id as address_request_id,
               decode(pay.site_use_type, 'PAY', 'Y', 'N') as pay_flag,
               decode(pur.site_use_type, 'PURCHASING', 'Y', 'N') as pur_flag,
               decode(rfq.site_use_type, 'RFQ', 'Y', 'N') as rfq_flag,
               'TCA' as address_type,
               hzl.address1 || ' , ' || hzl.address2 || ' , ' ||
               hzl.address3 || ' , ' || hzl.address4 || ' , ' || hzl.city ||
               ' , ' || hzl.county || ' , ' || hzl.STATE || ' , ' ||
               hzl.province || ' , ' || hzl.postal_code || ' , ' ||
               fvl.territory_short_name as address_detail_int,
               decode(par.request_type,
                      'UPDATE',
                      'SourceSystemEnabled',
                      'DELETE',
                      'SourceSystemDisabled') as source_system_switcher,
               POS_SUPP_CONTACT_PKG.get_address_purpose_string(hps.party_site_id,
                                                               'APPROVED') AS purpose
          from hz_party_sites        hps,
               hz_locations          hzl,
               fnd_territories_vl    fvl,
               hz_contact_points     email,
               hz_contact_points     phone,
               hz_contact_points     fax,
               pos_address_requests  par,
               pos_supplier_mappings psm,
               hz_party_site_uses    pay,
               hz_party_site_uses    pur,
               hz_party_site_uses    rfq
         where hps.status = 'A'
           and hps.party_id = 7345--:2 --and hps.created_by_module like 'POS%' 
           and hzl.COUNTRY = fvl.TERRITORY_CODE
           and email.owner_table_id(+) = hps.party_site_id
           and email.owner_table_name(+) = 'HZ_PARTY_SITES'
           and email.status(+) = 'A'
           and email.contact_point_type(+) = 'EMAIL'
           and email.primary_flag(+) = 'Y'
           and phone.owner_table_id(+) = hps.party_site_id
           and phone.owner_table_name(+) = 'HZ_PARTY_SITES'
           and phone.status(+) = 'A'
           and phone.contact_point_type(+) = 'PHONE'
           and phone.phone_line_type(+) = 'GEN'
           and phone.primary_flag(+) = 'Y'
           and fax.owner_table_id(+) = hps.party_site_id
           and fax.owner_table_name(+) = 'HZ_PARTY_SITES'
           and fax.status(+) = 'A'
           and fax.contact_point_type(+) = 'PHONE'
           and fax.phone_line_type(+) = 'FAX'
           and hps.location_id = hzl.location_id
           and par.party_site_id = hps.party_site_id
           and psm.party_id = hps.party_id
           and psm.mapping_id = par.mapping_id
           and par.request_type in ('UPDATE', 'DELETE')
           AND PAR.request_status = 'PENDING'
           and pay.party_site_id(+) = hps.party_site_id
           and pur.party_site_id(+) = hps.party_site_id
           and rfq.party_site_id(+) = hps.party_site_id
           and pay.status(+) = 'A'
           and pur.status(+) = 'A'
           and rfq.status(+) = 'A'
           and nvl(pay.end_date(+), sysdate) >= sysdate
           and nvl(pur.end_date(+), sysdate) >= sysdate
           and nvl(rfq.end_date(+), sysdate) >= sysdate
           and nvl(pay.begin_date(+), sysdate) <= sysdate
           and nvl(pur.begin_date(+), sysdate) <= sysdate
           and nvl(rfq.begin_date(+), sysdate) <= sysdate
           and pay.site_use_type(+) = 'PAY'
           and pur.site_use_type(+) = 'PURCHASING'
           and rfq.site_use_type(+) = 'RFQ'
        UNION ALL
        select par.party_site_id,
               par.party_site_name as address_name,
               decode(par.request_type,
                      'ADD',
                      'NEW',
                      'UPDATE',
                      'CHANGED',
                      'UNKNOWN') as status,
               par.address_line1 as loc_address1,
               par.address_line2 as loc_address2,
               par.address_line3 as loc_address3,
               par.city as loc_city,
               par.county as loc_county,
               par.state as loc_state,
               par.province as loc_province,
               par.postal_code as loc_postal_code,
               par.country as loc_country,
               fvl.territory_short_name as country_name,
               par.address_line4 as loc_address4,
               par.email_address,
               par.phone_area_code || ' ' || par.phone_number || ' ' ||
               par.PHONE_EXTENSION as phone_number,
               par.fax_area_code || ' ' || par.FAX_NUMBER as fax_number,
               'removeInActiveImage' as remove_image,
               decode(par.request_type,
                      'UPDATE',
                      'mngSites',
                      'mngSitesDisabled') as edit_image,
               par.address_request_id as address_request_id,
               decode(par.pay_flag, 'Y', 'Y', 'N') as pay_flag,
               decode(par.PUR_FLAG, 'Y', 'Y', 'N') as pur_flag,
               decode(par.rfq_flag, 'Y', 'Y', 'N') as rfq_flag,
               'POS' as address_type,
               par.address_line1 || ' , ' || par.address_line2 || ' , ' ||
               par.address_line3 || ' , ' || par.address_line4 || ' , ' ||
               par.city || ' , ' || par.county || ' , ' || par.STATE ||
               ' , ' || par.province || ' , ' || par.postal_code || ' , ' ||
               fvl.territory_short_name as address_detail_int,
               'SourceSystemDisabled' as source_system_switcher,
               POS_SUPP_CONTACT_PKG.get_address_purpose_string(par.address_request_id,
                                                               'REQUESTED') purpose
          from pos_address_requests  par,
               pos_supplier_mappings psm,
               fnd_territories_vl    fvl
         where par.mapping_id = psm.mapping_id
           and par.COUNTRY = fvl.TERRITORY_CODE
           and psm.party_id = /*:3*/7345) QRSLT
 WHERE (rownum < 302)
 ORDER BY ADDRESS_NAME ASC

查询配置文件
在这里插入图片描述

SELECT FND_PROFILE.value('CUX_WS_20BIP_APPKEY'),FND_PROFILE.value('CUX_WS_20BIP_APPSECRET') FROM SYS.DUAL;

供应商基础信息:

SELECT --ass.vendor_id vendor_id,
      --ass.party_id party_id,
       pv.vendor_id,
       pv.party_id,
       --REPLACE(REPLACE(ass.segment1, chr(13), ''), chr(10), '') vendor_code, --供应商编码
       --REPLACE(REPLACE(ass.vendor_name, chr(13), ''), chr(10), '') vendor_name, --供应商名称
       --REPLACE(REPLACE(ass.vendor_name, chr(13), ''), chr(10), '') vendor_short_name, --供应商短名称
       REPLACE(REPLACE(pv.SEGMENT1, chr(13), ''), chr(10), '') AS vendor_code,
       REPLACE(REPLACE(pv.vendor_name, chr(13), ''), chr(10), '') VENDOR_NAME,
       REPLACE(REPLACE(pv.VENDOR_NAME_ALT, chr(13), ''), chr(10), '') AS vendor_short_name,
       decode(upper(pv.vendor_type_lookup_code),
              'EMPLOYEE',
              papf.national_identifier,
              decode(pv.organization_type_lookup_code,
                     'INDIVIDUAL',
                     pv.individual_1099,
                     'FOREIGN INDIVIDUAL',
                     pv.individual_1099,
                     pv.num_1099)) NUM_1099 ---纳税人标识
        FROM --ap_suppliers ass, 
             po_vendors       pv,
             per_all_people_f papf
       WHERE /*(*/
      --ass.vendor_id = g_Param_Rec.vendor_id /*OR
      --AND ass.vendor_id = pv.vendor_id
       pv.last_update_date BETWEEN g_param_rec.last_update_date_fm AND
       g_param_rec.last_update_date_to
       AND pv.employee_id = papf.person_id(+)
       AND Nvl(papf.EFFECTIVE_END_DATE, SYSDATE) >= SYSDATE;

供应商银行信息:

 SELECT REPLACE(REPLACE(accts.bank_account_name, chr(13), ''),
                     chr(10),
                     '') bank_account_name, --账户名
             REPLACE(REPLACE(fc.name, chr(13), ''), chr(10), '') AS currency_name, --银行币种
             REPLACE(REPLACE(bank.party_name, chr(13), ''), chr(10), '') AS bank_name, --银行名称
             REPLACE(REPLACE(accts.masked_bank_account_num, chr(13), ''),
                     chr(10),
                     '') AS bank_account_number, ---银行账号
             REPLACE(REPLACE(branch.bank_branch_name, chr(13), ''),
                     chr(10),
                     '') bank_branch_name, --银行分行名称
             REPLACE(REPLACE(bankProfile.bank_or_branch_number, chr(13), ''),
                     chr(10),
                     '') AS bank_number, ---银行编码
             ExtBanksEO.BANK_PARTY_ID,
             countries.TERRITORY_SHORT_NAME ------------
        FROM iby_pmt_instr_uses_all   uses,
             iby_external_payees_all  payee,
             iby_ext_bank_accounts    accts,
             fnd_currencies_vl        fc,
             HZ_PARTIES               bank,
             HZ_ORGANIZATION_PROFILES bankProfile,
             CE_BANK_BRANCHES_V       branch,
             IBY_EXT_BANKS_V          ExtBanksEO,
             fnd_territories_vl       countries
       WHERE uses.instrument_type = 'BANKACCOUNT'
         AND payee.ext_payee_id = uses.ext_pmt_party_id
         AND payee.payee_party_id = l_payee_party_id
         AND payee.payment_function = 'PAYABLES_DISB'
            /*and payee.party_site_id is null
            and payee.org_id is null
            and payee.supplier_site_id is null*/
         AND uses.instrument_id = accts.ext_bank_account_id
         AND fc.currency_code(+) = accts.currency_code
         AND SYSDATE BETWEEN NVL(accts.start_date, SYSDATE) AND
             NVL(accts.end_date, SYSDATE)
         AND accts.bank_id = bank.party_id(+)
         AND accts.bank_id = bankProfile.party_id(+)
         AND accts.branch_id = branch.branch_party_id(+)
         AND SYSDATE BETWEEN TRUNC(bankProfile.effective_start_date(+)) AND
             NVL(TRUNC(bankProfile.effective_end_date(+)), SYSDATE + 1)
         AND accts.BANK_ID = ExtBanksEO.BANK_PARTY_ID
         AND ExtBanksEO.HOME_COUNTRY = countries.territory_code(+);

供应商地点信息:

 SELECT REPLACE(REPLACE(pvsa.VENDOR_SITE_CODE, chr(13), ''),
                     chr(10),
                     '') VENDOR_SITE_CODE, -------------详细地址
             REPLACE(REPLACE(hrou.name, chr(13), ''), chr(10), '') AS org_name, --------------公司段编码
             Decode(pv.VENDOR_TYPE_LOOKUP_CODE,
                    'EMPLOYEE',
                    Decode(pvsa.VENDOR_SITE_CODE,
                           'HOME',
                           fnd_message.get_string('POS', 'POS_HT_SP_HOME'),
                           'OFFICE',
                           fnd_message.get_string('POS', 'POS_HT_SP_OFFICE'),
                           'PROVISIONAL',
                           fnd_message.get_string('POS',
                                                  'POS_HT_SP_PROVISIONAL'),
                           pvsa.VENDOR_SITE_CODE),
                    pvsa.VENDOR_SITE_CODE) siteName ------------地点名称
        FROM ap_supplier_sites_all    pvsa, ---
             hr_operating_units       hrou, ---
             ap_supplier_sites_all    pay_site,
             po_location_associations poas,
             ap_system_parameters_all ap_param,
             hr_locations             hrl,
             ap_suppliers             pv ----
       WHERE pvsa.vendor_id = l_vendor_id
         AND pv.vendor_id = pvsa.vendor_id
         AND poas.vendor_id(+) = pvsa.vendor_id
         AND poas.vendor_site_id(+) = pvsa.vendor_site_id
         AND hrl.location_id(+) = pvsa.ship_to_location_id
         AND hrou.organization_id = pvsa.org_id
         AND pvsa.default_pay_site_id = pay_site.vendor_site_id(+)
            --and mo_global.check_access(pvsa.org_id) = 'Y'
         AND pvsa.org_id = ap_param.org_id;

同步ERP资产转移分配信息:
在这里插入图片描述

      select fdh.book_type_code, --资产帐簿编码--15
             AD.asset_id, --固定资产编码--1
             flo.segment1 Locations, --地点--
             gcc.segment1, --公司--
             gcc.segment2, --部门--
             gcc.segment3, --科目--
             gcc.segment4, --子目--
             gcc.segment5, --产品--
             gcc.segment6, --项目--
             gcc.segment7, --往来--
             gcc.segment8, --管理维度--
             gcc.segment9, --备用--
             ppf.last_name, --使用人名称
             ppf.person_id, --使用人编码
             (SELECT sum(fdha.UNITS_ASSIGNED)
                FROM FA_DISTRIBUTION_HISTORY fdha
               WHERE ('' IS NULL AND fdha.DATE_INEFFECTIVE IS NULL AND
                     fdha.BOOK_TYPE_CODE = fdh.book_type_code AND
                     fdha.ASSET_ID = fdh.asset_id AND 'TRANSFER' != 'TRANSFER IN')
                  OR ('' IS NOT NULL AND
                     (fdha.TRANSACTION_HEADER_ID_OUT = '' AND
                     'TRANSFER' IN
                     ('TRANSFER', 'TRANSFER OUT', 'UNIT ADJUSTMENT')) OR
                     (fdha.TRANSACTION_HEADER_ID_IN = '' AND
                     'TRANSFER' IN
                     ('TRANSFER IN', 'TRANSFER', 'UNIT ADJUSTMENT') AND
                     (fdha.CODE_COMBINATION_ID, fdha.LOCATION_ID,
                      NVL(fdha.ASSIGNED_TO, -99)) NOT IN
                     (SELECT DH.CODE_COMBINATION_ID,
                               DH.LOCATION_ID,
                               NVL(DH.ASSIGNED_TO, -99)
                          FROM FA_DISTRIBUTION_HISTORY DH
                         WHERE DH.ASSET_ID = fdh.asset_id
                           AND DH.BOOK_TYPE_CODE = fdh.book_type_code
                           AND DH.TRANSACTION_HEADER_ID_OUT = ''
                           AND 'TRANSFER' IN
                               ('TRANSFER', 'TRANSFER OUT', 'UNIT ADJUSTMENT'))))
                               and  ROWNUM = 1) IN_OUT, --卡片总数量
             fdh.UNITS_ASSIGNED, --数量
             fdh.DISTRIBUTION_ID, --行id
             gcc.chart_of_accounts_id
        from gl_code_combinations    gcc,
             fa_locations            flo,
             FA_ADDITIONS_B          AD,
             fa_distribution_history fdh,
             per_people_f            ppf
       where (fdh.book_type_code = g_Param_Rec.p_book_type_code OR
             g_Param_Rec.p_book_type_code is null) ---
         and (fdh.asset_id = g_Param_Rec.p_asset_id OR
             g_Param_Rec.p_asset_id is null) ---
         and (fdh.LAST_UPDATE_DATE >=
             to_date(g_Param_Rec.p_lu_date_begin, 'yyyy-mm-dd') OR
             g_Param_Rec.p_lu_date_begin is null) ---
         and (fdh.LAST_UPDATE_DATE <
             to_date(g_Param_Rec.p_lu_date_end, 'yyyy-mm-dd') OR
             g_Param_Rec.p_lu_date_end is null) ---
         and fdh.asset_id = AD.asset_id(+)
         AND fdh.location_id = flo.location_id(+)
         AND fdh.code_combination_id = gcc.code_combination_id(+)
         AND fdh.assigned_to = ppf.person_id(+)
         and fdh.DATE_INEFFECTIVE is null;

资产卡片-基本信息:

SELECT DISTINCT AD.asset_id,
                      AD.ASSET_NUMBER, --固定资产编码--03
                      AD.LAST_UPDATE_DATE, --最后更改时间
                      fdh.book_type_code, --资产帐簿编码--01
                      fbc.BOOK_TYPE_NAME, --资产帐簿名称--02
                      ADT.DESCRIPTION, --固定资产名称--04
                      fcv.segment4 asset_category, -- 资产类别最末级段--05
                      fck.concatenated_segments category_code, --资产类别--06
                      fcv.description category_desc, --资产类别说明--07
                      fb.prorate_convention_code, --折旧惯例----21
                      fb.deprn_method_code, --折旧方法----20
                      fak.SEGMENT1, --旧资产编号-----15
                      fak.SEGMENT2, --来源方式(说明)---16
                      AD.CURRENT_UNITS, --数量--------------08
                      AD.TAG_NUMBER, --标签号--------------09
                      AD.SERIAL_NUMBER, --序列号----------------11
                      AD.MODEL_NUMBER, --型号------------10
                      AD.in_use_flag, --L17 使用状态
                      AD.context, --L18 说明性弹性域
                      (SELECT 'Y'
                         FROM FA_RETIREMENTS fr
                        WHERE fr.book_type_code = fb.book_type_code
                          AND fr.asset_id = fb.asset_id
                          AND fr.status = 'PROCESSED'
                          AND ROWNUM = 1) retire_exists_flag, --L22 报废状态(R) 
                      (SELECT SUM(NVL(fr.cost_retired, 0))
                         FROM FA_RETIREMENTS fr
                        WHERE fr.book_type_code = fb.book_type_code
                          AND fr.asset_id = fb.asset_id
                          AND fr.status = 'PROCESSED') sum_retired_cost, --L51  已报废总额
                      fb.original_cost, --L10 原始成本
                      fb.date_placed_in_service, --L25 启用日期
                      fb.depreciate_flag, --L26 折旧状态
                      fb.life_in_months, --L29 资产寿命(月) 
                      (SELECT 'Y'
                         FROM FA_TRANSACTION_HEADERS fth1
                        WHERE fth1.book_type_code = fb.book_type_code
                          AND fth1.asset_id = fb.asset_id
                          AND (fth1.transaction_subtype = 'AMORTIZED' OR
                              fth1.transaction_key = 'UA')
                          AND fth1.transaction_header_id <=
                              fb.transaction_header_id_in
                          AND ROWNUM < 2) check_amort_flag --L37 是否摊销
        FROM FA_ADDITIONS_B          AD, --
             FA_ADDITIONS_TL         ADT, --
             fa_distribution_history fdh, --
             fa_book_controls        fbc, --
             fa_categories_vl        fcv, --
             fa_categories_b_kfv     fck, --
             fa_additions_b          fab,
             fa_books                fb, --
             FA_DEPRN_PERIODS        fdp,
             FA_ASSET_KEYWORDS       fak --
       WHERE --AD.asset_id = 10006269
       (fdh.book_type_code = g_Param_Rec.p_book_type_code OR
       g_Param_Rec.p_book_type_code is null) ---
       and (fdh.asset_id = g_Param_Rec.p_asset_id OR
       g_Param_Rec.p_asset_id is null) ---
       and (AD.LAST_UPDATE_DATE >=
       to_date(g_Param_Rec.p_lu_date_begin, 'yyyy-mm-dd') OR
       g_Param_Rec.p_lu_date_begin is null) ---
       and (AD.LAST_UPDATE_DATE <
       to_date(g_Param_Rec.p_lu_date_end, 'yyyy-mm-dd') OR
       g_Param_Rec.p_lu_date_end is null) ---
       AND fb.book_type_code = fdp.book_type_code(+)
       and fak.CODE_COMBINATION_ID = AD.ASSET_KEY_CCID
       AND fb.asset_id = fab.asset_id
       and fab.asset_id = fdh.asset_id
       AND fab.asset_category_id = fcv.category_id
       AND fcv.category_id = fck.category_id
       and fbc.BOOK_TYPE_CODE = fdh.book_type_code
       and AD.asset_id = fdh.asset_id
       AND AD.ASSET_ID = ADT.ASSET_ID
       AND ADT.LANGUAGE = userenv('LANG');

IF rec_apply.in_use_flag = 'YES' THEN
            lv_in_use_flag := '使用中';
          ELSE
            lv_in_use_flag := '不在使用中';
          END IF;
        
          begin
            SELECT LISTAGG(application_column_name, '||''' || '|' || '''||') WITHIN GROUP(ORDER BY column_seq_num) concatenated_struc,
                   LISTAGG(end_user_column_name, '|') WITHIN GROUP(ORDER BY column_seq_num) concatenated_value
              into l_concatenated_struc, l_concatenated_value
              FROM FND_DESCR_FLEX_COL_USAGE_VL
             WHERE 1 = 1
               AND enabled_flag = 'Y'
               AND descriptive_flexfield_name LIKE 'FA_ADDITIONS'
               AND descriptive_flex_context_code IN
                   (rec_apply.context, 'Global Data Elements')
             ORDER BY column_seq_num;
          
            IF l_concatenated_struc IS NULL THEN
              lv_dff_val := '';
            ELSE
              l_concatenated_struc := 'SELECT ' || l_concatenated_struc ||
                                      CHR(10) || 'FROM   FA_ADDITIONS_B' ||
                                      CHR(10) || 'WHERE  asset_id = ' ||
                                      rec_apply.asset_id;
              EXECUTE IMMEDIATE l_concatenated_struc
                INTO lv_dff_val;
            END IF;
          EXCEPTION
            WHEN NO_DATA_FOUND THEN
              l_concatenated_value := '';
              l_concatenated_struc := '';
              lv_dff_val           := '';
          END;
        
          ln_original_cost        := NVL(rec_apply.original_cost, 0);
          ln_cur_sum_retired_cost := NVL(rec_apply.sum_retired_cost, 0);
          ln_current_cost         := ln_original_cost -
                                     ln_cur_sum_retired_cost;
        
          IF rec_apply.retire_exists_flag = 'Y' THEN
            IF ln_current_cost <= 0 THEN
              lv_retire_exists_desc := '全部报废';
            ELSE
              lv_retire_exists_desc := '部分报废';
            END IF;
          ELSE
            lv_retire_exists_desc := '未报废';
          END IF;
        
          IF rec_apply.depreciate_flag = 'YES' THEN
            lv_depreciate_flag_desc := '需提折旧';
          ELSE
            lv_depreciate_flag_desc := '不提折旧';
          END IF;
          l_life_years  := rec_apply.life_in_months / 12;
          l_life_months := rec_apply.life_in_months - l_life_years * 12;
        
          SELECT PRORATE_DATE --折旧日期--22
            into l_PRORATE_DATE
            FROM FA_BOOKS_V
           WHERE date_ineffective is null
             and (BOOK_TYPE_CODE LIKE rec_apply.book_type_code)
             and (ASSET_ID = rec_apply.asset_id);
        
          select fdp.calendar_period_open_date,
                 fdp.calendar_period_close_date
            into l_calendar_period_open_date, l_calendar_period_close_date
            from FA_DEPRN_PERIODS fdp
           where fdp.book_type_code = rec_apply.book_type_code
             and fdp.calendar_period_close_date =
                 (select max(fdp.calendar_period_close_date)
                    from FA_DEPRN_PERIODS fdp
                   where fdp.book_type_code = rec_apply.book_type_code
                   group by fdp.book_type_code);
        
          IF rec_apply.check_amort_flag = 'Y' THEN
            lv_check_amort_flag_desc := '是';
            SELECT GREATEST(l_calendar_period_open_date,
                            LEAST(SYSDATE, l_calendar_period_close_date))
              INTO ld_amortization_start_date
              FROM FA_DEPRN_PERIODS
             WHERE book_type_code = rec_apply.book_type_code
               AND period_close_date IS NULL;
          ELSE
            lv_check_amort_flag_desc := '否';
          END IF;

资产账簿:

      SELECT hou.organization_id,
             hou.name,
             fbc.BOOK_TYPE_NAME,
             fbc.BOOK_TYPE_code,
             gcc.segment1 coa_com, --公司--,
             fbc.last_update_date,
             gcc.chart_of_accounts_id
        FROM hr_operating_units      hou,
             FA_BOOK_CONTROLS        fbc,
             gl_code_combinations    gcc,
             fa_distribution_history fdh
       WHERE hou.set_of_books_id = fbc.set_of_books_id
         and fbc.BOOK_TYPE_CODE = fdh.book_type_code
         AND fdh.code_combination_id = gcc.code_combination_id
         and (fbc.LAST_UPDATE_DATE > to_date(g_Param_Rec.p_lu_date_begin, 'yyyy-mm-dd') OR
             g_Param_Rec.p_lu_date_begin is null) 
         and (fbc.LAST_UPDATE_DATE < to_date(g_Param_Rec.p_lu_date_end, 'yyyy-mm-dd') OR
             g_Param_Rec.p_lu_date_end is null) ;

查询值集:
在这里插入图片描述

      SELECT ffvs.flex_value_set_name, --名称
             ffvs.flex_value_set_id, --id
             ffvs.description               description1, --名称说明
             ffvv.FLEX_VALUE, --值
             ffvv.FLEX_VALUE_MEANING, --转换的值
             ffvv.DESCRIPTION               DESCRIPTION2, --说明
             ffvv.ENABLED_FLAG, ----是否启用
             ffvv.START_DATE_ACTIVE, ---有效日期自
             ffvv.END_DATE_ACTIVE, ---有效日期至
             SUBSTR(ffvv.COMPILED_VALUE_ATTRIBUTES,5,1) COMPILED_VALUE_ATTRIBUTES
        FROM FND_FLEX_VALUES_VL ffvv, fnd_flex_value_sets ffvs
       WHERE (('' IS NULL) OR
             (structured_hierarchy_level IN
             (SELECT hierarchy_id
                  FROM fnd_flex_hierarchies_vl h
                 WHERE h.flex_value_set_id = ffvv.FLEX_VALUE_SET_ID
                   AND h.hierarchy_name like '')))
         and ffvv.FLEX_VALUE_SET_ID = ffvs.FLEX_VALUE_SET_ID
         and ffvs.flex_value_set_name = 'CG_COA_ACCOUNT' 
         and (ffvv.last_update_date >
             to_date(g_Param_Rec.P_LAST_UPDATE, 'yyyy-mm-dd') OR
             g_Param_Rec.P_LAST_UPDATE is null) ---
       order by flex_value;

银行总行数据获取:

      Select replace(replace(BankParty.PARTY_ID,chr(13),''),chr(10),'') bank_id,
             replace(replace(replace(BankParty.PARTY_NAME,chr(13),''),chr(10),''),chr(9),'') bank_name,
             replace(replace(FndTerritory.territory_short_name,chr(13),''),chr(10),'')  territory_short_name, ------
             BankParty.LAST_UPDATE_DATE
        From HZ_PARTIES               BankParty,
             HZ_ORGANIZATION_PROFILES BankOrgProfile,
             HZ_CODE_ASSIGNMENTS      BankCA,
             FND_TERRITORIES_VL       FndTerritory
       Where BankParty.PARTY_TYPE = 'ORGANIZATION'
         And BankParty.status = 'A'
         And BankParty.PARTY_ID = BankOrgProfile.PARTY_ID
         And SYSDATE between TRUNC(BankOrgProfile.effective_start_date) and
             NVL(TRUNC(BankOrgProfile.effective_end_date), SYSDATE + 1)
         And BankCA.CLASS_CATEGORY = 'BANK_INSTITUTION_TYPE'
         And BankCA.CLASS_CODE in ('BANK', 'CLEARINGHOUSE')
         And BankCA.OWNER_TABLE_NAME = 'HZ_PARTIES'
         And BankCA.OWNER_TABLE_ID = BankParty.PARTY_ID
         And NVL(BankCA.STATUS, 'A') = 'A'
         And BankOrgProfile.HOME_COUNTRY = FndTerritory.territory_code
         and BankParty.LAST_UPDATE_DATE >to_date(g_Param_Rec.p_lu_date_begin, 'yyyy-mm-dd')
         and BankParty.LAST_UPDATE_DATE <to_date(g_Param_Rec.p_lu_date_end, 'yyyy-mm-dd')

银行分行数据:

SELECT BranchParty.party_id,
             replace(replace(BankParty.PARTY_NAME,chr(13),''),chr(10),'')  AS 银行名, ---------------总行名称
             replace(replace(replace(replace(BranchParty.party_name,chr(13),''),chr(10),''),chr(34),'') ,chr(9),'')        AS bank_branch_name, -----------------分行名称
             BranchCA.end_date_active     AS 无效日期,
             BranchParty.LAST_UPDATE_DATE,
             replace(replace(BranchParty.party_id,chr(13),''),chr(10),'')           AS bank_branch_id, ---分行编号
             replace(replace(BankParty.PARTY_ID,chr(13),''),chr(10),'')             AS bank_id ------------------总行编号
        FROM hz_parties               BranchParty,
             hz_organization_profiles BranchOrgProfile,
             hz_code_assignments      BranchTypeCA,
             hz_code_assignments      RfcCA,
             hz_contact_points        BranchCP,
             HZ_CONTACT_POINTS        BranchCPEdi,
             hz_code_assignments      BranchCA,
             HZ_PARTIES               BankParty,
             HZ_ORGANIZATION_PROFILES BankOrgProfile,
             HZ_CODE_ASSIGNMENTS      BankCA,
             HZ_RELATIONSHIPS         BRRel
       WHERE BranchParty.PARTY_ID = BranchOrgProfile.PARTY_ID
         And SYSDATE between TRUNC(BranchOrgProfile.effective_start_date) and
             NVL(TRUNC(BranchOrgProfile.effective_end_date), SYSDATE + 1)
         AND BranchCA.owner_table_name = 'HZ_PARTIES'
         AND BranchCA.owner_table_id = BranchParty.party_id
         AND BranchCA.class_category = 'BANK_INSTITUTION_TYPE'
         And BranchCA.CLASS_CODE in ('BANK_BRANCH', 'CLEARINGHOUSE_BRANCH')
         And NVL(BranchCA.STATUS, 'A') = 'A'
         AND BranchTypeCA.owner_table_name(+) = 'HZ_PARTIES'
         AND BranchTypeCA.owner_table_id(+) = BranchParty.party_id
         AND BranchTypeCA.class_category(+) = 'BANK_BRANCH_TYPE'
         AND NVL(BranchTypeCA.primary_flag(+), 'Y') = 'Y' -- 8870466
         AND RfcCA.owner_table_name(+) = 'HZ_PARTIES'
         AND RfcCA.owner_table_id(+) = BranchParty.party_id
         AND RfcCA.class_category(+) = 'RFC_IDENTIFIER'
         And NVL(RfcCA.STATUS(+), 'A') = 'A'
         And SYSDATE between TRUNC(RfcCA.start_date_active(+)) and
             NVL(TRUNC(RfcCA.end_date_active(+)), SYSDATE + 1)
         AND BranchCP.owner_table_name(+) = 'HZ_PARTIES'
         AND BranchCP.owner_table_id(+) = BranchParty.party_id
         AND BranchCP.contact_point_type(+) = 'EFT'
         AND BranchCP.status(+) = 'A'
         And BranchCPEdi.OWNER_TABLE_NAME(+) = 'HZ_PARTIES'
         And BranchCPEdi.OWNER_TABLE_ID(+) = BranchParty.PARTY_ID
         And BranchCPEdi.CONTACT_POINT_TYPE(+) = 'EDI'
         And BranchCPEdi.STATUS(+) = 'A'
         AND BankParty.PARTY_ID = BankOrgProfile.PARTY_ID
         And SYSDATE between TRUNC(BankOrgProfile.effective_start_date) and
             NVL(TRUNC(BankOrgProfile.effective_end_date), SYSDATE + 1)
         AND BankParty.PARTY_TYPE = 'ORGANIZATION'
         And BankParty.status = 'A'
         And BankCA.CLASS_CATEGORY = 'BANK_INSTITUTION_TYPE'
         And BankCA.CLASS_CODE in ('BANK', 'CLEARINGHOUSE')
         And BankCA.OWNER_TABLE_NAME = 'HZ_PARTIES'
         And BankCA.OWNER_TABLE_ID = BankParty.PARTY_ID
         And NVL(BankCA.STATUS, 'A') = 'A'
         And BRRel.OBJECT_ID = BankParty.PARTY_ID
         And BranchParty.PARTY_ID = BRRel.SUBJECT_ID
         And BRRel.RELATIONSHIP_TYPE = 'BANK_AND_BRANCH'
         And BRRel.RELATIONSHIP_CODE = 'BRANCH_OF'
         And BRRel.STATUS = 'A'
         And BRRel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
         And BRRel.SUBJECT_TYPE = 'ORGANIZATION'
         And BRRel.OBJECT_TABLE_NAME = 'HZ_PARTIES'
         And BRRel.OBJECT_TYPE = 'ORGANIZATION'
         AND BranchParty.LAST_UPDATE_DATE >to_date(g_Param_Rec.p_lu_date_begin, 'yyyy-mm-dd')
         AND BranchParty.LAST_UPDATE_DATE <to_date(g_Param_Rec.p_lu_date_end, 'yyyy-mm-dd')

银行账户数据:

Select replace(replace(BranchParty.PARTY_NAME, chr(13), ''),
                     chr(10),
                     '') bank_branch_name, --分行名称
             BranchParty.PARTY_ID bank_branch_id, ---分行id
             BankAccountEO.BANK_ACCOUNT_ID,
             replace(replace(replace(replace(BankAccountEO.BANK_ACCOUNT_NAME,
                                             chr(13),
                                             ''),
                                     chr(10),
                                     ''),
                             chr(32),
                             ''),
                     chr(9),
                     '') bank_account_name, ----------帐户名
             CE_BANK_AND_ACCOUNT_UTIL.GET_MASKED_BANK_ACCT_NUM(BANK_ACCOUNT_ID) bank_account_num, ---------账户账号
             BankAccountEO.CURRENCY_CODE currency_code, ----币种 
             (select ffv1.description
                from fnd_flex_values_vl ffv1
               where ffv1.FLEX_VALUE(+) = BankAccountEO.ATTRIBUTE1
                 and ffv1.enabled_flag = 'Y'
                 and ffv1.LAST_UPDATE_DATE =
                     (select max(ffv2.LAST_UPDATE_DATE)
                        from fnd_flex_values_vl ffv2
                       where ffv2.flex_value = ffv1.flex_value)) ATTRIBUTE1 ----账户性质
        From HZ_PARTIES               BankParty,
             HZ_PARTIES               BranchParty,
             HZ_ORGANIZATION_PROFILES BankOrgProfile,
             HZ_ORGANIZATION_PROFILES BranchOrgProfile,
             HZ_RELATIONSHIPS         BRRel,
             HZ_CODE_ASSIGNMENTS      BankCA,
             HZ_CODE_ASSIGNMENTS      BranchCA,
             CE_LOOKUPS               CL,
             FND_TERRITORIES_VL       FT,
             CE_BANK_ACCOUNTS         BankAccountEO,
             CE_LOOKUPS               CLAccountType,
             xle_entity_profiles      xle
       Where BankParty.PARTY_TYPE = 'ORGANIZATION'
         And BankParty.status = 'A'
         And BankParty.PARTY_ID = BankOrgProfile.PARTY_ID
         And SYSDATE between TRUNC(BankOrgProfile.effective_start_date) and
             NVL(TRUNC(BankOrgProfile.effective_end_date), SYSDATE + 1)
         And BankCA.CLASS_CATEGORY = 'BANK_INSTITUTION_TYPE'
         And BankCA.CLASS_CODE = 'BANK'
         And BankCA.OWNER_TABLE_NAME = 'HZ_PARTIES'
         And BankCA.OWNER_TABLE_ID = BankParty.PARTY_ID
         And NVL(BankCA.STATUS, 'A') = 'A'
         And BranchParty.PARTY_TYPE = 'ORGANIZATION'
         And BranchParty.status = 'A'
         And BranchOrgProfile.PARTY_ID = BranchParty.PARTY_ID
         And SYSDATE between
             TRUNC(BranchOrgProfile.effective_start_date(+)) and
             NVL(TRUNC(BranchOrgProfile.effective_end_date(+)), SYSDATE + 1)
         And BranchCA.CLASS_CATEGORY = 'BANK_INSTITUTION_TYPE'
         And BranchCA.CLASS_CODE = 'BANK_BRANCH'
         And BranchCA.OWNER_TABLE_NAME = 'HZ_PARTIES'
         And BranchCA.OWNER_TABLE_ID = BranchParty.PARTY_ID
         And NVL(BranchCA.STATUS, 'A') = 'A'
         And BRRel.OBJECT_ID = BankParty.PARTY_ID
         And BranchParty.PARTY_ID = BRRel.SUBJECT_ID
         And BRRel.RELATIONSHIP_TYPE = 'BANK_AND_BRANCH'
         And BRRel.RELATIONSHIP_CODE = 'BRANCH_OF'
         And BRRel.STATUS = 'A'
         And BRRel.SUBJECT_TABLE_NAME = 'HZ_PARTIES'
         And BRRel.SUBJECT_TYPE = 'ORGANIZATION'
         And BRRel.OBJECT_TABLE_NAME = 'HZ_PARTIES'
         And BRRel.OBJECT_TYPE = 'ORGANIZATION'
         and cl.lookup_type = 'ACCOUNT_CLASSIFICATION'
         and cl.lookup_code = 'INTERNAL'
         and BankOrgProfile.home_country = FT.territory_code
         And BankAccountEO.BANK_BRANCH_ID = BranchParty.party_id
         And CLAccountType.lookup_type(+) = 'BANK_ACCOUNT_TYPE'
         and CLAccountType.lookup_code(+) = BankAccountEO.BANK_ACCOUNT_TYPE
         and xle.LEGAL_ENTITY_ID = BankAccountEO.ACCOUNT_OWNER_ORG_ID
         and (BankAccountEO.LAST_UPDATE_DATE >
             to_date(g_Param_Rec.p_lu_date_begin, 'yyyy-mm-dd') OR
             g_Param_Rec.p_lu_date_begin is null) ---
         and (BankAccountEO.LAST_UPDATE_DATE <
             to_date(g_Param_Rec.p_lu_date_end, 'yyyy-mm-dd') OR
             g_Param_Rec.p_lu_date_end is null) ---

一篇好的文章:https://blog.csdn.net/cai_xingyun/article/details/38016687

PRAGMA AUTONOMOUS_TRANSACTION(自治事务)
在这里插入图片描述
资产帐铺的期间:

SELECT period_name
        into l_coa_com
        FROM fa_deprn_periods
       WHERE book_type_code = rec_apply.BOOK_TYPE_NAME
         AND period_close_date is NULL;

在这里插入图片描述
在这里插入图片描述
客户表之间得关系:https://blog.csdn.net/rfb0204421/article/details/7606008

cux_ws_bip_pub_pkg.init_env;
          v_request_id := fnd_request.submit_request(application => 'CUX',
                                                     program     => 'OM_SETTLES_AUTO_GL_ARINV',
                                                     description => '接口自动开票',
                                                     start_time  => to_char(SYSDATE,
                                                                            'yyyy/mm/dd hh24:mi:ss'),
                                                     sub_request => FALSE,
                                                     argument1   => p_document_no,
                                                     argument2   => NULL,
                                                     argument3   => NULL,
                                                     argument4   => chr(0));
        SELECT CUX_WS_BIP_GL_RFD_DTLS_INFO_S.nextval
          INTO gn_info_id
          FROM dual;
        l_info_rec                   := NULL;
        l_info_rec.info_id           := gn_info_id;
        l_info_rec.request_id        := g_request_id;
        l_info_rec.creation_date     := SYSDATE;
        l_info_rec.created_by        := fnd_global.user_id;
        l_info_rec.last_updated_by   := fnd_global.user_id;
        l_info_rec.last_update_date  := SYSDATE;
        l_info_rec.last_update_login := fnd_global.login_id;
        INSERT INTO CUX_WS_BIP_GL_RFD_DTLS_INFO VALUES l_info_rec;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值