Tuesday, November 3, 2015

Create Payment Method - HRMS APIs

--
--Possible Error: ORA-20001: HR_7348_ASSIGNMENT_INVALID
--Check the date format of effective_date
--
declare
   ln_method_id         pay_personal_payment_methods_f.personal_payment_method_id%type;
   ln_ext_acc_id        pay_external_accounts.external_account_id%type;
   ln_obj_ver_num       pay_personal_payment_methods_f.object_version_number%type;
   lc_org_pay_method    pay_org_payment_methods_f_tl.org_payment_method_name%type;
   ld_eff_date          date := to_date('01-OCT-2011','DD-MON-YYYY');
   ld_eff_start_date    date;
   ld_eff_end_date      date;
   ln_comment_id        number;
   ln_assignment_id     number;
   ln_org_pay_method_id number;  
   lc_employee_num      varchar2(20) := '223344';
   lc_territory_code    varchar2(60) := 'GB';
   lc_bank_name         varchar2(60) := 'XX';
   lc_bank_branch       varchar2(60) ;
   lc_sort_code         varchar2(60) := '900011';
   lc_account_num       varchar2(60) := '91889999';
   lc_account_name      varchar2(60) := 'Mr A Kumar' ;
   lc_account_type      varchar2(60) := '0' ;
   lc_bld_s_account_num varchar2(60) := null;
   lc_branch_loc        varchar2(60) ;
begin
   --
    select assignment_id
          ,pay.payroll_name
      into ln_assignment_id
          ,lc_org_pay_method
      from per_all_assignments_f ass
          ,per_all_people_f      per
          ,pay_all_payrolls_f    pay
     where ass.person_id = per.person_id
       and per.employee_number = lc_employee_num
       and trunc(sysdate) between ass.effective_start_date and ass.effective_end_date
       and trunc(sysdate) between per.effective_start_date and per.effective_end_date
       and pay.payroll_id = ass.payroll_id;
     
    
    select org_payment_method_id
      into ln_org_pay_method_id
      from pay_org_payment_methods_f_tl
     where org_payment_method_name = lc_org_pay_method
       and language = 'US';
     
    -- Create Employee Payment Method
    -- --------------------------------------------------
    hr_personal_pay_method_api.create_personal_pay_method
    (-- Input Parameters
          p_effective_date                                      => ld_eff_date,
          p_assignment_id                                      => ln_assignment_id,
          p_org_payment_method_id                     => ln_org_pay_method_id,
          p_priority                                                 => 1,
          p_percentage                                            => 100,
          p_territory_code                                       => lc_territory_code,
          p_segment1                                              => lc_bank_name,
          p_segment2                                              => lc_bank_branch,
          p_segment3                                              => lc_sort_code,
          p_segment4                                              => lc_account_num,
          p_segment5                                              => lc_account_name,
          p_segment6                                              => lc_account_type,
          p_segment7                                              => lc_bld_s_account_num,
          p_segment8                                              => lc_branch_loc,
          -- Output parameters
          p_personal_payment_method_id             => ln_method_id,
          p_external_account_id                             => ln_ext_acc_id,
          p_object_version_number                        => ln_obj_ver_num,
          p_effective_start_date                              => ld_eff_start_date,
          p_effective_end_date                               => ld_eff_end_date,
          p_comment_id                                         => ln_comment_id
          );
     commit;
    dbms_output.put_line('Done');      
--

exception
   when others then
      dbms_output.put_line('Error: '||sqlerrm);
      rollback;
end;
--

No comments:

Post a Comment