Showing posts with label HRMS. Show all posts
Showing posts with label HRMS. Show all posts

Friday, May 12, 2017

Configuration Values - APIs

-- Global and localized configuration settings provide the appropriate defaults for business groups
-- Business Rules are held in pqp_configuration_values table
-- HRMS > Other Definitions > Configuration Values
-- Here I am updating a configuration value
declare
--
ln_con_val_id  number; 
ln_bg          number;
ln_ovn         number;
lc_cat         varchar2(200);
lc_info        varchar2(200);
--
begin
--
   select pcv.PCV_INFORMATION_CATEGORY
         ,pcv.PCV_INFORMATION2
         ,pcv.business_group_id
         ,pcv.configuration_value_id
         ,pcv.object_version_number
     into lc_cat
         ,lc_info
         ,ln_bg
         ,ln_con_val_id
         ,ln_ovn     
     from pqp_configuration_types   pct
         ,pqp_configuration_modules pcm
         ,pqp_configuration_values  pcv
    where 1=1
      and pct.module_id = pcm.module_id
      and pcm.module_name = 'Assignment Budget Value Maintenance'
      and pct.description = 'Maintenance Configuration'
      and pcv.pcv_information_category = pct.configuration_type
      ;
   
    dbms_output.put_line('Before:   lc_cat: '||lc_cat||'  lc_info: '||lc_info||' in_ovn: '|| ln_ovn);
   --
   pqp_pcv_api.update_configuration_value(p_validate        => false
                                         ,p_effective_date                 => sysdate
                                         ,p_business_group_id              => ln_bg
                                         ,p_configuration_value_id         => ln_con_val_id
                                         ,p_pcv_information_category       => lc_cat
                                         ,p_pcv_information2               => 'Y'
                                         ,p_object_version_number          => ln_ovn);
                                        
   
    dbms_output.put_line('Configuration Value Updated');    
   
    commit;                             
--
exception
   when others then
      dbms_output.put_line('Error : '||sqlerrm);
      rollback;
end; 
--

Ref: My Experience/Oracle Metalink/User Guides/Different other blogs available/Colleagues
  

HRMS RUP8 - APIs new validations

There are many new validations have been added to RUP8.

I came across few in hr_assignment_api, I shall keep adding if I find any new one.

1). Error :ORA-20001: This assignment does not have a contract type effective as of DD-MON-YYYY. Please use the Extra Details of Service form to assign a contract type.

> Check for Contract Type meaning/spelling/Lower/Upper case
> HRMS > People >  Enter and Maintain > Assignment > Others > Extra Details of Service
> Use pqp_aat_api.update_assignment_attribute to correct if any.


2). Error :ORA-20001: HR_500161_ASG_INV_SOB_DCC

> Check if you have default_code_combination_id populated without set_of_books_id
> HRMS > People > Enter and Maintain > Assignment > Purchase Order Information
> Use hr_assignment_api.update_emp_asg / update_cwk_asg API to correct if any




Ref: My Experience/Oracle Metalink/User Guides/Different other blogs available/Colleagues

Thursday, October 27, 2016

Signing Limit - API

Unfortunately there is no any API available to enter signing limit.

Is There A Method To Enter Signing Limits Other Than Through The Form? (Doc ID 171837.1)
fix:
This must be done through the form. There is no supported API or alternate method which can be used.

Through form >
Payable Manager > Employee > Signing Limit

Else,

Do the direct insert to the base table ?
           --
          insert into ap_web_signing_limits_all
                                        (document_type
                                        ,employee_id
                                        ,cost_center
                                        ,signing_limit
                                        ,last_update_date
                                        ,last_updated_by
                                        ,last_update_login
                                        ,creation_date
                                        ,created_by
                                        ,org_id
                                        )
                                  values('APEXP'
                                        ,ln_person_id
                                        ,lc_cost_center
                                        ,ln_signing_limit
                                        ,sysdate
                                        ,fnd_profile.value('USER_ID')
                                        ,fnd_profile.value('LOGIN_ID')
                                        ,sysdate
                                        ,fnd_profile.value('USER_ID')
                                        ,ln_org_id                                     
                                        );         

Ref: http://ebsanil.blogspot.co.uk/2012/09/oracle-employee-signingapproval-limits.html

Wednesday, June 1, 2016

Grade Rate API(s)

Use hr_grade_rate_value_api API to create/update/delete grade rate values

