Oracle EBS HR解除员工雇佣

–说明:以下代码已经经过本人测试,建议在实际应用时再次测试
declare
  –常量定义
  l_terminate_emp_flag varchar2(1) := 'N';
  l_terminate_msg      varchar2(600);
  –select t.person_id, t.last_name from per_people_f t;
  l_person_id number := 1383;
  l_le_terminate_emp_exception exception;

  –DECLARE variables for HR_EX_EMPLOYEE_WORKER_API.actual_termination_emp
  –IN variables
  l_effective_date date;
  –离职原因,需根据系统定义的参数输入 select distinct t.leaving_reason from hr.PER_PERIODS_OF_SERVICE t; 
  l_termination_reason per_periods_of_service.leaving_reason%type := 'EMP_TRANS';
  –当执行时显示:Error validating API: hr_ex_employee_api.actual_termination_emp : ORA-20001: 必须指定具有系统人员类型 EX_EMP 的人员类型。
  –运行下面命令找出 select t.person_type_id  from hr.per_person_types t where t.system_person_type = 'EX_EMP';得出'9'
  l_person_type_id             per_person_types.person_type_id%type := 9;
  l_period_of_service_id       per_periods_of_service.period_of_service_id%type;
  l_actual_termination_date    per_periods_of_service.actual_termination_date%type := trunc(sysdate);
  l_last_standard_process_date per_periods_of_service.last_standard_process_date%type := trunc(sysdate + 10);
  l_object_version_number      per_periods_of_service.object_version_number%type;
  l_start_date                 per_periods_of_service.date_start%type;
  l_notif_term_date            date;

  –OUT variables
  l_supervisor_warning         boolean := false;
  l_event_warning              boolean := false;
  l_interview_warning          boolean := false;
  l_review_warning             boolean := false;
  l_recruiter_warning          boolean := false;
  l_asg_future_changes_warning boolean := false;
  l_entries_changed_warning    varchar2(300);
  l_pay_proposal_warning       boolean := false;
  l_dod_warning                boolean := false;
  l_alu_change_warning         varchar2(300);

  –DECLARE variables for HR_EX_EMPLOYEE_WORKER_API.final_process_emp
  –IN variables
  l_final_process_date per_periods_of_service.final_process_date%type;

  –OUT variables
  l_org_now_no_manager_warning   boolean := false;
  l_f_asg_future_changes_warning boolean := false;
  l_f_entries_changed_warning    varchar2(300);
  —
