Social Icons

Friday, March 18, 2016

Receipt apply API script

/* Formatted on 2012/05/31 20:10 (Formatter Plus v4.8.8) */
DECLARE
   l_return_status     VARCHAR2 (1);
   l_msg_count         NUMBER;
   l_msg_data          VARCHAR2 (240);
   l_cash_receipt_id   NUMBER;
   l_customer_trx_id   NUMBER;

   CURSOR trx_lines_to_ar_c
   IS
      SELECT   sno, receipt_number, trx_number, account_number,
               amount_applied, apply_date, applied_gl_date
          FROM XXX_ar_receip_rec_3
         WHERE sno IN (1)
           AND UPPER (TRIM (customer_name)) IN (
                                              SELECT UPPER (TRIM (party_name))
                                                FROM hz_parties)
           AND receipt_amount NOT LIKE '-%'
           and account_number=5754
           AND receipt_number ='    270143-CASH'
      ORDER BY 1;
BEGIN
   mo_global.init ('AR');
   mo_global.set_policy_context ('S', '82');
   fnd_global.apps_initialize (1113, 20678, 222, 0);

   FOR c1 IN trx_lines_to_ar_c
   LOOP
      BEGIN
         SELECT cash_receipt_id
           INTO l_cash_receipt_id
           FROM ar_cash_receipts_all a, hz_cust_accounts_all b
          WHERE a.pay_from_customer = b.cust_account_id
            AND TRIM (b.account_number) = TRIM (c1.account_number)
            AND TRIM (receipt_number) = TRIM (c1.receipt_number);
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line (   'Recept Number Does not exist'
                                  || TRIM (c1.receipt_number)
                                 );
      END;

      BEGIN
         SELECT customer_trx_id
           INTO l_customer_trx_id
           FROM ra_customer_trx_all
          WHERE TRIM (trx_number) = TRIM (c1.trx_number);
      EXCEPTION
         WHEN OTHERS
         THEN
            DBMS_OUTPUT.put_line (   'Trx_number Does not exist'
                                  || TRIM (c1.trx_number)
                                 );
      END;

      ar_receipt_api_pub.APPLY
                            (p_api_version                      => 1.0,
                             p_init_msg_list                    => fnd_api.g_false,
                             p_commit                           => fnd_api.g_false,
                             p_validation_level                 => fnd_api.g_valid_level_full,
                             x_return_status                    => l_return_status,
                             x_msg_count                        => l_msg_count,
                             x_msg_data                         => l_msg_data,
                             p_cash_receipt_id                  => l_cash_receipt_id,
                             p_customer_trx_id                  => l_customer_trx_id,
                             p_applied_payment_schedule_id      => NULL,
                             p_amount_applied                   => c1.amount_applied,
                             p_show_closed_invoices             => 'Y',
                             p_apply_date                       => c1.apply_date,
                             p_apply_gl_date                    => c1.applied_gl_date,
                             p_line_number                      => 1
                            );
      COMMIT;
      DBMS_OUTPUT.put_line ('Message count ' || l_msg_count);
      DBMS_OUTPUT.put_line ('Status ' || l_return_status);

      IF l_msg_count = 1
      THEN
         DBMS_OUTPUT.put_line ('l_msg_data ' || l_msg_data);
      ELSIF l_msg_count > 1
      THEN
         LOOP
            l_msg_data :=
                        fnd_msg_pub.get (fnd_msg_pub.g_next, fnd_api.g_false);

            IF l_msg_data IS NULL
            THEN
               EXIT;
            END IF;

            DBMS_OUTPUT.put_line ('Message' || l_msg_data);
         END LOOP;
      END IF;

      arp_standard.disable_debug;
      DBMS_OUTPUT.put_line ('Successfully completed');
   END LOOP;
END;

No comments :

Post a Comment

">