Showing posts with label API. Show all posts
Showing posts with label API. Show all posts

Friday, January 6, 2023

Script to update Supplier pay_group_lookup_code in Oracle APPS R12

DECLARE
lc_return_status  VARCHAR2(2000);
ln_msg_count      NUMBER;
ll_msg_data        LONG;
Ln_Vendor_Id      NUMBER;
Ln_Vendor_site_Id NUMBER;
ln_message_int    NUMBER;
Ln_Party_Id        NUMBER;
lrec_vendor_rec ap_vendor_pub_pkg.r_vendor_rec_type;
BEGIN
-- Initialize apps session
fnd_global.apps_initialize(0, 50554, 200);
mo_global.set_policy_context('S',204);
mo_global.init('SQLAP');
 
Ln_Vendor_Id                          := 1;
Lrec_Vendor_Rec.pay_group_lookup_code := 'Employee';
ap_vendor_pub_pkg.update_vendor_public(p_api_version => 1
                                          ,x_return_status => lc_return_status
                                          ,x_msg_count => ln_msg_count
                                          ,x_msg_data => ll_msg_data
                                          ,p_vendor_rec => Lrec_Vendor_Rec
                                          ,p_Vendor_Id => Ln_Vendor_Id
  );
IF (lc_return_status <> 'S') 
THEN
IF ln_msg_count    >= 1 THEN
FOR v_index IN 1..ln_msg_count
LOOP
fnd_msg_pub.get (p_msg_index => v_index
                ,p_encoded => 'F'
                ,p_data => ll_msg_data
,p_msg_index_out => ln_message_int 
);
Ll_Msg_Data := 'UPDATE_VENDOR '||SUBSTR(Ll_Msg_Data,1,3900);
dbms_output.put_line('Ll_Msg_Data - '||Ll_Msg_Data );
END LOOP;
END IF;
END IF;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('SQLERRM - '||SQLERRM );
ROLLBACK;
END

Script to update Supplier Type(ap_suppliers.vendor_type_lookup_code) in Oracle APPS R12

DECLARE
lc_return_status  VARCHAR2(2000);
ln_msg_count      NUMBER;
ll_msg_data        LONG;
Ln_Vendor_Id      NUMBER;
Ln_Vendor_site_Id NUMBER;
ln_message_int    NUMBER;
Ln_Party_Id        NUMBER;
lrec_vendor_rec ap_vendor_pub_pkg.r_vendor_rec_type;
BEGIN
-- Initialize apps session
fnd_global.apps_initialize(0, 50554, 200);
mo_global.set_policy_context('S',204);
mo_global.init('SQLAP');
 
Ln_Vendor_Id                          := 1;
Lrec_Vendor_Rec.vendor_type_lookup_code := 'LOCAL';
ap_vendor_pub_pkg.update_vendor_public(p_api_version => 1
                                          ,x_return_status => lc_return_status
                                          ,x_msg_count => ln_msg_count
                                          ,x_msg_data => ll_msg_data
                                          ,p_vendor_rec => Lrec_Vendor_Rec
                                          ,p_Vendor_Id => Ln_Vendor_Id
  );
IF (lc_return_status <> 'S') 
THEN
IF ln_msg_count    >= 1 THEN
FOR v_index IN 1..ln_msg_count
LOOP
fnd_msg_pub.get (p_msg_index => v_index
                ,p_encoded => 'F'
                ,p_data => ll_msg_data
,p_msg_index_out => ln_message_int 
);
Ll_Msg_Data := 'UPDATE_VENDOR '||SUBSTR(Ll_Msg_Data,1,3900);
dbms_output.put_line('Ll_Msg_Data - '||Ll_Msg_Data );
END LOOP;
END IF;
END IF;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('SQLERRM - '||SQLERRM );
ROLLBACK;
END

Script to update Supplier Tax Payer ID(AP_SUPPLIERS.NUM_1099) in Oracle APPS R12

DECLARE
lc_return_status  VARCHAR2(2000);
ln_msg_count      NUMBER;
ll_msg_data        LONG;
Ln_Vendor_Id      NUMBER;
Ln_Vendor_site_Id NUMBER;
ln_message_int    NUMBER;
Ln_Party_Id        NUMBER;
lrec_vendor_rec ap_vendor_pub_pkg.r_vendor_rec_type;
BEGIN
-- Initialize apps session
fnd_global.apps_initialize(0, 50554, 200);
mo_global.set_policy_context('S',204);
mo_global.init('SQLAP');
 
Ln_Vendor_Id                          := 1;
Lrec_Vendor_Rec.jgzz_fiscal_code := 'X123456789X';
ap_vendor_pub_pkg.update_vendor_public(p_api_version => 1
                                          ,x_return_status => lc_return_status
                                          ,x_msg_count => ln_msg_count
                                          ,x_msg_data => ll_msg_data
                                          ,p_vendor_rec => Lrec_Vendor_Rec
                                          ,p_Vendor_Id => Ln_Vendor_Id
  );
IF (lc_return_status <> 'S') 
THEN
IF ln_msg_count    >= 1 THEN
FOR v_index IN 1..ln_msg_count
LOOP
fnd_msg_pub.get (p_msg_index     => v_index
                ,p_encoded       => 'F'
,p_data          => ll_msg_data
,p_msg_index_out => ln_message_int 
);
Ll_Msg_Data := 'UPDATE_VENDOR '||SUBSTR(Ll_Msg_Data,1,3900);
dbms_output.put_line('Ll_Msg_Data - '||Ll_Msg_Data );
END LOOP;
END IF;
END IF;
COMMIT;
EXCEPTION
WHEN OTHERS THEN
dbms_output.put_line('SQLERRM - '||SQLERRM );
ROLLBACK;
END

Sunday, December 18, 2022

API to Create Online Accounting for AP Payment in Oracle APPS R12 (ap_drilldown_pub_pkg.payment_online_accounting)

    PROCEDURE xx_payment_accounting(errbuf OUT VARCHAR2
   ,retcode           OUT VARCHAR2
   ,p_invoice_id    IN  NUMBER
   )
IS
CURSOR c1 
IS
SELECT DISTINCT aca.check_id, aca.check_number        
              FROM ap_invoices_all xlpi
      ,ap_invoice_payments_all aipa
  ,ap_checks_all aca
             WHERE xlpi.invoice_id   = aipa.invoice_id
               AND xlpi.invoice_id   = pin_invoice_id
               AND aipa.check_id     = aca.check_id
               AND ap_checks_pkg.get_posting_status(aca.check_id) = 'N';
   -- This condition is to pick invoices which are paid and unaccounted
   ;  
ln_processed_cnt    NUMBER := 0;
ln_failed_cnt       NUMBER := 0;  
lv_error_buf        VARCHAR2(4000);
ln_retcode          NUMBER; 
BEGIN

