Search This Blog

Wednesday, March 30, 2022

create job api for Oracle Apps R12

DECLARE
  lv_group_name            VARCHAR2(200) := 'HR_51';
  ln_business_group_id     NUMBER;
  ln_job_group_id          NUMBER; 
  ln_job_id                NUMBER;
  ln_object_version_number NUMBER;
  ln_job_definition_id     NUMBER;
  lv_job_name              VARCHAR2(200);
  
  CURSOR C1 IS 
  
  SELECT INITCAP(A)JOB_NAME
   FROM TESTA
   where   UPPER(A)  NOT IN (SELECT UPPER(NAME) FROM PER_JOBS)
   ;
   
   
   
BEGIN

  -- get group id and business group id
  BEGIN
    SELECT business_group_id,
           job_group_id
      INTO ln_business_group_id,
           ln_job_group_id
      FROM per_job_groups
     --WHERE displayed_name = lv_group_name;
     where business_group_id = 81;
  EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line('Unable to get the job group details.Error:'||SQLERRM);
      RAISE;
  END;
FOR I  IN C1 LOOP
BEGIN
  HR_JOB_API.CREATE_JOB
  (p_validate                      => FALSE
  ,p_business_group_id             => ln_business_group_id
  ,p_date_from                     => TO_DATE('01-JAN-1950')
  ,p_comments                      => 'Uploaded from API 31032022'
  ,p_date_to                       => NULL
  ,p_job_group_id                  => ln_job_group_id
  ,p_concat_segments               => i.JOB_NAME
  ,p_language_code                 => 'US'
  ,p_job_id                        => ln_job_id
  ,p_object_version_number         => ln_object_version_number
  ,p_job_definition_id             => ln_job_definition_id
  ,p_name                          => lv_job_name
  );
 

UPDATE TESTA SET B = 'DONE'
WHERE A = I.JOB_NAME;

  DBMS_OUTPUT.PUT_LINE('JOB ID: '||ln_job_id);
  DBMS_OUTPUT.PUT_LINE('OBJECT_VERSION_NUMBER: '||ln_object_version_number);
  DBMS_OUTPUT.PUT_LINE('JOB_DEFINITION_ID: '||ln_job_definition_id);
  DBMS_OUTPUT.PUT_LINE('JOB_NAME: '||lv_job_name);
  
EXCEPTION
    WHEN OTHERS THEN
      dbms_output.put_line('Unable to create a job.Error:'||SQLERRM);
      --RAISE;
      UPDATE TESTA SET B = 'ERROR'
WHERE A = I.JOB_NAME;
 
      
END;


END LOOP;

END;

No comments:

Post a Comment