Tuesday, November 3, 2015

Showing Custom Error Message - Web ADI

There are two ways to do this.

1>  Simplest way is to change the 'API Returns' attribute to 'FND Message Code' and use raise_application_errro to raise errors
 Desktop Integration Manager > Manage Integrators
  >> Search the Integrator and go to the 'Interfaces' screen and select the Interface
     >> Change the 'API Returns' to 'FND Message Code' if it is null or 'Error Message'
 
>> Now change the exception section of the related API packaged procedure  

when ex_web_adi1 then
   raise_application_error(-20001,'Web ADI Error Message: '||lc_emp_number);

2> Change the exception section of the related API packaged procedure as below

when ex_web_adi1 then
   lc_err_msg := 'Web ADI Error Message: '||lc_emp_number;
   fnd_message.set_name('XXCMN', lc_err_msg);
   --fnd_message.set_token('ERROR_MESSAGE', lc_err_msg);
   lc_mesg := fnd_message.get;     
   raise_application_error(-20001, lc_mesg);


Deployment - Web ADI

We will use the FNDLOAD utility to deploy the Web ADI to other instances.

> We just need to deploy the 'Integrator' because it also includes the realted content,layout and mappings and then the related Form Function (R12)

>> Integrator

select * --integrator_code, application_id,user_name
  from bne_integrators_vl vl
 where user_name like 'XXAK%%'
   and integrator_code like 'XXAK%';
 
fndload apps/<apps password> 0 y download $bne_top/patch/115/import/bneintegrator.lct xxaktestadi_xintg.ldt bne_integrators integrator_asn="XXAKTEST_ADI_XINTG" integrator_code="XXAKTESTADI_XINTG"

fndload apps/<apps password> 0 y upload $bne_top/patch/115/import/bneintegrator.lct xxaktestadi_xintg.ldt

>> Form Function

select * --function_name
  from fnd_form_functions_vl
 where function_name like 'XXAK%';
 
fndload apps/<apps password> 0 y download $fnd_top/patch/115/import/afsload.lct xxaktestadi_func.ldt function function_name="XXAKTESTADI"
 
fndload apps/<apps password> 0 y upload $fnd_top/patch/115/import/afsload.lct xxaktestadi_func.ldt - warning=yes upload_mode=replace custom_mode=force

Please use below scripts if you have to deploy contents/layouts/mappings

>> Content 

select * --content_code
  from bne_content_cols_vl
 where content_code like '%XXAK%';

fndload apps/<apps password> 0 y download $bne_top/patch/115/import/bnecont.lct xxaktestadi_cnt2.ldt bne_contents content_asn="XXAK" content_code="XXAKTESTADI_CNT2"

fndload apps/<apps password> 0 y upload $bne_top/patch/115/import/bnecont.lct xxaktestadi_cnt2.ldt

>> Layout

select *--LAYOUT_CODE
  from bne_layouts_vl vl
 where integrator_code like 'XXAK%';

fndload apps/<apps password> 0 y download $bne_top/patch/115/import/bnelay.lct xxaktestadi_lay.ldt bne_layouts layout_asn="XXAK" layout_code="XXAKTESTADI"

fndload apps/<apps password> 0 y upload $bne_top/patch/115/import/bnelay.lct xxaktestadi_lay.ldt


>> Mapping

select * --mapping_code, integrator_code
  from bne_mappings_vl
 where mapping_code like 'XXAK%';

fndload apps/<apps password> 0 y download $bne_top/patch/115/import/bnemap.lct xxaktestadi_map.ldt bne_mappings mapping_asn="XXAK" mapping_code="XXAKTESTADI"

fndload apps/<apps password> 0 y upload $bne_top/patch/115/import/bnemap.lct xxaktestadi_map.ldt

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;
--

Create/Update Person extra info - HRMS APIs

--
declare
--
  cursor cur_eit_details
  is
  select per.person_id
        ,'EIT_VALUE' eit_val
        ,to_char(sysdate,'YYYY/MM/DD HH24:MI:SS') begin_date
        ,null end_date
    from per_all_people_f per
   where per.employee_number = '123456'
     and trunc(sysdate) between per.effective_start_date and per.effective_end_date
     ;
  lc_information_type  varchar2(20) := 'XXAK_TEST_EIT';
  lc_information_cat    varchar2(20) := 'XXAK_TEST_EIT';
  ln_per_extra_info_id number;
  ln_ovn_pei                number;
--
begin
--
   -- Please use your own business logic, this is a basic case
   for rec_eit_details in cur_eit_details loop
   --     
      begin
      --
         select ppei.person_extra_info_id
               ,ppei.object_version_number
           into ln_per_extra_info_id
               ,ln_ovn_pei
           from per_people_extra_info           ppei
          where ppei.person_id                    = rec_eit_details.person_id
            and ppei.information_type          = lc_information_type
            and ppei.pei_information_category  = lc_information_cat
          ;
         --
         begin
            -- UPDATE
            hr_person_extra_info_api.update_person_extra_info
                      ( p_validate                              =>  false
                      , p_person_extra_info_id           =>  ln_per_extra_info_id
                      -- In / Out
                      , p_object_version_number       =>  ln_ovn_pei
                      -- In
                      , p_pei_information_category   =>  lc_information_cat
                      , p_pei_information1           =>  rec_eit_details.eit_val
                      , p_pei_information2           =>  rec_eit_details.begin_date
                      , p_pei_information3           =>  rec_eit_details.end_date
                     );               
            dbms_output.put_line('EIT Updated ');
            commit;  
            --   
         exception
            when others then
               dbms_output.put_line('Update Failed '||sqlerrm);
               rollback;
         end;
      --
      exception
         when no_data_found then
         --
            begin
               -- CREATE
               ln_per_extra_info_id := null;
               ln_ovn_pei           := null;
               --
               hr_person_extra_info_api.create_person_extra_info
                      ( p_validate                               =>  false
                      , p_person_id                            =>  rec_eit_details.person_id
                      , p_information_type                =>  lc_information_type
                      , p_pei_information_category  =>  lc_information_cat
                      , p_pei_information1                =>  rec_eit_details.eit_val
                      , p_pei_information2                =>  rec_eit_details.begin_date
                      , p_pei_information3                =>  rec_eit_details.end_date
                       -- Out
                      , p_person_extra_info_id         =>  ln_per_extra_info_id
                      , p_object_version_number     =>  ln_ovn_pei
                      );
               --                                  
               dbms_output.put_line('EIT Created '||ln_per_extra_info_id);               
               commit;
               --
            exception
               when others then
                  dbms_output.put_line('Creation Failed '||sqlerrm);
                  rollback;                 
                  --
            end;
           --
        when others then
           dbms_output.put_line('Error: Selecting Person Extra Info '||sqlerrm);
      end;
      -- 
   end loop;
--
   dbms_output.put_line('Done!');
--
exception
when others    then
   dbms_output.put_line('Error: '||sqlerrm);
   rollback;
end;
--