begin
  begin
    select pos.period_of_service_id, pos.object_version_number, date_start
      into l_period_of_service_id, l_object_version_number, l_start_date
      from per_periods_of_service pos
     where pos.person_id = l_person_id;
  exception
    when others then
      l_terminate_msg := 'Error while selecting employee details : ' ||
                         substr(sqlerrm, 1, 150);
      raise l_le_terminate_emp_exception;
  end;
  –保存点
  savepoint terminate_employee_s1;
  begin
    /*
    * This API terminates an employee.
    * This API converts a person of type Employee >to a person of type
    * Ex-Employee. The person's period of service and any employee assignments are ended.
    */
    hr_ex_employee_api.actual_termination_emp(p_validate                   => false –l_validate
                                             ,
                                              p_effective_date             => trunc(sysdate),
                                              p_period_of_service_id       => l_period_of_service_id,
                                              p_object_version_number      => l_object_version_number,
                                              p_actual_termination_date    => l_actual_termination_date,
                                              p_last_standard_process_date => l_last_standard_process_date,
                                              p_person_type_id             => l_person_type_id,
                                              p_leaving_reason             => l_termination_reason
                                              –Out
                                             ,
                                              p_supervisor_warning         => l_supervisor_warning,
                                              p_event_warning              => l_event_warning,
                                              p_interview_warning          => l_interview_warning,
                                              p_review_warning             => l_review_warning,
                                              p_recruiter_warning          => l_recruiter_warning,
                                              p_asg_future_changes_warning => l_asg_future_changes_warning,
                                              p_entries_changed_warning    => l_entries_changed_warning,
                                              p_pay_proposal_warning       => l_pay_proposal_warning,
                                              p_dod_warning                => l_dod_warning,
                                              p_alu_change_warning         => l_alu_change_warning);
 
    if l_object_version_number is null then
      l_terminate_emp_flag := 'N';
      l_terminate_msg      := 'Warning validating API: hr_ex_employee_api.actual_termination_emp';
      raise l_le_terminate_emp_exception;
    end if;
 
    l_terminate_emp_flag := 'Y';
  exception
    when others then
      l_terminate_msg := 'Error validating API: hr_ex_employee_api.actual_termination_emp : ' ||
                         substr(sqlerrm, 1, 150);
      raise l_le_terminate_emp_exception;
  end;
  — hr_ex_employee_api.actual_termination_emp

  if l_terminate_emp_flag = 'Y' then
    begin
   
      if l_start_date > trunc(sysdate) then
        l_notif_term_date := l_start_date + 1;
      else
        l_notif_term_date := trunc(sysdate);
      end if;
      /*
      * This API updates employee termination information.
      * The ex-employee must exist in the relevant business group
      */
      apps.hr_ex_employee_api.update_term_details_emp(p_validate                   => false –l_validate   
                                                     ,
                                                      p_effective_date             => trunc(sysdate),
                                                      p_period_of_service_id       => l_period_of_service_id,
                                                      p_notified_termination_date  => l_notif_term_date,
                                                      p_projected_termination_date => l_notif_term_date
                                                      –In/Out 
                                                     ,
                                                      p_object_version_number => l_object_version_number);
    exception
      when others then
        l_terminate_msg      := 'Error validating API: hr_ex_employee_api.update_term_details_emp : ' ||
                                substr(sqlerrm, 1, 150);
        l_terminate_emp_flag := 'N';
        raise l_le_terminate_emp_exception;
    end; –hr_ex_employee_api.update_term_details_emp
 
    begin
      /*
      * This API set the final process date for a terminated employee.
      * This API covers the second step in terminating a period of service and all
      * current assignments for an employee. It updates the period of service
      * details and date-effectively deletes all employee assignments as of the final process date.
      */
      apps.hr_ex_employee_api.final_process_emp(p_validate             => false –l_validate    
                                               ,
                                                p_period_of_service_id => l_period_of_service_id
                                                –Out  
                                               ,
                                                p_object_version_number      => l_object_version_number,
                                                p_final_process_date         => l_final_process_date,
                                                p_org_now_no_manager_warning => l_org_now_no_manager_warning,
                                                p_asg_future_changes_warning => l_f_asg_future_changes_warning,
                                                p_entries_changed_warning    => l_f_entries_changed_warning);
    exception
      when others then
        l_terminate_msg := 'Error validating API: hr_ex_employee_api.final_process_emp : ' ||
                           substr(sqlerrm, 1, 150);
        raise l_le_terminate_emp_exception;
    end; –hr_ex_employee_api.final_process_emp
 
  end if;
  commit;
exception
  when l_le_terminate_emp_exception then
    dbms_output.put_line(l_terminate_msg);
    rollback to terminate_employee_s1;
  when others then
    dbms_output.put_line('Terminate Employee. Error OTHERS while validating: ' ||
                         sqlerrm);
    rollback to terminate_employee_s1;
end;

获取银行分行所在的省、市信息

    之前在做一个银行抽盘文件的时候,需要获取到供应商对应维护的银行分行所在的省市信息,于是记录下获取的sql命令,如下:

 记录银行信息的界面:

  来源界面

