Tuesday 31 January 2017

Employee Grade Step Creation API

Employee Grade Step Creation API



declare
-- api parameters
    l_placement_id           NUMBER;
    l_object_version_number NUMBER;
    l_effective_start_date     DATE;
    l_effective_end_date     DATE;
--
    -- local parameters
    l_error_msg             VARCHAR2(1000);
--
    -- Main Cursor
    cursor main_rec
    is
    SELECT   a.s_no,
             b.employee_number,
             c.assignment_id,
             a.effective_start_date,
             b.business_group_id,
             a.basic_salary_amount,
             (SELECT pspsf.step_id
                FROM per_grades pg,
                     per_grade_spines_f pgsf,
                     pay_rates pr,
                     pay_grade_rules_f pgrf,
                     per_spinal_point_steps_f pspsf
               WHERE pg.NAME                 = a.grade
                 AND pr.parent_spine_id     = pgsf.parent_spine_id
                 AND pgsf.grade_id             = pg.grade_id
                 AND pgrf.rate_id             = pr.rate_id
                 AND pspsf.spinal_point_id     = pgrf.grade_or_spinal_point_id
                 AND SYSDATE BETWEEN pgsf.effective_start_date
                                 AND pgsf.effective_end_date
                 AND SYSDATE BETWEEN pgrf.effective_start_date
                                 AND pgrf.effective_end_date
                 AND SYSDATE BETWEEN pspsf.effective_start_date
                                 AND pspsf.effective_end_date
                 AND pgrf.VALUE = a.basic_salary_amount) step_id
        FROM xxnbk_emp_grade_step_load a,
             per_people_x b,
             per_assignments_x c
       WHERE 1 = 1
         AND a.employee_number     = b.employee_number
         AND c.person_id         = b.person_id
--         and s_no <=10
         AND STATUS IS NULL
         order by s_no;
---
    -- begin the process
begin
--
for i in main_rec
loop
--
    IF I.step_id IS NOT NULL THEN  --Checking grade step defined for that salary
        BEGIN
        --
            hr_sp_placement_api.create_spp
              (p_validate                      =>  FALSE
              ,p_effective_date                =>  i.effective_start_date
              ,p_business_group_id             =>  i.business_group_id
              ,p_assignment_id                 =>  i.assignment_id
              ,p_step_id                       =>  i.step_id
              ,p_auto_increment_flag           =>  'N'
              ,p_reason                        =>  null
              ,p_request_id                    =>  null
              ,p_program_application_id        =>  null
              ,p_program_id                    =>  null
              ,p_program_update_date           =>  null
              ,p_increment_number              =>  null
              ,p_information1                  =>  null
              ,p_information2                  =>  null
              ,p_information3                  =>  null
              ,p_information4                  =>  null
              ,p_information5                  =>  null
              ,p_information6                  =>  null
              ,p_information7                  =>  null
              ,p_information8                  =>  null
              ,p_information9                  =>  null
              ,p_information10                 =>  null
              ,p_information11                 =>  null
              ,p_information12                 =>  null
              ,p_information13                 =>  null
              ,p_information14                 =>  null
              ,p_information15                 =>  null
              ,p_information16                 =>  null
              ,p_information17                 =>  null
              ,p_information18                 =>  null
              ,p_information19                 =>  null
              ,p_information20                 =>  null
              ,p_information21                 =>  null
              ,p_information22                 =>  null
              ,p_information23                 =>  null
              ,p_information24                 =>  null
              ,p_information25                 =>  null
              ,p_information26                 =>  null
              ,p_information27                 =>  null
              ,p_information28                 =>  null
              ,p_information29                 =>  null
              ,p_information30                 =>  null
              ,p_information_category          =>  'KE'
              ,p_placement_id                  =>  l_placement_id
              ,p_object_version_number         =>  l_object_version_number
              ,p_effective_start_date          =>  l_effective_start_date
              ,p_effective_end_date            =>  l_effective_end_date
              ,p_replace_future_spp            =>  false
              );
              --
              update xxnbk_emp_grade_step_load
              set Status ='S'
              WHERE S_NO=i.S_NO;
              COMMIT;
              --
      EXCEPTION WHEN OTHERS THEN
      --
         l_error_msg :=sqlerrm;
         --
          update xxnbk_emp_grade_step_load
          set Status ='E',Error_message=l_error_msg
          WHERE S_NO=i.S_NO;
          --
      END;
      --
    ELSE
    --
        update xxnbk_emp_grade_step_load
          set Status ='E',Error_message='Grade Step not defined'
          WHERE S_NO=i.S_NO;
          --
    END IF;
    --
 end loop;
 --
 commit;
 --
  dbms_output.put_line('Success ');
  --
 exception when others then
 dbms_output.put_line('Error in main '||sqlerrm);
 end;

FND User UPDATE API Script

