Loading

Friday, March 12, 2010

How to apply invoice in detail against the receipt through api (AR_RECEIPT_API_PUB.Apply_In_Detail)

The below script has been tested in R12.1.1

set serveroutput on; 
DECLARE
llca_trx_lines_tbl_type1   AR_RECEIPT_API_PUB.llca_trx_lines_tbl_type;
l_cash_receipt_id   NUMBER;
l_return_status  VARCHAR2(1);
l_msg_count  NUMBER;
p_count  NUMBER;
l_msg_data  VARCHAR2(240); 
-- Concurrent Program Parameters  --- 
v_receipt_number VARCHAR2(100) := '&RECEIPT_NUMBER';
v_trx_number varchar2(100) := '&TRX_NUMBER';
v_line_number number := '&LINE_NUMBER';
v_line_amount number(10,3) := NULL;
v_tax_amount number(10,3) := NULL;
v_total_amount number(10,3) := 10000; 
-- End of Parameters ----- 
v_context varchar2(100);

FUNCTION set_context( i_user_name    IN  VARCHAR2
                     ,i_resp_name    IN  VARCHAR2
                     ,i_org_id       IN  NUMBER)
RETURN VARCHAR2
IS
--  Inorder to reduce the content of the post I moved the implementation part of this function to another post and it is available here 
END set_context; 

BEGIN 
-- Setting the context ---- 
v_context := set_context('&V_USER_NAME','&V_RESPONSIBILITY',82);
IF v_context = 'F'
    THEN
        DBMS_OUTPUT.PUT_LINE('Error while setting the context');       
    END IF;
DBMS_OUTPUT.PUT_LINE('2');
--- context done ------------

l_msg_count:=0;
l_msg_data:=NULL; 
llca_trx_lines_tbl_type1(1).line_number:=v_line_number;
llca_trx_lines_tbl_type1(1).line_amount:=v_line_amount;
llca_trx_lines_tbl_type1(1).tax_amount:=v_tax_amount;
llca_trx_lines_tbl_type1(1).amount_applied:=v_total_amount; 
AR_RECEIPT_API_PUB.Apply_In_Detail(
 -- Standard API parameters.
      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,
 --  Receipt application parameters.
      p_cash_receipt_id             => NULL,
      p_receipt_number            =>v_receipt_number,
      p_customer_trx_id            =>NULL,
      p_trx_number                     =>v_trx_number,
      p_installment                     => NULL,
      p_applied_payment_schedule_id => NULL,
-- LLCA Parameters
      p_llca_type                           => 'L',
      p_llca_trx_lines_tbl          => llca_trx_lines_tbl_type1,
      p_group_id                           => NULL,  
      p_line_amount                   => v_line_amount,
      p_tax_amount                     => v_tax_amount,
      p_freight_amount             => NULL,
      p_charges_amount           => NULL,
      p_amount_applied           => v_total_amount,
      p_line_discount                => NULL,
      p_tax_discount                  => NULL,
      p_freight_discount           => NULL,
      p_trans_to_receipt_rate=> NULL,
      p_discount                           => NULL,
      p_apply_date                      => SYSDATE,
      p_apply_gl_date                => SYSDATE,
      p_ussgl_transaction_code => NULL,
      p_show_closed_invoices   => 'N',
      p_called_from                       => NULL,
      p_move_deferred_tax       => 'Y',
      p_comments                          => NULL,
      p_payment_set_id              => NULL,
      p_application_ref_type     => NULL,
      p_application_ref_id          => NULL,
      p_application_ref_num     => NULL,
      p_secondary_application_ref_id=> NULL,
      p_application_ref_reason=> NULL,
      p_customer_reference      => NULL,
      p_customer_reason            => NULL,
      p_org_id                                   => 82  
                  );
DBMS_OUTPUT.put_line('Message count ' || l_msg_count);
IF l_msg_count = 1 Then
  DBMS_OUTPUT.put_line('l_msg_data '||l_msg_data);
ELSIF l_msg_count > 1 Then
  LOOP
  p_count := p_count+1;
  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' || p_count ||' ---'||l_msg_data);
  END LOOP;
END IF;  
end;

1 Responses to “How to apply invoice in detail against the receipt through api (AR_RECEIPT_API_PUB.Apply_In_Detail)”

Anonymous said...
June 12, 2015 at 4:51 AM

Can you just pay the second line of an invoice (ie not touch the first line)


Post a Comment

Disclaimer

The ideas, thoughts and concepts expressed here are my own. They, in no way reflect those of my employer or any other organization/client that I am associated. The articles presented doesn't imply to any particular organization or client and are meant only for knowledge Sharing purpose. The articles can't be reproduced or copied without the Owner's knowledge or permission.