FOR rec_create_pmt_accounting IN c1
LOOP
BEGIN
fnd_file.put_line(fnd_file.log,'Check ID: '||rec_create_pmt_accounting.check_id);
ln_retcode   := NULL;
lv_error_buf := NULL;
ap_drilldown_pub_pkg.payment_online_accounting(p_check_id           => rec_create_pmt_accounting.check_id
  ,p_accounting_mode    => 'P'      
  ,p_errbuf             => lv_error_buf
  ,p_retcode            => ln_retcode
  ,p_calling_sequence   => 'XX_PAYMENT_ACCOUNTING'
  );
IF ln_retcode = 0 
THEN
fnd_file.put_line(fnd_file.log,'Invoice Check ID: '
||rec_create_pmt_accounting.check_id 
||'. Payment ('
||rec_create_pmt_accounting.check_number
||') Accounted Sucessfully'
);
ln_processed_cnt := ln_processed_cnt+1;
ELSIF ln_retcode = 1 THEN
fnd_file.put_line(fnd_file.log,'Invoice Check ID: '
||rec_create_pmt_accounting.check_id
||'. Payment ('
||rec_create_pmt_accounting.check_number
||') Accounting ended in WARNING. Errbuf : '
||lv_error_buf
);
ln_processed_cnt := ln_processed_cnt+1;
ELSIF ln_retcode = 2 THEN
fnd_file.put_line(fnd_file.log,'Invoice Check ID: '
||rec_create_pmt_accounting.check_id 
||'. Payment ('
||rec_create_pmt_accounting.check_number
||') Accounting ended in ERROR. Errbuf : '
||lv_error_buf
);       
ln_failed_cnt := ln_failed_cnt +1;          
ELSE
fnd_file.put_line(fnd_file.log,'Invoice Check ID: '
||rec_create_pmt_accounting.check_id 
||'. Payment ('
||rec_create_pmt_accounting.check_number
||') Accounting ended in ERROR. Errbuf : '
||lv_error_buf
||' Retcode: '
||ln_retcode
);
ln_failed_cnt := ln_failed_cnt +1;
END IF; 
COMMIT;
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line(fnd_file.log,'Invoice Check ID: ' 
||rec_create_pmt_accounting.check_id
||'. Payment Accounting failed with Unhandled Exception. Error Message:' 
||SQLERRM);
ln_failed_cnt := ln_failed_cnt + 1;
END;
END LOOP;
fnd_file.put_line ( fnd_file.log,'Processed Record Count: '
||ln_processed_cnt
||' Failed Record Count: '
||ln_failed_cnt);
EXCEPTION
WHEN OTHERS THEN
fnd_file.put_line ( fnd_file.log,'Main Error in xx_payment_accounting. Error Message: '||SQLERRM);
END xx_payment_accounting;

ap_checks_pkg.get_posting_status(check_id) to pick AP Invoice Payments which are not acconted.

Pass check_id from ap_checks_all (aca) to ap_checks_pkg.get_posting_status to pick invoice payments which are not accounted.

ap_checks_pkg.get_posting_status(aca.check_id)

Thursday, November 3, 2022

Invalid customer transaction identifier.APPLY : ORA-01403: no data foundORA-01403: no data found in Package AR_RECEIPT_API_PUB Procedure Apply

One of the possible reason is Invoice already paid.

You can validate with below query. 

select * from ra_customer_trx_all where trx_number = '1'

note customer_trx_id from the above query.

select * from ar_receivable_applications_all

where applied_customer_trx_id = <pass customer trx id>

note cash_receipt_id from above query 

select * from ar_cash_receipts_all

where cash_receipt_id = <pass cash receipt id>


Tuesday, October 25, 2022

Is there any API to End Date GL Code Combinations from Backend in Oracle APPS

As per the Oracle as of now there is no API to End Date GL Code Combinations from Backend. Please refer below notes from Oracle Support.

  • Is Effective Date From / 'Start Date Active' Mandatory for GL Code Combinations? Can it Be Changed to "null" Value? (Doc ID 2763034.1)
    • Check if these details could have been ported from the segment values, in that case verify if you want to have Start/End Date for the segment values left in the system while the same details would be removed for the code combinations
    • Any sql update on gl_code_combinations table will not be supported in any way. You must perform the changes in the code combinations form, manually.
    • To port changes from segment values to code combinations, you may use Program - Inherit Segment Value Attributes (see referenced documents)
  • GLNSVI: What is the Purpose of the Segment Value Inheritance Program/ Program - Inherit Segment Value Attributes ? (Doc ID 170569.1)

Friday, October 21, 2022

Script to Update Liability Account, Prepay Account, Invoice Withholding Tax Group and Tax Classification Code at Supplier Site Level in Oracle APPS

Table Script:

DROP TABLE XXSCHEMA.XX_VENDOR_MASTER_DATA CASCADE CONSTRAINTS;

CREATE TABLE XXSCHEMA.XX_VENDOR_MASTER_DATA
(
  VENDOR_NAME                    VARCHAR2(250 BYTE),
  VENDOR_ID                      NUMBER,
  VENDOR_SITE_CODE               VARCHAR2(15 BYTE),
  ORG_ID                         NUMBER,
  LIABILITY_ACCOUNT              VARCHAR2(207 BYTE),
  NEW_LIABILITY_ACCOUNT          VARCHAR2(207 BYTE),
  PRE_PAYMENT_ACCOUNT            VARCHAR2(207 BYTE),
  NEW_PRE_PAYMENT_ACCOUNT        VARCHAR2(207 BYTE),
  TAX_CLASSIFICATION_CODE        VARCHAR2(207 BYTE),
  NEW_TAX_CLASSIFICATION_CODE    VARCHAR2(30 BYTE),
  INVOICE_WITHHOLDING_TAX_GROUP  VARCHAR2(25 BYTE),
  NEW_INVOICE_WHT_TAX_GROUP      VARCHAR2(25 BYTE),
  SUPPLIER_TYPE                  VARCHAR2(80 BYTE),
  NEW_SUPPLIER_TYPE              VARCHAR2(80 BYTE),
  TAX_APPLICABILITY              VARCHAR2(80 BYTE),
  SUPP_STATUS_FLAG               VARCHAR2(1 BYTE),
  SUPP_STATUS_MSG                VARCHAR2(2000 BYTE),
  SUPP_SITE_STATUS_FLAG          VARCHAR2(1 BYTE),
  SUPP_SITE_STATUS_MSG           VARCHAR2(2000 BYTE)
);

DROP SYNONYM APPS.XX_VENDOR_MASTER_DATA;

CREATE OR REPLACE SYNONYM APPS.XX_VENDOR_MASTER_DATA FOR XXSCHEMA.XX_VENDOR_MASTER_DATA;

API Script:
-----------------------------------------------------------------------------------------------
DECLARE
    v_api_version              NUMBER;
    v_init_msg_list            VARCHAR2(200);
    v_commit                    VARCHAR2(200);
    v_validation_level          NUMBER;
    x_return_status            VARCHAR2(200);
    x_msg_count                NUMBER;
    v_vendor                    NUMBER;
    x_msg_data                  VARCHAR2(200);
    l_vendor_site_rec          apps.ap_vendor_pub_pkg.r_vendor_site_rec_type;
    l_existing_vendor_site_rec ap_supplier_sites_all%rowtype;
    l_vendor_site_id            NUMBER;