FND User UPDATE API Script


DECLARE
   CURSOR get_details
   IS
      SELECT *
        FROM ptl_user_stg
       WHERE status IS NULL AND sno <=1;

   v_user_name        VARCHAR2 (30);
   v_resp             VARCHAR2 (30);
   v_resp_key         VARCHAR2 (30);
   v_app_short_name   VARCHAR2 (50);
   v_email_address    VARCHAR2 (100);
   l_err_msg          VARCHAR2 (2500) := NULL;
BEGIN
   FOR fetch_details IN get_details
   LOOP
     
      v_resp_key := NULL;
      v_app_short_name := NULL;

      BEGIN
         fnd_user_pkg.updateuser (x_user_name                       => v_user_name,
                                  x_owner                           => NULL,
                                  x_unencrypted_password            => NULL,
                                  x_session_number                  => 0,
                                  x_start_date                      => NULL,
                                  x_end_date                        => SYSDATE,
                                  x_last_logon_date                 => NULL,
                                  x_description                     => NULL,
                                  x_password_date                   => NULL,
                                  x_password_accesses_left          => NULL,
                                  x_password_lifespan_accesses      => NULL,
                                  x_password_lifespan_days          => NULL,
                                  x_employee_id                     => NULL,
                                  x_email_address                   => NULL,
                                  x_fax                             => NULL,
                                  x_customer_id                     => NULL,
                                  x_supplier_id                     => NULL,
                                  x_user_guid                       => NULL,
                                  x_change_source                   => NULL
                                 );

         UPDATE ptl_user_stg
            SET status = 'S',
                error_msg = NULL
          WHERE user_name = fetch_details.user_name;

         COMMIT;
      EXCEPTION
         WHEN OTHERS
         THEN
            l_err_msg := SQLERRM;

            UPDATE ptl_user_stg
               SET status = 'E',
                   error_msg = l_err_msg
             WHERE user_name = fetch_details.user_name;

            COMMIT;
      END;
   END LOOP;
EXCEPTION
   WHEN OTHERS
   THEN
      l_err_msg := SQLERRM;
      DBMS_OUTPUT.put_line ('Main Exception: ' || l_err_msg);
END;

Update SIT API Script

Update SIT API Script



DECLARE
   p_person_id                   NUMBER          := NULL;
   p_business_group_id           NUMBER;
   p_id_flex_num                 NUMBER;
------------------
   p_analysis_criteria_id        NUMBER          := NULL;
   p_person_analysis_id          NUMBER          := NULL;
   p_per_object_version_number   NUMBER          := NULL;
   v_err                         VARCHAR2 (1000) := NULL;s
   driving_license_number                  VARCHAR2 (100)  := NULL;
 
   CURSOR c1
      IS
         SELECT
           FROM xx_hrms_sit_upload
          WHERE status is not null;
 
BEGIN
   FOR i IN c1
   LOOP
      p_id_flex_num := 50530;
      BEGIN
         SELECT   NVL (sit.object_version_number, 1),
                  sit.analysis_criteria_id, MAX (sit.person_analysis_id)
             INTO p_per_object_version_number,
                  p_analysis_criteria_id, p_person_analysis_id
             FROM fnd_id_flex_structures_tl sttl,
                  fnd_id_flex_structures st,
                  per_person_analyses sit,
                  per_analysis_criteria sv
            WHERE sttl.id_flex_structure_name = 'Driving License'
              AND sttl.LANGUAGE = USERENV ('LANG')
              AND st.id_flex_code = sttl.id_flex_code
              AND st.id_flex_num = sttl.id_flex_num
              AND st.id_flex_num = sit.id_flex_num
              AND st.id_flex_num = sv.id_flex_num
              AND sit.analysis_criteria_id = sv.analysis_criteria_id
              AND sit.person_id = i.person_id
         --and sv.SEGMENT1 = '4602001140'
         GROUP BY sv.segment1,
                  NVL (sit.object_version_number, 1),
                  sit.analysis_criteria_id;
      END;
      BEGIN
           
            hr_sit_api.update_sit
                 (p_validate                       => FALSE,
                  p_person_analysis_id             => p_person_analysis_id,
                  p_pea_object_version_number      => p_per_object_version_number,
                  p_date_from                      => TRUNC (SYSDATE),
                  p_segment1                       => i.driving_license_number,
                  p_analysis_criteria_id           => p_analysis_criteria_id
                 );
       
         UPDATE xx_hrms_sit_upload xx
            SET xx.status = 'S'
          WHERE xx.sno=i.sno;
      EXCEPTION
         WHEN OTHERS
         THEN
           
            v_err := SQLERRM;
            UPDATE xx_hrms_sit_upload xx
               SET xx.status = 'E',xx.error_msg = v_err
             WHERE sno=i.sno;
      END;
   END LOOP;
   COMMIT;
END;