Ex: Update grade rate
--
DECLARE
   CURSOR get_details
   IS
      select pgr.effective_start_date
            ,pgr.effective_end_date
            ,pgr.object_version_number
            ,pgr.value
            ,pgr.maximum
            ,pgr.mid_value
            ,pgr.minimum
            ,pgr.sequence
            ,pgr.grade_rule_id
            ,pgr.currency_code
        from per_grades pg,
             pay_grade_rules_f pgr
       where pg.name = 'AK General|12|Standard XX'
         and pgr.grade_or_spinal_point_id = pg.grade_id  
         and trunc(sysdate) between pgr.effective_start_date  and pgr.effective_end_date
         ;

   l_effective_start_date    DATE   := NULL;
   l_effective_end_date      DATE   := NULL;
   l_grade_rule_id           NUMBER := NULL;
   l_object_version_number   NUMBER := NULL;
   l_err_msg                 VARCHAR2 (500) := NULL;
   l_value                   NUMBER;
   l_mid_value               NUMBER;
   l_max_vlaue               NUMBER;
   l_mim_value               NUMBER;
BEGIN

      FOR i IN get_details    LOOP
         --
         l_object_version_number := i.object_version_number;        
         l_max_vlaue             := 40000;
         l_mim_value             := 30000;
         l_mid_value              := 35000;
         l_value                     := 35000;
         --
         BEGIN
            hr_grade_rate_value_api.update_grade_rate_value (
               p_validate                    => FALSE,
               p_grade_rule_id           => i.grade_rule_id,
               p_effective_date          => TO_DATE ('10-MAY-2014', 'DD-MON-YYYY'),
               p_datetrack_update_mode   => 'UPDATE',--'CORRECTION',
               p_currency_code           => i.currency_code,
               p_maximum                  => l_max_vlaue,
               p_mid_value                => l_mid_value,
               p_minimum                 => l_mim_value,
               p_value                        => l_value,
               p_sequence                  => i.sequence,
               p_object_version_number   => l_object_version_number,
               p_effective_start_date    => l_effective_start_date,
               p_effective_end_date      => l_effective_end_date
            );
            COMMIT;
            DBMS_OUTPUT.put_line ('Grate Rate has been Updated: ' || i.grade_rule_id  );
         EXCEPTION
            WHEN OTHERS THEN
               l_err_msg := SQLERRM;
               DBMS_OUTPUT.put_line ('Inner Exception: ' || l_err_msg);
         END;
      END LOOP;
--
EXCEPTION
   WHEN OTHERS THEN
      l_err_msg := SQLERRM;
      DBMS_OUTPUT.put_line ('Main Exception: ' || l_err_msg);
END;
--


Ref: My Experience/Oracle Metalink/User Guides/Different other blogs available/Colleagues

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

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

Wednesday, July 29, 2015

Delete/End Date Element Entry - HRMS APIs

--
declare
--
   ld_effective_start_date      date;
   ld_effective_end_date       date;
   lb_delete_warning             boolean;
   ln_element_entry_id          number;
   ln_object_version_number number;
   ln_assin_id                          number;
   --  
   lc_element_name       pay_element_types_f.element_name%type := 'AK Element';
   lc_emp_num               per_all_people_f.employee_number := '123425';

begin
--
     select pee.element_entry_id
           ,pee.object_version_number
           ,paf.assignment_id
       into ln_element_entry_id
           ,ln_object_version_number
           ,ln_assin_id
       from per_all_people_f        per
           ,per_all_assignments_f   paf
           ,pay_element_entries_f   pee
           ,pay_element_types_f_tl  petl
           ,pay_element_types_f     pet
      where per.employee_number = lc_emp_num
        and trunc(sysdate) between per.effective_start_date and per.effective_end_date
        and paf.person_id       = per.person_id
        and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
        and pee.assignment_id   = paf.assignment_id
        and pee.element_type_id = pet.element_type_id
        and trunc(sysdate) between pee.effective_start_date and pee.effective_end_date
        and petl.element_name   = lc_element_name
        and petl.language       = 'US'
        and pet.element_type_id = petl.element_type_id;
       
   /* Date Track modes
    DELETE             >> end date element entry
    DELETE_NEXT_CHANGE >> delete next changes
    FUTURE_CHANGE      >> delete future changes
    ZAP                >> completely remove element entry from the database
   */      

    pay_element_entry_api.delete_element_entry
      (p_validate                     => false
      ,p_datetrack_delete_mode        => 'DELETE'
      ,p_effective_date               => trunc(sysdate)
      ,p_element_entry_id             => ln_element_entry_id
      ,p_object_version_number        => ln_object_version_number
      ,p_effective_start_date         => ld_effective_start_date
      ,p_effective_end_date           => ld_effective_end_date
      ,p_delete_warning               => lb_delete_warning
      ) ;
 