–银行分行的地址行1和城市数据
SELECT HP.ADDRESS1, HP.CITY
  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,
       HZ_PARTIES              HP
 WHERE 1 = 1
   AND HP.PARTY_ID = IEB.branch_party_id
   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 ASP.ENABLED_FLAG = 'Y'
   AND ASP.SUMMARY_FLAG = 'N'
   AND IEP.PARTY_SITE_ID IS NULL
   AND IEP.SUPPLIER_SITE_ID IS NULL
   AND IEP.ORG_ID IS NULL
   AND (USES.END_DATE IS NULL OR USES.END_DATE > SYSDATE)
   AND (IEB.END_DATE IS NULL OR IEB.END_DATE > SYSDATE)
   AND (ASP.END_DATE_ACTIVE IS NULL OR ASP.END_DATE_ACTIVE > SYSDATE)
   AND (ASS.INACTIVE_DATE IS NULL OR ASS.INACTIVE_DATE > SYSDATE)
   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 IEB.BANK_ACCOUNT_ID = P_BANK_ACC_ID –银行ID
   –AND ASP.VENDOR_ID = P_VENDOR_ID         –供应商ID
   –AND ASS.VENDOR_SITE_ID = P_VENDOR_SITE_ID –供应商地点ID
 ORDER BY ASP.VENDOR_TYPE_LOOKUP_CODE;

获取待核销或者待付款的发票信息

select ai.org_id,
       ai.invoice_id,
       aps.vendor_name,
       ai.invoice_num,
       –ail.attribute1, –标准发票中存储预付款发票编号
       nvl(sum(ail.amount + nvl((select sum(zl.tax_amt)
                                  from zx_lines zl
                                 where ail.invoice_id = zl.trx_id
                                   and ail.line_number = zl.trx_line_id
                                   and (zl.tax_amt_included_flag is null or
                                       zl.tax_amt_included_flag = 'N')),
                                0)),
           0) invoice_amount_remaining,
       nvl(sum(ap_prepay_utils_pkg.get_invoice_unpaid_amount(ai.invoice_id) +
               nvl(ai.total_tax_amount, 0)),
           0) invoice_unpaid, –未付或未核销金额
       ai.gl_date,
       ai.vendor_id,
       ai.vendor_site_id,
       ai.invoice_currency_code,
       ai.set_of_books_id,
       ail.line_number

  from ap_invoices_all      ai,
       ap_invoice_lines_all ail,
       gl_code_combinations gcc,
       ap_suppliers         aps
 where 1 = 1
   and ai.invoice_id = ail.invoice_id
   and aps.vendor_id = ai.vendor_id
   and ai.accts_pay_code_combination_id = gcc.code_combination_id
   and ail.line_type_lookup_code(+) = 'ITEM'
      –只获取已付金额小于总金额的发票
   and nvl(ai.amount_paid, 0) < ai.invoice_amount
      –根据需要是否需要验证或者不验证核销(排除取消过的发票)
      –APPROVED已验证,NEVER APPROVED从未验证
   and ap_invoices_utility_pkg.get_approval_status(ai.invoice_id,
                                                   ai.invoice_amount,
                                                   ai.payment_status_flag,
                                                   ai.invoice_type_lookup_code) <>
       'CANCELLED'
   and ai.invoice_type_lookup_code = 'STANDARD'
— and ail.attribute1 is not null
— and ai.org_id = p_org_id
— and (ai.vendor_id = p_vendor_id or p_vendor_id is null)
 group by ai.invoice_id,
          ai.invoice_num,
          ai.org_id,
          ai.gl_date,
          ai.vendor_id,
          aps.vendor_name,
          ai.vendor_site_id,
          ai.invoice_currency_code,
          ai.set_of_books_id,
          ail.line_number,
          ai.creation_date
          –ail.attribute1
 order by ai.creation_date;

伪文艺青年形成之吉他篇

感觉自己还是比较喜欢乐器,从小时候最先接触到笛子、口琴,到前段时间接触到陶笛,到最近接触到吉他(人总是需要有自己的兴趣所在)。首次接触吉他是3月初,经过一家吉他培训中心,于是进去了解了一下,从最基础学起,到今天为止学习的歌曲(后续会记录自己吉他弹唱):
1. 《同桌的你》  入门必学歌曲
2. 《小情歌》    喜欢这首歌的调调
3. 《父亲》      情感表达
4. 《问》        纯属自己喜欢
5. 《滴答》

笛子与陶笛  吉他

技术笔记(小潘的技术记录博客)