DBA Data[Home] [Help]

APPS.AR_AUTOREM_API SQL Statements

The following lines contain the word 'select', 'insert', 'update' or 'delete':

Line: 125

             l_last_updated_by         NUMBER;
Line: 127

             l_last_update_login       NUMBER;
Line: 225

       l_last_updated_by := arp_standard.profile.user_id ;
Line: 227

       l_last_update_login := arp_standard.profile.last_update_login ;
Line: 238

   fnd_file.put_line(FND_FILE.LOG,  'value  l_last_updated_by ' || l_last_updated_by);
Line: 240

   fnd_file.put_line(FND_FILE.LOG,  'value  l_last_update_login'|| l_last_update_login);
Line: 259

 create_and_update_remit_rec_pa(
          p_batch_id      => o_batch_id,
          p_return_status => cr_return_status
                              );
Line: 280

   select count(*)
   INTO l_count
   from AR_CASH_RECEIPTS
   where selected_remittance_batch_id = p_batch_id;
Line: 327

      select batch_date ,gl_date , remit_method_code, currency_code,
             receipt_method_id, REMITTANCE_BANK_BRANCH_ID,REMIT_BANK_ACCT_USE_ID
      into  l_batch_date,l_gl_date,l_remittance_method,l_currency_code,
            l_receipt_method_id,l_remittance_bank_branch_id,l_remittance_bank_account_id
      from  AR_BATCHES
      where batch_id = p_batch_id;
Line: 359

/* insert batch */

    insert_batch(
       l_batch_date,
       l_gl_date,
       l_approve_flag,
       l_format_flag,
       l_currency_code,
       l_remittance_method,
       l_receipt_class_id,
       l_receipt_method_id,
       l_remittance_bank_branch_id,
       l_remittance_bank_account_id,
       p_remit_bank_deposit_number,
       o_batch_id
      );
Line: 376

/* select and update receipt */

if l_receipt_method_id is not null then /* bug7173199: subsituted p_payment_method_id with l_receipt_method_id*/
           select rm.payment_channel_code,b.set_of_books_id
             into  p_payment_type_code, p_sob_id
             from  ar_receipt_methods rm,
                   ar_batches b
             where rm.receipt_method_id = l_receipt_method_id /* bug7173199: subsituted p_payment_method_id with l_receipt_method_id*/
             and   b.receipt_method_id = rm.receipt_method_id
             and   b.batch_id = o_batch_id;
Line: 388

           select b.set_of_books_id
             into  p_sob_id
             from  ar_batches b
             where b.batch_id = o_batch_id;
Line: 396

                          select_update_rec(
                                p_customer_number_l=> p_customer_number_l,
                                p_customer_number_h=>  p_customer_number_h,
                                p_customer_name_l=> p_customer_name_l,
                                p_customer_name_h=>  p_customer_name_h,
                                p_doc_num_l=> p_doc_num_l,
                                p_doc_num_h=>  p_doc_num_h,
                                p_trx_date_l=> fnd_date.canonical_to_date(p_trx_date_l),
                                p_trx_date_h=> fnd_date.canonical_to_date(p_trx_date_h),
                                p_due_date_l=> fnd_date.canonical_to_date(p_due_date_l),
                                p_due_date_h=> fnd_date.canonical_to_date(p_due_date_h),
                                p_trx_num_l=> p_trx_num_l,
                                p_trx_num_h=> p_trx_num_h,
                                p_remittance_total_to=> p_remittance_total_to,
                                p_remittance_total_from=> p_remittance_total_from,
                                p_batch_id=>  o_batch_id ,
                                p_receipt_method_id=>  l_receipt_method_id ,
                                p_currency_code=> p_batch_currency,
                                p_payment_type_code=> p_payment_type_code,
                                p_sob_id=>  p_sob_id ,
                                p_remit_method_code=> p_remit_method_code,
                                p_remit_bank_account_id=>  l_remittance_bank_account_id ,
                                p_return_status=>l_return_status);
Line: 431

/* CALL TO INSERT BATCH FROM MAIN */

    insert_batch(
       l_batch_date,
       l_gl_date,
       l_approve_flag,
       l_format_flag,
       l_currency_code,
       l_remittance_method,
       l_receipt_class_id,
       l_receipt_method_id,
       l_remittance_bank_branch_id,
       l_remittance_bank_account_id,
       p_remit_bank_deposit_number,
       o_batch_id
      );
Line: 450

/* CALL TO select_and_update receipts */

if l_receipt_method_id is not null then /* bug7173199: subsituted p_payment_method_id with l_receipt_method_id*/
             select rm.payment_channel_code,b.set_of_books_id
             into  p_payment_type_code, p_sob_id
             from  ar_receipt_methods rm,
                   ar_batches b
             where rm.receipt_method_id = l_receipt_method_id /* bug7173199: subsituted p_payment_method_id with l_receipt_method_id*/
             and   b.receipt_method_id = rm.receipt_method_id
             and   b.batch_id = o_batch_id;
Line: 462

           select b.set_of_books_id
             into  p_sob_id
             from  ar_batches b
             where b.batch_id = o_batch_id;
Line: 470

                          select_update_rec(
                                p_customer_number_l=> p_customer_number_l,
                                p_customer_number_h=>  p_customer_number_h,
                                p_customer_name_l=> p_customer_name_l,
                                p_customer_name_h=>  p_customer_name_h,
                                p_doc_num_l=> p_doc_num_l,
                                p_doc_num_h=>  p_doc_num_h,
                                p_trx_date_l=> fnd_date.canonical_to_date(p_trx_date_l),
                                p_trx_date_h=> fnd_date.canonical_to_date(p_trx_date_h),
                                p_due_date_l=> fnd_date.canonical_to_date(p_due_date_l),
                                p_due_date_h=> fnd_date.canonical_to_date(p_due_date_h),
                                p_trx_num_l=> p_trx_num_l,
                                p_trx_num_h=> p_trx_num_h,
                                p_remittance_total_to=> p_remittance_total_to,
                                p_remittance_total_from=> p_remittance_total_from,
                                p_batch_id=>  o_batch_id ,
                                p_receipt_method_id=>  l_receipt_method_id ,
                                p_currency_code=> p_batch_currency,
                                p_payment_type_code=> p_payment_type_code,
                                p_sob_id=>  p_sob_id ,
                                p_remit_method_code=> p_remit_method_code,
                                p_remit_bank_account_id=>  l_remittance_bank_account_id ,
                                p_return_status=>l_return_status);
Line: 495

/* CALL TO CREATE AND UPDATE REM RECEIPTS */


 IF PG_DEBUG in ('Y','C') THEN
   fnd_file.put_line(FND_FILE.LOG,  'value of o_batch_id  bef call to create remit rec ' || to_char(o_batch_id));
Line: 504

 create_and_update_remit_rec(
          p_batch_id      => o_batch_id,
          p_return_status => cr_return_status
                              );
Line: 546

            select rm.payment_channel_code,b.set_of_books_id
             into  p_payment_type_code, p_sob_id
             from  ar_receipt_methods rm,
                   ar_batches b
             where b.receipt_method_id = rm.receipt_method_id
             and   b.batch_id = o_batch_id;
Line: 554

           select b.set_of_books_id
             into  p_sob_id
             from  ar_batches b
             where b.batch_id = o_batch_id;
Line: 562

                          select_update_rec(
                                p_customer_number_l=> p_customer_number_l,
                                p_customer_number_h=>  p_customer_number_h,
                                p_customer_name_l=> p_customer_name_l,
                                p_customer_name_h=>  p_customer_name_h,
                                p_doc_num_l=> p_doc_num_l,
                                p_doc_num_h=>  p_doc_num_h,
                                p_trx_date_l=> fnd_date.canonical_to_date(p_trx_date_l),
                                p_trx_date_h=> fnd_date.canonical_to_date(p_trx_date_h),
                                p_due_date_l=> fnd_date.canonical_to_date(p_due_date_l),
                                p_due_date_h=> fnd_date.canonical_to_date(p_due_date_h),
                                p_trx_num_l=> p_trx_num_l,
                                p_trx_num_h=> p_trx_num_h,
                                p_remittance_total_to=> p_remittance_total_to,
                                p_remittance_total_from=> p_remittance_total_from,
                                p_batch_id=>  o_batch_id ,
                                p_receipt_method_id=>  l_receipt_method_id ,
                                p_currency_code=> l_currency_code,
                                p_payment_type_code=> p_payment_type_code,
                                p_sob_id=>  p_sob_id ,
                                p_remit_method_code=> l_remittance_method,
                                p_remit_bank_account_id=>  l_remittance_bank_account_id ,
                                p_return_status=>l_return_status);
Line: 599

   fnd_file.put_line(FND_FILE.LOG,  'value of o_batch_id  bef call to select update rec ' || to_char(o_batch_id));
Line: 604

            select rm.payment_channel_code,b.set_of_books_id
             into  p_payment_type_code, p_sob_id
             from  ar_receipt_methods rm,
                   ar_batches b
             where b.receipt_method_id = rm.receipt_method_id
             and   b.batch_id = o_batch_id;
Line: 612

           select b.set_of_books_id
             into  p_sob_id
             from  ar_batches b
             where b.batch_id = o_batch_id;
Line: 619

                          select_update_rec(
                                p_customer_number_l=> p_customer_number_l,
                                p_customer_number_h=>  p_customer_number_h,
                                p_customer_name_l=> p_customer_name_l,
                                p_customer_name_h=>  p_customer_name_h,
                                p_doc_num_l=> p_doc_num_l,
                                p_doc_num_h=>  p_doc_num_h,
                                p_trx_date_l=> fnd_date.canonical_to_date(p_trx_date_l),
                                p_trx_date_h=> fnd_date.canonical_to_date(p_trx_date_h),
                                p_due_date_l=> fnd_date.canonical_to_date(p_due_date_l),
                                p_due_date_h=> fnd_date.canonical_to_date(p_due_date_h),
                                p_trx_num_l=> p_trx_num_l,
                                p_trx_num_h=> p_trx_num_h,
                                p_remittance_total_to=> p_remittance_total_to,
                                p_remittance_total_from=> p_remittance_total_from,
                                p_batch_id=>  o_batch_id ,
                                p_receipt_method_id=>  l_receipt_method_id ,
                                p_currency_code=> l_currency_code,
                                p_payment_type_code=> p_payment_type_code,
                                p_sob_id=>  p_sob_id ,
                                p_remit_method_code=> l_remittance_method,
                                p_remit_bank_account_id=>  l_remittance_bank_account_id ,
                                p_return_status=>l_return_status);
Line: 655

 create_and_update_remit_rec(
          p_batch_id      => o_batch_id,
          p_return_status => cr_return_status
                              );
Line: 695

 create_and_update_remit_rec(
          p_batch_id      => o_batch_id,
          p_return_status => cr_return_status
                              );
Line: 725

   fnd_file.put_line(FND_FILE.LOG,'reset selected_remittance_batch_id for all receipts after approval');
Line: 727

   update ar_cash_receipts
   set selected_remittance_batch_id = null
   where selected_remittance_batch_id = o_batch_id
   and cash_receipt_id in (select cash_receipt_id from
                       ar_cash_receipt_history
                       where request_id = l_request_id
                       and status = 'REMITTED'
                       and current_record_flag = 'Y');
Line: 736

   fnd_file.put_line(FND_FILE.LOG,'selected_remittance_batch_id reset for rows: '||sql%rowcount);
Line: 741

/* CALL TO REC_RESET to delete bad rows */

IF G_ERROR = 'Y'  THEN

        fnd_file.put_line( FND_FILE.LOG, 'CALLING REC_RESET');
Line: 751

/* Bug 5051186  Update the Batch Status  */
IF TOTAL_WORKERS < 1 THEN
       IF   l_format_flag = 'Y' THEN
            l_batch_applied_status := 'COMPLETED_FORMAT';
Line: 761

       /*bug 7352164 update control count and control amount */
       IF p_create_only = 'Y' THEN
           SELECT
             nvl(sum(cr.amount),0),
             count(*) into
             l_control_amount,
             l_control_count
           FROM    ar_cash_receipts cr
           WHERE   cr.selected_remittance_batch_id = o_batch_id;
Line: 771

           update ar_batches
               SET batch_applied_status =  l_batch_applied_status,
                   control_count = l_control_count,
                   control_amount= l_control_amount
               where batch_id = o_batch_id;
Line: 778

           SELECT
             nvl(sum(crh.amount),0),
             count(*) into
             l_control_amount,
             l_control_count
           FROM    ar_cash_receipt_history crh
           WHERE   crh.batch_id = o_batch_id
           AND     crh.status = 'REMITTED'
           AND     crh.current_record_flag = 'Y';