--
commit;
--
exception
   when others then
      dbms_output.put_line('Error: '||sqlerrm);
      rollback;
end;

Update Element Entry - HRMS APIs

--
declare
--
cursor cur_input_name(c_ele_name   varchar2)
  is
    select piv.display_sequence
          ,piv.name
          ,piv.element_type_id
      from pay_element_types_f_tl petl
          ,pay_element_types_f    pet
          ,pay_input_values_f     piv
     where petl.element_name   = c_ele_name
       and petl.language       = 'US'
       and pet.element_type_id = petl.element_type_id
       and piv.element_type_id = pet.element_type_id
       order by piv.display_sequence;
--      
   ld_effective_start_date   date;
   ld_effective_end_date     date;
   ln_object_version_number  pay_element_entries_f.object_version_number %type;
   lb_update_warning         boolean;
   ln_screen_entry_value     pay_element_entry_values_f.screen_entry_value%type;
   ln_element_type_id        pay_element_types_f.element_type_id%type;
   ln_input_value_id1        pay_input_values_f.input_value_id%type;
   ln_input_value_id2        pay_input_values_f.input_value_id%type;
   ln_input_value_id         pay_input_values_f.input_value_id%type;
 
   -- DT API Out Variables
   lb_correction             boolean;                      
   lb_update                 boolean;                      
   lb_upover                 boolean;                        
   lb_upchin                 boolean;
   --  
   lc_element_name           pay_element_types_f.element_name%type := 'AK Element';
   lc_emp_num                per_all_people_f.employee_number := '123425';
   lc_dt_mode                varchar2(20);

begin

   --
   savepoint sv_update;
   --
 
   select pee.element_entry_id
         ,pee.object_version_number
     into ln_element_entry_id
         ,ln_object_version_number
     from per_all_people_f        per
         ,per_all_assignments_f   paf
         ,pay_element_entries_f   pee
         ,pay_element_types_f_tl  petl
         ,pay_element_types_f     pet
    where per.employee_number = lc_emp_num
      and trunc(sysdate) between per.effective_start_date and per.effective_end_date
      and paf.person_id       = per.person_id
      and trunc(sysdate) between paf.effective_start_date and paf.effective_end_date
      and pee.assignment_id   = paf.assignment_id
      and pee.element_type_id = pet.element_type_id
      and trunc(sysdate) between pee.effective_start_date and pee.effective_end_date
      and petl.element_name   = lc_element_name
      and petl.language       = 'US'
      and pet.element_type_id = petl.element_type_id;
     
      --Determine the Date Track Mode for Update..
 
   dt_api.find_dt_upd_modes
      ( p_effective_date        =>  trunc(sysdate)
      , p_base_table_name       =>  'PAY_ELEMENT_ENTRIES_F'
      , p_base_key_column       =>  'ELEMENT_ENTRY_ID'
      , p_base_key_value        =>  ln_element_entry_id
      , p_correction            =>  lb_correction
      , p_update                =>  lb_update
      , p_update_override       =>  lb_upover
      , p_update_change_insert  =>  lb_upchin
      );
                               
   if lb_upover or lb_upchin then
      lc_dt_mode := 'UPDATE_OVERRIDE';
   --elsif lb_upchin then
   --   p_dt_mode := 'UPDATE_CHANGE_INSERT';
   elsif lb_update then
      lc_dt_mode := 'UPDATE';
   elsif lb_correction then
      lc_dt_mode := 'CORRECTION';      
   end if;
 
   -- Get input value ids
   for rec_input_name in cur_input_name(lc_element_name) loop

      select piv.input_value_id
        into ln_input_value_id
        from pay_input_values_f    piv
       where piv.element_type_id = rec_input_name.element_type_id
         and piv.name            = rec_input_name.name
        ;
      if rec_input_name.display_sequence = 1 then  -- AK Value
     
         p_input_value_id1 := ln_input_value_id;
     
      elsif rec_input_name.display_sequence = 2 then  -- Employee Rate
     
         p_input_value_id2 := ln_input_value_id;    
   
      end if;
 
   end loop;
 
   -- Update Element Entry
   -- ------------------------------
   pay_element_entry_api.update_element_entry
     (     -- Input data elements
           -- -----------------------------
           p_validate                           => false, --true
           p_datetrack_update_mode              => lc_dt_mode,
           p_effective_date    => to_date('25-JUN-2012','DD-MON-YYYY'),
           p_business_group_id  => fnd_profile.value('PER_BUSINESS_GROUP_ID'),
           p_element_entry_id                   => ln_element_entry_id,
           p_object_version_number              => ln_object_version_number,
           p_input_value_id1                    => ln_input_value_id1,
           p_entry_value1                       => null,
           p_input_value_id2                    => ln_input_value_id2,
           p_entry_value2                       => 10,
           -- Output data elements
           -- --------------------------------
           p_effective_start_date               => ld_effective_start_date,
           p_effective_end_date                 => ld_effective_end_date,              
           p_update_warning                     => lb_update_warning
     );
 
  dbms_output.put_line( '  API: pay_element_entry_api.update_element_entry successfull - Element Entry Id: ' );

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

