The following lines contain the word 'select', 'insert', 'update' or 'delete':
SELECT COUNT(*)
INTO l_cnt
FROM ar_trx_salescredits_gt
WHERE trx_line_id = (
SELECT trx_line_id
FROM ar_trx_lines_gt
WHERE customer_trx_line_id = p_cust_trx_line_id);
'N', -- p_delete_scredits_first_flag
'N', -- p_run_autoaccounting_flag
l_status1 );
PROCEDURE INSERT_TRX_HEADER (
ar_trx_header_rec IN ar_trx_header_gt%rowtype,
p_batch_id IN NUMBER DEFAULT NULL,
x_errmsg OUT NOCOPY VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2)
IS
l_ct_reference ra_customer_trx.ct_reference%type;
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.INSERT_TRX_HEADER(+)' );
ar_invoice_utils.debug ('Before calling AR_TRX_BULK_PROCESS_HEADER.insert_row (+)' );
AR_TRX_BULK_PROCESS_HEADER.insert_row(
p_trx_header_id => ar_trx_header_rec.trx_header_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status);
ar_invoice_utils.debug ('Before calling AR_TRX_BULK_PROCESS_HEADER.insert_row (-)' );
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.INSERT_TRX_HEADER(-)' );
x_errmsg := 'Error in AR_INVOICE_TABLE_HANDLER.INSERT_TRX_HEADER '||sqlerrm;
PROCEDURE INSERT_TRX_LINES (
ar_trx_lines_rec IN ar_trx_lines_gt%rowtype,
p_cust_trx_id IN NUMBER,
p_batch_id NUMBER DEFAULT NULL,
x_errmsg OUT NOCOPY VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2) IS
BEGIN
IF pg_debug = 'Y'
THEN
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.INSERT_TRX_LINES(+)' );
AR_TRX_BULK_PROCESS_LINES.insert_row(
p_trx_header_id => ar_trx_lines_rec.trx_header_id,
p_trx_line_id => ar_trx_lines_rec.trx_line_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status );
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.INSERT_TRX_LINES(-)' );
x_errmsg := 'Error in AR_INVOICE_TABLE_HANDLER.INSERT_TRX_LINES '||sqlerrm;
PROCEDURE INSERT_TRX_DIST (
p_trx_dist_id IN NUMBER DEFAULT NULL,
p_batch_id IN NUMBER DEFAULT NULL,
x_errmsg OUT NOCOPY VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2) IS
BEGIN
IF pg_debug = 'Y'
THEN
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.INSERT_TRX_DIST(+)' );
AR_TRX_BULK_PROCESS_DIST.INSERT_ROW (
p_trx_dist_id => p_trx_dist_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status );
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.INSERT_TRX_DIST(-)' );
x_errmsg := 'Error in AR_INVOICE_TABLE_HANDLER.INSERT_TRX_DIST '||sqlerrm;
END INSERT_TRX_DIST;
PROCEDURE INSERT_TRX_SALESCR (
p_trx_salescredit_id IN NUMBER DEFAULT NULL,
p_batch_id IN NUMBER DEFAULT NULL,
x_errmsg OUT NOCOPY VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2) IS
BEGIN
IF pg_debug = 'Y'
THEN
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.INSERT_SALESCR(+)' );
UPDATE ar_trx_salescredits_gt
SET request_id = -(p_batch_id);
AR_TRX_BULK_PROCESS_SALESCR.INSERT_ROW (
p_trx_salescredit_id => p_trx_salescredit_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status );
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.INSERT_SALESCR(-)' );
x_errmsg := 'Error in AR_INVOICE_TABLE_HANDLER.INSERT_TRX_SALESCR '||sqlerrm;
END INSERT_TRX_SALESCR;
INSERT INTO RA_BATCHES
(
CREATED_BY,
CREATION_DATE,
LAST_UPDATED_BY,
LAST_UPDATE_DATE,
LAST_UPDATE_LOGIN,
PROGRAM_APPLICATION_ID,
PROGRAM_ID,
PROGRAM_UPDATE_DATE,
BATCH_ID,
request_id,
NAME,
BATCH_DATE,
GL_DATE,
TYPE,
BATCH_SOURCE_ID,
SET_OF_BOOKS_ID
,org_id
)
values (
fnd_global.user_id,
sysdate,
fnd_global.user_id,
sysdate,
fnd_global.login_id,
fnd_global.prog_appl_id,
null,
sysdate,
RA_BATCHES_S.NEXTVAL,
-(RA_BATCHES_S.currval),
'AR_INVOICE_API'||'_'||RA_BATCHES_S.currval,
sysdate,
trunc(nvl(p_batch_source_rec.default_date,trunc(sysdate))),
'INV',
nvl(p_batch_source_rec.batch_source_id, p_trx_profile_rec.ar_ra_batch_source),
p_trx_system_parameters_rec.set_of_books_id
,arp_standard.sysparm.org_id)
returning batch_id INTO p_batch_id;
INSERT INTO ar_trx_errors_gt (
trx_header_id,
trx_line_id,
trx_dist_id,
trx_salescredit_id,
error_message,
invalid_value)
VALUES
( p_trx_header_id,
p_trx_line_id,
p_trx_dist_id,
p_trx_salescredit_id,
p_error_message,
p_invalid_value);
delete from ra_customer_trx where customer_trx_id = p_customer_trx_id;
delete from ra_customer_trx_lines where customer_trx_id = p_customer_trx_id;
delete from ra_cust_trx_line_gl_dist where customer_trx_id = p_customer_trx_id;
delete from ar_payment_schedules where customer_trx_id = p_customer_trx_id;
delete from RA_CUST_TRX_LINE_SALESREPS where customer_trx_id = p_customer_trx_id;
SELECT ct.customer_trx_id
FROM ra_customer_trx ct
WHERE
EXISTS (SELECT 'error'
FROM ar_trx_errors_gt err,
ar_trx_header_gt head
WHERE err.trx_header_id = head.trx_header_id
AND head.customer_trx_id = ct.customer_trx_id);
/* Delete everything else */
delete from ra_customer_trx
where customer_trx_id in (
select distinct th.customer_trx_id
from ar_trx_errors_gt err,
ar_trx_header_gt th
where err.trx_header_id = th.trx_header_id);
delete from ra_customer_trx_lines
where customer_trx_id in (
select distinct th.customer_trx_id
from ar_trx_errors_gt err,
ar_trx_header_gt th
where err.trx_header_id = th.trx_header_id);
delete from ra_cust_trx_line_gl_dist
where customer_trx_id in (
select distinct th.customer_trx_id
from ar_trx_errors_gt err,
ar_trx_header_gt th
where err.trx_header_id = th.trx_header_id);
delete from ar_payment_schedules
where customer_trx_id in (
select distinct th.customer_trx_id
from ar_trx_errors_gt err,
ar_trx_header_gt th
where err.trx_header_id = th.trx_header_id);
delete from RA_CUST_TRX_LINE_SALESREPS
where customer_trx_id in (
select distinct th.customer_trx_id
from ar_trx_errors_gt err,
ar_trx_header_gt th
where err.trx_header_id = th.trx_header_id);
PROCEDURE INSERT_ROW(
p_trx_system_parameters_rec IN AR_INVOICE_DEFAULT_PVT.trx_system_parameters_rec_type,
p_trx_profile_rec IN AR_INVOICE_DEFAULT_PVT.trx_profile_rec_type,
p_batch_source_rec IN AR_INVOICE_API_PUB.batch_source_rec_type,
x_errmsg OUT NOCOPY VARCHAR2,
x_return_status OUT NOCOPY VARCHAR2) AS
l_cust_trx_id NUMBER;
SELECT * FROM ar_trx_header_gt gt
WHERE NOT EXISTS ( SELECT 'X' FROM
ar_trx_errors_gt err
WHERE err.trx_header_id = gt.trx_header_id);
SELECT * FROM ar_trx_lines_gt gt
WHERE trx_header_id = l_trx_header_id
order by trx_header_id, trx_line_id, line_number;
SELECT * FROM ar_trx_dist_gt
where trx_header_id = l_trx_header_id
AND account_class = 'REC'
AND process_flag = 'N';
ar_invoice_utils.debug ('AR_INVOICE_TABLE_HANDLER.insert_row(+)' );
ar_invoice_utils.debug ('calling insert_trx_header (+)' );
insert_trx_header ( ar_trx_header_rec => ar_trx_header_rec,
p_batch_id => l_batch_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status);
ar_invoice_utils.debug ('calling insert_trx_header (-)' );
/* 5921925 - Do not call insert unless there were dists rows */
IF ar_invoice_api_pub.g_dist_exist
THEN
BEGIN
FOR ar_trx_dist_rec IN ar_trx_dist_c
LOOP
INSERT_TRX_DIST(
p_trx_dist_id => ar_trx_dist_rec.trx_dist_id,
p_batch_id => l_batch_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status);
ar_invoice_utils.debug ('Calling insert_trx_lines (+)' );
insert_trx_lines(ar_trx_lines_rec => ar_trx_lines_rec,
p_cust_trx_id => l_cust_trx_id,
p_batch_id => l_batch_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status);
ar_invoice_utils.debug ('Calling insert_trx_lines (-)' );
arp_process_tax.after_insert_line */
IF ar_trx_lines_rec.line_type = 'FREIGHT' THEN
BEGIN
/* Changes for Bug 5398561 starts. */
DECLARE
lv_ship_via ar_trx_header_gt.ship_via%type;
select ship_via, ship_date_actual
into lv_ship_via, lv_ship_dt_actual
from ar_trx_header_gt
where customer_trx_id = l_cust_trx_id;
select ship_via
into lv_ship_via
from ar_trx_header_gt
where customer_trx_id = l_cust_trx_id;
arp_process_header.update_header_freight_cover(
'AR_INVOICE_API',
1,
l_cust_trx_id,
'INV',
null,
ar_trx_lines_rec.ship_via,
ar_trx_lines_rec.ship_date_actual,
ar_trx_lines_rec.waybill_number,
ar_trx_lines_rec.fob_point,
l_status);
'arp_process_header.update_header_freight_cover '
|| 'raised unexpected error!';
INSERT_TRX_DIST( p_trx_dist_id => null,
p_batch_id => l_batch_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status );
INSERT_TRX_SALESCR ( p_trx_salescredit_id => null,
p_batch_id => l_batch_id,
x_errmsg => x_errmsg,
x_return_status => x_return_status );
arp_util.debug('EXCEPTION: ar_invoice_table_handler.insert_row()');
INSERT INTO ar_trx_errors_gt (
trx_header_id,
error_message)
VALUES
( ar_trx_header_rec.trx_header_id,
x_errmsg);
ar_invoice_utils.debug ('Insert_row(-)' );
END INSERT_ROW;