l_liability_ccid gl_code_combinations_kfv.code_combination_id%TYPE;
l_prepay_ccid gl_code_combinations_kfv.code_combination_id%TYPE;
l_ap_awt_group_id ap_awt_groups.group_id%TYPE;
l_allow_awt_flag ap_suppliers.allow_awt_flag%TYPE;
    v_calling_prog              VARCHAR2(200);
    
    l_msg                      VARCHAR2(200);
    l_status_flag         VARCHAR(1):='N';
    l_status_msg     VARCHAR2(2000) := NULL;
        
    CURSOR c 
IS
SELECT DISTINCT 
            vendor_id
               ,vendor_site_code
   ,new_tax_classification_code
                   ,new_invoice_wht_tax_group
                   ,new_liability_account
                   ,new_pre_payment_account
          FROM xx_vendor_master_data
         WHERE NVL(supp_status_flag, 'N') = 'S'
   AND NVL(supp_site_status_flag, 'N') IN ('N', 'E')
   --AND vendor_id = 7216
   --AND vendor_id IN (5041)--5059)
   ;

BEGIN
    FOR i IN c 
LOOP
l_status_flag     := 'N';
l_status_msg      := NULL;
l_liability_ccid  := NULL;
l_prepay_ccid   := NULL;
l_ap_awt_group_id := NULL;
l_allow_awt_flag  := 'N';
BEGIN
SELECT vendor_site_id 
  INTO l_vendor_site_id
  FROM ap_supplier_sites_all
WHERE vendor_id = i.vendor_id
   AND vendor_site_code = i.vendor_site_code
   AND org_id = 101
   ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_vendor_site_id := null;
l_status_flag := 'E';
l_status_msg := 'Unable to find vendor_site_code. '; 
WHEN OTHERS THEN
l_vendor_site_id := NULL;
l_status_flag := 'E';
l_status_msg := 'Error while validating vendor_site_code. error message: ' || SQLERRM;  
END;
BEGIN
SELECT code_combination_id 
  INTO l_liability_ccid
  FROM gl_code_combinations_kfv
WHERE concatenated_segments = TRIM(i.new_liability_account)
   ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_liability_ccid := NULL;
l_status_flag := 'E';
l_status_msg := l_status_msg||'-Unable to find new_liability_account. '; 
WHEN OTHERS THEN
l_liability_ccid := NULL;
l_status_flag := 'E';
l_status_msg := l_status_msg||'-Error while validating new_liability_account. error message: ' || SQLERRM;  
END;
BEGIN
SELECT code_combination_id 
  INTO l_prepay_ccid
  FROM gl_code_combinations_kfv
WHERE concatenated_segments = TRIM(i.new_pre_payment_account)
   ;
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_prepay_ccid := NULL;
l_status_flag := 'E';
l_status_msg := l_status_msg||'-Unable to find new_pre_payment_account. '; 
WHEN OTHERS THEN
l_prepay_ccid := NULL;
l_status_flag := 'E';
l_status_msg := l_status_msg||'-Error while validating new_pre_payment_account. error message: ' || SQLERRM;  
END;
IF TRIM(i.new_invoice_wht_tax_group) IS NOT NULL THEN
BEGIN
SELECT group_id 
  INTO l_ap_awt_group_id
  FROM ap_awt_groups
WHERE name = TRIM(i.new_invoice_wht_tax_group)
   ;
l_allow_awt_flag := 'Y';
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_ap_awt_group_id := NULL;
l_status_flag := 'E';
l_status_msg := l_status_msg||'-Unable to find new_invoice_wht_tax_group. '; 
WHEN OTHERS THEN
l_ap_awt_group_id := NULL;
l_status_flag := 'E';
l_status_msg := l_status_msg||'-Error while validating new_invoice_wht_tax_group. error message: ' || SQLERRM;  
END;
END IF;
dbms_output.put_line('l_status_flag = ' || l_status_flag);
dbms_output.put_line('l_status_msg = ' || l_status_msg);
        IF l_status_flag <> 'E' THEN
fnd_global.apps_initialize(0, 50240, 200);
mo_global.init('SQLAP');
mo_global.set_policy_context('S', 101);
v_api_version := 1.0;
v_init_msg_list := fnd_api.g_true;
v_commit := fnd_api.g_true;
v_validation_level := fnd_api.g_valid_level_full;
--l_vendor_site_id := j.vendor_site_id; -- to be end dated
v_calling_prog := 'Supplier Tax code update';
l_vendor_site_rec.vendor_site_id := l_existing_vendor_site_rec.vendor_site_id;
l_vendor_site_rec.last_update_date := sysdate;
--l_vendor_site_rec.last_updated_by := 6147023;
l_vendor_site_rec.vendor_id := l_existing_vendor_site_rec.vendor_id;
l_vendor_site_rec.org_id := l_existing_vendor_site_rec.org_id;
l_vendor_site_rec.accts_pay_code_combination_id := l_liability_ccid;
l_vendor_site_rec.prepay_code_combination_id := l_prepay_ccid;
l_vendor_site_rec.vat_code := i.new_tax_classification_code;
l_vendor_site_rec.awt_group_id := l_ap_awt_group_id;
l_vendor_site_rec.allow_awt_flag := l_allow_awt_flag;
--l_vendor_site_rec.auto_tax_calc_flag := 'y';
--l_vendor_site_rec.vat_registration_num := i.tax_registration_no;
ap_vendor_pub_pkg.update_vendor_site_public(p_api_version => v_api_version
                                           ,p_init_msg_list => v_init_msg_list
       ,p_commit => v_commit
                                           ,p_validation_level  => v_validation_level
       ,x_return_status => x_return_status
       ,x_msg_count => x_msg_count
       ,x_msg_data     => x_msg_data
       ,p_vendor_site_rec   => l_vendor_site_rec
       ,p_vendor_site_id    => l_vendor_site_id
       ,p_calling_prog      => v_calling_prog
       );

dbms_output.put_line('x_return_status = ' || x_return_status);
dbms_output.put_line('x_msg_count = ' || x_msg_count);
dbms_output.put_line('x_msg_data = ' || x_msg_data);
IF (x_return_status <> fnd_api.g_ret_sts_success) 
THEN
FOR i1 IN 1 .. fnd_msg_pub.count_msg 
LOOP
l_msg := fnd_msg_pub.get(p_msg_index => i1,
  p_encoded   => fnd_api.g_false);
DBMS_OUTPUT.put_line('The API call failed with error ' || l_msg);
UPDATE xx_vendor_master_data 
   SET supp_site_status_flag = 'E'
      ,supp_site_status_msg = l_msg 
     WHERE vendor_id = i.vendor_id
   AND vendor_site_code = i.vendor_site_code;