Thursday, July 23, 2015

Create Element Entry - HRMS APIs

--
declare
--
cursor cur_input_name (p_ele_name    varchar2)
  is
    select piv.display_sequence
          ,piv.name
          ,piv.element_type_id
      from pay_element_types_f_tl petl
          ,pay_element_types_f    pet
          ,pay_input_values_f     piv
     where petl.element_name   = p_ele_name
       and petl.language       = 'US'
       and pet.element_type_id = petl.element_type_id
       and piv.element_type_id = pet.element_type_id
       order by piv.display_sequence;
  --
   ln_element_link_id                pay_element_links_f.element_link_id%type;
   ld_effective_start_date           date;
   ld_effective_end_date            date;
   ln_element_entry_id               pay_element_entries_f.element_entry_id%type;
   ln_object_version_number     pay_element_entries_f.object_version_number%type;
   lb_create_warning                  boolean;
   ln_screen_entry_value           pay_element_entry_values_f.screen_entry_value%type;
   ln_element_type_id                pay_element_types_f.element_type_id%type;
   ln_input_value_id1                 pay_input_values_f.input_value_id%type;
   ln_input_value_id2                 pay_input_values_f.input_value_id%type;
   ln_input_value_id                   pay_input_values_f.input_value_id%type;
                                                   
   ln_element_type_id                  pay_element_types_f.element_type_id%type;
   --
   ln_assignment_id                    NUMBER := 12346;
   lc_element_name                     pay_element_types_f.element_name%type := 'AK Test Element';
--  
BEGIN
--
   --
   savepoint sv_create_element;
   --

   -- Get the element type id
   select tl.element_type_id
     into ln_element_type_id
     from pay_element_types_f_tl tl
         ,pay_element_types_f    t
    where tl.element_name = lc_element_name
      and language = 'US'
      and t.element_type_id = tl.element_type_id
      and trunc(sysdate) between t.effective_start_date and t.effective_end_date;

   -- You can have upto many more input values depending on the element setup, modify the script accordingly
   for rec_input_name in cur_input_name (lc_element_name ) loop

      select piv.input_value_id
        into ln_input_value_id
        from pay_input_values_f    piv
       where piv.element_type_id = rec_input_name.element_type_id
         and piv.name            = rec_input_name.name
        ;
      if rec_input_name.display_sequence = 1 then  -- AK Value      
         ln_input_value_id1 := ln_input_value_id;    
      elsif rec_input_name.display_sequence = 2 then  -- Employee Rate    
         ln_input_value_id2 := ln_input_value_id;
      end if;
    --
    end loop;

 
    -- Get Element Link Id
    -- ------------------------------
    ln_element_link_id :=  hr_entry_api.get_link
                                             (p_assignment_id     => ln_assignment_id,
                                              p_element_type_id   => ln_element_type_id,
                                              p_session_date  => TRUNC(SYSDATE)
                                              );
 
       dbms_output.put_line( '  API: Element Link Id: ' || ln_element_link_id );
 
       -- Create Element Entry
       -- ------------------------------
       pay_element_entry_api.create_element_entry
         (     -- Input data elements
               -- -----------------------------
               p_validate                   => false,
               p_effective_date          => TO_DATE('22-JUN-2012','DD-MON-YYYY'),
               p_business_group_id  => fnd_profile.value('PER_BUSINESS_GROUP_ID'),
               p_assignment_id         => ln_assignment_id,
               p_element_link_id       => ln_element_link_id,
               p_entry_type                => 'E',
               p_input_value_id1       => ln_input_value_id1,
               p_entry_value1            => null,
               p_input_value_id2       => ln_input_value_id2,
               p_entry_value2            => 4,
               -- Output data elements
               -- --------------------------------
               p_effective_start_date   => ld_effective_start_date,
               p_effective_end_date    => ld_effective_end_date,
               p_element_entry_id       => ln_element_entry_id,
               p_object_version_number  => ln_object_version_number,
               p_create_warning            => lb_create_warning
         );
 
     dbms_output.put_line( '  API: pay_element_entry_api.create_element_entry successfull - Element Entry Id: ' || ln_element_entry_id );

