Thursday, August 28, 2014

Update Employee Assignment/Criteria - HRMS APIs

--
declare
   --
   l_mode                      varchar2(10) := 'CRITERIA'; --'ASG'
   --- DECLARE variables for HR_ASSIGNMENT_API.update_emp_asg
   --- IN variables
   l_assignment_id             number := 123456;
   l_normal_hours              number := 37;
   l_probation_period          number := 6;
   l_probation_unit            varchar2(4) := 'M';
   l_contract_id               number := 4;
   --per_assignment_status_types.assignment_status_type_id%TYPE;
   l_assignment_status_type_id number := 1;
   l_sob_id                    number := 1;
   l_default_expense_ccid      number := 1234;
   l_frequency                 varchar2(4) := 'W'; --Weekly
   l_bargaining_unit_code      varchar2(4) := 'FTE';

   --- OUT variables
   l_asg_object_version_number    number := 3;
   l_cagr_grade_def_id            number;
   l_cagr_concatenated_segments   varchar2(300);
   l_concatenated_segments        varchar2(300);
   l_soft_coding_keyflex_id       number;
   l_comment_id                   number;
   l_effective_start_date         date;
   l_effective_end_date           date;
   l_no_managers_warning          boolean := false;
   l_other_manager_warning        boolean := false;
   l_hourly_salaried_warning      boolean := false;
   l_gsp_post_process_warning     varchar2(300);

   --- DECLARE variables for HR_ASSIGNMENT_API.update_emp_asg_criteria
   --- IN variables
   l_payroll_id                    number := 125;
   l_organization_id               number := 5678;
   l_position_id                   number := 9904567;
   l_job_id                        number := 3456;
   l_location_id                   number := 12345;
   l_grade_id                      number := 12;

   --- OUT variables
   ln_ceil_step_id                 number;
   ln_keyflex_id                   number;
   lc_concatenated_segments        varchar2(1000);  
   ln_people_group_id              number;
   lb_org_now_no_manager_warn      boolean;
   lb_other_manager_warning        boolean;
   lc_group_name                   varchar2(1000);
   ld_start_date                   date;
   ld_end_date                     date;
   lb_spp_delete_warning           boolean;
   lb_entries_changed_warning      varchar2(10);
   lb_tax_district_changed_warn    boolean;
   lc_gsp_post_process_warning     varchar2(1000);

begin
    --
    if l_mode = 'ASG' then

       /* This API updates employee assignment details which do not affect entitlement
       * to element entries.
       * The assignment must be an employee assignment. The assignment must exist as
       * of the effective date of the change
       */
     
       hr_assignment_api.update_emp_asg
                      (p_validate                     => false --in boolean  default false
                      ,p_effective_date               => trunc(sysdate)            
                      ,p_datetrack_update_mode        => 'CORRECTION'      
                      ,p_assignment_id                => l_assignment_id    
                      ,p_assignment_status_type_id    => l_assignment_status_type_id
                      ,p_default_code_comb_id         => l_default_expense_ccid
                      ,p_set_of_books_id              => l_sob_id
                      ,p_normal_hours                 => l_normal_hours  
                      ,p_probation_period             => l_probation_period    
                      ,p_probation_unit               => l_probation_unit    
                      ,p_contract_id                  => l_contract_id                      
                      --,p_notice_period                => l_notice_period
                      --,p_notice_period_uom            => l_notice_period_uom
                      ,p_frequency                    => l_frequency                      
                      ,p_bargaining_unit_code         => l_bargaining_unit_code
                      ,p_ass_attribute5               => to_char(sysdate,'YYYY/MM/DD HH:MI:SS')
                       --In/Out
                      ,p_object_version_number        => l_asg_object_version_number              
                      ,p_cagr_grade_def_id            => l_cagr_grade_def_id    
                      ,p_soft_coding_keyflex_id       => l_soft_coding_keyflex_id                      
                       --Out
                      ,p_cagr_concatenated_segments   => l_cagr_concatenated_segments
                      ,p_concatenated_segments        => l_concatenated_segments    
                      ,p_comment_id                   => l_comment_id          
                      ,p_effective_start_date         => l_effective_start_date      
                      ,p_effective_end_date           => l_effective_end_date  
                      ,p_no_managers_warning          => l_no_managers_warning      
                      ,p_other_manager_warning        => l_other_manager_warning  
                      ,p_hourly_salaried_warning      => l_hourly_salaried_warning  
                      ,p_gsp_post_process_warning     => l_gsp_post_process_warning
                      );
                     

       if (l_gsp_post_process_warning is not null or l_no_managers_warning = true
         or l_other_manager_warning = true or l_hourly_salaried_warning = true) then
          dbms_output.put_line('Warning processing API: hr_assignment_api.update_emp_asg');
          rollback;
       else
          dbms_output.put_line('Success ');
          commit;
       end if;  
     
    elsif l_mode = 'CRITERIA' then
   
       /* This API updates attributes of the employee assignment that affect the
       * entitlement criteria for any element entry.
       * The assignment must be an employee assignment. The assignment must exist as
       * of the effective date of the change
       */
       hr_assignment_api.update_emp_asg_criteria
                            ( p_effective_date                =>  trunc(sysdate)
                            , p_datetrack_update_mode         =>  'CORRECTION'
                            , p_assignment_id                 =>  l_assignment_id
                            , p_validate                      =>  false --lb_validate_mode
                            , p_called_from_mass_update       =>  false
                            , p_position_id                   =>  l_position_id
                            , p_job_id                        =>  l_job_id
                            , p_payroll_id                    =>  l_payroll_id
                            , p_grade_id                      =>  l_grade_id
                            , p_location_id                   =>  l_location_id
                            , p_organization_id               =>  l_organization_id
                            -- In/Out
                            , p_object_version_number         =>  l_asg_object_version_number
                            , p_special_ceiling_step_id       =>  ln_ceil_step_id
                            , p_people_group_id               =>  ln_people_group_id
                            , p_soft_coding_keyflex_id        =>  ln_keyflex_id  
                            -- Out
                            , p_group_name                    =>  lc_group_name
                            , p_effective_start_date          =>  ld_start_date
                            , p_effective_end_date            =>  ld_end_date
                            , p_org_now_no_manager_warning =>  lb_org_now_no_manager_warn
                            , p_other_manager_warning         =>  lb_other_manager_warning
                            , p_spp_delete_warning            =>  lb_spp_delete_warning
                            , p_entries_changed_warning       =>  lb_entries_changed_warning
                            , p_tax_district_changed_warning  =>  lb_tax_district_changed_warn
                            , p_concatenated_segments         =>  lc_concatenated_segments
                            , p_gsp_post_process_warning      =>  lc_gsp_post_process_warning
                           );
                         
       if (lb_org_now_no_manager_warn = true or lb_other_manager_warning = true
         or lb_spp_delete_warning = true or lb_entries_changed_warning <> 'N'
         or lb_tax_district_changed_warn = true or lc_gsp_post_process_warning is not null)
       then
         dbms_output.put_line('Error: API update_emp_asg_criteria Failed ');
         rollback;
       else
         dbms_output.put_line('Success ');
         commit;
       end if;
   
    end if ;
       
