The following lines contain the word 'select', 'insert', 'update' or 'delete':
select distinct primary_ledger_id
into h_set_of_books_id
from GL_LEDGER_LE_V
where legal_entity_id = p_reporting_entity_id;
select set_of_books_id into h_set_of_books_id
from hr_operating_units
where organization_id = p_reporting_entity_id;
Select currency_code,
short_name,
alc_ledger_type_code,
chart_of_accounts_id
into h_currency_code,
h_book_short_name,
h_mrc_sob_type_code,
h_chart_of_acct_id
From GL_LEDGERS
where ledger_id = h_set_of_books_id;
SELECT nvl(sort_by_alternate_field,'N') --Bug 5591940
INTO h_sort_by_alternate
FROM AP_SYSTEM_PARAMETERS;
(Select DIST.INVOICE_ID
from AP_INVOICE_DISTS_MRC_V DIST,
GL_CODE_COMBINATIONS GC1
where AP_INV.INVOICE_ID =DIST.INVOICE_ID
and DIST.DIST_CODE_COMBINATION_ID = GC1.CODE_COMBINATION_ID (+)'
||l_dist_acct_range_where||'
'||l_dist_amount_range_where||'
'||l_acct_date_where||'
'||l_unapproved_inv_where||'
'||p_dist_org_where||'
'||')';
(Select DIST.INVOICE_ID
from AP_INVOICE_DISTRIBUTIONS_ALL DIST,
GL_CODE_COMBINATIONS GC1
where AP_INV.INVOICE_ID =DIST.INVOICE_ID
and DIST.DIST_CODE_COMBINATION_ID = GC1.CODE_COMBINATION_ID (+)'
||l_dist_acct_range_where||'
'||l_dist_amount_range_where||'
'||l_acct_date_where||'
'||l_unapproved_inv_where||'
'||p_dist_org_where||'
'||')';
'Select AP_INV.INVOICE_ID INVOICE_ID,
AP_INV.ACCTS_PAY_CODE_COMBINATION_ID LIABILITY_CCID,
AP_INV.INVOICE_TYPE_LOOKUP_CODE INVOICE_TYPE,
DIST.INVOICE_DISTRIBUTION_ID INVOICE_DISTRIBUTION_ID,
DIST.DISTRIBUTION_LINE_NUMBER DIST_NUMBER,
DIST.LINE_TYPE_LOOKUP_CODE DIST_TYPE, -- Originally LINE_TYPE,
DIST.DIST_CODE_COMBINATION_ID DISTRIBUTION_CCID,
-- Added for AP Invoice Line Project
DIST.ACCOUNTING_DATE DIST_ACCT_DATE, -- If necessary will join XLA tables
INV_LINE.LINE_NUMBER LINE_NUMBER,
INV_LINE.LINE_TYPE_LOOKUP_CODE LINE_TYPE
From '|| l_main_from ||'
Where AP_INV.VENDOR_ID = PO_PV.VENDOR_ID
-- and AP_INV.INVOICE_ID = DIST.INVOICE_ID (+) -- This condition is removed
-- Added for AP Invoice Line Project
AND AP_INV.INVOICE_ID = INV_LINE.INVOICE_ID (+)
AND INV_LINE.INVOICE_ID = DIST.INVOICE_ID (+)
AND INV_LINE.LINE_NUMBER = DIST.INVOICE_LINE_NUMBER (+)
-- End of addition
and GC1.CODE_COMBINATION_ID (+) = DIST.DIST_CODE_COMBINATION_ID
and GC2.CODE_COMBINATION_ID (+) = AP_INV.ACCTS_PAY_CODE_COMBINATION_ID
'||l_inv_type_where||'
' ||l_batch_id_where||'
' ||l_entry_person_where||'
' ||l_inv_type_where||'
' ||l_batch_id_where||'
' ||l_doc_seq_id_where||'
' ||l_doc_seq_value_where||'
' ||l_inv_currency_code_where||'
' ||l_supplier_where||'
' ||l_liability_range_where||'
' ||l_entered_date_where||'
' ||l_cancelled_where||'
' ||l_line_inv_where||'
' ||p_inv_org_where||'
' ||p_line_org_where||'
' ||p_dist_org_where||'
ORDER BY ap_inv.invoice_currency_code,
ap_inv.batch_id,
decode(:c_sort_by_alternate, ''Y'', upper(po_pv.vendor_name_alt), upper(po_pv.vendor_name)),
ap_inv.invoice_num,
dist.distribution_line_number';
/* Insert to JG_ZZ_AP_IR_REP_ITF */
Insert into JG_ZZ_AP_IR_REP_ITF (
REQUEST_ID,
CREATED_BY,
CREATION_DATE,
LAST_UPDATE_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_LOGIN,
FUNCTIONAL_CURRENCY_CODE,
ORGANIZATION_NAME,
INVOICE_ID,
LIABILITY_CCID,
LIABILITY_ACCOUNT,
LIABILITY_DESC,
LIABILITY_NATACC,
LIABILITY_NATACC_DESC,
INVOICE_TYPE,
INVOICE_DISTRIBUTION_ID,
LINE_NUMBER,
LINE_TYPE,
DIST_NUMBER, -- Newly Added
DIST_TYPE, -- Newly Added
ACCOUNTING_DATE, -- Newly Added
DISTRIBUTION_CCID,
DISTRIBUTION_ACCOUNT,
DISTRIBUTION_ACCOUNT_DESC,
DISTRIBUTION_NATACC,
DISTRIBUTION_NATACC_DESC
)
values (
p_request_id,
p_login_id,
sysdate,
sysdate,
p_login_id,
1,
h_currency_code,
h_book_short_name,
h_invoice_id,
h_liability_ccid,
h_liability_acct,
h_liability_desc,
h_liability_natacct,
h_liability_natdesc,
h_invoice_type,
h_inv_dist_id,
h_line_number,
h_line_type,
h_dist_number, -- Newly Added
h_dist_type, -- Newly Added
h_dist_acct_date, -- Newly Added
h_dist_ccid,
h_dist_acct,
h_dist_desc,
h_dist_natacct,
h_dist_natdesc
);
fa_rx_util_pkg.debug('Inserted invoice_id: '||h_invoice_id||' inv_dist_id : '||h_inv_dist_id);