--rollback;
commit;

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

Thursday, June 4, 2015

OTL- Employee's Time Card Details

select hts.resource_id                      "Person id"
      ,to_char(hts.start_time,'Mon-DD-YYYY') "Start Date"
      ,to_char(hts.stop_time,'Mon-DD-YYYY')  "End Date"
      ,htb2.measure                          "Hours"
      ,petf.element_name                     "Hours Type"
      ,hta.attribute12                       "Description"
      ,htb.comment_text                      "Comments"
  from hxc_time_building_blocks  htb,
       hxc_time_building_blocks  htb1,
       hxc_time_building_blocks  htb2,
       hxc_time_attribute_usages htau,
       hxc_time_attributes       hta,
       hxc_timecard_summary      hts,
       pay_element_types_f       petf
 where htb1.parent_building_block_id= htb.time_building_block_id
   and htb1.parent_building_block_ovn = htb.object_version_number
   and htb.date_to  = hr_general.end_of_time
   and htb.scope    = 'TIMECARD'
   and htb1.scope   = 'DAY'
   and htb1.date_to = hr_general.end_of_time
   and htb2.parent_building_block_id= htb1.time_building_block_id
   and htb2.parent_building_block_ovn= htb1.object_version_number
   and htb2.scope   = 'DETAIL'
   and htb2.date_to = hr_general.end_of_time
   and htau.time_building_block_id  = htb2.time_building_block_id
   and htau.time_building_block_ovn = htb2.object_version_number
   and htau.time_attribute_id       = hta.time_attribute_id
   and hts.start_time  = htb.start_time
   and hts.resource_id = htb.resource_id
   and to_char(petf.element_type_id) = (substr(hta.attribute_category,11,length(hta.attribute_category)))
   and hts.resource_id                       = :p_person_id
   and to_char(hts.start_time,'DD-MON-YYYY') = :p_start_date
   and hta.attribute_category is not null
   order by htb1.start_time;

-- More Specific with element name

select *
  from (select tt.resource_id                 "Person id"
              ,rt.status_name                 "Status"
              ,tt.start_date                  "Start Date"
              ,tt.stop_date                   "Stop Date"
              ,round (tt.hours_worked, 2)     "Hours"
              ,round (tt.hours_worked, 2) as hours
              ,td.detail_attribute12          "Description"
              ,substr(rt.timecard_comment,40) "Comments"
              ,(select alias_value_name
                  from hxc_alias_values_v
                 where alias_definition_id = 1051 -->>
                   and attribute1 =
                       substr (td.detail_attribute_category,11,length(td.detail_attribute_category)))
                       as ot_type
         from hxc_resource_total_time_v tt,
              hxc_resource_timecards_v rt,
              hxc_timecard_details_v td
        where tt.time_id = rt.timecard_id
          and tt.detail_id = td.detail_timecard_id
          and td.detail_bld_blk_info_type_id = 1
          and tt.resource_id   = :p_person_id  
          and to_char(tt.start_date,'DD-MON-YYYY') = :p_start_date
          and tt.start_date >=
              trunc((last_day (add_months (sysdate, -3)) + 1))) pivot                          (sum (hours) 
             for ot_type 
             in ('01. Half Time Hours (0.5)' "Half Time"
                ,'02. Single Time Hours (1.0)' "Single Time"
                ,'03. Time and a Quarter (1.25)' "Time And a Quarter"
                ,'04. Time and a Half (1.5)' "Time And a Half"
                ,'05. Double Time Hours (2.0)' "Double Time"
                ,'06. Time and three quarters (1.75)' "Time And Three Quarters"
                ,'07. EW - Premium @ 1/3 Third of Time' "Premium Third"
                ,'08. EW - Premium @ 1/2 Half of Time'  "Premium Half"
                ,'09. EW - Premium @ Single'  "Uremium Single"
                ,'10. EW - Unsocial Hours @ 1/5 Fifth of Time' "Unsocial"
               ));