END LOOP;
ELSE
   DBMS_OUTPUT.put_line('The API call ended with SUCESSS status');
   UPDATE xx_vendor_master_data 
  SET supp_site_status_flag = 'S'
,supp_site_status_msg = 'Update Successful' 
WHERE vendor_id = i.vendor_id
  AND vendor_site_code = i.vendor_site_code
  ;
END IF;
ELSE
UPDATE xx_vendor_master_data 
   SET supp_site_status_flag = 'E'
      ,supp_site_status_msg = l_status_msg 
WHERE vendor_id = i.vendor_id
   AND vendor_site_code = i.vendor_site_code
   ;
END IF;
COMMIT;
    END LOOP;
END;


Script to Update Supplier Vendor Type and Invoice Withholding Tax Group at Supplier Level in Oracle APPS

Table Script:

DROP TABLE XXSCHEMA.XX_VENDOR_MASTER_DATA CASCADE CONSTRAINTS;

CREATE TABLE XXSCHEMA.XX_VENDOR_MASTER_DATA
(
  VENDOR_NAME                    VARCHAR2(250 BYTE),
  VENDOR_ID                      NUMBER,
  VENDOR_SITE_CODE               VARCHAR2(15 BYTE),
  ORG_ID                         NUMBER,
  LIABILITY_ACCOUNT              VARCHAR2(207 BYTE),
  NEW_LIABILITY_ACCOUNT          VARCHAR2(207 BYTE),
  PRE_PAYMENT_ACCOUNT            VARCHAR2(207 BYTE),
  NEW_PRE_PAYMENT_ACCOUNT        VARCHAR2(207 BYTE),
  TAX_CLASSIFICATION_CODE        VARCHAR2(207 BYTE),
  NEW_TAX_CLASSIFICATION_CODE    VARCHAR2(30 BYTE),
  INVOICE_WITHHOLDING_TAX_GROUP  VARCHAR2(25 BYTE),
  NEW_INVOICE_WHT_TAX_GROUP      VARCHAR2(25 BYTE),
  SUPPLIER_TYPE                  VARCHAR2(80 BYTE),
  NEW_SUPPLIER_TYPE              VARCHAR2(80 BYTE),
  TAX_APPLICABILITY              VARCHAR2(80 BYTE),
  SUPP_STATUS_FLAG               VARCHAR2(1 BYTE),
  SUPP_STATUS_MSG                VARCHAR2(2000 BYTE),
  SUPP_SITE_STATUS_FLAG          VARCHAR2(1 BYTE),
  SUPP_SITE_STATUS_MSG           VARCHAR2(2000 BYTE)
);

DROP SYNONYM APPS.XX_VENDOR_MASTER_DATA;

CREATE OR REPLACE SYNONYM APPS.XX_VENDOR_MASTER_DATA FOR XXSCHEMA.XX_VENDOR_MASTER_DATA;


API Script:
-----------------------------------------------------------------------------------------------
--SET serveroutput on;
DECLARE
p_api_version          NUMBER;
p_init_msg_list        VARCHAR2(200);
p_commit                VARCHAR2(200);
p_validation_level      NUMBER;
x_return_status        VARCHAR2(200);
x_msg_count            NUMBER;
x_msg_data              VARCHAR2(200);
lr_vendor_rec          apps.ap_vendor_pub_pkg.r_vendor_rec_type;
lr_existing_vendor_rec ap_suppliers%ROWTYPE;
l_msg                  VARCHAR2(200);
p_vendor_id            NUMBER;
l_new_supplier_type fnd_lookup_values.lookup_code%type;
l_allow_awt_flag ap_suppliers.allow_awt_flag%TYPE;
l_ap_awt_group_id     ap_awt_groups.group_id%TYPE;
l_status_flag VARCHAR(1):='N';
l_status_msg VARCHAR2(2000) := NULL;

CURSOR c_vendor_type IS
SELECT DISTINCT vendor_id
               ,supplier_type
   ,new_supplier_type
                       ,new_invoice_wht_tax_group    
  FROM xx_vendor_master_data
WHERE NVL(supp_status_flag, 'N') IN ('N', 'E')
   --AND vendor_id = 7216
   AND vendor_id IN (5041)--5059)
   ;
    BEGIN
-- Initialize apps session
fnd_global.apps_initialize(0, 50240, 200); --user_id, 
mo_global.init('SQLAP');
fnd_client_info.set_org_context(101);
-- Assign Basic Values
p_api_version      := 1.0;
p_init_msg_list    := fnd_api.g_true;
p_commit           := fnd_api.g_true;
p_validation_level := fnd_api.g_valid_level_full;
     
FOR j in c_vendor_type 
        LOOP
            p_vendor_id        := j.vendor_id;
l_status_flag     := 'N';
l_status_msg      := NULL;
l_ap_awt_group_id := NULL;
l_allow_awt_flag  := 'N';
    
            -- gather vendor details
            BEGIN
                SELECT *
                  INTO lr_existing_vendor_rec
                  FROM ap_suppliers asa
                 WHERE asa.vendor_id = p_vendor_id;
            EXCEPTION
    WHEN OTHERS THEN
DBMS_OUTPUT.put_line('Unable to derive the supplier  information for vendor id:' ||
                                      p_vendor_id);
END;
            
IF j.supplier_type <> j.new_supplier_type THEN
BEGIN
SELECT lookup_code
  INTO l_new_supplier_type
  FROM fnd_lookup_values
WHERE meaning = j.new_supplier_type
   AND lookup_type = 'VENDOR TYPE'
   AND enabled_flag = 'Y'
   AND language = userenv('LANG');
EXCEPTION
WHEN NO_DATA_FOUND THEN
l_new_supplier_type := null;
l_status_flag := 'E';
l_status_msg := 'Supplier Type does not exists in VENDOR TYPE Lookup: ' || SQLERRM; 
WHEN OTHERS THEN
l_new_supplier_type := null;
l_status_flag := 'E';
l_status_msg := 'Error while validating new supplier type. error message: ' || SQLERRM;  
END;
ELSE
NULL;
END IF;
IF TRIM(j.new_invoice_wht_tax_group) IS NOT NULL THEN
BEGIN
SELECT group_id 
  INTO l_ap_awt_group_id
  FROM ap_awt_groups
WHERE name = TRIM(j.new_invoice_wht_tax_group)
   ;
l_allow_awt_flag := 'Y';
EXCEPTION
WHEN OTHERS THEN
l_ap_awt_group_id := NULL;
l_status_flag := 'E';
l_status_msg := l_status_msg||'-Error while validating new_invoice_wht_tax_group. error message: ' || SQLERRM;  
END;
END IF;
dbms_output.put_line('l_status_flag = ' || l_status_flag);
dbms_output.put_line('l_status_msg = ' || l_status_msg);
    
             lr_vendor_rec.vendor_id       := lr_existing_vendor_rec.vendor_id;
-----------------------------------------------
--Deactivate Vendor
             -- lr_vendor_rec.end_date_active := SYSDATE;
             -- lr_vendor_rec.enabled_flag    := 'N';