Line: 788

           update ar_batches
               SET batch_applied_status =  l_batch_applied_status,
                   control_count = l_control_count,
                   control_amount= l_control_amount
               where batch_id = o_batch_id;
Line: 794

        /* No need to update counts if the batch is submitted for format only */
            update ar_batches
               SET batch_applied_status =  l_batch_applied_status
               where batch_id = o_batch_id;
Line: 824

                SELECT PC.INSTRUMENT_TYPE INTO l_instrument_type
                FROM   AR_RECEIPT_METHODS RM, IBY_FNDCPT_PMT_CHNNLS_B PC
                WHERE  RECEIPT_METHOD_ID = l_receipt_method_id
                AND    RM.PAYMENT_CHANNEL_CODE = PC.PAYMENT_CHANNEL_CODE;
Line: 1114

      SELECT batch_applied_status
      INTO l_batch_applied_status
      FROM ar_batches
      WHERE batch_id = p_batch_id;
Line: 1154

	      insert_batch( l_batch_date,
				    l_gl_date,
				    l_approve_flag,
				    l_format_flag,
				    l_currency_code,
				    l_remittance_method,
				    l_receipt_class_id,
				    l_receipt_method_id,
				    l_remittance_bank_branch_id,
				    l_remittance_bank_account_id,
				    p_remit_bank_deposit_number,
				    o_batch_id
				    );
Line: 1168

           select rm.payment_channel_code,b.set_of_books_id
             into  p_payment_type_code, p_sob_id
             from  ar_receipt_methods rm,
                   ar_batches b
             where rm.receipt_method_id = p_payment_method_id
             and   b.receipt_method_id = rm.receipt_method_id
             and   b.batch_id = o_batch_id;
Line: 1177

           select b.set_of_books_id
             into  p_sob_id
             from  ar_batches b
             where b.batch_id = o_batch_id;
Line: 1182

                          select_update_rec(
                                p_customer_number_l=> p_customer_number_l,
                                p_customer_number_h=>  p_customer_number_h,
                                p_customer_name_l=> p_customer_name_l,
                                p_customer_name_h=>  p_customer_name_h,
                                p_doc_num_l=> p_doc_num_l,
                                p_doc_num_h=>  p_doc_num_h,
                                p_trx_date_l=> fnd_date.canonical_to_date(p_trx_date_l),
                                p_trx_date_h=> fnd_date.canonical_to_date(p_trx_date_h),
                                p_due_date_l=> fnd_date.canonical_to_date(p_due_date_l),
                                p_due_date_h=> fnd_date.canonical_to_date(p_due_date_h),
                                p_trx_num_l=> p_trx_num_l,
                                p_trx_num_h=> p_trx_num_h,
                                p_remittance_total_to=> p_remittance_total_to,
                                p_remittance_total_from=> p_remittance_total_from,
                                p_batch_id=>  o_batch_id ,
                                p_receipt_method_id=>  l_receipt_method_id ,
                                p_currency_code=> p_batch_currency,
                                p_payment_type_code=> p_payment_type_code,
                                p_sob_id=>  p_sob_id ,
                                p_remit_method_code=> p_remit_method_code,
                                p_remit_bank_account_id=>  l_remittance_bank_account_id ,
                                p_return_status=>l_return_status);
Line: 1219

	insert_exceptions( p_batch_id => -333,
			  p_request_id =>l_request_id,
			  p_exception_code => 'NO_BATCH',
			  p_additional_message => 'Error during inserting the
batch' );
Line: 1234

   select count(*)
   INTO l_count
   from AR_CASH_RECEIPTS
   where selected_remittance_batch_id = o_batch_id;
Line: 1243

    SELECT org_id
    INTO l_org_id
    FROM ar_system_parameters;
Line: 1249

        l_ins_stmt := 'INSERT  /*+ append */ INTO ar_autorem_interim ';
Line: 1251

        l_ins_stmt := 'INSERT INTO ar_autorem_interim ';
Line: 1287

                'SELECT
/*+ leading(gtt,crh) cardinality(gtt 1000) swap_join_inputs(bat) use_hash(bat) parallel(gtt) parallel(crh) use_nl(crh,cr,hca,party,ps,d) index(cr AR_CASH_RECEIPTS_U1) */';
Line: 1291

                'SELECT
/*+ leading(gtt,crh) cardinality(gtt 1000) swap_join_inputs(bat) use_hash(bat) use_nl(crh,cr,hca,party,ps,d) */';
Line: 1326

            cr.selected_remittance_batch_id,
            --MOD(cr.cash_receipt_id, p_total_workers) + 1
            --MOD(CEIL(cr.cash_receipt_id/10000), p_total_workers) + 1
            MOD(CEIL((DENSE_RANK() over(order by crh.cash_receipt_id))/5000), :b_total_workers) + 1
 FROM       ar_rem_cr_id_gtt gtt,
            ar_cash_receipts cr,
            ar_receipt_methods rm,
            ar_receipt_classes rc,
            hz_cust_accounts hca,
            hz_parties    party,
            /*ar_remit_gt g,*/
            ar_cash_receipt_history crh,
            ar_batches bat,
            ar_receipt_method_accounts rma,
            ar_distributions d
WHERE      cr.selected_remittance_batch_id = :b_batch_id
           AND cr.REMIT_BANK_ACCT_USE_ID = rma.REMIT_BANK_ACCT_USE_ID
           AND bat.batch_id = cr.selected_remittance_batch_id
           AND rm.receipt_method_id = cr.receipt_method_id
           AND rma.receipt_method_id = cr.receipt_method_id
           AND cr.cash_receipt_id = crh.cash_receipt_id
           AND crh.current_record_flag = ''Y''
           AND crh.status = ''CONFIRMED''
           AND crh.cash_receipt_history_id = d.source_id
           AND d.source_type = ''CONFIRMATION''
           AND d.source_table = ''CRH''
           AND hca.party_id = party.party_id(+)
           AND hca.cust_account_id(+) = cr.pay_from_customer
           AND cr.receipt_method_id = rm.receipt_method_id
           AND rm.receipt_class_id = rc.receipt_class_id
           and gtt.CASH_RECEIPT_HISTORY_ID = CRH.CASH_RECEIPT_HISTORY_ID ';
Line: 1405

    delete from ar_autorem_interim where batch_id = o_batch_id;
Line: 1407

/* Bug 5051186  Update the Batch Status  */
    IF   l_format_flag = 'Y' THEN
         l_batch_applied_status := 'COMPLETED_FORMAT';
Line: 1416

    /* bug 7352164 update control count and control amount */
    IF ( l_create_flag = 'Y' AND l_approve_flag = 'N' AND l_format_flag = 'N') THEN
       SELECT
         nvl(sum(cr.amount),0),
         count(*) into
         l_control_amount,
         l_control_count
       FROM   ar_cash_receipts cr
       WHERE  cr.selected_remittance_batch_id = o_batch_id;
Line: 1426

       UPDATE ar_batches
            SET batch_applied_status =  l_batch_applied_status,
                           control_count = l_control_count,
                           control_amount= l_control_amount
            WHERE batch_id = o_batch_id;
Line: 1433

       SELECT
             nvl(sum(crh.amount),0),
             count(*) into
             l_control_amount,
             l_control_count
       FROM    ar_cash_receipt_history crh
       WHERE   crh.batch_id = o_batch_id
       AND     crh.status = 'REMITTED'
       AND     crh.current_record_flag = 'Y';
Line: 1443

       UPDATE ar_batches
            SET batch_applied_status =  l_batch_applied_status,
                           control_count = l_control_count,
                           control_amount= l_control_amount
            WHERE batch_id = o_batch_id;
Line: 1449

   /* No need to update counts if the batch is submitted for format only */
        UPDATE ar_batches
            SET batch_applied_status =  l_batch_applied_status
        WHERE batch_id = o_batch_id;
Line: 1479

 |  PROCEDURE insert_batch                                                |
 |                                                                        |
 | DESCRIPTION                                                            |
 |                                                                        |
 |   This procedure is used to insert the batch record when called from   |
 |   srs. It also gets the other required parameters from sysparm         |
 |   and conc program                                                     |
 | PSEUDO CODE/LOGIC                                                      |
 |                                                                        |
 | PARAMETERS                                                             |
 |                                                                        |
 |                                                                        |
 | KNOWN ISSUES                                                           |
 |                                                                        |
 | NOTES                                                                  |
 |                                                                        |
 |                                                                        |
 | MODIFICATION HISTORY                                                   |
 | Date                     Author            Description of Changes      |
 | 16-JUL-2005              bichatte           Created                    |
 *=========================================================================*/

PROCEDURE insert_batch(
      p_batch_date                       IN  ar_cash_receipts.receipt_date%TYPE DEFAULT NULL,
      p_batch_gl_date                    IN  ar_cash_receipt_history.gl_date%TYPE DEFAULT NULL,
      p_approve_flag                     IN  ar_cash_receipts.override_remit_account_flag%TYPE DEFAULT NULL,
      p_format_flag                      IN  ar_cash_receipts.override_remit_account_flag%TYPE DEFAULT NULL,
      p_currency_code                    IN  ar_batches.currency_code%TYPE,
      p_remmitance_method                IN  ar_batches.remit_method_code%TYPE,
      p_receipt_class_id                    IN  ar_receipt_classes.receipt_class_id%TYPE,
      p_payment_method_id                   IN  ar_receipt_methods.receipt_method_id%TYPE,
      p_remmitance_bank_branch_id           IN  ap_bank_accounts.bank_branch_id%TYPE DEFAULT NULL,
      p_remmitance_bank_account_id               IN  ar_receipt_method_accounts.REMIT_BANK_ACCT_USE_ID%TYPE DEFAULT NULL,
      p_remit_bank_deposit_number        IN ar_batches.bank_deposit_number%TYPE DEFAULT NULL, --bug12924584
      p_batch_id                         OUT NOCOPY NUMBER
      ) IS
            l_batch_rec             ar_batches%ROWTYPE;
Line: 1542

             l_last_updated_by         NUMBER;
Line: 1544

             l_last_update_login       NUMBER;
Line: 1571

       l_last_updated_by := arp_standard.profile.user_id ;
Line: 1573

       l_last_update_login := arp_standard.profile.last_update_login ;
Line: 1588

select bbt.bank_branch_id ,bbt.remit_account_id
from ap_bank_branches bbt
where bbt.bank_branch_id in
(select distinct bb.bank_branch_id
from ap_bank_accounts ba, ap_bank_branches bb, ar_receipt_method_accounts rma, ar_system_parameters asp
where rma.receipt_method_id = nvl(p_receipt_method_id, rma.receipt_method_id )
and rma.bank_account_id = ba.bank_account_id
and ( ba.currency_code = p_currency_code
or ba.receipt_multi_currency_flag = 'Y' )
and ba.set_of_books_id =  asp.set_of_books_id
and nvl(ba.inactive_date , fnd_date.canonical_to_date(p_batch_date) + 1 ) > fnd_date.canonical_to_date(p_batch_date)
and fnd_date.canonical_to_date(p_batch_date)
between rma.start_date
and nvl(rma.end_date,fnd_date.canonical_to_date(p_batch_date))
and ( bb.bank_branch_id = ba.bank_branch_id
or ( bb.institution_type = 'CLEARING HOUSE'
and exists
( select 1
from ar_receipt_method_accounts rma2, ap_bank_accounts ba2, ap_bank_branches bb2
where rma2.receipt_method_id = nvl(p_receipt_method_id, rma2.receipt_method_id)
and rma2.bank_account_id = ba2.bank_account_id
and ba2.set_of_books_id = asp.set_of_books_id
and ba2.currency_code = p_currency_code
and ba2.bank_branch_id = bb2.bank_branch_id
and bb2.clearing_house_id = bb.bank_branch_id) ) ) )
order by bbt.bank_branch_name, bbt.bank_name;
Line: 1657

                   arp_rw_batches_pkg.insert_remit_batch(
                               l_row_id,
                               l_batch_id,
                               l_batch_rec.batch_date,
                               l_batch_rec.currency_code,
                               l_batch_name, --out
                               l_batch_rec.comments,
                               l_batch_rec.exchange_date,
                               l_batch_rec.exchange_rate,
                               l_batch_rec.exchange_rate_type,
                               l_batch_rec.gl_date,
                               l_batch_rec.media_reference,
                               l_batch_rec.remit_method_code,
                               l_batch_rec.receipt_class_id,
                               l_batch_rec.receipt_method_id,
                               l_batch_rec.remittance_bank_account_id,
                               l_batch_rec.remittance_bank_branch_id,
                               l_batch_rec.bank_deposit_number,
                               l_batch_rec.attribute_category,
                               l_batch_rec.attribute1,
                               l_batch_rec.attribute2,
                               l_batch_rec.attribute3,
                               l_batch_rec.attribute4,
                               l_batch_rec.attribute5,
                               l_batch_rec.attribute6,
                               l_batch_rec.attribute7,
                               l_batch_rec.attribute8,
                               l_batch_rec.attribute9,
                               l_batch_rec.attribute10,
                               l_batch_rec.attribute11,
                               l_batch_rec.attribute12,
                               l_batch_rec.attribute13,
                               l_batch_rec.attribute14,
                               l_batch_rec.attribute15,
                               'Y',
                               l_batch_applied_status, --Out
                               'AUTOREMSRS',
                               '1.0'
                               );
Line: 1722

/* inserted the batch record end */


/* GET THE VALUES from SYSTEM PARAMETERS */
IF PG_DEBUG in ('Y','C') THEN
   fnd_file.put_line(FND_FILE.LOG, 'get info from system parameters');
Line: 1732

     SELECT asp.site_required_flag,
                    asp.auto_rec_invoices_per_commit,
                    asp.auto_rec_receipts_per_commit,
                    gsob.currency_code,
                    asp.accounting_method
               INTO psite_required,
                    pinvoices_per_commit,
                    preceipts_per_commit,
                    pfunctional_currency,
                    pacc_method
               FROM ar_system_parameters asp,
                    gl_sets_of_books gsob,
                    ar_batches ab
              WHERE ab.batch_id = p_batch_id
                AND ab.set_of_books_id = gsob.set_of_books_id
                AND gsob.set_of_books_id = asp.set_of_books_id;
Line: 1766

     fnd_file.put_line(FND_FILE.LOG,'insert_batch ()-');
Line: 1773

     fnd_file.put_line(FND_FILE.LOG,'Exception : insert_batch() ');
Line: 1779

END insert_batch;
Line: 1782

 |  PROCEDURE create_and_update_remit_rec                                 |
 |                                                                        |
 | DESCRIPTION                                                            |
 |                                                                        |
 |   This procedure is used to select receipts to be remitted             |
 |   update and insert records into the necessary tables.                 |
 | PSEUDO CODE/LOGIC                                                      |
 |                                                                        |
 | PARAMETERS                                                             |
 |                                                                        |
 |                                                                        |
 | KNOWN ISSUES                                                           |
 |                                                                        |
 | NOTES                                                                  |
 |                                                                        |
 |                                                                        |
 | MODIFICATION HISTORY                                                   |
 | Date                     Author            Description of Changes      |
 | 16-JUL-2005              bichatte           Created                    |
 *=========================================================================*/
PROCEDURE create_and_update_remit_rec(
          p_batch_id       IN  NUMBER,
          p_return_status  OUT NOCOPY  VARCHAR2
                              ) IS

l_rows_processed INTEGER;
Line: 1841

/* declare the insert array elements */
i                              NUMBER;
Line: 1886

     select hist.cash_receipt_id cr_id
     from ar_cash_receipt_history hist,
          AR_REMIT_GT rec
     where hist.STATUS = 'REMITTED'
     and   hist.cash_receipt_id = rec.cash_receipt_id;
Line: 1901

             l_last_updated_by         NUMBER;
Line: 1903

             l_last_update_login       NUMBER;
Line: 1918

   select decode(remit_method_code, 'FACTORING', 'Y', 'N')
   into l_factor_flag
   from ar_batches
   where batch_id = p_batch_id;
Line: 1925

       l_last_updated_by := arp_standard.profile.user_id ;
Line: 1927

       l_last_update_login := arp_standard.profile.last_update_login ;
Line: 1933

    l_sel_stmt := ' SELECT cr.cash_receipt_id,
               rm.payment_channel_code,
               rm.merchant_ref,
               cr.currency_code,
               cr.pay_from_customer,
               cr.customer_site_use_id,
               crh.cash_receipt_history_id,
               crh.exchange_date,
               crh.exchange_rate,
               crh.exchange_rate_type,
               crh.amount,
               crh.acctd_amount,
               nvl(cr.factor_discount_amount,0),
               decode( bat.remit_method_code,
                       ''FACTORING'', rma.factor_ccid,
                       rma.remittance_ccid),
               rma.bank_charges_ccid,
               d.code_combination_id,
               ar_cash_receipt_history_s.nextval,
               greatest((bat.gl_date), (crh.gl_date)),
               greatest((bat.batch_date), (crh.trx_date)),
               cr.payment_server_order_num,
               cr.approval_code,
               cr.receipt_number,
               DECODE(cr.unique_reference,
                         NULL,SYS_GUID(),
                         cr.unique_reference ),
               cr.customer_bank_account_id,
               cr.payment_trxn_extension_id
          FROM ar_cash_receipts cr, ar_cash_receipt_history crh,
               ar_receipt_methods rm,
               ar_batches bat,
               ar_receipt_method_accounts rma,
               ar_payment_schedules ps,
               ar_distributions d
          WHERE cr.selected_remittance_batch_id = :ab_batch_id
           AND cr.REMIT_BANK_ACCT_USE_ID = rma.REMIT_BANK_ACCT_USE_ID
           AND bat.batch_id = cr.selected_remittance_batch_id
           AND rm.receipt_method_id = cr.receipt_method_id
           AND rma.receipt_method_id = cr.receipt_method_id
           AND cr.cash_receipt_id = crh.cash_receipt_id
           AND crh.current_record_flag = ''Y''
           AND ps.cash_receipt_id(+) = cr.cash_receipt_id
           AND crh.status = ''CONFIRMED''
           AND crh.cash_receipt_history_id = d.source_id
           AND d.source_type = ''CONFIRMATION''
           AND d.source_table = ''CRH''
	   ';
Line: 2015

             fnd_file.put_line(FND_FILE.LOG, 'the select statemnt' || l_sel_stmt);
Line: 2111

     inst_stmt := 'insert into AR_REMIT_GT values ( :c1_array,:c2_array,:c3_array,:c4_array,:c5_array,
                                               :c6_array,:c7_array,:c8_array,:c9_array,:c10_array,:c11_array,:c12_array,
                                               :c13_array,:c14_array,:c15_array,:c16_array,:c17_array,:c18_array,
                                               :c19_array,:c20_array,:c21_array,:c22_array,:c23_array,:c24_array,:c25_array)';