exception
   when others then
      dbms_output.put_line('Error: '||sqlerrm);                          
end;        
--                 

14 comments:

  1. Please, I have ran series of API for assignments criteria for newly created employees, but not working what could be the problem?

    ReplyDelete
    Replies
    1. Hi,

      I hope you are passing all the mandatory parameters, what error you are getting?

      Delete
    2. I entered all the mandatory fields for this API: hr_assignment_api.update_emp_asg_criteria only,
      or do i need to also run hr_assignment_api.update_emp_asg.

      The assignment_id, is it the person type are they referring to here or ASSIGNMENT_ID in the assignment table

      The procedure will completed successfully and committed but when i checked it in the front end,it has not effect.
      Please, Help.

      Delete
    3. If you are updating only criteria, no need to call update_emp_asg. assignment_id is the assignment_id. Is it an employee or contingent worker? are you committing it after the API call?

      provide me your anonymous API calling block here.

      Delete
  2. The API is more than what I can paste here, this page is complaining of 4,096 characters. if you can send me your mail

    ReplyDelete
  3. When, try to debug the script, it gives me this error:


    Error report -
    ORA-20001: The primary key specified is invalid

    Cause: The primary key values specified are invalid and do not exist in the schema.

    Action: Check the primary key values before attempting to carry out the operation again.
    ORA-06512: at "APPS.HR_ASSIGNMENT_API", line 16095
    ORA-06512: at line 30

    ReplyDelete
  4. Why trying to make further research i got this error:

    Error report -
    ORA-20001: The primary key specified is invalid

    Cause: The primary key values specified are invalid and do not exist in the schema.

    Action: Check the primary key values before attempting to carry out the operation again.
    ORA-06512: at "APPS.HR_ASSIGNMENT_API", line 16095
    ORA-06512: at line 30

    ReplyDelete
    Replies
    1. You will get an email option on clicking on my profile name. In between please double check the datatype of all the parameters.

      Delete
    2. I have sent you a mail.

      Thank you.

      Delete
  5. Ademola - Not sure, if the issue is resolved for you. If this is not yet resolved and you're facing this issue in the database, please follow the below steps.


    To implement the solution, please execute the following steps:

    1. Set NLS_LANG to 'US' or ‘AMERICAN’ in TOAD/SQL Developer:
    a. For SQL Developer:
    1. Select Tools > Preferences > Database > NLS Parameters
    2. Update to have Language = AMERICAN and Territory = AMERICA
    b. For TOAD:
    1. Access NLS Parameters, from the Database menu
    2. Select Administer| -> NLS Parameters
    3. Set the NLS_LANGUAGE to ‘AMERICAN’

    2. Retest the issue.

    3. Migrate the solution as appropriate to other environments.

    ReplyDelete
  6. Hi

    The issue is with the out parameter l_asg_object_version_number not being passed correctly. Its is a bug on this API.

    Select the object_version_number from assignment table for the assignment ID and pass it to the API.

    Kamlesh

    ReplyDelete
  7. Hi,

    I'm getting error while calling hr_assignment_api.update_emp_asg_criteria API.

    Error:
    -ORA-20001: FLEX-DUPLICATE CCID: N, CCID

    Thanks,
    Ankush.



    ReplyDelete
    Replies
    1. Hi Ankush1818,
      Were you able to solve the Error:
      -ORA-20001: FLEX-DUPLICATE CCID: N, CCID ?

      Delete