-----------------------------------------------
             lr_vendor_rec.vendor_type_lookup_code := l_new_supplier_type;
lr_vendor_rec.allow_awt_flag := l_allow_awt_flag;
lr_vendor_rec.awt_group_id := l_ap_awt_group_id;
            IF l_status_flag != 'E'
THEN
ap_vendor_pub_pkg.update_vendor(p_api_version      => p_api_version
   ,p_init_msg_list    => p_init_msg_list
   ,p_commit           => p_commit
   ,p_validation_level => p_validation_level
   ,x_return_status    => x_return_status
   ,x_msg_count        => x_msg_count
   ,x_msg_data         => x_msg_data
   ,p_vendor_rec       => lr_vendor_rec
   ,p_vendor_id        => p_vendor_id
   );
DBMS_OUTPUT.put_line('X_RETURN_STATUS = ' || x_return_status);
DBMS_OUTPUT.put_line('X_MSG_COUNT = ' || x_msg_count);
                DBMS_OUTPUT.put_line('X_MSG_DATA = ' || x_msg_data);
    
IF (x_return_status <> fnd_api.g_ret_sts_success) THEN
FOR i IN 1 .. fnd_msg_pub.count_msg 
LOOP
l_msg := fnd_msg_pub.get(p_msg_index => i
                        ,p_encoded   => fnd_api.g_false
);
DBMS_OUTPUT.put_line('The API call failed with error ' || l_msg);
UPDATE xx_vendor_master_data 
                           SET supp_status_flag = 'E'
      ,supp_status_msg = l_msg 
     WHERE vendor_id = j.vendor_id;
                    END LOOP;
                ELSE
DBMS_OUTPUT.put_line('The API call ended with SUCESSS status');
    UPDATE xx_vendor_master_data 
   SET supp_status_flag = 'S'
  ,supp_status_msg = 'Update Successful' 
WHERE vendor_id = j.vendor_id;
END IF;
ELSE
UPDATE xx_vendor_master_data 
   SET supp_status_flag = 'E'
      ,supp_status_msg = l_status_msg 
WHERE vendor_id = j.vendor_id;
            END IF;
        END LOOP;
    END;
/

AP_SUPPLIER_SITES_ALL.AUTO_TAX_CALC_FLAG in Oracle APPS(AP_TAX_CALCULATION_METHOD)

SELECT *
  FROM fnd_lookup_values
 WHERE lookup_type = 'AP_TAX_CALCULATION_METHOD'
 AND language = USERENV('LANG')

Here AP_SUPPLIER_SITES_ALL.AUTO_TAX_CALC_FLAG will be fnd_lookup_values.lookup_code



Wednesday, October 19, 2022

API call failed with error ORA-01403: no data found in Package AP_VENDOR_PUB_PKG Procedure Validate_Vendor_Site

We had a requirement to update Tax Classification Code, Invoice Withholding Tax Group at supplier level. While using ap_vendor_pub_pkg.update_vendor_site API we got below error message:

The API call failed with error ORA-01403: no data found in Package AP_VENDOR_PUB_PKG Procedure Validate_Vendor_Site

But when used ap_vendor_pub_pkg.update_vendor_site_public the update was successful.

Monday, August 22, 2022

API to End Date FND_USER in Oracle APPS

DECLARE
    l_user_name       VARCHAR2(100)  := 'SYSADMIN';
    l_user_end_date   DATE  := SYSDATE+1;
BEGIN
fnd_user_pkg.updateuser(x_user_name               => l_user_name
                           ,x_owner                   => NULL
                           ,x_unencrypted_password    => NULL
                           ,x_start_date              => NULL
                           ,x_end_date                => l_user_end_date
                           ,x_password_date           => NULL
                           ,x_password_lifespan_days  => NULL
                           ,x_employee_id             => NULL
                           ,x_email_address           => NULL
);

 COMMIT;
EXCEPTION
  WHEN OTHERS THEN
    ROLLBACK;
    DBMS_OUTPUT.PUT_LINE(SQLERRM);
END;

Thursday, July 7, 2022

API to get the Segment Delimiter for the specified (KFF)Key Flex Field Structure using FND_FLEX_EXT.GET_DELIMITER in Oracle APPS

DECLARE
  l_application_short_name VARCHAR2(50);--fnd_application.application_short_name
  l_key_flex_code          VARCHAR2(200);
  l_structure_number       NUMBER; -- gl_ledgers.chart_of_accounts_id
  l_segment_delimiter      VARCHAR2(10);
BEGIN
l_application_short_name := 'SQLGL';
l_key_flex_code          := 'GL#';
l_structure_number       := 51234;

l_segment_delimiter := fnd_flex_ext.get_delimiter
                    (
                      application_short_name => l_application_short_name
                     ,key_flex_code          => l_key_flex_code
                     ,structure_number       => l_structure_number
                    ); 

DBMS_OUTPUT.PUT_LINE('l_segment_delimiter = ' || l_segment_delimiter);
END;

Wednesday, March 16, 2022

API to validate AP Invoice using AP_APPROVAL_PKG.BATCH_APPROVAL(To Change Invoice Status to Validated) in Oracle APPS

CREATE OR REPLACE PROCEDURE xx_apinv_wht_validate(errbuf   OUT VARCHAR2
                                                 ,retcode  OUT VARCHAR2
         ,p_inv_date_from IN VARCHAR2
         ,p_inv_date_to   IN VARCHAR2
                                                 )
AS
CURSOR cur_wht_inv(p_org_id    IN NUMBER
                  ,v_inv_date_from IN DATE
  ,v_inv_date_to   IN DATE
  )
IS
SELECT DISTINCT aia.invoice_id
              ,aia.org_id
              ,aia.invoice_num
              ,aia.invoice_type_lookup_code
          FROM ap_invoices_all aia
              ,ap_invoice_lines_all aila
         WHERE 1 = 1
           AND aia.invoice_type_lookup_code = 'AWT'
   AND aia.invoice_id = aila.invoice_id
           AND aia.org_id = aila.org_id
   AND NVL(aila.cancelled_flag,'Y') <> 'Y'
           AND ap_invoices_pkg.get_approval_status(aia.invoice_id
                                                  ,aia.invoice_amount
                                                  ,aia.payment_status_flag
                                                  ,aia.invoice_type_lookup_code
                )NOT IN ('APPROVED', 'UNPAID')
           AND aia.org_id = p_org_id
   AND aia.invoice_date BETWEEN NVL(v_inv_date_from, aia.invoice_date) AND NVL(v_inv_date_to, aia.invoice_date)
;

l_org_id hr_operating_units.organization_id%TYPE;
l_hold_cnt NUMBER;
l_inv_from_date DATE;
l_inv_to_date   DATE;
 
BEGIN
fnd_file.put_line (fnd_file.log , 'XX WHT Invoice Validation Start');
l_org_id := fnd_profile.value('ORG_ID');
l_inv_from_date := fnd_date.canonical_to_date(p_inv_date_from);
l_inv_to_date := fnd_date.canonical_to_date(p_inv_date_to);