Line: 2160

/* the update and inserts */

  BEGIN

  IF PG_DEBUG in ('Y', 'C') THEN
     fnd_file.put_line(FND_FILE.LOG,'upd-crh1 ()+');
Line: 2170

/* the first update into ar_cash_receipt_history */

  upd_stmt1 := ' UPDATE ar_cash_receipt_history
                SET reversal_cash_receipt_hist_id = :ucrh_id_array,
                reversal_gl_date = :ucrh_gl_date_array,
                reversal_created_from = ''ARZARM'',
                current_record_flag = NULL,
                        last_update_date              = sysdate,
                        last_updated_by               = :i_last_updated_by,
                        last_update_login             = :i_last_update_login,
                        request_id                    = :i_request_id,
                        program_application_id        = :i_program_application_id,
                        program_id                    = :i_program_id,
                        program_update_date           = sysdate
                  WHERE cash_receipt_id = :cr_id_array
                  AND current_record_flag = ''Y''
                  AND status = ''CONFIRMED''
		  ';
Line: 2199

  dbms_sql.bind_variable (rem_t1,':i_last_updated_by',l_last_updated_by);
Line: 2200

  dbms_sql.bind_variable (rem_t1,':i_last_update_login',l_last_update_login);
Line: 2210

     arp_standard.debug (to_char(SQL%ROWCOUNT) || ' row(s) updated.');
Line: 2219

     fnd_file.put_line(FND_FILE.LOG,'failed to update() '|| to_char(SQLCODE));
Line: 2226

/* insert into crh  */

 BEGIN


 IF PG_DEBUG in ('Y', 'C') THEN
     fnd_file.put_line(FND_FILE.LOG,'insert-crh1 ()+');
Line: 2238

/* the first update into ar_cash_receipt_history */

   ins_crh1 := 'INSERT into ar_cash_receipt_history
         (cash_receipt_history_id,
          cash_receipt_id,
          status,
          trx_date,
          amount,
          acctd_amount,
          first_posted_record_flag,
          postable_flag,
          factor_flag,
          gl_date,
          current_record_flag,
          batch_id,
          exchange_date,
          exchange_rate,
          exchange_rate_type,
          account_code_combination_id,
          reversal_gl_date,
          reversal_cash_receipt_hist_id,
          prv_stat_cash_receipt_hist_id,
          factor_discount_amount,
          acctd_factor_discount_amount,
          bank_charge_account_ccid,
          posting_control_id,
          created_from,
          reversal_posting_control_id,
          gl_posted_date,
          reversal_gl_posted_date,
          created_by,
          creation_date,
          last_updated_by,
          last_update_date,
          last_update_login,
          request_id,
          org_id,
          program_application_id,
          program_id,
          program_update_date
         )
    select
           r.CASH_RECEIPT_HISTORY_ID,
           r.CASH_RECEIPT_ID,
          ''REMITTED'',
           r.CRH_TRX_DATE,
           r.cr_amount - r.cr_factor_discount_amount,
           r.cr_acctd_amount - DECODE(r.exchange_type, null, r.cr_factor_discount_amount,
               ''User'', arp_util.functional_amount(
                            r.cr_factor_discount_amount,
                            '''||ARP_GLOBAL.functional_currency||''',
                            nvl(r.exchange_rate,1),
                            NULL, NULL),
               gl_currency_api.convert_amount(
                       r.currency_code,
                       '''||ARP_GLOBAL.functional_currency||''',
                       r.exchange_date,
                       r.exchange_type,
                       r.cr_factor_discount_amount)),
          ''N'',
          ''Y'',
           :factor_flag,
           r.crh_gl_date,
          ''Y'',
           :i_batch_id,
           r.exchange_date,
           r.exchange_rate,
           r.exchange_type,
           r.remmitance_ccid,
          NULL,
          NULL,
           r.prv_cash_receipt_hist_id,
           r.cr_factor_discount_amount,
           DECODE(r.exchange_type, null, r.cr_factor_discount_amount,
           ''User'', arp_util.functional_amount(
                            r.cr_factor_discount_amount,
                            '''||ARP_GLOBAL.functional_currency||''',
                            nvl(r.exchange_rate,1),
                            NULL, NULL),
               gl_currency_api.convert_amount(
                       r.currency_code,
                       '''||ARP_GLOBAL.functional_currency||''',
                       r.exchange_date,
                       r.exchange_type,
                       r.cr_factor_discount_amount)),
           r.bank_charges_ccid,
          ''-3'',
          ''ARZARM'',
          NULL,
          NULL,
          NULL,
          :i_created_by,
          sysdate,
          :i_last_updated_by,
          sysdate,
          :i_last_update_login,
          :i_request_id,
          :i_org_id,
          :i_program_application_id,
          :i_program_id,
          sysdate
          FROM AR_REMIT_GT r
          WHERE r.cash_receipt_history_id is not null';
Line: 2355

  dbms_sql.bind_variable (rem_t3,':i_last_updated_by',l_last_updated_by);
Line: 2356

  dbms_sql.bind_variable (rem_t3,':i_last_update_login',l_last_update_login);
Line: 2364

             fnd_file.put_line(FND_FILE.LOG, 'the insert statemnt' || ins_crh1);
Line: 2372

/* BICHATTE after the insert into crh we have to fire the XLA event */

   FOR rec in c_rec LOOP

          l_xla_ev_rec.xla_from_doc_id := rec.cr_id;
Line: 2404

             fnd_file.put_line(FND_FILE.LOG, 'the insert statemnt' || ins_crh1);
Line: 2409

     fnd_file.put_line(FND_FILE.LOG,'failed to insert() '|| to_char(SQLCODE));
Line: 2410

             fnd_file.put_line(FND_FILE.LOG, 'the insert statemnt' || ins_crh1);
Line: 2416

/* end insert into crh */

/* insert into dist */
 BEGIN


 IF PG_DEBUG in ('Y', 'C') THEN
     fnd_file.put_line(FND_FILE.LOG,'insert-dist1 ()+');
Line: 2428

