UTL_FILE reqeust taking too much time for completion

Hi,
We are running utl_file reqeust.
the select statement fetching 6000 records, for this it taking 22 mins for completion.
the code is
CREATE OR REPLACE PACKAGE BODY "XXC"."XXC_MOD_IN_068_AP_TO_FIS_PKG"
AS
* Module Type : PL/SQL
* Module Name : XXC_MOD_IN_068_AP_FIS_PKG
* Description : This package is used for AP to Fiscal Interface.
* Run Env. : SQL*Plus
* Procedure Name Description
* XXC_MOD_068_AP_PR XXC_MOD_068_AP_PR Procedure is used to insert transactions
* into CSV OutPut File from Oracle Account Payables.
* Calling Module: None
* Modules Called: XXC_COMMON_INT_PK.INSERT_AUDIT
* Module Number : MOD_IN_068
* Known Bugs and Restrictions: none
* History
* =======
* Version Name Date Description of Change
* 0.1 Sanjeev Khurana 25-JULY-2011 Initial Creation.
* 0.2 Rohit 09-DEC-2011 Updated header details for the file
* 0.3 Amit Kulwal 28-AUG-2012 Updated the cursor query for incident 671520
* 0.4 Swaraj Goud 20-Nov-2012 Updated as per the CR 671520
| PACKAGE BODY
-- Actual Code Start Here
-- Procedure : XXC_MOD_068_AP_PR
-- Description : XXC_MOD_068_AP_PR Procedure is used to insert transactions
-- into CSV OUTPUT File from Oracle Account Payables.
-- Parameters:
-- Parm Name I/O Description
-- p_errbuf OUT Error message.
-- p_retcode OUT Error code. Returns 0 if no errors otherwise returns 1.
-- p_start_date IN Start Date
-- p_end_date IN End Date
PROCEDURE xxc_mod_068_ap_pr (
p_errbuf OUT VARCHAR2,
p_retcode OUT NUMBER,
p_start_date IN VARCHAR2,
p_end_date IN VARCHAR2
IS
-- Define variables and assign default values
l_sucess_count NUMBER := 0;
l_error_count NUMBER := 0;
-- Standard declaration
l_source VARCHAR2 (10);
l_target VARCHAR2 (10);
lc_module_description VARCHAR2 (50)
:= 'MOD_IN_068 - AP to Fiscal';
l_status CONSTANT VARCHAR2 (50) := 'NEW';
p_status NUMBER;
l_batch_id NUMBER;
l_batch_id_next NUMBER
:= apps_common_out_batch_id_s1.NEXTVAL;
l_proc_name VARCHAR2 (100) := 'XXC_MOD_IN_068';
l_request_id NUMBER
:= fnd_global.conc_request_id;
l_audit_master_id NUMBER := NULL;
l_mod_code VARCHAR2 (100);
l_log_type NUMBER := 1; --INFORMATION
l_det_status_success NUMBER := 0; --SUCCESS
l_det_status_inprocess NUMBER := 3; --INPROCESS
l_det_status_rejected NUMBER := 4; --REJECTED
l_det_status_err NUMBER := 3; --Error
l_det_status_complete NUMBER := 9; --COMPLETE
-- Standard who Columns
l_created_by NUMBER := fnd_global.user_id;
l_creation_date DATE := SYSDATE;
l_last_update_date DATE := SYSDATE;
l_last_update_login NUMBER := fnd_global.user_id;
v_file UTL_FILE.file_type;
l_location VARCHAR2 (150);
l_archive_location VARCHAR2 (150);
l_date VARCHAR2 (50);
l_filename VARCHAR2 (50);
l_open_mode VARCHAR2 (1) := 'W';
--- l_max_linesize NUMBER := 32767;
l_max_linesize VARCHAR2 (150); -- Updated 09-Nov-2012
--Cursor is used to fetch valid records for the interface
CURSOR get_ap_data_inv
IS
SELECT asp.segment1 supplier_ref,
-- asp.vendor_name supplier_name,
replace(asp.vendor_name, ',', ' ') supplier_name,
--aia.invoice_num invoice_number,
replace(aia.invoice_num, ',','') invoice_number,
aia.invoice_date,
aia.invoice_amount amount,
aia.doc_sequence_value unique_id,
aia.creation_date date_invoice_entered,
apsa.due_date date_invoice_paid,
aia.SOURCE user_id,
aia.payment_status_flag,
aia.invoice_type_lookup_code doc_type,
--aia.description,
replace(aia.description, ',' , ' ') description,
apsa.gross_amount
FROM ap_invoices_all aia,
ap_suppliers asp,
apps.ap_payment_schedules_all apsa
-- apps.iby_payments_all iba,
-- apps.iby_docs_payable_all dp
WHERE aia.invoice_id = apsa.invoice_id
AND aia.vendor_id = asp.vendor_id
AND aia.org_id = apsa.org_id
-- AND apsa.payment_status_flag != 'Y' -- commented for CR
-- AND dp.payment_id = iba.payment_id(+)
-- AND aia.invoice_id = dp.calling_app_doc_unique_ref2(+)
-- AND apsa.due_date <= (SYSDATE + 1)
AND TRUNC (aia.creation_date)
BETWEEN NVL (fnd_date.canonical_to_date (p_start_date),
TRUNC (aia.creation_date))
AND NVL (fnd_date.canonical_to_date (p_end_date),
TRUNC (aia.creation_date));
     TYPE xxc_tbl IS TABLE OF get_ap_data_inv%ROWTYPE;
xxc_tbl1 xxc_tbl;
BEGIN
l_batch_id := apps_common_out_batch_id_s1.CURRVAL;
xxc_common_int_pk.insert_audit (p_batch_id => l_batch_id,
p_request_id => l_request_id,
p_source_system => l_source,
p_proc_name => l_proc_name,
p_log_type => l_log_type,
p_det_status => l_det_status_inprocess,
p_msg_code => NULL,
p_entity => NULL,
p_msg_desc => 'Process Starts',
p_mast_request_id => l_request_id,
p_record_id => NULL,
p_source => l_source,
p_target => l_target,
p_email => NULL,
p_mod_code => l_mod_code,
p_audit_master_id => l_audit_master_id
-- Get Module Code
BEGIN
SELECT TRIM (fval.flex_value),
TRIM (SUBSTR (fval.description,
1,
INSTR (fval.description, ' -')
INTO l_source,
l_mod_code
FROM fnd_flex_values_vl fval, fnd_flex_value_sets vset
WHERE vset.flex_value_set_id = fval.flex_value_set_id
AND vset.flex_value_set_name IN ('XXC_COMM_INT_CONFIG')
AND fval.enabled_flag = 'Y'
AND fval.description = lc_module_description;
EXCEPTION
WHEN OTHERS
THEN
xxc_common_int_pk.insert_audit (p_batch_id => l_batch_id,
p_request_id => l_request_id,
p_source_system => l_source,
p_proc_name => l_proc_name,
p_log_type => l_log_type,
p_det_status => l_det_status_err,
p_msg_code => NULL,
p_entity => NULL,
p_msg_desc => 'Error Mode Code',
p_mast_request_id => l_request_id,
p_record_id => NULL,
p_source => l_source,
p_target => l_target,
p_email => NULL,
p_mod_code => l_mod_code,
p_audit_master_id => l_audit_master_id
raise_application_error (-20045, SQLERRM);
END;
--File Location Path for OutPut File
BEGIN
SELECT fnd_profile.VALUE ('XXC_MOD_IN_068_AP_OUTBOUND'),
fnd_profile.VALUE ('XXC_MOD_IN_068_AP_ARCHIVE')
INTO l_location,
l_archive_location
FROM DUAL;
EXCEPTION
WHEN OTHERS
THEN
xxc_common_int_pk.insert_audit
(p_batch_id => l_batch_id,
p_request_id => l_request_id,
p_source_system => l_source,
p_proc_name => l_proc_name,
p_log_type => l_log_type,
p_det_status => l_det_status_rejected,
p_msg_code => NULL,
p_entity => NULL,
p_msg_desc => 'Profile Value not found',
p_mast_request_id => l_request_id,
p_record_id => NULL,
p_source => l_source,
p_target => l_target,
p_email => NULL,
p_mod_code => l_mod_code,
p_audit_master_id => l_audit_master_id
END;
BEGIN
SELECT TO_CHAR (SYSDATE, 'YYYYMMDDhh24miss')
INTO l_date
FROM DUAL;
EXCEPTION
WHEN OTHERS
THEN
xxc_common_int_pk.insert_audit (p_batch_id => l_batch_id,
p_request_id => l_request_id,
p_source_system => l_source,
p_proc_name => l_proc_name,
p_log_type => l_log_type,
p_det_status => l_det_status_rejected,
p_msg_code => NULL,
p_entity => NULL,
p_msg_desc => 'status not found',
p_mast_request_id => l_request_id,
p_record_id => NULL,
p_source => l_source,
p_target => l_target,
p_email => NULL,
p_mod_code => l_mod_code,
p_audit_master_id => l_audit_master_id
END;
l_filename := 'AP_Fiscal_' || l_date || '.csv';
v_file :=
UTL_FILE.fopen (LOCATION => l_location,
filename => l_filename,
open_mode => l_open_mode,
max_linesize => l_max_linesize
-- Changed as per Sarah's email on 9th Decemeber
/* UTL_FILE.put_line (v_file,
'SUPPLIER_REF'
|| ','
|| 'SUPPLIER_NAME'
|| ','
|| 'INVOICE_NUMBER'
|| ','
|| 'INVOICE_DATE'
|| ','
|| 'AMOUNT'
|| ','
|| 'UNIQUE_ID'
|| ','
|| 'DATE_INVOICE_ENTERED'
|| ','
|| 'DATE_INVOICE_PAID'
|| ','
|| 'USER_ID'
|| ','
|| 'PAYMENT_STATUS_FLAG'
|| ','
|| 'DOC_TYPE'
|| ','
|| 'DESCRIPTION'
|| ','
|| 'PAYMENT_AMOUNT'
UTL_FILE.put_line (v_file,
'SUPPLIERREF'
|| ','
|| 'SUPPLIERNAME'
|| ','
|| 'INVOICENUMBER'
|| ','
|| 'DATE'
|| ','
|| 'AMOUNT'
|| ','
|| 'UNIQUEID'
|| ','
|| 'DATEINVOICEENTERED'
|| ','
|| 'DATEINVOICEPAID'
|| ','
|| 'USERID'
|| ','
|| 'PAYMENTSTATUS'
|| ','
|| 'DOCTYPE'
|| ','
|| 'DESCRIPTION'
|| ','
|| 'PAYMENTAMOUNT');
UTL_FILE.put_line (v_file,
'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX'
|| ','
|| 'XX');
                         open get_ap_data_inv;
                         loop
                         fetch get_ap_data_inv bulk collect into xxc_tbl1 limit 6000;
fnd_file.put_line(fnd_file.log, 'Cursor Count is : '||xxc_tbl1.count);
                         for i in xxc_tbl1.first .. xxc_tbl1.count
--FOR cur_rec IN get_ap_data_inv
LOOP
BEGIN
--Common package used for proper sequence for Record_id and Bath_id
l_sucess_count := l_sucess_count + 1;
--Insert into CSV file
fnd_file.put_line (fnd_file.LOG, 'Before Utl file');
UTL_FILE.put_line (v_file,
xxc_tbl1(i).supplier_ref
|| ','
|| xxc_tbl1(i).supplier_name
|| ','
|| xxc_tbl1(i).invoice_number
|| ','
|| xxc_tbl1(i).invoice_date
|| ','
|| xxc_tbl1(i).amount
|| ','
|| xxc_tbl1(i).unique_id
|| ','
|| xxc_tbl1(i).date_invoice_entered
|| ','
|| xxc_tbl1(i).date_invoice_paid
|| ','
|| xxc_tbl1(i).user_id
|| ','
|| xxc_tbl1(i).payment_status_flag
|| ','
|| xxc_tbl1(i).doc_type
|| ','
|| xxc_tbl1(i).description
|| ','
|| xxc_tbl1(i).gross_amount);
fnd_file.put_line (fnd_file.LOG,
'Supplier Reference : ' || xxc_tbl1(i).supplier_ref);
xxc_common_int_pk.insert_audit
(p_batch_id => l_batch_id,
p_request_id => l_request_id,
p_source_system => l_source,
p_proc_name => l_proc_name,
p_log_type => l_log_type,
p_det_status => l_det_status_complete,
p_msg_code => NULL,
p_entity => NULL,
p_msg_desc => 'Inserting records from AP to Fiscal Successfully',
p_mast_request_id => l_request_id,
p_record_id => NULL,
p_source => l_source,
p_target => l_target,
p_email => NULL,
p_mod_code => l_mod_code,
p_audit_master_id => l_audit_master_id
EXCEPTION
WHEN OTHERS
THEN
l_error_count := l_error_count + 1;
fnd_file.put_line (fnd_file.LOG,
'Error While Inserting from AP to Fiscal '
|| SQLERRM);
-- Create audit log for AP Inv records insert Exception
--Insert into the Audit table XXC_COMM_AUDIT_DETAIL_LOG and XXC_COMM_AUDIT_MASTER_LOG
xxc_common_int_pk.insert_audit
(p_batch_id => l_batch_id,
p_request_id => l_request_id,
p_source_system => l_source,
p_proc_name => l_proc_name,
p_log_type => l_log_type,
p_det_status => l_det_status_rejected,
p_msg_code => NULL,
p_entity => NULL,
p_msg_desc => 'Error While Inserting from AP to Fiscal',
p_mast_request_id => l_request_id,
p_record_id => NULL,
p_source => l_source,
p_target => l_target,
p_email => NULL,
p_mod_code => l_mod_code,
p_audit_master_id => l_audit_master_id
END;
END LOOP;
exit when get_ap_data_inv%NOTFOUND;
end loop;
     close get_ap_data_inv;
UTL_FILE.fclose (v_file);
UTL_FILE.fcopy (l_location,
l_filename,
l_archive_location,
l_filename
-- Create audit log for Successfully processed records
-- Procedure call to insert in Audit tables
xxc_common_int_pk.insert_audit
(p_batch_id => l_batch_id,
p_request_id => l_request_id,
p_source_system => l_source,
p_proc_name => l_proc_name,
p_log_type => l_log_type,
p_det_status => l_det_status_complete,
p_msg_code => NULL,
p_entity => NULL,
p_msg_desc => 'Compeleted Sucessfully AP to Fiscal',
p_mast_request_id => l_request_id,
p_record_id => NULL,
p_source => l_source,
p_target => l_target,
p_email => NULL,
p_mod_code => l_mod_code,
p_audit_master_id => l_audit_master_id
--Insert into the Audit table XXC_COMM_AUDIT_DETAIL_LOG and XXC_COMM_AUDIT_MASTER_LOG for populating email drop table
BEGIN
SELECT transaction_status
INTO p_status
FROM xxc_comm_audit_master_log
WHERE audit_master_id = l_audit_master_id;
EXCEPTION
WHEN OTHERS
THEN
xxc_common_int_pk.insert_audit (p_batch_id => l_batch_id,
p_request_id => l_request_id,
p_source_system => l_source,
p_proc_name => l_proc_name,
p_log_type => l_log_type,
p_det_status => l_det_status_err,
p_msg_code => NULL,
p_entity => NULL,
p_msg_desc => 'Status Error',
p_mast_request_id => l_request_id,
p_record_id => NULL,
p_source => l_source,
p_target => l_target,
p_email => NULL,
p_mod_code => l_mod_code,
p_audit_master_id => l_audit_master_id
END;
IF p_status <> 0
THEN
xxc_comm_audit_log_pk.populate_email_drop_table (l_audit_master_id,
l_batch_id);
END IF;
EXCEPTION
WHEN UTL_FILE.invalid_path
THEN
UTL_FILE.fclose (v_file);
raise_application_error (-20000, 'File location is invalid.');
WHEN UTL_FILE.invalid_mode
THEN
UTL_FILE.fclose (v_file);
raise_application_error (-20001,
'The open_mode parameter in FOPEN is invalid.');
WHEN UTL_FILE.invalid_filehandle
THEN
UTL_FILE.fclose (v_file);
raise_application_error (-20002, 'File handle is invalid.');
WHEN UTL_FILE.invalid_operation
THEN
UTL_FILE.fclose (v_file);
raise_application_error
(-20003,
'File could not be opened or operated on as requested.');
WHEN UTL_FILE.write_error
THEN
UTL_FILE.fclose (v_file);
raise_application_error
(-20005,
'Operating system error occurred during the write operation.');
WHEN UTL_FILE.file_open
THEN
UTL_FILE.fclose (v_file);
raise_application_error
(-20008,
'The requested operation failed because the file is open.');
WHEN UTL_FILE.invalid_maxlinesize
THEN
UTL_FILE.fclose (v_file);
raise_application_error
(-20009,
'The MAX_LINESIZE value for FOPEN() is invalid; it should '
|| 'be within the range 1 to 32767.');
COMMIT;
ROLLBACK TO data_extract;
WHEN OTHERS
THEN
raise_application_error (-20045, SQLERRM);
UTL_FILE.fclose (v_file);
END xxc_mod_068_ap_pr;
END xxc_mod_in_068_ap_to_fis_pkg;
Show Errors
Iam implemented BULK collect concept in programe,can anyone please suggest how can I imporve performance....
Thanks,
Rakesh

  CREATE OR REPLACE PACKAGE BODY "XXC"."XXC_MOD_IN_068_AP_TO_FIS_PKG"
AS
  PROCEDURE xxc_mod_068_ap_pr (
    p_errbuf                         OUT      VARCHAR2,
    p_retcode                        OUT      NUMBER,
    p_start_date                     IN       VARCHAR2,
    p_end_date                       IN       VARCHAR2
  IS
    -- Define variables and assign default values
    l_sucess_count                          NUMBER := 0;
    l_error_count                           NUMBER := 0;
    -- Standard declaration
    l_source                                VARCHAR2 (10);
    l_target                                VARCHAR2 (10);
    lc_module_description                   VARCHAR2 (50)
                                                 := 'MOD_IN_068 - AP to Fiscal';
    l_status                       CONSTANT VARCHAR2 (50) := 'NEW';
    p_status                                NUMBER;
    l_batch_id                              NUMBER;
    l_batch_id_next                         NUMBER
                                         := apps_common_out_batch_id_s1.NEXTVAL;
    l_proc_name                             VARCHAR2 (100) := 'XXC_MOD_IN_068';
    l_request_id                            NUMBER
                                                  := fnd_global.conc_request_id;
    l_audit_master_id                       NUMBER := NULL;
    l_mod_code                              VARCHAR2 (100);
    l_log_type                              NUMBER := 1;   --INFORMATION
    l_det_status_success                    NUMBER := 0;   --SUCCESS
    l_det_status_inprocess                  NUMBER := 3;   --INPROCESS
    l_det_status_rejected                   NUMBER := 4;   --REJECTED
    l_det_status_err                        NUMBER := 3;   --Error
    l_det_status_complete                   NUMBER := 9;   --COMPLETE
    -- Standard who Columns
    l_created_by                            NUMBER := fnd_global.user_id;
    l_creation_date                         DATE := SYSDATE;
    l_last_update_date                      DATE := SYSDATE;
    l_last_update_login                     NUMBER := fnd_global.user_id;
    v_file                                  UTL_FILE.file_type;
    l_location                              VARCHAR2 (150);
    l_archive_location                      VARCHAR2 (150);
    l_date                                  VARCHAR2 (50);
    l_filename                              VARCHAR2 (50);
    l_open_mode                             VARCHAR2 (1) := 'W';
--- l_max_linesize                          NUMBER := 32767;
    l_max_linesize                          VARCHAR2 (150); -- Updated 09-Nov-2012
    --Cursor is used to fetch valid records for the interface
    CURSOR get_ap_data_inv
    IS
      SELECT       asp.segment1 supplier_ref,
             -- asp.vendor_name supplier_name,
             replace(asp.vendor_name, ',', ' ') supplier_name,
             --aia.invoice_num invoice_number,
             replace(aia.invoice_num, ',','') invoice_number,
             aia.invoice_date,
             aia.invoice_amount amount,
             aia.doc_sequence_value unique_id,
             aia.creation_date date_invoice_entered,
             apsa.due_date date_invoice_paid,
             aia.SOURCE user_id,
             aia.payment_status_flag,
             aia.invoice_type_lookup_code doc_type,
             --aia.description,
             replace(aia.description, ',' , ' ') description,
             apsa.gross_amount
      FROM   ap_invoices_all aia,
             ap_suppliers asp,
             apps.ap_payment_schedules_all apsa
            -- apps.iby_payments_all iba,
        --     apps.iby_docs_payable_all dp
      WHERE  aia.invoice_id = apsa.invoice_id
      AND    aia.vendor_id  = asp.vendor_id
      AND    aia.org_id     = apsa.org_id
  --  AND    apsa.payment_status_flag != 'Y'   -- commented for CR
  --  AND    dp.payment_id = iba.payment_id(+)
  --  AND    aia.invoice_id = dp.calling_app_doc_unique_ref2(+)
  --  AND    apsa.due_date <= (SYSDATE + 1)
      AND    TRUNC (aia.creation_date)
               BETWEEN NVL (fnd_date.canonical_to_date (p_start_date),
                            TRUNC (aia.creation_date))
                   AND NVL (fnd_date.canonical_to_date (p_end_date),
                            TRUNC (aia.creation_date));
                                 TYPE xxc_tbl IS TABLE OF get_ap_data_inv%ROWTYPE;
                              xxc_tbl1 xxc_tbl;
  BEGIN
    l_batch_id                      := apps_common_out_batch_id_s1.CURRVAL;
    xxc_common_int_pk.insert_audit (p_batch_id                        => l_batch_id,
                                    p_request_id                      => l_request_id,
                                    p_source_system                   => l_source,
                                    p_proc_name                       => l_proc_name,
                                    p_log_type                        => l_log_type,
                                    p_det_status                      => l_det_status_inprocess,
                                    p_msg_code                        => NULL,
                                    p_entity                          => NULL,
                                    p_msg_desc                        => 'Process Starts',
                                    p_mast_request_id                 => l_request_id,
                                    p_record_id                       => NULL,
                                    p_source                          => l_source,
                                    p_target                          => l_target,
                                    p_email                           => NULL,
                                    p_mod_code                        => l_mod_code,
                                    p_audit_master_id                 => l_audit_master_id
-- Get Module Code
    BEGIN
      SELECT TRIM (fval.flex_value),
             TRIM (SUBSTR (fval.description,
                           1,
                           INSTR (fval.description, ' -')
      INTO   l_source,
             l_mod_code
      FROM   fnd_flex_values_vl fval, fnd_flex_value_sets vset
      WHERE  vset.flex_value_set_id = fval.flex_value_set_id
      AND    vset.flex_value_set_name IN ('XXC_COMM_INT_CONFIG')
      AND    fval.enabled_flag = 'Y'
      AND    fval.description = lc_module_description;
    EXCEPTION
      WHEN OTHERS
      THEN
        xxc_common_int_pk.insert_audit (p_batch_id                        => l_batch_id,
                                        p_request_id                      => l_request_id,
                                        p_source_system                   => l_source,
                                        p_proc_name                       => l_proc_name,
                                        p_log_type                        => l_log_type,
                                        p_det_status                      => l_det_status_err,
                                        p_msg_code                        => NULL,
                                        p_entity                          => NULL,
                                        p_msg_desc                        => 'Error Mode Code',
                                        p_mast_request_id                 => l_request_id,
                                        p_record_id                       => NULL,
                                        p_source                          => l_source,
                                        p_target                          => l_target,
                                        p_email                           => NULL,
                                        p_mod_code                        => l_mod_code,
                                        p_audit_master_id                 => l_audit_master_id
        raise_application_error (-20045, SQLERRM);
    END;
--File Location Path for OutPut File
    BEGIN
      SELECT fnd_profile.VALUE ('XXC_MOD_IN_068_AP_OUTBOUND'),
             fnd_profile.VALUE ('XXC_MOD_IN_068_AP_ARCHIVE')
      INTO   l_location,
             l_archive_location
      FROM   DUAL;
    EXCEPTION
      WHEN OTHERS
      THEN
        xxc_common_int_pk.insert_audit
                                      (p_batch_id                        => l_batch_id,
                                       p_request_id                      => l_request_id,
                                       p_source_system                   => l_source,
                                       p_proc_name                       => l_proc_name,
                                       p_log_type                        => l_log_type,
                                       p_det_status                      => l_det_status_rejected,
                                       p_msg_code                        => NULL,
                                       p_entity                          => NULL,
                                       p_msg_desc                        => 'Profile Value not found',
                                       p_mast_request_id                 => l_request_id,
                                       p_record_id                       => NULL,
                                       p_source                          => l_source,
                                       p_target                          => l_target,
                                       p_email                           => NULL,
                                       p_mod_code                        => l_mod_code,
                                       p_audit_master_id                 => l_audit_master_id
    END;
    BEGIN
      SELECT TO_CHAR (SYSDATE, 'YYYYMMDDhh24miss')
      INTO   l_date
      FROM   DUAL;
    EXCEPTION
      WHEN OTHERS
      THEN
        xxc_common_int_pk.insert_audit (p_batch_id                        => l_batch_id,
                                        p_request_id                      => l_request_id,
                                        p_source_system                   => l_source,
                                        p_proc_name                       => l_proc_name,
                                        p_log_type                        => l_log_type,
                                        p_det_status                      => l_det_status_rejected,
                                        p_msg_code                        => NULL,
                                        p_entity                          => NULL,
                                        p_msg_desc                        => 'status not found',
                                        p_mast_request_id                 => l_request_id,
                                        p_record_id                       => NULL,
                                        p_source                          => l_source,
                                        p_target                          => l_target,
                                        p_email                           => NULL,
                                        p_mod_code                        => l_mod_code,
                                        p_audit_master_id                 => l_audit_master_id
    END;
    l_filename                      := 'AP_Fiscal_' || l_date || '.csv';
    v_file                          :=
      UTL_FILE.fopen (LOCATION                          => l_location,
                      filename                          => l_filename,
                      open_mode                         => l_open_mode,
                      max_linesize                      => l_max_linesize
                       -- Changed as per Sarah's email on 9th Decemeber
    /* UTL_FILE.put_line (v_file,
                           'SUPPLIER_REF'
                        || ','
                        || 'SUPPLIER_NAME'
                        || ','
                        || 'INVOICE_NUMBER'
                        || ','
                        || 'INVOICE_DATE'
                        || ','
                        || 'AMOUNT'
                        || ','
                        || 'UNIQUE_ID'
                        || ','
                        || 'DATE_INVOICE_ENTERED'
                        || ','
                        || 'DATE_INVOICE_PAID'
                        || ','
                        || 'USER_ID'
                        || ','
                        || 'PAYMENT_STATUS_FLAG'
                        || ','
                        || 'DOC_TYPE'
                        || ','
                        || 'DESCRIPTION'
                        || ','
                        || 'PAYMENT_AMOUNT'
    UTL_FILE.put_line (v_file,
                          'SUPPLIERREF'
                       || ','
                       || 'SUPPLIERNAME'
                       || ','
                       || 'INVOICENUMBER'
                       || ','
                       || 'DATE'
                       || ','
                       || 'AMOUNT'
                       || ','
                       || 'UNIQUEID'
                       || ','
                       || 'DATEINVOICEENTERED'
                       || ','
                       || 'DATEINVOICEPAID'
                       || ','
                       || 'USERID'
                       || ','
                       || 'PAYMENTSTATUS'
                       || ','
                       || 'DOCTYPE'
                       || ','
                       || 'DESCRIPTION'
                       || ','
                       || 'PAYMENTAMOUNT');
    UTL_FILE.put_line (v_file,
                          'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX'
                       || ','
                       || 'XX');
                            open get_ap_data_inv;
                            loop
                            fetch get_ap_data_inv bulk collect into xxc_tbl1 limit 6000;
             fnd_file.put_line(fnd_file.log, 'Cursor Count is : '||xxc_tbl1.count);
                            for i in xxc_tbl1.first .. xxc_tbl1.count
    --FOR cur_rec IN get_ap_data_inv
    LOOP
      BEGIN
        --Common package used for proper sequence for Record_id and Bath_id
        l_sucess_count                  := l_sucess_count + 1;
        --Insert into CSV file
        fnd_file.put_line (fnd_file.LOG, 'Before Utl file');
        UTL_FILE.put_line (v_file,
                              xxc_tbl1(i).supplier_ref
                           || ','
                           || xxc_tbl1(i).supplier_name
                           || ','
                           || xxc_tbl1(i).invoice_number
                           || ','
                           || xxc_tbl1(i).invoice_date
                           || ','
                           || xxc_tbl1(i).amount
                           || ','
                           || xxc_tbl1(i).unique_id
                           || ','
                           ||  xxc_tbl1(i).date_invoice_entered
                           || ','
                           ||  xxc_tbl1(i).date_invoice_paid
                           || ','
                           ||  xxc_tbl1(i).user_id
                           || ','
                           ||  xxc_tbl1(i).payment_status_flag
                           || ','
                           ||  xxc_tbl1(i).doc_type
                           || ','
                           ||  xxc_tbl1(i).description
                           || ','
                           ||  xxc_tbl1(i).gross_amount);
        fnd_file.put_line (fnd_file.LOG,
                           'Supplier Reference : ' ||  xxc_tbl1(i).supplier_ref);
        xxc_common_int_pk.insert_audit
              (p_batch_id                        => l_batch_id,
               p_request_id                      => l_request_id,
               p_source_system                   => l_source,
               p_proc_name                       => l_proc_name,
               p_log_type                        => l_log_type,
               p_det_status                      => l_det_status_complete,
               p_msg_code                        => NULL,
               p_entity                          => NULL,
               p_msg_desc                        => 'Inserting records from AP to Fiscal Successfully',
               p_mast_request_id                 => l_request_id,
               p_record_id                       => NULL,
               p_source                          => l_source,
               p_target                          => l_target,
               p_email                           => NULL,
               p_mod_code                        => l_mod_code,
               p_audit_master_id                 => l_audit_master_id
      EXCEPTION
        WHEN OTHERS
        THEN
          l_error_count                   := l_error_count + 1;
          fnd_file.put_line (fnd_file.LOG,
                                'Error While Inserting from AP to Fiscal '
                             || SQLERRM);
             -- Create audit log for AP Inv records insert Exception
          --Insert into the Audit table XXC_COMM_AUDIT_DETAIL_LOG and XXC_COMM_AUDIT_MASTER_LOG
          xxc_common_int_pk.insert_audit
                       (p_batch_id                        => l_batch_id,
                        p_request_id                      => l_request_id,
                        p_source_system                   => l_source,
                        p_proc_name                       => l_proc_name,
                        p_log_type                        => l_log_type,
                        p_det_status                      => l_det_status_rejected,
                        p_msg_code                        => NULL,
                        p_entity                          => NULL,
                        p_msg_desc                        => 'Error While Inserting from AP to Fiscal',
                        p_mast_request_id                 => l_request_id,
                        p_record_id                       => NULL,
                        p_source                          => l_source,
                        p_target                          => l_target,
                        p_email                           => NULL,
                        p_mod_code                        => l_mod_code,
                        p_audit_master_id                 => l_audit_master_id
      END;
    END LOOP;
     exit when get_ap_data_inv%NOTFOUND;
    end loop;
     close get_ap_data_inv;
    UTL_FILE.fclose (v_file);
    UTL_FILE.fcopy (l_location,
                    l_filename,
                    l_archive_location,
                    l_filename
      -- Create audit log for Successfully processed records
    -- Procedure call to insert in Audit tables
    xxc_common_int_pk.insert_audit
                           (p_batch_id                        => l_batch_id,
                            p_request_id                      => l_request_id,
                            p_source_system                   => l_source,
                            p_proc_name                       => l_proc_name,
                            p_log_type                        => l_log_type,
                            p_det_status                      => l_det_status_complete,
                            p_msg_code                        => NULL,
                            p_entity                          => NULL,
                            p_msg_desc                        => 'Compeleted Sucessfully AP to Fiscal',
                            p_mast_request_id                 => l_request_id,
                            p_record_id                       => NULL,
                            p_source                          => l_source,
                            p_target                          => l_target,
                            p_email                           => NULL,
                            p_mod_code                        => l_mod_code,
                            p_audit_master_id                 => l_audit_master_id
    --Insert into the Audit table XXC_COMM_AUDIT_DETAIL_LOG and XXC_COMM_AUDIT_MASTER_LOG for populating email drop table
    BEGIN
      SELECT transaction_status
      INTO   p_status
      FROM   xxc_comm_audit_master_log
      WHERE  audit_master_id = l_audit_master_id;
    EXCEPTION
      WHEN OTHERS
      THEN
        xxc_common_int_pk.insert_audit (p_batch_id                        => l_batch_id,
                                        p_request_id                      => l_request_id,
                                        p_source_system                   => l_source,
                                        p_proc_name                       => l_proc_name,
                                        p_log_type                        => l_log_type,
                                        p_det_status                      => l_det_status_err,
                                        p_msg_code                        => NULL,
                                        p_entity                          => NULL,
                                        p_msg_desc                        => 'Status Error',
                                        p_mast_request_id                 => l_request_id,
                                        p_record_id                       => NULL,
                                        p_source                          => l_source,
                                        p_target                          => l_target,
                                        p_email                           => NULL,
                                        p_mod_code                        => l_mod_code,
                                        p_audit_master_id                 => l_audit_master_id
    END;
    IF p_status <> 0
    THEN
      xxc_comm_audit_log_pk.populate_email_drop_table (l_audit_master_id,
                                                       l_batch_id);
    END IF;
  EXCEPTION
    WHEN UTL_FILE.invalid_path
    THEN
      UTL_FILE.fclose (v_file);
      raise_application_error (-20000, 'File location is invalid.');
    WHEN UTL_FILE.invalid_mode
    THEN
      UTL_FILE.fclose (v_file);
      raise_application_error (-20001,
                               'The open_mode parameter in FOPEN is invalid.');
    WHEN UTL_FILE.invalid_filehandle
    THEN
      UTL_FILE.fclose (v_file);
      raise_application_error (-20002, 'File handle is invalid.');
    WHEN UTL_FILE.invalid_operation
    THEN
      UTL_FILE.fclose (v_file);
      raise_application_error
                       (-20003,
                        'File could not be opened or operated on as requested.');
    WHEN UTL_FILE.write_error
    THEN
      UTL_FILE.fclose (v_file);
      raise_application_error
                 (-20005,
                  'Operating system error occurred during the write operation.');
    WHEN UTL_FILE.file_open
    THEN
      UTL_FILE.fclose (v_file);
      raise_application_error
                    (-20008,
                     'The requested operation failed because the file is open.');
    WHEN UTL_FILE.invalid_maxlinesize
    THEN
      UTL_FILE.fclose (v_file);
      raise_application_error
                (-20009,
                    'The MAX_LINESIZE value for FOPEN() is invalid; it should '
                 || 'be within the range 1 to 32767.');
      COMMIT;
      ROLLBACK TO data_extract;
    WHEN OTHERS
    THEN
      raise_application_error (-20045, SQLERRM);
      UTL_FILE.fclose (v_file);
  END xxc_mod_068_ap_pr;
END xxc_mod_in_068_ap_to_fis_pkg;Please verify...

Similar Messages

  • Taking too much time for saving PO with line item more than 600

    HI
    We are trying to save PO with line items more than 600, but it is taking too much time to save. It is taking more than 1 hour to save the PO.
    Kindly let me know is there any restriction for no. of line items in the PO. Pls guide
    regards
    Sanjay

    Hi,
    I suggest you to do a trace (tcode ST05) to identify the bottleneck.
    You can know some reasons in Note 205005 - Performance composite note: Purchase order.
    I hope this helps you
    Regards
    Eduardo

  • JDBC adapter taking too much time for inserting

    we` have given a "update insert" query to be used in the JDBC adapter to insert these records into the database. Consists of 3 tables with 29fields in first, 4 fields in the other two.
    While message in XI gets processed in just 1-3 secs, the database processing time goes up to as much as 8 minutes for one record to get inserted.
    As immediate solution, is there any way we can have the JDBC adapter process these messages faster? These messages get queued up and hence all the other messages also get queued up delaying the other interfaces. We have a central adapter engine...
    Also is there any way we can get alert when the status is in "Processing/To be delivered/Delivering" and the message count exceeds a certain number say 1000

    I am using only one receiver JDBC channel
    We have been inserting three different table by using 3 different statemets tags(i.e) statement1(for table1),statement2(for table2),statement3(for table3).
    My structure is,
    <messagetype Name>
        <Statement1>
                 <tag1>
                          <action>UPDATE_INSERT</action>
                          <table>Table1</table>
                           <access>
                                        <field1>
                                         <field2>
                                          <field28>
                            <key>
                                   <MatNumber>
                 </tag1>
        </statement1>
       <Statement2>
                 <tag1>
                          <action>UPDATE_INSERT</action>
                          <table>Table2</table>
                           <access>
                                        <field1>
                                         <field2>
                                          <field4>
                            <key>
                                   <MatNumber>
                 </tag1>
        </statement2>
        <Statement3>
                 <tag3>
                         <action>UPDATE_INSERT</action>
                          <table>Table3</table>
                           <access>
                                        <field1>
                                         <field2>
                                          <field4>
                            <key>
                                   <MatNumber>
                 </tag3>
        </statement3>
    You can see we are also using key as well.In the first table we have 28 fields,second & third we are having 4.
    Edited by: rajesh shanmugasundaram on Jul 31, 2008 11:08 AM

  • Variable screen is taking too much time for some reports

    Hi all,
    We are using a sales billing cube for our billing reports . For one query , variable screen takes lot of time to come , i have in RSRT , i have generated the reoprt there and also executed the report there , it s fine there.Morever iam not using any customer exit variable for this.
    Can anybody suggets me whats is the exact problem;

    How I can improve further. Will it be good enough if I create Indexes on the columns for the temp table and try.or what If I use derived tables??
    I suggest you start with index tuning.  Specifically, make sure columns specified in the WHERE and JOIN columns are properly indexed (ideally clustered or covering, and unique when possible).  Changing outer joins to inner joins is appropriate
    if you don't need outer joins in the first place.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • Query is taking too much time for inserting into a temp table and for spooling

    Hi,
    I am working on a query optimization project where I have found a query which takes hell lot of time to execute.
    Temp table is defined as follows:
    DECLARE @CastSummary TABLE (CastID INT, SalesOrderID INT, ProductionOrderID INT, Actual FLOAT,
    ProductionOrderNo NVARCHAR(50), SalesOrderNo NVARCHAR(50), Customer NVARCHAR(MAX), Targets FLOAT)
    SELECT
    C.CastID,
    SO.SalesOrderID,
    PO.ProductionOrderID,
    F.CalculatedWeight,
    PO.ProductionOrderNo,
    SO.SalesOrderNo,
    SC.Name,
    SO.OrderQty
    FROM
    CastCast C
    JOIN Sales.Production PO ON PO.ProductionOrderID = C.ProductionOrderID
    join Sales.ProductionDetail d on d.ProductionOrderID = PO.ProductionOrderID
    LEFT JOIN Sales.SalesOrder SO ON d.SalesOrderID = SO.SalesOrderID
    LEFT JOIN FinishedGoods.Equipment F ON F.CastID = C.CastID
    JOIN Sales.Customer SC ON SC.CustomerID = SO.CustomerID
    WHERE
    (C.CreatedDate >= @StartDate AND C.CreatedDate < @EndDate)
    It takes almost 33% for Table Insert when I insert the data in a temp table and then 67% for Spooling. I had removed 2 LEFT joins and made it as JOIN from the above query and then tried. Query execution became bit fast. But still needs improvement.
    How I can improve further. Will it be good enough if I create Indexes on the columns for the temp table and try.or what If I use derived tables?? Please suggest.
    -Pep

    How I can improve further. Will it be good enough if I create Indexes on the columns for the temp table and try.or what If I use derived tables??
    I suggest you start with index tuning.  Specifically, make sure columns specified in the WHERE and JOIN columns are properly indexed (ideally clustered or covering, and unique when possible).  Changing outer joins to inner joins is appropriate
    if you don't need outer joins in the first place.
    Dan Guzman, SQL Server MVP, http://www.dbdelta.com

  • 0BBP_BPART_BUYID_ATTR Datasource taking too much time for full load

    Hello Gurus,
    This Data source is fetching 95000 records for five hours in full load. There is no Delta capability. When I run trace and try to see code, It has Oracle and MS SQL inxes but not DB2, and we are on DB2 database. Also all the fields are hidden except Business partner and Buyer ID. I didnot find any notes on this datasource.
    Did any one faced this issue, Help me how can I make this loading Faster in Daily Full loads.

    Hi,
    Divide the load using selections in different infopackages
    Thanks
    HP

  • SAP GUI taking too much time to open transactions

    Hi guys,
    i have done system copy from Production to Quality server completely.
    after that i started SAP on Quality server, it is taking too much time for opening SAP transactions (it is going in compilation mode).
    i started SGEN, but it is giving time_out errors. please help me on this issue.
    MY hardware details on quality server
    operating system : SuSE Linux 10 SP2
    Database : 10.2.0.2
    SAP : ECC 6.0  SR2
    RAM size : 8 GB
    Hard disk space : 500 GB
    swap space : 16 GB.
    regards
    Ramesh

    Hi,
    >i started SGEN, but it is giving time_out errors. please help me on this issue.
    You are supposed to run SGEN as a batch job and so, it should be possible  to get time out errors.
    I've seen Full SGEN lasting from 3 hours on high end systems up to 8 full days on PC hardware...
    Regards,
    Olivier

  • Spatial query with sdo_aggregate_union taking too much time

    Hello friends,
    the following query taking too much time for execution.
    table1 contains around 2000 records.
    table2 contains 124 rows
    SELECT
    table1.id
    , table1.txt
    , table1.id2
    , table1.acti
    , table1.acti
    , table1.geom as geom
    FROM
    table1
    WHERE
    sdo_relate
    table1.geom,
    select sdo_aggr_union(sdoaggrtype(geom, 0.0005))
    from table2
    ,'mask=(ANYINTERACT) querytype=window'
    )='TRUE'
    I am new in spatial. trying to find out list of geometry which is fall within geometry stored in table2.
    Thanks

    Hi Thanks lot for your reply.
    But It is not require to use sdo_aggregate function to find out whether geomatry in one table is in other geomatry..
    Let me give you clear picture....
    What I trying to do is, tale1 contains list of all station (station information) of state and table2 contains list of area of city. So I want to find out station which is belonging to city.
    For this I thought to get aggregation union of city area and then check for any interaction of that final aggregation result with station geometry to check whether it is in city or not.
    I hope this would help you to understand my query.
    Thanks
    I appreciate your efforts.

  • Filling aggregates is taking too much time

    Hello,
      Filling aggregates is taking too much time for around 17000 records & we have checked the cube consistancy in rsrv is everything is fine .
      how can i trace the problem .
    THanks in advance.
    Ravinder

    hi ravinder,
    can you tell me how many records are there in the cube at line item level.
    Regards
    Amar.

  • ACCTIT table Taking too much time

    Hi,
      In SE16: ACCTIT table i gave the G/L account no after that i executed in my production its taking too much time for to show the result.
    Thanku

    Hi,
    Here iam sending details of technical settings.
    Name                 ACCTIT                          Transparent Table
    Short text            Compressed Data from FI/CO Document
    Last Change        SAP              10.02.2005
    Status                 Active           Saved
    Data class         APPL1   Transaction data, transparent tables
    Size category      4       Data records expected: 24,000 to 89,000
    Thanku

  • Creative Cloud is taking too much time to load and is not downloading the one month trial for Photoshop I just paid money for.

    Creative Cloud is taking too much time to load and is not downloading the one month trial for Photoshop I just paid money for.

    stop the download if it's stalled, and restart your download.

  • Client import taking too much time

    hi all,
    i am importing a client , i it has complete copy table 19,803 of 19,803 but for last four hours its status is processing
    scc3
    Target Client           650
    Copy Type               Client Import Post-Proc
    Profile                 SAP_CUST
    Status                  Processing...
    User                    SAP*
    Start on                24.05.2009 / 15:08:03
    Last Entry on           24.05.2009 / 15:36:25
    Current Action:         Post Processing
    -  Last Exit Program    RGBCFL01
    Transport Requests
    - Client-Specific       PRDKT00004
    - Texts                 PRDKX00004
    Statistics for this Run
    - No. of Tables             19803 of     19803
    - Deleted Lines                 7
    - Copied Lines                  0
    sm50
    1 DIA 542           Running Yes             SAPLTHFB 650 SAP*     
    7 BGD 4172   Running Yes 11479  RGTBGD23 650 SAP* Sequential Read     D010INC
    sm66
    Server  No. Type PID Status  Reason Sem Start Error CPU Time   User Report   Action          Table
    prdsap_PRD_00  7  BTC 4172 Running   Yes    11711 SAP* RGTBGD23 Sequential Read D010INC
    plz guide me why it is taking too much time , while it has finished most of the things
    best regard
    Khan

    The import is in post processing. It digs through all the documents and adapts them to the new client. Most of the tables in the application area have a "MANDT" (= client) field which needs to be changed. Depending of the size of the client this can take a huge amount of time.
    You can try to improve the speed by updating the table statistics for table D010INC.
    Markus

  • Archive Delete job taking too much time - STXH Sequential Read

    Hello,
    We have been running Archive sessions in our production system in last couple of months. We use SARA and selecting the appropriate variants for WRITE, DELETE and STORAGE options.
    Currently we use the Archive object FI_DOCUMNT and the write job is finished as per the normal time (5 hrs based on the selection criteria). After that normally the delete job is used to complete in 1hr or less than 2hrs always (in last 3 months).
    But in last few days the delete job is taking too much to complete (around 8 - 10hrs) when I monitor the system found that the Sequential Read for table STXH is taking too much time to read and it seems this is the cause.
    Could you please provide a solution for the same, so that the job will run faster as earlier.
    Thanks for your time
    Shyl

    Hi Juan,
    After the statistics run the performance is quite good. Now the job getting finished as expected.
    Thanks. Problem solved
    Shyl

  • Simple APD is taking too much time in running

    Hi All,
    We have one APD created on our developement system which is taking too much time in running.
    This APD is fetching data from a Query having only 1200 records and directly putting into a master attribute.
    The Query is running fine in RSRT transaction and giving output within 5 seconds but in APD if I do display data over Query it is taking too much time.
    The APD is taking arrount 1.20 hours in running.
    Thanks in advance!!

    Hi,
    When a query runs in APD it normally takes much, much longer than it takes in RSRT. Run times such as what you are saying (5secs in RSRT and >1.5 hrs in APD) are quite normal; I've seen them in some of my queries running for several hours in APD as well.
    You just have to wait for it to complete.
    Regards,
    Suhas

  • Statspack taking too much time

    Hi
    when t try to execute
    exec perfstat.statspack.snap(i_snap_level=>10);it is taking too much time.....
    can anybody suggest me for the same....

    Excerpt from $ORACLE_HOME/rdbms/admin/spdoc.txt
    <p>
    Levels >= 10 Additional statistics: Parent and Child latches
    This level includes all statistics gathered in the lower levels, and
    additionally gathers Parent and Child Latch information. Data
    gathered at this level can sometimes cause the snapshot to take longer
    to complete i.e. this level can be resource intensive, and should
    only be used when advised by Oracle personnel.
    </p>

Maybe you are looking for

  • Problems with a free space on C: drive - Nokia N97

    Greetings to everyoneMy phone tells me that his C: drive is full and ask me to delete some data from his. Thats nice, but when i accessing C: drive (of phone) via PC suite or file manager on the phone i can't see any huge files on it. But memory desc

  • Where are the files saved in?

    Hello. This might look a silly question for you, but it's not for me, since I started using JNLP a couple hours ago. Well. I usually would give the users a JAR file or use a setup to put it in a specific folder. In my program, I have a database that'

  • I plug IPod into computer and it says it's charging

    I have no clue what I did. when I used to plug my IPod into the computer ITunes recognized it, then once it said "Do not disconnect" and I unplugged it and now ITunes never recognizes my Ipod and it says it's charging instead. Help, my computer is a

  • HT4113 CAnnot get past Apple ID Disabled. Even after resinking the i pad to the Mac. Yikes!

    I have resunk the ipad to teh mac. Updated software, itunes, etc. When I attempt to update applications on the Ipad continue to get Apple ID Disabled. Help!

  • Missing Codition Types at 2LIS_13_VDKON data source  in RSA3 Tcode.

    Dear All, i am getting problam with 2LIS_13_VDKON data source in RSA3 Tcode. When i am checking it, some condition types are missing. i checked it condition types are active also. and reloaded setup table. Still same problam is coming . please provid