mo_global.set_policy_context('S', l_org_id);
fnd_global.apps_initialize(user_id      => fnd_global.user_id
                          ,resp_id      => fnd_global.resp_id
  ,resp_appl_id => fnd_global.resp_appl_id
  );

FOR rec_wht_inv IN cur_wht_inv(l_org_id
                              ,l_inv_from_date
  ,l_inv_to_date
  )
LOOP
fnd_file.put_line (fnd_file.log ,'WHT invoice_num: '||rec_wht_inv.invoice_num);
  
BEGIN
l_hold_cnt := NULL;
IF (ap_approval_pkg.batch_approval(p_run_option => NULL
  ,p_sob_id => fnd_profile.VALUE('GL_SET_OF_BKS_ID')
  ,p_inv_start_date => NULL
  ,p_inv_end_date => NULL
  ,p_inv_batch_id => NULL
  ,p_vendor_id => NULL
  ,p_pay_group => NULL
  ,p_invoice_id => rec_wht_inv.invoice_id
  ,p_entered_by => NULL
  ,p_debug_switch => 'N'
  ,p_conc_request_id => fnd_profile.VALUE('CONC_REQUEST_ID')
  ,p_commit_size => NULL
  ,p_org_id => rec_wht_inv.org_id
  ,p_report_holds_count => l_hold_cnt
  ,p_transaction_num => NULL
  )
)
THEN   
fnd_file.put_line (fnd_file.log , 'Invoice Validated: '||rec_wht_inv.invoice_num);
ELSE
fnd_file.put_line (fnd_file.log , 'Invoice Validation Failed: '||rec_wht_inv.invoice_num);
END IF;

COMMIT;
  
EXCEPTION 
WHEN OTHERS THEN
fnd_file.put_line (fnd_file.log , rec_wht_inv.invoice_num ||' Invoice Validation failed with unhandled exception.Error: '||SQLERRM);
END;
END LOOP;
fnd_file.put_line (fnd_file.log , 'XX WHT Invoice Validation End');
EXCEPTION 
WHEN OTHERS THEN
fnd_file.put_line (fnd_file.log ,' XX_APINV_WHT_VALIDATE failed with Unhandled Exception.Error: '||SQLERRM);
END;

Friday, December 10, 2021

PAY_GROUP_LOOKUP_CODE is invalid. Pay Group is invalid. Invalid Payee context values. Org parameters exist only with party site and supplier site.

As per Oracle Note: 2325864.1

Ensure that a valid pay group has been set up in Payables, by navigating to Setup -> Option -> Payables -> Expense Report Tab.


To verify whether the pay group is valid, please run:

SELECT lookup_code
FROM po_lookup_codes
WHERE lookup_type = 'PAY GROUP'
AND lookup_code = 'Enter Pay Group Name Here'
AND enabled_flag = 'Y'
AND nvl(inactive_date,sysdate+1) > sysdate;

Thursday, December 9, 2021

Employee Data migration in Oracle APPS

  1. Extract Data from Source System.
    • If Source system is Oracle EBS only then use the following query to extract data. Please note that query having few columns only. Based on your requirement add additional columns or remove which are not required.
    • Employee Data Extraction Query
  2. Create Staging Table.
  3. Load Data into Staging Table
  4. Run API Script.

    

Step2: Create Staging Table.

DROP TABLE XXSCHEMA.XX_EMPLOYEE_STG
/
DROP SYNONYM APPS.XX_EMPLOYEE_STG
/
CREATE TABLE XXSCHEMA.XX_EMPLOYEE_STG
(
  EMPLOYEE_NUMBER        VARCHAR2(30),
  LAST_NAME              VARCHAR2(150),
  FIRST_NAME             VARCHAR2(150),
  MIDDLE_NAMES           VARCHAR2(60),
  TITLE                  VARCHAR2(30),
  FULL_NAME              VARCHAR2(240),
  HIRE_DATE              DATE,
  ORIGINAL_DATE_OF_HIRE  DATE,
  DATE_OF_BIRTH          DATE,
  TOWN_OF_BIRTH          VARCHAR2(90),
  REGION_OF_BIRTH        VARCHAR2(90),
  COUNTRY_OF_BIRTH       VARCHAR2(90),
  SEX                    VARCHAR2(30),
  NATIONALITY            VARCHAR2(30),
  PERSON_TYPE            VARCHAR2(90),
  NATIONAL_IDENTIFIER    VARCHAR2(30),
  BLOOD_TYPE             VARCHAR2(30),
  EMAIL_ADDRESS          VARCHAR2(240),
  MARITAL_STATUS         VARCHAR2(30),
  OFFICE_NUMBER          VARCHAR2(45),
  DISABILITY VARCHAR2(1),
  ATTRIBUTE_CATEGORY     VARCHAR2(30),
  ATTRIBUTE1             VARCHAR2(150),
  ATTRIBUTE2             VARCHAR2(150),
  ATTRIBUTE3             VARCHAR2(150),
  ATTRIBUTE4             VARCHAR2(150),
  ATTRIBUTE5             VARCHAR2(150),
  ATTRIBUTE6             VARCHAR2(150),
  ATTRIBUTE7             VARCHAR2(150),
  ATTRIBUTE8             VARCHAR2(150),
  ATTRIBUTE9             VARCHAR2(150),
  ATTRIBUTE10            VARCHAR2(150),
  PERSON_ID              NUMBER,
  BUSINESS_GROUP_ID      NUMBER,
  ASSIGNMENT_ID          NUMBER(15),
  STATUS                 VARCHAR2(5),
  ERROR_MSG              VARCHAR2(4000)
)
/
CREATE SYNONYM APPS.XX_EMPLOYEE_STG FOR XXSCHEMA.XX_EMPLOYEE_STG
/

STEP3: Load Data into Staging Table
Load data into staging table either using Control File or directly load from Toad/SQL Developer, etc.