/* the first update into ar_cash_receipt_history */

   ins_dist1 := 'INSERT into ar_distributions
		(line_id,
                source_id,
                source_table,
                source_type,
                code_combination_id,
                currency_code,
                third_party_id,
                third_party_sub_id,
                currency_conversion_date,
                currency_conversion_rate,
                currency_conversion_type,
                amount_dr,
                amount_cr,
                acctd_amount_dr,
                acctd_amount_cr,
		creation_date,
                created_by,
                last_update_date,
                last_updated_by,
                org_id,
                last_update_login)
	select
                ar_distributions_s.nextval,
                r.cash_receipt_history_id,
                ''CRH'',
                decode(:factor_flag,
                       ''N'',decode(l.lookup_code,
				''1'',''REMITTANCE'',
				''2'',''CONFIRMATION''),
                       ''Y'',decode(l.lookup_code,
				''1'',''FACTOR'',
				''2'',''CONFIRMATION'')),
		decode(l.lookup_code,
			''1'',r.REMMITANCE_CCID,
			''2'',r.code_combination_id),  /* its confirmation_ccid */
                r.currency_code,
                r.pay_from_customer,
                r.customer_site_use_id,
                r.exchange_date,
                r.exchange_rate,
                r.exchange_type,
		decode(l.lookup_code,
			''1'',decode(sign(to_number(r.cr_amount)),
                                   ''-1'',null,
                                  to_number(r.cr_amount)),
			''2'',decode(sign(to_number(r.cr_amount)),
                                   ''1'',null,
                                  -(to_number(r.cr_amount)))),
		decode(l.lookup_code,
			''1'',decode(sign(to_number(r.cr_amount)),
                                   ''1'',null,
                                  -(to_number(r.cr_amount))),
			''2'',decode(sign(to_number(r.cr_amount)),
                                   ''-1'',null,
                                  to_number(r.cr_amount))),
		decode(l.lookup_code,
			''1'',decode(sign(to_number(r.cr_acctd_amount)),
                                   ''-1'',null,
                                  to_number(r.cr_acctd_amount)),
			''2'',decode(sign(to_number(r.cr_acctd_amount)),
                                   ''1'',null,
                                  -(to_number(r.cr_acctd_amount)))),
		decode(l.lookup_code,
			''1'',decode(sign(to_number(r.cr_acctd_amount)),
                                   ''1'',null,
                                  -(to_number(r.cr_acctd_amount))),
			''2'',decode(sign(to_number(r.cr_acctd_amount)),
                                   ''-1'',null,
                                  to_number(r.cr_acctd_amount))),
                sysdate,
                :i_created_by,
                sysdate,
                :i_last_updated_by,
                :i_org_id,
                :i_last_update_login
        FROM    ar_cash_receipt_history crh,AR_REMIT_GT r,
		    ar_lookups l
	WHERE	crh.cash_receipt_history_id = r.cash_receipt_history_id
	AND	l.lookup_type = ''AR_CARTESIAN_JOIN''
	AND	l.lookup_code IN (''1'',''2'')';
Line: 2517

      fnd_file.put_line(FND_FILE.LOG, 'the insert dist statement is ' || ins_dist1);
Line: 2523

  dbms_sql.bind_variable (rem_t4,':i_last_updated_by',l_last_updated_by);
Line: 2525

  dbms_sql.bind_variable (rem_t4,':i_last_update_login',l_last_update_login);
Line: 2541

   fnd_file.put_line(FND_FILE.LOG, 'the insert dist statement is ' || ins_dist1);
Line: 2542

     fnd_file.put_line(FND_FILE.LOG,'DIST failed to insert() '|| to_char(SQLCODE));
Line: 2548

/* end insert into dist */
END IF;--check for rows returned > 0
Line: 2554

     fnd_file.put_line(FND_FILE.LOG,'Exception : create_and_update_remit_rec() ');
Line: 2559

END create_and_update_remit_rec ;
Line: 2563

 |  PROCEDURE create_and_update_remit_rec_pa                              |
 |                                                                        |
 | DESCRIPTION                                                            |
 |                                                                        |
 |   This procedure is used to select receipts to be remitted             |
 |   update and insert records into the necessary tables.                 |
 | PSEUDO CODE/LOGIC                                                      |
 |                                                                        |
 | PARAMETERS                                                             |
 |                                                                        |
 |                                                                        |
 | KNOWN ISSUES                                                           |
 |                                                                        |
 | NOTES                                                                  |
 |                                                                        |
 |                                                                        |
 | MODIFICATION HISTORY                                                   |
 | Date                     Author            Description of Changes      |
 | 10-JUN-2008              AGHORAKA         Created for Parallelization  |
 *=========================================================================*/
PROCEDURE create_and_update_remit_rec_pa(
          p_batch_id       IN  NUMBER,
          p_return_status  OUT NOCOPY  VARCHAR2
                              ) IS

l_rows_processed INTEGER;
Line: 2622

/* declare the insert array elements */
i                              NUMBER;
Line: 2667

     select hist.cash_receipt_id cr_id
     from ar_cash_receipt_history hist,
          AR_REMIT_GT rec
     where hist.STATUS = 'REMITTED'
     and   hist.cash_receipt_id = rec.cash_receipt_id;
Line: 2682

             l_last_updated_by         NUMBER;
Line: 2684

             l_last_update_login       NUMBER;
Line: 2699

   select decode(remit_method_code, 'FACTORING', 'Y', 'N')
   into l_factor_flag
   from ar_batches
   where batch_id = p_batch_id;
Line: 2705

       l_last_updated_by := arp_standard.profile.user_id ;
Line: 2707

       l_last_update_login := arp_standard.profile.last_update_login ;
Line: 2713

    l_sel_stmt := ' SELECT cash_receipt_id,
               payment_channel_code,
               merchant_ref,
               currency_code,
               pay_from_customer,
               customer_site_use_id,
               cash_receipt_history_id,
               exchange_date,
               exchange_rate,
               exchange_rate_type,
               amount1,
               acctd_amount,
               nvl(factor_discount_amount,0),
               remittance_ccid,
               bank_charges_ccid,
               code_combination_id,
               ar_cash_receipt_history_s.nextval,
               crh_gl_date,
               crh_trx_date,
               payment_server_order_num,
               approval_code,
               receipt_number,
               unique_ref,
               customer_bank_account_id,
               payment_trxn_extension_id
          FROM ar_autorem_interim
          WHERE batch_id = :ab_batch_id
          AND current_worker = :h_worker_number
            ';
Line: 2778

             fnd_file.put_line(FND_FILE.LOG, 'the select statemnt' || l_sel_stmt);
Line: 2882

     inst_stmt := 'insert into AR_REMIT_GT values
        ( :c1_array,:c2_array,:c3_array,:c4_array,:c5_array,
       :c6_array,:c7_array,:c8_array,:c9_array,:c10_array,:c11_array,:c12_array,
       :c13_array,:c14_array,:c15_array,:c16_array,:c17_array,:c18_array,
       :c19_array,:c20_array,:c21_array,:c22_array,:c23_array,:c24_array,:c25_array)';
Line: 2932

/* the update and inserts */

  BEGIN

  IF PG_DEBUG in ('Y', 'C') THEN
     fnd_file.put_line(FND_FILE.LOG,'upd-crh1 ()+');
Line: 2942

/* the first update into ar_cash_receipt_history */

  upd_stmt1 := ' UPDATE ar_cash_receipt_history
                SET reversal_cash_receipt_hist_id = :ucrh_id_array,
                reversal_gl_date = :ucrh_gl_date_array,
                reversal_created_from = ''ARZARM'',
                current_record_flag = NULL,
                        last_update_date              = sysdate,
                        last_updated_by               = :i_last_updated_by,
                        last_update_login             = :i_last_update_login,
                        request_id                    = :i_request_id,
                        program_application_id        = :i_program_application_id,
                        program_id                    = :i_program_id,
                        program_update_date           = sysdate
                  WHERE cash_receipt_id = :cr_id_array
                  AND current_record_flag = ''Y''
                  AND status = ''CONFIRMED''
		  ';
Line: 2971

  dbms_sql.bind_variable (rem_t1,':i_last_updated_by',l_last_updated_by);
Line: 2972

  dbms_sql.bind_variable (rem_t1,':i_last_update_login',l_last_update_login);
Line: 2982

     arp_standard.debug (to_char(SQL%ROWCOUNT) || ' row(s) updated.');
Line: 2991

     fnd_file.put_line(FND_FILE.LOG,'failed to update() '|| to_char(SQLCODE));
Line: 2998

/* insert into crh  */

 BEGIN


 IF PG_DEBUG in ('Y', 'C') THEN
     fnd_file.put_line(FND_FILE.LOG,'insert-crh1 ()+');
Line: 3010

/* the first update into ar_cash_receipt_history */

   ins_crh1 := 'INSERT into ar_cash_receipt_history
         (cash_receipt_history_id,
          cash_receipt_id,
          status,
          trx_date,
          amount,
          acctd_amount,
          first_posted_record_flag,
          postable_flag,
          factor_flag,
          gl_date,
          current_record_flag,
          batch_id,
          exchange_date,
          exchange_rate,
          exchange_rate_type,
          account_code_combination_id,
          reversal_gl_date,
          reversal_cash_receipt_hist_id,
          prv_stat_cash_receipt_hist_id,
          factor_discount_amount,
          acctd_factor_discount_amount,
          bank_charge_account_ccid,
          posting_control_id,
          created_from,
          reversal_posting_control_id,
          gl_posted_date,
          reversal_gl_posted_date,
          created_by,
          creation_date,
          last_updated_by,
          last_update_date,
          last_update_login,
          request_id,
          org_id,
          program_application_id,
          program_id,
          program_update_date
         )
    select
           r.CASH_RECEIPT_HISTORY_ID,
           r.CASH_RECEIPT_ID,
          ''REMITTED'',
           r.CRH_TRX_DATE,
           r.cr_amount - r.cr_factor_discount_amount,
           r.cr_acctd_amount - DECODE(r.exchange_type, null, r.cr_factor_discount_amount,
               ''User'', arp_util.functional_amount(
                            r.cr_factor_discount_amount,
                            '''||ARP_GLOBAL.functional_currency||''',
                            nvl(r.exchange_rate,1),
                            NULL, NULL),
               gl_currency_api.convert_amount(
                       r.currency_code,
                       '''||ARP_GLOBAL.functional_currency||''',
                       r.exchange_date,
                       r.exchange_type,
                       r.cr_factor_discount_amount)),
          ''N'',
          ''Y'',
           :factor_flag,
           r.crh_gl_date,
          ''Y'',
           :i_batch_id,
           r.exchange_date,
           r.exchange_rate,
           r.exchange_type,
           r.remmitance_ccid,
          NULL,
          NULL,
           r.prv_cash_receipt_hist_id,
           r.cr_factor_discount_amount,
           DECODE(r.exchange_type, null, r.cr_factor_discount_amount,
           ''User'', arp_util.functional_amount(
                            r.cr_factor_discount_amount,
                            '''||ARP_GLOBAL.functional_currency||''',
                            nvl(r.exchange_rate,1),
                            NULL, NULL),
               gl_currency_api.convert_amount(
                       r.currency_code,
                       '''||ARP_GLOBAL.functional_currency||''',
                       r.exchange_date,
                       r.exchange_type,
                       r.cr_factor_discount_amount)),
           r.bank_charges_ccid,
          ''-3'',
          ''ARZARM'',
          NULL,
          NULL,
          NULL,
          :i_created_by,
          sysdate,
          :i_last_updated_by,
          sysdate,
          :i_last_update_login,
          :i_request_id,
          :i_org_id,
          :i_program_application_id,
          :i_program_id,
          sysdate
          FROM AR_REMIT_GT r
          WHERE r.cash_receipt_history_id is not null';
Line: 3127

  dbms_sql.bind_variable (rem_t3,':i_last_updated_by',l_last_updated_by);
Line: 3128

  dbms_sql.bind_variable (rem_t3,':i_last_update_login',l_last_update_login);
Line: 3136

             fnd_file.put_line(FND_FILE.LOG, 'the insert statemnt' || ins_crh1);
Line: 3144

/* BICHATTE after the insert into crh we have to fire the XLA event */

   FOR rec in c_rec LOOP

          l_xla_ev_rec.xla_from_doc_id := rec.cr_id;
Line: 3176

             fnd_file.put_line(FND_FILE.LOG, 'the insert statemnt' || ins_crh1);
Line: 3181

     fnd_file.put_line(FND_FILE.LOG,'failed to insert() '|| to_char(SQLCODE));
Line: 3182

             fnd_file.put_line(FND_FILE.LOG, 'the insert statemnt' || ins_crh1);
Line: 3188

/* end insert into crh */

/* insert into dist */
 BEGIN


 IF PG_DEBUG in ('Y', 'C') THEN
     fnd_file.put_line(FND_FILE.LOG,'insert-dist1 ()+');
Line: 3200

