Sample API Code for AR_RECEIPT_API_PUB.Apply_on_account



This API   AR_RECEIPT_API_PUB.Apply_on_account  will comes into picture  when amount needs to be apply against the receipt but there is no valid transaction for the customer . For those records you apply them as ON ACCOUNT against the receipts and later you can associate customer as well from front end.

Sample API code to apply ON Account amount against Receipt.

DECLARE
   p_api_version                    NUMBER;
   p_init_msg_list                  VARCHAR2 (200);
   p_commit                         VARCHAR2 (200);
   p_validation_level               NUMBER;
   x_return_status                  VARCHAR2 (200);
   x_msg_count                      NUMBER;
   x_msg_data                       VARCHAR2 (200);
   p_cash_receipt_id                ar_cash_receipts.cash_receipt_id%TYPE;
   p_receipt_number                 ar_cash_receipts.receipt_number%TYPE;
   p_amount_applied                 ar_receivable_applications.amount_applied%TYPE;
   p_apply_date                     ar_receivable_applications.apply_date%TYPE;
   p_apply_gl_date                  ar_receivable_applications.gl_date%TYPE;
   p_ussgl_transaction_code         ar_receivable_applications.ussgl_transaction_code%TYPE;
   p_attribute_rec                  AR_RECEIPT_API_PUB.attribute_rec_type;
   p_global_attribute_rec           AR_RECEIPT_API_PUB.global_attribute_rec_type;
   p_comments                       ar_receivable_applications.comments%TYPE;
   p_application_ref_num            ar_receivable_applications.application_ref_num%TYPE;
   p_secondary_application_ref_id   ar_receivable_applications.secondary_application_ref_id%TYPE;
   p_customer_reference             ar_receivable_applications.customer_reference%TYPE;
   p_called_from                    VARCHAR2 (200);
   p_customer_reason                ar_receivable_applications.customer_reason%TYPE;
   p_secondary_app_ref_type         ar_receivable_applications.secondary_application_ref_type%TYPE;
   p_secondary_app_ref_num          ar_receivable_applications.secondary_application_ref_num%TYPE;
BEGIN
   mo_global.SET_POLICY_CONTEXT ('S', 414);                     -- your org id
   mo_global.init ('AR');
   ---- p_receipt_number := '909RR9';
   p_cash_receipt_id := 95951; ----<Cash Receipt id >
   p_amount_applied := 120;  ------< Amount needs to on accounted>
   p_apply_date := TRUNC (SYSDATE);
   p_apply_gl_date := TRUNC (SYSDATE);

   AR_RECEIPT_API_PUB.Apply_on_account (
      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                  => x_return_status,
      x_msg_count                      => x_msg_count,
      x_msg_data                       => x_msg_data,
      p_cash_receipt_id                => p_cash_receipt_id,
      p_receipt_number                 => p_receipt_number,
      p_amount_applied                 => p_amount_applied,
      p_apply_date                     => p_apply_date,
      p_apply_gl_date                  => p_apply_gl_date,
      p_org_id                         => 414, ------ <Org id >
      p_ussgl_transaction_code         => p_ussgl_transaction_code,
      p_attribute_rec                  => p_attribute_rec,
      p_global_attribute_rec           => p_global_attribute_rec,
      p_comments                       => p_comments,
      p_application_ref_num            => p_application_ref_num,
      p_secondary_application_ref_id   => p_secondary_application_ref_id,
      p_customer_reference             => p_customer_reference,
      p_called_from                    => p_called_from,
      p_customer_reason                => p_customer_reason,
      p_secondary_app_ref_type         => p_secondary_app_ref_type,
      p_secondary_app_ref_num          => p_secondary_app_ref_num
   );

   IF (x_return_status = 'S')
   THEN
      COMMIT;

      DBMS_OUTPUT.put_line ('SUCCESS');
      DBMS_OUTPUT.put_line (
         'Return Status            = ' || SUBSTR (x_return_status, 1, 255)
      );
      DBMS_OUTPUT.put_line ('Message Count             = ' || x_msg_count);
      DBMS_OUTPUT.put_line ('Message Data            = ' || x_msg_data);
   ELSE
      ROLLBACK;

      DBMS_OUTPUT.put_line (
         'Return Status    = ' || SUBSTR (x_return_status, 1, 255)
      );
      DBMS_OUTPUT.put_line ('Message Count     = ' || TO_CHAR (x_msg_count));
      DBMS_OUTPUT.put_line (
         'Message Data    = ' || SUBSTR (x_msg_data, 1, 255)
      );
      DBMS_OUTPUT.put_line(APPS.FND_MSG_PUB.Get (
                              p_msg_index   => APPS.FND_MSG_PUB.G_LAST,
                              p_encoded     => APPS.FND_API.G_FALSE
                           ));

      IF x_msg_count >= 0
      THEN
         FOR I IN 1 .. 10
         LOOP
            DBMS_OUTPUT.put_line(I || '. '
                                 || SUBSTR (
                                       FND_MSG_PUB.Get (
                                          p_encoded   => FND_API.G_FALSE
                                       ),
                                       1,
                                       255
                                    ));
         END LOOP;
      END IF;
   END IF;
EXCEPTION
   WHEN OTHERS
   THEN
      DBMS_OUTPUT.put_line ('Exception :' || SQLERRM);
END;

Comments

Popular posts from this blog

Sample HZ API's script to Create Contacts and Contact Points in Oracle

REST integration built-in OIC to read Large files with size more than 10MB