STEP4: API Script
DECLARE
  /*Declaration Of Local variables*/
  /*===========================================================================*/
  v_status                       VARCHAR2(1) := NULL;
  v_err_msg                      VARCHAR2(4000) := NULL;
  v_total_records                NUMBER(15) := 0;
  v_success_records              NUMBER(15) := 0;
  v_failure_records              NUMBER(15) := 0;
  v_emp_exists_cnt               NUMBER(15) := 0;
  v_national_identifier_exts_cnt NUMBER(15) := 0;
  x_person_id                    NUMBER := NULL;
  v_gender_code                  VARCHAR2(15) := NULL;
  v_marital_status               VARCHAR2(15) := NULL;
  v_nationality              VARCHAR2(15) := NULL;
  v_country_of_birth             VARCHAR2(15) := NULL;
  --x_lang_code                    VARCHAR2(15) := NULL;
  v_title                    VARCHAR2(15) := NULL;
  x_assignment_id                NUMBER := NULL;
  v_person_type_id               NUMBER := NULL;
  x_race                         VARCHAR2(60) := NULL;
  x_out_employee_number          NUMBER := NULL;
  x_out_person_id                NUMBER := NULL;
  x_out_assignment_id            NUMBER := NULL;
  x_out_per_obj_vers_no          NUMBER := NULL;
  x_out_asg_obj_vers_no          NUMBER := NULL;
  x_out_per_effective_start_date DATE;
  x_out_per_effective_end_date   DATE;
  x_out_full_name                VARCHAR2(240) := NULL;
  x_out_per_comment_id           NUMBER := NULL;
  x_out_assignment_sequence      NUMBER := NULL;
  x_out_assignment_number        NUMBER := NULL;
  x_religion_code                VARCHAR2(200);
  x_out_orig_hire_warning        BOOLEAN;
  ni_number EXCEPTION;
  v_business_group_id            NUMBER := 1;
  x_ni                           VARCHAR2(30) := NULL;
  x_work_schedule                varchar2(50);
  x_out_name_combination_warning BOOLEAN;
  x_out_assign_payroll_warning   BOOLEAN;
  
l_user_id fnd_user.user_id%TYPE;
l_resp_id fnd_responsibility_tl.responsibility_id%TYPE;
l_resp_appl_id fnd_responsibility_tl.application_id%TYPE;
l_org_id hr_operating_units.organization_id%TYPE;
  ----

  CURSOR cur_xxhr_employee IS
SELECT *
  FROM XX_employee_stg stg
WHERE NVL(status, 'E') = 'E'
   and employee_number NOT IN (SELECT NVL(employee_number, 1) FROM per_all_people_f papf)
   and employee_number = '1234567890'
ORDER BY employee_number ASC, hire_date DESC;

BEGIN
l_user_id := NULL;
l_resp_id := NULL;
l_resp_appl_id := NULL;
l_org_id := NULL;
BEGIN
SELECT user_id
  INTO l_user_id
  FROM fnd_user
WHERE user_name = 'XX_USER';
EXCEPTION
WHEN OTHERS THEN
l_user_id := NULL;
END;
BEGIN
SELECT responsibility_id, application_id 
  INTO l_resp_id, l_resp_appl_id
  FROM fnd_responsibility_tl
WHERE responsibility_name = 'Global HRMS Manager'
   AND language = USERENV('LANG')
   ;
EXCEPTION
WHEN OTHERS THEN
l_resp_id := NULL;
l_resp_appl_id := NULL;
END;
-- Initialize apps session
fnd_global.apps_initialize(user_id      => l_user_id
                          ,resp_id      => l_resp_id
  ,resp_appl_id => l_resp_appl_id
  );
DBMS_OUTPUT.PUT_LINE('#############################################################');
DBMS_OUTPUT.PUT_LINE('DATA MIGRATION OF EMPLOYEE :');
DBMS_OUTPUT.PUT_LINE('#############################################################');
DBMS_OUTPUT.PUT_LINE('START TIME : ' ||TO_CHAR(SYSDATE, 'DD-MON-YYYY HH24:MI:SS'));

FOR rec_xxhr_employee IN cur_xxhr_employee LOOP
dbms_output.put_line('Loop Opened');
  
v_status           := 'N';
v_err_msg          := NULL;
v_total_records    := v_total_records + 1;
v_emp_exists_cnt   := 0;
v_national_identifier_exts_cnt := 0;
x_person_id        := 0;
v_gender_code      := NULL;
x_assignment_id    := 0;
v_person_type_id   := 0;
v_marital_status   := NULL;
v_nationality      := NULL;
v_title    := NULL;
v_country_of_birth := NULL;
/*x_registered_disabled     := NULL;
x_country_code            := NULL;
x_lang_code               := NULL;*/
x_out_employee_number     := NULL;
x_out_person_id           := NULL;
x_out_assignment_id       := NULL;
x_out_per_obj_vers_no     := NULL;
x_out_asg_obj_vers_no     := NULL;
x_out_full_name           := NULL;
x_out_per_comment_id      := NULL;
x_out_assignment_sequence := NULL;
x_out_assignment_number   := NULL;
  
/* Check For Local Employee Numbmer */
IF rec_xxhr_employee.employee_number IS NULL THEN
v_err_msg := v_err_msg || 'Employee Number cannot be blank';
v_status  := 'E';
ELSE
SELECT COUNT(1)
  INTO v_emp_exists_cnt
  FROM per_all_people_f papf
WHERE UPPER(TRIM(papf.employee_number)) = UPPER(TRIM(rec_xxhr_employee.employee_number))
   AND papf.business_group_id = v_business_group_id
   AND papf.current_employee_flag = 'Y'
   AND TRUNC(SYSDATE) BETWEEN papf.effective_start_date AND effective_end_date;
IF v_emp_exists_cnt > 0 THEN
v_status:='E';
v_err_msg := v_err_msg||'EMPLOYEE_NUMBER already exists; ';
END IF;
END IF;
  
--Validation For Gender
IF rec_xxhr_employee.sex IS NULL THEN
v_status:='E';
v_err_msg := v_err_msg||'Employee Gender Cannot be Null; ';
ELSIF rec_xxhr_employee.sex IS NOT NULL THEN
BEGIN
SELECT lookup_code
  INTO v_gender_code
  FROM hr_lookups
WHERE lookup_type ='SEX'
   AND UPPER(TRIM(MEANING))=UPPER(TRIM(rec_xxhr_employee.sex));
EXCEPTION 
WHEN OTHERS THEN
v_status:='E';
v_err_msg := v_err_msg||'Employee GENDER(SEX) is not valid; ';
END;
END IF;
--Validation for Person_type
IF rec_xxhr_employee.person_type IS NULL THEN
v_err_msg := 'E';
v_err_msg := v_err_msg||'PERSON_TYPE cannot be Null; ';
ELSIF rec_xxhr_employee.person_type IS NOT NULL THEN
BEGIN
SELECT person_type_id
  INTO v_person_type_id
  FROM per_person_types
WHERE UPPER(TRIM(user_person_type)) = UPPER(TRIM(rec_xxhr_employee.person_type))
   AND business_group_id = v_business_group_id;
EXCEPTION 
WHEN OTHERS THEN
v_status :='E';
v_err_msg := v_err_msg||'PERSON_TYPE is not valid; ';
END;
END IF;
--Validation for Birth Date
IF rec_xxhr_employee.date_of_birth IS NULL THEN
v_status :='E';
v_err_msg := v_err_msg||'DATE_OF_BIRTH cannot Null; ';
END IF;

--Validation for Email Address
IF rec_xxhr_employee.email_address IS NULL THEN
v_status := 'E';
v_err_msg := v_err_msg||'EMAIL_ADDRESS cannot Null; ';
END IF;
--Validation for Marital Status
IF rec_xxhr_employee.marital_status IS NOT NULL THEN
BEGIN
SELECT lookup_code
  INTO v_marital_status
  FROM hr_lookups