/* the first update into ar_cash_receipt_history */

   ins_dist1 := 'INSERT into ar_distributions
		(line_id,
                source_id,
                source_table,
                source_type,
                code_combination_id,
                currency_code,
                third_party_id,
                third_party_sub_id,
                currency_conversion_date,
                currency_conversion_rate,
                currency_conversion_type,
                amount_dr,
                amount_cr,
                acctd_amount_dr,
                acctd_amount_cr,
		creation_date,
                created_by,
                last_update_date,
                last_updated_by,
                org_id,
                last_update_login)
	select
                ar_distributions_s.nextval,
                r.cash_receipt_history_id,
                ''CRH'',
                decode(:factor_flag,
                       ''N'',decode(l.lookup_code,
				''1'',''REMITTANCE'',
				''2'',''CONFIRMATION''),
                       ''Y'',decode(l.lookup_code,
				''1'',''FACTOR'',
				''2'',''CONFIRMATION'')),
		decode(l.lookup_code,
			''1'',r.REMMITANCE_CCID,
			''2'',r.code_combination_id),  /* its confirmation_ccid */
                r.currency_code,
                r.pay_from_customer,
                r.customer_site_use_id,
                r.exchange_date,
                r.exchange_rate,
                r.exchange_type,
		decode(l.lookup_code,
			''1'',decode(sign(to_number(r.cr_amount)),
                                   ''-1'',null,
                                  to_number(r.cr_amount)),
			''2'',decode(sign(to_number(r.cr_amount)),
                                   ''1'',null,
                                  -(to_number(r.cr_amount)))),
		decode(l.lookup_code,
			''1'',decode(sign(to_number(r.cr_amount)),
                                   ''1'',null,
                                  -(to_number(r.cr_amount))),
			''2'',decode(sign(to_number(r.cr_amount)),
                                   ''-1'',null,
                                  to_number(r.cr_amount))),
		decode(l.lookup_code,
			''1'',decode(sign(to_number(r.cr_acctd_amount)),
                                   ''-1'',null,
                                  to_number(r.cr_acctd_amount)),
			''2'',decode(sign(to_number(r.cr_acctd_amount)),
                                   ''1'',null,
                                  -(to_number(r.cr_acctd_amount)))),
		decode(l.lookup_code,
			''1'',decode(sign(to_number(r.cr_acctd_amount)),
                                   ''1'',null,
                                  -(to_number(r.cr_acctd_amount))),
			''2'',decode(sign(to_number(r.cr_acctd_amount)),
                                   ''-1'',null,
                                  to_number(r.cr_acctd_amount))),
                sysdate,
                :i_created_by,
                sysdate,
                :i_last_updated_by,
                :i_org_id,
                :i_last_update_login
        FROM    ar_cash_receipt_history crh,AR_REMIT_GT r,
		    ar_lookups l
	WHERE	crh.cash_receipt_history_id = r.cash_receipt_history_id
	AND	l.lookup_type = ''AR_CARTESIAN_JOIN''
	AND	l.lookup_code IN (''1'',''2'')';
Line: 3289

     fnd_file.put_line(FND_FILE.LOG, 'the insert dist statement is ' || ins_dist1);
Line: 3295

  dbms_sql.bind_variable (rem_t4,':i_last_updated_by',l_last_updated_by);
Line: 3297

  dbms_sql.bind_variable (rem_t4,':i_last_update_login',l_last_update_login);
Line: 3313

   fnd_file.put_line(FND_FILE.LOG, 'the insert dist statement is ' || ins_dist1);
Line: 3314

     fnd_file.put_line(FND_FILE.LOG,'DIST failed to insert() '|| to_char(SQLCODE));
Line: 3320

/* end insert into dist */


EXCEPTION
 WHEN others THEN
  --IF PG_DEBUG in ('Y', 'C') THEN
     fnd_file.put_line(FND_FILE.LOG,'Exception : create_and_update_remit_rec_pa() ');
Line: 3331

END create_and_update_remit_rec_pa ;
Line: 3335

 |  PROCEDURE select_and_update_rec                                       |
 |                                                                        |
 | DESCRIPTION                                                            |
 |                                                                        |
 |   This procedure is used to select receipts to be remitted             |
 |   update and insert records into the necessary tables.                 |
 | PSEUDO CODE/LOGIC                                                      |
 |                                                                        |
 | PARAMETERS                                                             |
 |                                                                        |
 |                                                                        |
 | KNOWN ISSUES                                                           |
 |                                                                        |
 | NOTES                                                                  |
 |                                                                        |
 |                                                                        |
 | MODIFICATION HISTORY                                                   |
 | Date                     Author            Description of Changes      |
 | 16-JUL-2005              bichatte           Created                    |
 | 06-DEC-2012              riqi               Fixed bug 14798599         |
 *=========================================================================*/

PROCEDURE select_update_rec(
                                p_customer_number_l             IN hz_cust_accounts.account_number%TYPE,
                                p_customer_number_h             IN hz_cust_accounts.account_number%TYPE,
                                p_customer_name_l               IN hz_parties.party_name%type,
                                p_customer_name_h               IN hz_parties.party_name%type,
                                p_doc_num_l                     IN ar_cash_receipts.doc_sequence_value%type,
                                p_doc_num_h                     IN ar_cash_receipts.doc_sequence_value%type,
                                p_trx_date_l                    IN ar_payment_schedules.trx_date%TYPE,
                                p_trx_date_h                    IN ar_payment_schedules.trx_date%TYPE,
                                p_due_date_l                    IN ar_payment_schedules.due_date%TYPE,
                                p_due_date_h                    IN ar_payment_schedules.due_date%TYPE,
                                p_trx_num_l                     IN ar_payment_schedules.trx_number%TYPE,
                                p_trx_num_h                     IN ar_payment_schedules.trx_number%TYPE,
                                p_remittance_total_to           IN ar_cash_receipts.amount%TYPE,
                                p_remittance_total_from         IN ar_cash_receipts.amount%TYPE,
                                p_batch_id                      IN ar_batches.batch_id%TYPE,
                                p_receipt_method_id             IN ar_receipt_methods.receipt_method_id%TYPE,
                                p_currency_code                 IN ar_cash_receipts.currency_code%TYPE,
                                p_payment_type_code             IN ar_receipt_methods.payment_type_code%TYPE,
                                p_sob_id                        IN ar_cash_receipts.set_of_books_id%TYPE,
                                p_remit_method_code             IN ar_receipt_classes.remit_method_code%TYPE,
                                p_remit_bank_account_id         IN ar_cash_receipts.remittance_bank_account_id%TYPE,
                                p_return_status                 OUT NOCOPY  VARCHAR2
                                 ) IS

    remit_recs                INTEGER;
Line: 3405

    l_last_updated_by         NUMBER;
Line: 3407

    l_last_update_login       NUMBER;
Line: 3413

    l_last_updated_by := arp_standard.profile.user_id ;
Line: 3415

    l_last_update_login := arp_standard.profile.last_update_login ;
Line: 3443

			ins_stmt := 'insert /*+ append parallel(gtt) */ into ar_rem_cr_id_gtt gtt ';
Line: 3445

			ins_stmt := 'insert /*+ append */ into ar_rem_cr_id_gtt gtt ';
Line: 3448

		ins_stmt := ins_stmt ||' select /*+ index(crh AR_CASH_RECEIPT_HISTORY_N6) */
											CASH_RECEIPT_HISTORY_ID,
											cash_receipt_id
								from    ar_cash_receipt_history crh
								where   crh.status = ''CONFIRMED'' AND
											crh.current_record_flag = ''Y'' ';
Line: 3471

		  l_sel_stmt := ' SELECT /*+ unnest LEADING(crh,crh1,cr) parallel(crh) parallel(crh1) parallel(cr) parallel(ps) swap_join_inputs(rm) swap_join_inputs(rclass) use_hash(rm,rclass) use_nl(crh1,cr,ps,rma1,rma2) cardinality(crh,10000) */';
Line: 3473

		  l_sel_stmt := ' SELECT /*+ unnest LEADING(crh,crh1,cr) swap_join_inputs(rm) swap_join_inputs(rclass) use_hash(rm,rclass) use_nl(crh1,cr,ps,rma1,rma2) cardinality(crh,10000) */';
Line: 3476

		l_sel_stmt := 'SELECT /*+ LEADING(rma2, rma1,cr,crh1) */  ';
Line: 3508

           (SELECT 1 FROM ar_lookups l
            WHERE NVL(cr.reversal_category,''~'')    = l.lookup_code
            AND l.lookup_type           = ''REVERSAL_CATEGORY_TYPE'') ';
Line: 3529

	       AND cr.selected_remittance_batch_id is null
		   AND (nvl(rm.payment_channel_code,''~'')<>''CREDIT_CARD'' OR (rm.payment_channel_code=''CREDIT_CARD'' AND cr.cc_error_flag IS NULL))
	       AND rma2.REMIT_BANK_ACCT_USE_ID= :bs_remit_account_id
		   AND rma1.receipt_method_id = rma2.receipt_method_id
		   AND cr.REMIT_BANK_ACCT_USE_ID = rma1.REMIT_BANK_ACCT_USE_ID
           AND cr.receipt_method_id  = rma1.receipt_method_id
           AND (( cr.amount >= 0) OR
                (cr.type = ''MISC'' and cr.amount < 0)
			   )
           AND rm.receipt_class_id = rclass.receipt_class_id
           AND (rclass.remit_method_code = :bs_remit_method_code
               OR rclass.remit_method_code = ''STANDARD_AND_FACTORING''
               )
		    AND ((
                (nvl(cr.override_remit_account_flag,''Y'') = ''Y'')
                AND rma1.unapplied_ccid = rma2.unapplied_ccid
                AND rma1.on_account_ccid = rma2.on_account_ccid
                AND rma1.unidentified_ccid = rma2.unidentified_ccid
               )
               OR
               (
                (nvl(cr.override_remit_account_flag,''Y'') = ''N'')
                and cr.REMIT_BANK_ACCT_USE_ID = :bs_remit_account_id
               )) ';
