The following lines contain the word 'select', 'insert', 'update' or 'delete':
PROCEDURE insert_1099_data
( p_calling_module IN varchar2,
p_sob_id IN number,
p_tax_entity_id IN number,
p_combined_flag IN varchar2,
p_start_date IN date,
p_end_date IN date,
p_vendor_id IN number,
p_query_driver IN varchar2,
p_min_reportable_flag IN varchar2,
p_federal_reportable_flag in varchar2,
p_region varchar2) is
l_chart_of_accounts_id number;
SELECT fnd.application_column_name, gl.chart_of_accounts_id
INTO l_app_column_name, l_chart_of_accounts_id
FROM fnd_segment_attribute_values fnd, gl_sets_of_books gl
WHERE segment_attribute_type = 'GL_BALANCING'
AND fnd.attribute_value = 'Y'
AND fnd.id_flex_code = 'GL#'
AND fnd.id_flex_num = gl.chart_of_accounts_id
AND gl.set_of_books_id = p_sob_id;
'INSERT INTO ap_1099_tape_data '
|| '(vendor_id,region_code,'
|| 'misc1,misc2,misc3,misc4,misc5,'
|| ' misc6,misc7,misc8,misc9,misc10,'
|| 'misc13, misc14, misc15aNT, misc15aT, misc15b,org_id) ' -- Bug 4946930
|| 'SELECT P.vendor_id,';
|| '( select AI.invoice_id , nvl(AIL1.amount+AI.invoice_amount , AI.invoice_amount) as netamount ' --Bug5943123
|| ' from ap_invoices_all AI, ( select AIL.invoice_id, SUM(AIL.amount) as amount '
|| ' FROM ap_invoice_lines_all AIL ' --Bug6064614
|| ' WHERE (nvl(AIL.invoice_includes_prepay_flag,''N'') = ''N'' ' --Bug6052333
|| ' AND (AIL.line_type_lookup_code = ''PREPAY'' '
|| ' OR (AIL.line_type_lookup_code =''TAX'' '
|| ' AND AIL.prepay_invoice_id IS NOT NULL '
|| ' AND AIL.prepay_line_number IS NOT NULL))) '
|| ' OR AIL.line_type_lookup_code = ''AWT'' '
|| ' GROUP by AIL.invoice_id ) AIL1 ' --Bug5943123
|| ' where AI.invoice_id = AIL1.invoice_id (+) ) INV_NET_AMT '
|| 'WHERE ID.income_tax_region = ITR.region_short_name (+) '
|| 'AND P.vendor_id=I.vendor_id '
|| 'AND AC.void_date is null ' --4480766
|| 'AND I.invoice_id=IP.invoice_id '
|| 'AND I.invoice_id=ID.invoice_id '
|| 'AND INV_NET_AMT.invoice_id = I.invoice_id '
|| 'AND IP.accounting_date BETWEEN '''|| p_start_date || ''' AND '''|| p_end_date || ''' '
|| 'AND ID.type_1099 is not null '
---- || 'AND AC.bank_account_id = ABA.bank_account_id ' Commeted this for bug 6275528 - as in ap_checks_all
---bank_account_id is not getting stamped in R12.bank_account_anme is there so we will use it.
--|| 'AND AC.bank_account_name = ABA.bank_account_name ' --added for bug 6275528 for the aobve explained reason.
-- Commented for Bug 6604204.
|| 'AND AC.ce_bank_acct_use_id = BAU.bank_acct_use_id ' -- Bug 6604204. Please refer bug for details.
|| 'AND BAU.bank_account_id = ABA.bank_account_id ' -- Bug 6604204. Please refer bug for details.
|| 'AND AC.org_id = mo_global.get_current_org_id ' --added for bug 6275528
|| 'AND IP.check_id = AC.check_id '
|| 'AND REL.tax_entity_id = ' || p_tax_entity_id|| ' '
|| 'AND CC.chart_of_accounts_id = ' || l_chart_of_accounts_id || ' ';
select count(*) into x from ap_1099_tape_data;
end insert_1099_data;