WHERE lookup_type = 'MAR_STATUS'
   AND UPPER(TRIM(meaning))=UPPER(TRIM(rec_xxhr_employee.marital_status));
EXCEPTION 
WHEN OTHERS THEN
v_status := 'E';
v_err_msg := v_err_msg||'MARITAL_STATUS is not valid; ';
END;
END IF;
--Validation for Nationality
IF rec_xxhr_employee.nationality IS NOT NULL THEN
BEGIN
SELECT lookup_code
  INTO v_nationality
  FROM hr_lookups
WHERE lookup_type = 'NATIONALITY'
  AND UPPER(TRIM(meaning)) = UPPER(TRIM(rec_xxhr_employee.nationality));
EXCEPTION 
WHEN OTHERS THEN
v_status := 'E';
v_err_msg := v_err_msg||'NATIONALITY is not valid; ';
END;
END IF;
--Validation for Title

IF rec_xxhr_employee.title IS NULL THEN
v_status := 'E';
v_err_msg := v_err_msg||'TITLE cannot Null; ';
ELSIF rec_xxhr_employee.title IS NOT NULL THEN
BEGIN
SELECT lookup_code
  INTO v_title
  FROM hr_lookups
WHERE lookup_type ='TITLE'
   AND UPPER(TRIM(meaning)) = UPPER(TRIM(rec_xxhr_employee.title));
EXCEPTION 
WHEN OTHERS THEN
v_status := 'E';
v_err_msg := v_err_msg||'TITLE is not valid; ';
END;
END IF;

--Validation for Country
IF rec_xxhr_employee.COUNTRY_OF_BIRTH IS NOT NULL THEN
BEGIN
SELECT territory_code
  INTO v_country_of_birth
  FROM apps.fnd_territories_vl
--WHERE UPPER(TRIM (territory_short_name)) = UPPER(TRIM(rec_xxhr_employee.country_of_birth));
WHERE UPPER(TRIM (territory_code)) = UPPER(TRIM(rec_xxhr_employee.country_of_birth));
EXCEPTION 
WHEN OTHERS THEN
v_status := 'E';
v_err_msg := v_err_msg||'COUNTRY_OF_BIRTH is not valid; ';
END;
END IF;
IF rec_xxhr_employee.national_identifier IS NOT NULL THEN
SELECT COUNT(national_identifier)
  INTO v_national_identifier_exts_cnt
  FROM per_all_people_f papf
WHERE UPPER(TRIM(papf.national_identifier)) = UPPER(TRIM(rec_xxhr_employee.national_identifier))
   AND papf.business_group_id = v_business_group_id
   AND TRUNC(sysdate) BETWEEN papf.effective_start_date AND effective_end_date;
IF v_national_identifier_exts_cnt > 0 THEN
v_status := 'E';
v_err_msg := v_err_msg||'NATIONAL_IDENTIFIER is already exists; ';
END IF;
END IF;
IF v_status <> 'E' THEN
BEGIN
APPS.Hr_Employee_Api.create_employee(p_validate                  => FALSE,
p_hire_date                 => rec_xxhr_employee.hire_date,
p_business_group_id         => v_business_group_id,
p_last_name                 => rec_xxhr_employee.last_name,
p_sex                       => v_gender_code,--rec_xxhr_employee.sex,
p_person_type_id            => v_person_type_id,
p_date_of_birth             => rec_xxhr_employee.date_of_birth,
p_email_address             => rec_xxhr_employee.email_address,
p_employee_number           => rec_xxhr_employee.employee_number,
p_first_name                => rec_xxhr_employee.first_name,
p_marital_status            => v_marital_status,--rec_xxhr_employee.marital_status,
p_middle_names              => rec_xxhr_employee.middle_names,
p_nationality               => v_nationality,--rec_xxhr_employee.nationality,
p_national_identifier       => rec_xxhr_employee.national_identifier,
p_registered_disabled_flag  => rec_xxhr_employee.disability,
p_title                     => v_title,--UPPER(rec_xxhr_employee.title),
p_attribute_category        => rec_xxhr_employee.attribute_Category,
p_attribute1                => rec_xxhr_employee.attribute1,
p_Attribute2                => rec_xxhr_employee.attribute2,
p_attribute3                => rec_xxhr_employee.attribute3,
p_blood_type                => rec_xxhr_employee.blood_type,
p_office_number             => rec_xxhr_employee.office_number,
p_original_date_of_hire     => rec_xxhr_employee.original_date_of_hire,
p_town_of_birth             => rec_xxhr_employee.town_of_birth,
p_region_of_birth           => rec_xxhr_employee.region_of_birth,
p_country_of_birth          => v_country_of_birth,--rec_xxhr_employee.country_of_birth,
p_person_id                 => x_out_person_id,
p_assignment_id             => x_out_assignment_id,
p_per_object_version_number => x_out_per_obj_vers_no,
p_asg_object_version_number => x_out_asg_obj_vers_no,
p_per_effective_start_date  => x_out_per_effective_start_date,
p_per_effective_end_date    => x_out_per_effective_end_date,
p_full_name                 => x_out_full_name,
p_per_comment_id            => x_out_per_comment_id,
p_assignment_sequence       => x_out_assignment_sequence,
p_assignment_number         => x_out_assignment_number,
p_name_combination_warning  => x_out_name_combination_warning,
p_assign_payroll_warning    => x_out_assign_payroll_warning,
p_orig_hire_warning         => x_out_orig_hire_warning
   );
  --COMMIT;
  v_success_records := v_success_records + 1;
  UPDATE XX_employee_stg
SET status        = 'S',
error_msg     = 'Success',
person_id     = x_out_person_id,
assignment_id = x_out_assignment_id
   WHERE employee_number = rec_xxhr_employee.employee_number;
  --COMMIT;
EXCEPTION
WHEN OTHERS THEN
v_err_msg         := SQLERRM;
v_failure_records := v_failure_records + 1;
  
DBMS_OUTPUT.PUT_LINE('API Exception :' || SQLERRM);
  
UPDATE XX_employee_stg
   SET status = 'E'
  ,error_msg = v_err_msg
WHERE employee_number = rec_xxhr_employee.employee_number;
  
--COMMIT;
END;
ELSE
v_failure_records := v_failure_records + 1;
UPDATE XX_employee_stg
   SET status = 'E'
  ,error_msg = v_err_msg
WHERE employee_number = rec_xxhr_employee.employee_number;
END IF;
  
END LOOP;
DBMS_OUTPUT.PUT_LINE('v_total_records   :' || v_total_records);
DBMS_OUTPUT.PUT_LINE('v_success_records :' || v_success_records);
DBMS_OUTPUT.PUT_LINE('v_failure_records :' || v_failure_records);
EXCEPTION
WHEN OTHERS THEN
DBMS_OUTPUT.PUT_LINE('Main Exception :-' || SQLERRM);
END;

APEX$TASK_PK

  APEX$TASK_PK is a substitution string holding the primary key value of the system of records