Line: 3563

           AND EXISTS ( select ''x''
                        from    hz_cust_accounts rc
                        where   rc.cust_account_id = cr.pay_from_customer  ' ;
Line: 3584

           AND EXISTS ( select ''x''
                        from    hz_cust_accounts rc, HZ_PARTIES party
                        where   rc.cust_account_id = cr.pay_from_customer
                        and     rc.party_id = party.party_id  ' ;
Line: 3654

    upd_stmt2 := ' UPDATE /*+ parallel(R) index(R) */ ar_cash_receipts R';
Line: 3656

    upd_stmt2 := ' UPDATE /*+ index(R) */ ar_cash_receipts R';
Line: 3658

  upd_stmt2 := upd_stmt2 ||' SET selected_remittance_batch_id  = :u_batch_id,
			REMIT_BANK_ACCT_USE_ID        = :u_remit_bank_account_id,
			last_update_date              = sysdate,
			last_updated_by               = :i_last_updated_by,
			last_update_login             = :i_last_update_login,
			request_id                    = :i_request_id,
			program_application_id        = :i_program_application_id,
			program_id                    = :i_program_id,
			program_update_date           = sysdate
		WHERE selected_remittance_batch_id is null ';
Line: 3675

  /* bind the variables used in update statement */
  dbms_sql.bind_variable (remit_recs,':u_batch_id',p_batch_id);
Line: 3680

  dbms_sql.bind_variable (remit_recs,':i_last_updated_by',l_last_updated_by);
Line: 3681

  dbms_sql.bind_variable (remit_recs,':i_last_update_login',l_last_update_login);
Line: 3766

     fnd_file.put_line(FND_FILE.LOG, 'the select statemnt' || l_sel_stmt);
Line: 3813

      upd_stmt2 := ' UPDATE /*+ parallel(R) index(R) */ ar_cash_receipts R';
Line: 3815

      upd_stmt2 := ' UPDATE /*+ index(R) */ ar_cash_receipts R';
Line: 3817

    upd_stmt2 := upd_stmt2 ||' SET selected_remittance_batch_id  = :u_batch_id,
			REMIT_BANK_ACCT_USE_ID        = :u_remit_bank_account_id,
			last_update_date              = sysdate,
			last_updated_by               = :i_last_updated_by,
			last_update_login             = :i_last_update_login,
			request_id                    = :i_request_id,
			program_application_id        = :i_program_application_id,
			program_id                    = :i_program_id,
			program_update_date           = sysdate
		WHERE selected_remittance_batch_id is null ';
Line: 3835

    /* bind the variables used in update statement */
    dbms_sql.bind_variable (upd_recs,':u_batch_id',p_batch_id);
Line: 3840

    dbms_sql.bind_variable (upd_recs,':i_last_updated_by',l_last_updated_by);
Line: 3841

    dbms_sql.bind_variable (upd_recs,':i_last_update_login',l_last_update_login);
Line: 3871

     fnd_file.put_line(FND_FILE.LOG,'sel_and_update recs ()-');
Line: 3876

     fnd_file.put_line(FND_FILE.LOG,'Exception : select and upd  err () ');
Line: 3878

     fnd_file.put_line(FND_FILE.LOG, 'the select statemnt' || l_sel_stmt);
Line: 3880

END select_update_rec;
Line: 3887

 |   This procedure is used to select receipts to be remitted             |
 |   update and insert records into the necessary tables.                 |
 | PSEUDO CODE/LOGIC                                                      |
 |                                                                        |
 | PARAMETERS                                                             |
 |                                                                        |
 |                                                                        |
 | KNOWN ISSUES                                                           |
 |                                                                        |
 | NOTES                                                                  |
 |                                                                        |
 |                                                                        |
 | MODIFICATION HISTORY                                                   |
 | Date                     Author            Description of Changes      |
 | 16-JUL-2005              bichatte           Created                    |
 *=========================================================================*/

PROCEDURE process_pay_receipt(
                p_batch_id            IN  NUMBER,
                p_called_from         IN  VARCHAR2,
                x_msg_count           OUT NOCOPY NUMBER,
                x_msg_data            OUT NOCOPY VARCHAR2,
                x_return_status       OUT NOCOPY VARCHAR2
                ) IS

  CURSOR rct_info_cur IS
     SELECT cr.receipt_number,
            cr.amount,
            cr.cash_receipt_id,
            cr.currency_code,
            rm.PAYMENT_CHANNEL_CODE,       /* NEW ADDED */
            rc.creation_status,            /* AR USE */
            cr.org_id,
            party.party_id,
            cr.pay_from_customer,
            cr.customer_site_use_id,
            cr.payment_trxn_extension_id,
            cr.selected_remittance_batch_id,
            cr.receipt_date,
	    pr.home_country
     FROM   ar_cash_receipts cr,
            ar_receipt_methods rm,
            ar_receipt_classes rc,
            hz_cust_accounts hca,
            hz_parties    party,
            ar_remit_gt g,
	    /* Need to pass country code for SEPA specific receipts */
            ce_bank_acct_uses bau,
            ce_bank_accounts cba,
            hz_parties bank,
	    hz_organization_profiles pr
     WHERE  cr.selected_remittance_batch_id = p_batch_id
     AND    g.cash_receipt_id = cr.cash_receipt_id
     AND    hca.party_id = party.party_id
     AND    hca.cust_account_id = cr.pay_from_customer
     AND    cr.receipt_method_id = rm.receipt_method_id
     AND    rm.receipt_class_id = rc.receipt_class_id
     AND    bau.bank_acct_use_id = cr.remit_bank_acct_use_id
     AND    cba.bank_account_id = bau.bank_account_id
     AND    bank.party_id = cba.bank_id
     AND    pr.party_id = bank.party_id
     AND    sysdate between pr.effective_start_date and nvl(pr.effective_end_date,sysdate) ;
Line: 4008

             l_last_updated_by         NUMBER;
Line: 4010

             l_last_update_login       NUMBER;
Line: 4027

       l_last_updated_by := arp_standard.profile.user_id ;
Line: 4029

       l_last_update_login := arp_standard.profile.last_update_login ;
Line: 4213

                       UPDATE ar_cash_receipts
        		SET cc_error_flag = 'Y',
                 	cc_error_code = l_response_rec.Result_Code,
                 	cc_error_text = nvl(l_iby_msg_data,pl_msg_data),
                 	last_updated_by = l_last_updated_by,
           		last_update_date = sysdate,
           		last_update_login = l_last_update_login,
         		request_id = l_request_id,
                 	program_application_id= l_program_application_id,
                	program_id = l_program_id,
             		program_update_date = sysdate
           	       WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 4226

                                fnd_file.put_line(FND_FILE.LOG,'UPDATE CR with cc_err_flag ' || SQL%ROWCOUNT );
Line: 4242

                       UPDATE ar_cash_receipts
        	        SET cc_error_flag = 'Y',
                        cc_error_code = l_authresult_rec.PaymentSys_Code,
                        cc_error_text = substr(l_authresult_rec.PaymentSys_Msg,1,240),
                        last_updated_by = l_last_updated_by,
           	        last_update_date = sysdate,
           	        last_update_login = l_last_update_login,
         	        request_id = l_request_id,
                        program_application_id= l_program_application_id,
                        program_id = l_program_id,
             	        program_update_date = sysdate
           	       WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 4255

                      fnd_file.put_line(FND_FILE.LOG,'UPDATE CR with cc_err_flag ' || SQL%ROWCOUNT );
Line: 4259

                        insert_exceptions(
                           p_batch_id   =>p_batch_id,
                           p_request_id =>l_request_id,
                           p_paying_customer_id =>l_payer_rec.cust_account_id,
                           p_cash_receipt_id => rct_info.cash_receipt_id,
                           p_exception_code  => 'AR_CC_AUTH_FAILED',
                           p_additional_message => substrb(l_iby_msg_data||l_vend_msg_data,1,240)
                             );
Line: 4278

                     insert_exceptions(
                           p_batch_id   =>p_batch_id,
                           p_request_id =>l_request_id,
                           p_paying_customer_id =>l_payer_rec.cust_account_id,
                           p_cash_receipt_id => rct_info.cash_receipt_id,
                           p_exception_code  => 'AR_CC_AUTH_FAILED',
                           p_additional_message => l_iby_msg_data
                             );
Line: 4287

                     UPDATE ar_cash_receipts
        	      SET cc_error_flag = 'Y',
                      last_updated_by = l_last_updated_by,
           	      last_update_date = sysdate,
           	      last_update_login = l_last_update_login,
         	      request_id = l_request_id,
                      program_application_id= l_program_application_id,
                      program_id = l_program_id,
             	      program_update_date = sysdate
           	     WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 4298

                     fnd_file.put_line(FND_FILE.LOG,'UPDATE CR with cc_err_flag ' || SQL%ROWCOUNT );
Line: 4411

                      insert_exceptions(
                           p_batch_id   =>p_batch_id,
                           p_request_id =>l_request_id,
                           p_paying_customer_id =>l_payer_rec.cust_account_id,
                           p_cash_receipt_id => rct_info.cash_receipt_id,
                           p_exception_code  => 'AR_CC_AUTH_FAILED',
                           p_additional_message => lc_iby_msg_data
                             );
Line: 4420

                      UPDATE ar_cash_receipts
          	       SET cc_error_flag = 'Y',
                       cc_error_code = lc_response_rec.Result_Code,
                       cc_error_text = nvl(lc_iby_msg_data,pl_msg_data),
                       last_updated_by = l_last_updated_by,
             	       last_update_date = sysdate,
            	       last_update_login = l_last_update_login,
          	       request_id = l_request_id,
                       program_application_id= l_program_application_id,
                       program_id = l_program_id,
              	       program_update_date = sysdate
           	      WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 4447

                     insert_exceptions(
                           p_batch_id   =>p_batch_id,
                           p_request_id =>l_request_id,
                           p_paying_customer_id =>l_payer_rec.cust_account_id,
                           p_cash_receipt_id => rct_info.cash_receipt_id,
                           p_exception_code  => 'AR_CC_AUTH_FAILED',
                           p_additional_message => l_iby_msg_data
                             );
Line: 4456

                     UPDATE ar_cash_receipts
        	      SET cc_error_flag = 'Y',
                      last_updated_by = l_last_updated_by,
           	      last_update_date = sysdate,
           	      last_update_login = l_last_update_login,
         	      request_id = l_request_id,
                      program_application_id= l_program_application_id,
                      program_id = l_program_id,
             	      program_update_date = sysdate
           	     WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 4467

                     fnd_file.put_line(FND_FILE.LOG,'UPDATE CR with cc_err_flag ' || SQL%ROWCOUNT );
Line: 4485

                    select count(*)
                    into l_count1
                    from AR_FUNDS_CAPTURE_ORDERS_V
                    where SELECTED_REMITTANCE_BATCH_ID = p_batch_id and CALL_APP_SERVICE_REQ_CODE = 'AR_'||p_batch_id;
Line: 4572

                                      select /*+ INDEX(ar_cash_receipts ar_cash_receipts_n15) */
                                             cash_receipt_id,pay_from_customer,customer_site_use_id
                                      into   l_cr_id,l_paying_customer_id,l_cust_site_id
                                      from ar_cash_receipts
                                      where  selected_remittance_batch_id = p_batch_id and
                                      payment_trxn_extension_id = ls_response_rec_tab(i).Trxn_Extension_Id;
Line: 4581

                                           insert_exceptions(
                                           p_batch_id   =>p_batch_id,
                                           p_request_id =>l_request_id,
                                           p_cash_receipt_id => l_cr_id,
                                           p_paying_customer_id =>l_paying_customer_id,
                                           p_paying_site_use_id => l_cust_site_id,
                                           p_exception_code  => 'AR_CC_CAPTURE_FAILED',
                                           p_additional_message => ls_iby_msg_data
                                           );
Line: 4592

                                UPDATE ar_cash_receipts
                                   SET cc_error_flag = 'Y',
                                         cc_error_code = decode(ls_response_rec_tab(i).Result.Result_Code,'INVALID_AUTHORIZATION',cc_error_code,ls_response_rec_tab(i).Result.Result_Code),
                                         cc_error_text = decode(ls_response_rec_tab(i).Result.Result_Code,'INVALID_AUTHORIZATION',cc_error_text,substr(ls_response_rec_tab(i).Result.Result_Message,1,240)),
                                         last_updated_by = l_last_updated_by,
                                         last_update_date = sysdate,
                                         last_update_login = l_last_update_login,
                                         request_id = l_request_id,
                                         program_application_id= l_program_application_id,
                                         program_id = l_program_id,
                                         program_update_date = sysdate
                                        WHERE cash_receipt_id  = l_cr_id;
Line: 4642

 |   This procedure is used to select receipts to be remitted             |
 |   update and insert records into the necessary tables.                 |
 | PSEUDO CODE/LOGIC                                                      |
 |                                                                        |
 | PARAMETERS                                                             |
 |                                                                        |
 |                                                                        |
 | KNOWN ISSUES                                                           |
 |                                                                        |
 | NOTES                                                                  |
 |                                                                        |
 |                                                                        |
 | MODIFICATION HISTORY                                                   |
 | Date                     Author            Description of Changes      |
 | 10-JUN-2008             AGHORAKA           Created for Parallelization |
 *=========================================================================*/

PROCEDURE process_pay_receipt_parallel(
                p_batch_id            IN  NUMBER,
                p_called_from         IN  VARCHAR2,
                x_msg_count           OUT NOCOPY NUMBER,
                x_msg_data            OUT NOCOPY VARCHAR2,
                x_return_status       OUT NOCOPY VARCHAR2
                ) IS

  CURSOR rct_info_cur IS
     SELECT a.receipt_number,
            a.amount2 amount,
            a.cash_receipt_id,
            a.currency_code,
            a.PAYMENT_CHANNEL_CODE,       /* NEW ADDED */
            a.creation_status,            /* AR USE */
            a.org_id,
            a.party_id,
            a.pay_from_customer,
            a.customer_site_use_id,
            a.payment_trxn_extension_id,
            a.batch_id,
	    pr.home_country
     FROM   ar_autorem_interim a,
             /* Need to pass country code for SEPA specific receipts */
	    ar_cash_receipts_all cr,
	    ce_bank_acct_uses bau,
            ce_bank_accounts cba,
            hz_parties bank,
	    hz_organization_profiles pr
     WHERE  a.batch_id = p_batch_id
     AND    a.current_worker = WORKER_NUMBER
     AND    a.cash_receipt_id = cr.cash_receipt_id
     AND    bau.bank_acct_use_id = cr.remit_bank_acct_use_id
     AND    cba.bank_account_id = bau.bank_account_id
     AND    bank.party_id = cba.bank_id
     AND    pr.party_id = bank.party_id
     AND    sysdate between pr.effective_start_date and nvl(pr.effective_end_date,sysdate) ;
Line: 4701

  SELECT receipt_date
  FROM  ar_cash_receipts
  WHERE cash_receipt_id = c_cash_receipt_id;
Line: 4767

             l_last_updated_by         NUMBER;
Line: 4769

             l_last_update_login       NUMBER;
Line: 4783

       l_last_updated_by := arp_standard.profile.user_id ;
Line: 4785

       l_last_update_login := arp_standard.profile.last_update_login ;
Line: 4960

                       UPDATE ar_cash_receipts
        		SET cc_error_flag = 'Y',
                 	cc_error_code = l_response_rec.Result_Code,
                 	cc_error_text = nvl(l_iby_msg_data,pl_msg_data),
                 	last_updated_by = l_last_updated_by,
           		last_update_date = sysdate,
           		last_update_login = l_last_update_login,
         		request_id = l_request_id,
                 	program_application_id= l_program_application_id,
                	program_id = l_program_id,
             		program_update_date = sysdate
           	       WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 4973

                       fnd_file.put_line(FND_FILE.LOG,'UPDATE CR with cc_err_flag ' || SQL%ROWCOUNT );
Line: 4987

                       UPDATE ar_cash_receipts
        	        SET cc_error_flag = 'Y',
                        cc_error_code = l_authresult_rec.PaymentSys_Code,
                        cc_error_text = substr(l_authresult_rec.PaymentSys_Msg,1,240),
                        last_updated_by = l_last_updated_by,
           	        last_update_date = sysdate,
           	        last_update_login = l_last_update_login,
         	          request_id = l_request_id,
                        program_application_id= l_program_application_id,
                        program_id = l_program_id,
             	        program_update_date = sysdate
           	       WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 5000

                      fnd_file.put_line(FND_FILE.LOG,'UPDATE CR with cc_err_flag ' || SQL%ROWCOUNT );
Line: 5004

                        insert_exceptions(
                           p_batch_id   =>p_batch_id,
                           p_request_id =>l_request_id,
                           p_paying_customer_id =>l_payer_rec.cust_account_id,
                           p_cash_receipt_id => rct_info.cash_receipt_id,
                           p_exception_code  => 'AR_CC_AUTH_FAILED',
                           p_additional_message => substrb(l_iby_msg_data||l_vend_msg_data,1,240)
                             );
Line: 5023

                     insert_exceptions(
                           p_batch_id   =>p_batch_id,
                           p_request_id =>l_request_id,
                           p_paying_customer_id =>l_payer_rec.cust_account_id,
                           p_cash_receipt_id => rct_info.cash_receipt_id,
                           p_exception_code  => 'AR_CC_AUTH_FAILED',
                           p_additional_message => l_iby_msg_data
                             );
Line: 5032

                     UPDATE ar_cash_receipts
        	      SET cc_error_flag = 'Y',
                      last_updated_by = l_last_updated_by,
           	      last_update_date = sysdate,
           	      last_update_login = l_last_update_login,
         	      request_id = l_request_id,
                      program_application_id= l_program_application_id,
                      program_id = l_program_id,
             	      program_update_date = sysdate
           	     WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 5043

                     fnd_file.put_line(FND_FILE.LOG,'UPDATE CR with cc_err_flag ' || SQL%ROWCOUNT );
Line: 5070

                     /* 7666285 - Selecting settlement_date*/
                IF (rct_info.cash_receipt_id IS NOT NULL) THEN
                      OPEN rct_date_cur(rct_info.cash_receipt_id);
Line: 5175

                      insert_exceptions(
                           p_batch_id   =>p_batch_id,
                           p_request_id =>l_request_id,
                           p_paying_customer_id =>l_payer_rec.cust_account_id,
                           p_cash_receipt_id => rct_info.cash_receipt_id,
                           p_exception_code  => 'AR_CC_AUTH_FAILED',
                           p_additional_message => lc_iby_msg_data
                             );
Line: 5184

                      UPDATE ar_cash_receipts
          	       SET cc_error_flag = 'Y',
                       cc_error_code = lc_response_rec.Result_Code,
                       cc_error_text = nvl(lc_iby_msg_data,pl_msg_data),
                       last_updated_by = l_last_updated_by,
             	       last_update_date = sysdate,
            	       last_update_login = l_last_update_login,
          	       request_id = l_request_id,
                       program_application_id= l_program_application_id,
                       program_id = l_program_id,
              	       program_update_date = sysdate
           	      WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 5211

                     insert_exceptions(
                           p_batch_id   =>p_batch_id,
                           p_request_id =>l_request_id,
                           p_paying_customer_id =>l_payer_rec.cust_account_id,
                           p_cash_receipt_id => rct_info.cash_receipt_id,
                           p_exception_code  => 'AR_CC_AUTH_FAILED',
                           p_additional_message => l_iby_msg_data
                             );
Line: 5220

                     UPDATE ar_cash_receipts
        	      SET cc_error_flag = 'Y',
                      last_updated_by = l_last_updated_by,
           	      last_update_date = sysdate,
           	      last_update_login = l_last_update_login,
         	      request_id = l_request_id,
                      program_application_id= l_program_application_id,
                      program_id = l_program_id,
             	      program_update_date = sysdate
           	     WHERE cash_receipt_id  = rct_info.cash_receipt_id;
Line: 5231

                     fnd_file.put_line(FND_FILE.LOG,'UPDATE CR with cc_err_flag ' || SQL%ROWCOUNT );
Line: 5251

                    select count(*)
                    into l_count1
                    from AR_FUNDS_CAPTURE_ORDERS_V
                    where SELECTED_REMITTANCE_BATCH_ID = p_batch_id and CALL_APP_SERVICE_REQ_CODE = 'AR_'||p_batch_id;
Line: 5344

                                      select /*+ INDEX(ar_cash_receipts ar_cash_receipts_n15) */
                                      	     cash_receipt_id,pay_from_customer,customer_site_use_id
                                      into   l_cr_id,l_paying_customer_id,l_cust_site_id
                                      from ar_cash_receipts
                                      where  selected_remittance_batch_id = p_batch_id and
                                      payment_trxn_extension_id = ls_response_rec_tab(i).Trxn_Extension_Id;
Line: 5353

                                           insert_exceptions(
                                           p_batch_id   =>p_batch_id,
                                           p_request_id =>l_request_id,
                                           p_cash_receipt_id => l_cr_id,
                                           p_paying_customer_id =>l_paying_customer_id,
                                           p_paying_site_use_id => l_cust_site_id,
                                           p_exception_code  => 'AR_CC_CAPTURE_FAILED',
                                           p_additional_message => ls_iby_msg_data
                                           );
Line: 5364

                                UPDATE ar_cash_receipts
                                   SET cc_error_flag = 'Y',
                                         cc_error_code = ls_response_rec_tab(i).Result.Result_Code,
                                         cc_error_text = ls_response_rec_tab(i).Result.Result_Message,
                                         last_updated_by = l_last_updated_by,
                                         last_update_date = sysdate,
                                         last_update_login = l_last_update_login,
                                         request_id = l_request_id,
                                         program_application_id= l_program_application_id,
                                         program_id = l_program_id,
                                         program_update_date = sysdate
                                        WHERE cash_receipt_id  = l_cr_id;
Line: 5413

 |  PROCEDURE insert_exceptions                                           |
 |                                                                        |
 | DESCRIPTION                                                            |
 |                                                                        |
 |   This procedure is used to insert the exception record when           |
 |                                                                        |
 | PSEUDO CODE/LOGIC                                                      |
 |                                                                        |
 | PARAMETERS                                                             |
 |                                                                        |
 |                                                                        |
 | KNOWN ISSUES                                                           |
 |                                                                        |
 | NOTES                                                                  |
 |                                                                        |
 |                                                                        |
 | MODIFICATION HISTORY                                                   |
 | Date                     Author            Description of Changes      |
 | 16-JUL-2005              bichatte           Created                    |
 *=========================================================================*/
PROCEDURE insert_exceptions(
             p_batch_id               IN  ar_batches.batch_id%TYPE DEFAULT NULL,
             p_request_id             IN  ar_cash_receipts.request_id%TYPE DEFAULT NULL,
             p_cash_receipt_id        IN  ar_cash_receipts.cash_receipt_id%TYPE DEFAULT NULL,
             p_payment_schedule_id    IN  ar_payment_schedules.payment_schedule_id%TYPE DEFAULT NULL,
             p_paying_customer_id     IN  ar_cash_receipts.pay_from_customer%TYPE DEFAULT NULL,
             p_paying_site_use_id     IN  ar_cash_receipts.customer_site_use_id%TYPE DEFAULT NULL,
             p_due_date               IN  ar_payment_schedules.due_date%TYPE DEFAULT NULL,
             p_cust_min_rec_amount    IN  NUMBER DEFAULT NULL,
             p_bank_min_rec_amount    IN NUMBER DEFAULT NULL,
             p_exception_code         IN VARCHAR2,
             p_additional_message     IN VARCHAR2
             ) IS



             l_request_id              NUMBER;
Line: 5450

             l_last_updated_by         NUMBER;
Line: 5452

             l_last_update_login       NUMBER;
Line: 5461

             fnd_file.put_line(FND_FILE.LOG, 'enter insert exceptions');
Line: 5480

       l_last_updated_by := arp_standard.profile.user_id ;
Line: 5482

       l_last_update_login := arp_standard.profile.last_update_login ;
Line: 5489

fnd_file.put_line(FND_FILE.LOG,  'value of l_last_updated_by  '      || l_last_updated_by );
Line: 5491

fnd_file.put_line(FND_FILE.LOG,  'value of l_last_update_login '     || l_last_update_login );
Line: 5498

 INSERT
        INTO ar_autorec_exceptions
            (batch_id,
             request_id,
             cash_receipt_id,
             payment_schedule_id,
             paying_customer_id,
             paying_site_use_id,
             due_date,
             cust_min_rec_amount,
             bank_min_rec_amount,
             exception_code,
             additional_message,
             last_update_date,
             last_updated_by,
             creation_date,
             created_by,
             last_update_login,
             program_application_id,
             program_id,
             program_update_date)
        SELECT
             p_batch_id,
             l_request_id,
             p_cash_receipt_id,
             p_payment_schedule_id,
             p_paying_customer_id,
             p_paying_site_use_id,
             p_due_date,
             p_cust_min_rec_amount,
             p_bank_min_rec_amount,
             p_exception_code,
             p_additional_message,
             sysdate,
             l_last_updated_by,
             sysdate,
             l_created_by,
             l_last_update_login,
             l_program_application_id,
             l_program_id,
             sysdate  FROM DUAL;
Line: 5550

      fnd_file.put_line(FND_FILE.LOG,'ERROR IN INSERT_AUTOREC_EXCEPTIONS' );
Line: 5554

END insert_exceptions;
Line: 5610

select org_id into l_org_id
from ar_batches_all
where batch_id = p_batch_id;
Line: 5684

select org_id into l_org_id
from ar_batches_all
where batch_id = p_batch_id;
Line: 5697

select nvl(decode(ab.remit_method_code,'FACTORING',appfactor.program_name,appremit.program_name),'ARXAPFRM')
into  l_prog_name
from ar_batches ab,
     ar_receipt_method_accounts rma,
     ap_payment_programs appremit,
     ap_payment_programs appfactor
where ab.type = 'REMITTANCE'
and ab.batch_id = p_batch_id
and ab.receipt_method_id = rma.receipt_method_id
and ab.remit_bank_acct_use_id = rma.remit_bank_acct_use_id
and rma.factor_print_program_id= appfactor.program_id(+)
and rma.remit_print_program_id = appremit.program_id(+);
Line: 5740

   l_last_updated_by         NUMBER;
Line: 5742

   l_last_update_login       NUMBER;
Line: 5751

    l_last_updated_by := arp_standard.profile.user_id ;
Line: 5753

    l_last_update_login := arp_standard.profile.last_update_login ;
Line: 5757

UPDATE ar_cash_receipts
SET cc_error_flag = 'Y',
  last_updated_by = l_last_updated_by,
  last_update_date = sysdate,
  last_update_login = l_last_update_login,
  request_id = l_request_id,
  program_application_id = l_program_application_id,
  program_id = l_program_id,
  program_update_date = sysdate
WHERE cash_receipt_id in (
SELECT cr.cash_receipt_id
FROM ar_cash_receipts cr,
  ar_cash_receipt_history crh,
  iby_trxn_extensions_v trxn_ext
WHERE crh.request_id = l_request_id
 AND crh.status = 'REMITTED'
 AND crh.current_record_flag = 'Y'
 AND crh.cash_receipt_id = cr.cash_receipt_id
 AND cr.type = 'CASH'
 AND cr.payment_trxn_extension_id = trxn_ext.trxn_extension_id
 AND trxn_ext.settled_flag = 'N'
 AND NOT EXISTS (SELECT 'x'
   FROM iby_fndcpt_tx_operations op,    iby_trxn_summaries_all summ
   WHERE cr.payment_trxn_extension_id = op.trxn_extension_id
   AND op.transactionid = summ.transactionid
   AND summ.reqtype in ('ORAPMTCAPTURE','ORAPMTBATCHREQ')
   AND summ.status IN(0, 11, 100, 111))
  ) AND selected_remittance_batch_id = p_batch_id;
Line: 5790

  INSERT INTO ar_autorec_exceptions
            (batch_id,
             request_id,
             cash_receipt_id,
             paying_customer_id,
             exception_code,
             additional_message,
             last_update_date,
             last_updated_by,
             creation_date,
             created_by,
             last_update_login,
             program_application_id,
             program_id,
             program_update_date)
        SELECT
             p_batch_id,
             l_request_id,
             cr.cash_receipt_id,
             cr.pay_from_customer,
             'AR_CC_AUTH_FAILED',
             'Failure in settlements',
             sysdate,
             l_last_updated_by,
             sysdate,
             l_created_by,
             l_last_update_login,
             l_program_application_id,
             l_program_id,
             sysdate
          FROM ar_cash_receipts cr,
               ar_cash_receipt_history crh,
               iby_trxn_extensions_v trxn_ext
          WHERE crh.request_id = l_request_id
                AND crh.status = 'REMITTED'
                AND crh.current_record_flag = 'Y'
                AND crh.cash_receipt_id = cr.cash_receipt_id
                AND cr.type = 'CASH'
                AND cr.payment_trxn_extension_id = trxn_ext.trxn_extension_id
                AND trxn_ext.settled_flag = 'N'
                AND NOT EXISTS (SELECT 'x'
                  FROM iby_fndcpt_tx_operations op,    iby_trxn_summaries_all summ
                  WHERE cr.payment_trxn_extension_id = op.trxn_extension_id
                  AND op.transactionid = summ.transactionid
                  AND summ.reqtype in ('ORAPMTCAPTURE','ORAPMTBATCHREQ')
                  AND summ.status IN(0, 11, 100, 111));
Line: 5838

UPDATE ar_cash_receipts
SET cc_error_flag = 'Y',
  last_updated_by = l_last_updated_by,
  last_update_date = sysdate,
  last_update_login = l_last_update_login,
  request_id = l_request_id,
  program_application_id = l_program_application_id,
  program_id = l_program_id,
  program_update_date = sysdate
WHERE cash_receipt_id in (
SELECT cr.cash_receipt_id
FROM ar_cash_receipts cr,
  ar_cash_receipt_history crh,
  iby_trxn_extensions_v trxn_ext
WHERE crh.request_id = l_request_id
 AND crh.status = 'REMITTED'
 AND crh.current_record_flag = 'Y'
 AND crh.cash_receipt_id = cr.cash_receipt_id
 AND cr.type = 'MISC'
 AND cr.payment_trxn_extension_id = trxn_ext.trxn_extension_id
 AND trxn_ext.returned_flag = 'N'
 AND NOT EXISTS (SELECT 'x'
     FROM iby_fndcpt_tx_operations op,    iby_trxn_summaries_all summ
     WHERE cr.payment_trxn_extension_id = op.trxn_extension_id
     AND op.transactionid = summ.transactionid
     AND summ.reqtype in ('ORAPMTRETURN','ORAPMTCREDIT')
     AND status IN(0, 11, 100, 111))
 ) AND selected_remittance_batch_id = p_batch_id;
Line: 5871

  INSERT INTO ar_autorec_exceptions
            (batch_id,
             request_id,
             cash_receipt_id,
             paying_customer_id,
             exception_code,
             additional_message,
             last_update_date,
             last_updated_by,
             creation_date,
             created_by,
             last_update_login,
             program_application_id,
             program_id,
             program_update_date)
        SELECT
             p_batch_id,
             l_request_id,
             cr.cash_receipt_id,
             cr.pay_from_customer,
             'AR_CC_AUTH_FAILED',
             'Failure in settlements',
             sysdate,
             l_last_updated_by,
             sysdate,
             l_created_by,
             l_last_update_login,
             l_program_application_id,
             l_program_id,
             sysdate
          FROM ar_cash_receipts cr,
               ar_cash_receipt_history crh,
               iby_trxn_extensions_v trxn_ext
          WHERE crh.request_id = l_request_id
                AND crh.status = 'REMITTED'
                AND crh.current_record_flag = 'Y'
                AND crh.cash_receipt_id = cr.cash_receipt_id
                AND cr.type = 'MISC'
                AND cr.payment_trxn_extension_id = trxn_ext.trxn_extension_id
                AND trxn_ext.returned_flag = 'N'
                AND NOT EXISTS (SELECT 'x'
                  FROM iby_fndcpt_tx_operations op,    iby_trxn_summaries_all summ
                  WHERE cr.payment_trxn_extension_id = op.trxn_extension_id
                  AND op.transactionid = summ.transactionid
                  AND summ.reqtype in ('ORAPMTRETURN','ORAPMTCREDIT')
                  AND status IN(0, 11, 100, 111));
Line: 5944

UPDATE ar_cash_receipts
SET cc_error_flag = null
WHERE cash_receipt_id in (
SELECT cr.cash_receipt_id
FROM ar_cash_receipts cr,
  ar_cash_receipt_history crh,
  iby_trxn_extensions_v trxn_ext
WHERE cr.request_id = p_request_id
 AND cr.cc_error_flag = 'Y'
 AND cr.type = 'CASH'
 AND crh.cash_receipt_id = cr.cash_receipt_id
 AND crh.status = 'REMITTED'
 AND crh.current_record_flag = 'Y'
 AND cr.payment_trxn_extension_id = trxn_ext.trxn_extension_id
 AND trxn_ext.settled_flag = 'Y'
 AND EXISTS (SELECT 'x'
   FROM iby_fndcpt_tx_operations op,    iby_trxn_summaries_all summ
   WHERE cr.payment_trxn_extension_id = op.trxn_extension_id
   AND op.transactionid = summ.transactionid
   AND summ.reqtype in ('ORAPMTCAPTURE','ORAPMTBATCHREQ')
   AND summ.status IN(0, 11, 100, 111))
  ) AND request_id = p_request_id
    AND cc_error_flag = 'Y';
Line: 5968

 fnd_file.put_line(FND_FILE.LOG,'CASH receipt rows updated : '||sql%rowcount);
Line: 5971

UPDATE ar_cash_receipts
SET cc_error_flag = null
WHERE cash_receipt_id in (
SELECT cr.cash_receipt_id
FROM ar_cash_receipts cr,
  ar_cash_receipt_history crh,
  iby_trxn_extensions_v trxn_ext
WHERE cr.request_id = p_request_id
 AND cr.cc_error_flag = 'Y'
 AND cr.type = 'MISC'
 AND crh.cash_receipt_id = cr.cash_receipt_id
 AND crh.status = 'REMITTED'
 AND crh.current_record_flag = 'Y'
 AND cr.payment_trxn_extension_id = trxn_ext.trxn_extension_id
 AND trxn_ext.returned_flag = 'Y'
 AND EXISTS (SELECT 'x'
   FROM iby_fndcpt_tx_operations op,    iby_trxn_summaries_all summ
   WHERE cr.payment_trxn_extension_id = op.trxn_extension_id
   AND op.transactionid = summ.transactionid
   AND summ.reqtype in ('ORAPMTRETURN','ORAPMTCREDIT')
   AND status IN(0, 11, 100, 111))
  ) AND request_id = p_request_id
    AND cc_error_flag = 'Y';
Line: 5995

 fnd_file.put_line(FND_FILE.LOG,'MISC receipt rows updated : '||sql%rowcount);
Line: 5997

           fnd_file.put_line(FND_FILE.LOG,'delete the bad receipts');
Line: 5999

             update ar_cash_receipts
             set selected_remittance_batch_id = null
             where request_id = p_request_id
             and   cc_error_flag = 'Y';
Line: 6005

             fnd_file.put_line(FND_FILE.LOG,' rows updated CR = ' || SQL%ROWCOUNT );
Line: 6009

                UPDATE ar_cash_receipt_history
                SET reversal_cash_receipt_hist_id = null,
                reversal_gl_date = null,
                reversal_created_from = null,
                current_record_flag = 'Y'
                where request_id = p_request_id
                and  status = 'CONFIRMED'
                and cash_receipt_id in ( select cash_receipt_id
                              from ar_cash_receipts
                              where request_id = p_request_id
                              and   cc_error_flag = 'Y');
Line: 6022

             fnd_file.put_line(FND_FILE.LOG,' rows UPDATED CRH = ' || SQL%ROWCOUNT );
Line: 6025

		delete from ar_distributions
		where source_table = 'CRH'
		and source_id in ( select crh.cash_receipt_history_id
		from ar_cash_receipt_history crh,
                     ar_cash_receipts cr
		where crh.STATUS = 'REMITTED'
                and crh.request_id = p_request_id
                and cr.cash_receipt_id = crh.cash_receipt_id
                and cr.request_id = p_request_id
                and cr.cc_error_flag = 'Y' );
Line: 6037

             fnd_file.put_line(FND_FILE.LOG,' rows DELETED AR_DIST = ' || SQL%ROWCOUNT );
Line: 6040

		delete from ar_cash_receipt_history
		where STATUS = 'REMITTED'
            and request_id = p_request_id
            and cash_receipt_id in ( select cash_receipt_id
                                     from ar_cash_receipts
                                     where request_id = p_request_id
                                     and cc_error_flag = 'Y');
Line: 6050

             fnd_file.put_line(FND_FILE.LOG,' rows DELETED CRH = ' || SQL%ROWCOUNT );
Line: 6053

/* Start of delete XLA events code. Doing this is bulk */
BEGIN

  IF pg_debug IN('Y',   'C') THEN
    arp_debug.debug('Start calling xla delete_bulk_events');
Line: 6058

    arp_debug.debug('Inserting into xla_events_int_gt...');
Line: 6061

  INSERT INTO xla_events_int_gt(
       event_id,
       ledger_id,
       entity_code,
       application_id,
       event_type_code,
       entity_id,
       event_number,
       event_status_code,
       process_status_code,
       event_date,
       transaction_date,
       budgetary_control_flag,
       reference_num_1,
       reference_num_2,
       reference_num_3,
       reference_num_4,
       reference_char_1,
       reference_char_2,
       reference_char_3,
       reference_char_4,
       reference_date_1,
       reference_date_2,
       reference_date_3,
       reference_date_4,
       on_hold_flag)
    (SELECT event_id,
       ledger_id,
       entity_code,
       xte.application_id,
       event_type_code,
       xte.entity_id,
       event_number,
       event_status_code,
       process_status_code,
       TRUNC(event_date),
       nvl(transaction_date,    TRUNC(event_date)),
       'N',
       reference_num_1,
       reference_num_2,
       reference_num_3,
       reference_num_4,
       reference_char_1,
       reference_char_2,
       reference_char_3,
       reference_char_4,
       reference_date_1,
       reference_date_2,
       reference_date_3,
       reference_date_4,
       on_hold_flag
     FROM ar_cash_receipts cr,
       xla_transaction_entities_upg xte,
       xla_events xe
     WHERE cr.request_id = p_request_id
     AND cr.cc_error_flag = 'Y'
     AND nvl(xte.source_id_int_1,    -99) = cr.cash_receipt_id
     AND xte.ledger_id = arp_standard.sysparm.set_of_books_id
     AND xte.application_id = 222
     AND xte.entity_code = 'RECEIPTS'
     AND xe.entity_id = xte.entity_id
     AND xe.event_status_code <> 'P'
     AND xe.application_id = 222
     AND xe.event_number > 0
     AND NOT EXISTS
      (SELECT 'x'
       FROM ar_receivable_applications ra,
         ar_distributions dis
       WHERE ra.cash_receipt_id = cr.cash_receipt_id
       AND dis.source_id = ra.receivable_application_id
       AND dis.source_table = 'RA'
       AND ra.posting_control_id = -3
       AND ra.event_id = xe.event_id
       UNION
       SELECT 'x'
       FROM ar_cash_receipt_history crh,
         ar_distributions dis
       WHERE crh.cash_receipt_id = cr.cash_receipt_id
       AND dis.source_id = crh.cash_receipt_history_id
       AND dis.source_table = 'CRH'
       AND crh.posting_control_id = -3
       AND crh.event_id = xe.event_id
       UNION
       SELECT 'x'
       FROM ar_misc_cash_distributions mcd,
         ar_distributions dis
       WHERE mcd.cash_receipt_id = cr.cash_receipt_id
       AND dis.source_id = mcd.misc_cash_distribution_id
       AND dis.source_table = 'MCD'
       AND mcd.posting_control_id = -3
       AND mcd.event_id = xe.event_id));
Line: 6154

    arp_debug.debug('rows inserted into xla gt table = ' || SQL % rowcount);
Line: 6155

    arp_debug.debug('Calling xla_events_pub_pkg.delete_bulk_events()');
Line: 6158

  xla_events_pub_pkg.delete_bulk_events(222);
Line: 6161

    arp_debug.debug('End calling xla delete_bulk_events');
Line: 6168

    arp_debug.debug('Error in call to xla_events_pub_pkg.delete_bulk_events ' || sqlerrm);
Line: 6173

/* End of delete XLA events code */



      END IF;