Sample API Code for Receipt Write off Activity

Receipt Write off Activity : This activity will come into role if any adjustments needs to be made against the receipt apply amount

For example Receipt amount is $100 and for that already applied amount is $50 and now you want to adjust that $50 from applied amount for that receipt write off functionality

Prequisite setup

To enable Receipt Write off functionality Approval limits for the users needs to be define

Set up for the Approval Limits

Receivables Managerà Transactions àApproval Limits 




Select the relevant user with which you want to perform write off operations. Where document type has many activities but our aim is to write off amounts so choose  "Receipt Write Off". select currency as USD and set the approval limit amounts 



Below is the sample code to create write off amounts but before that  we need to set the context for user without it , API wont kick off  and another mandatory paramter is Receivables_trx_id which can be defined from below query

/* Query to determine receivables_Trx_id*/

         SELECT   RECEIVABLES_TRX_ID
           INTO   l_receivables_trx_id
           FROM   AR_RECEIVABLES_TRX_ALL
          WHERE   NAME = 'Customer Claim' AND ORG_ID =<ORG_ID>;


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_applied_payment_schedule_id    ar_payment_schedules.payment_schedule_id%TYPE;
      p_link_to_customer_trx_id           ra_customer_trx.customer_trx_id%TYPE;
      p_receivables_trx_id             ar_receivable_applications.receivables_trx_id%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_type           ar_receivable_applications.application_ref_type%TYPE;
      p_application_ref_id             ar_receivable_applications.application_ref_id%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_payment_set_id                 ar_receivable_applications.payment_set_id%TYPE;
      p_receivable_application_id      ar_receivable_applications.receivable_application_id%TYPE;
      p_customer_reference             ar_receivable_applications.customer_reference%TYPE;
      p_val_writeoff_limits_flag       VARCHAR2(200);
      p_called_from               VARCHAR2(200);
      p_netted_receipt_flag           VARCHAR2(200);
      p_netted_cash_receipt_id         ar_cash_receipts.cash_receipt_id%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

    p_cash_receipt_id                    := 95951;        
    p_amount_applied                     := 3;      
    p_applied_payment_schedule_id        := -3;      
    p_receivables_trx_id                 := 16040;      
     
   fnd_global.apps_initialize (1648, 222, 20678);

AR_RECEIPT_API_PUB.Activity_application(
      p_api_version                   => 1.0,      
      p_init_msg_list                   => FND_API.G_TRUE,
      p_commit                          => FND_API.G_TRUE,
      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_applied_payment_schedule_id     => p_applied_payment_schedule_id,
      p_link_to_customer_trx_id            => p_link_to_customer_trx_id,
      p_receivables_trx_id              => p_receivables_trx_id,
      p_apply_date                      => p_apply_date,
      p_apply_gl_date                   => p_apply_gl_date,
      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_type            => p_application_ref_type,            
      p_application_ref_id              => p_application_ref_id,
      p_application_ref_num             => p_application_ref_num,
      p_secondary_application_ref_id    => p_secondary_application_ref_id,
      p_payment_set_id              => p_payment_set_id,
      p_receivable_application_id       => p_receivable_application_id,
      p_customer_reference              => p_customer_reference,
      p_val_writeoff_limits_flag        => p_val_writeoff_limits_flag,
      p_called_from                      => p_called_from,
      p_netted_receipt_flag             => p_netted_receipt_flag,
      p_netted_cash_receipt_id          => p_netted_cash_receipt_id,
      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);
    dbms_output.put_line('p_receivable_application_id   = '||p_receivable_application_id);
 
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