1 Reply Latest reply on May 7, 2012 9:05 AM by 862738

    Please correct the receivable account assignment  while using API

      Hi All,
      I am creation Invoice in AR using API " AR_INVOICE_API_PUB.create_single_invoice " in R12.1.3
      when i run the script in error table " ar_trx_errors_gt " it show "Please correct the receivable account assignment ".
      date is inserted into
      but not inserted into RA_CUSTOMER_TRX .
      Please give me a solution to overcome this error.
      Code is given below

      l_return_status varchar2(1);
      p_count NUMBER;
      l_msg_count number;
      l_msg_data varchar2(8000);
      l_batch_id number;
      l_cnt number := 0;
      l_batch_source_rec ar_invoice_api_pub.batch_source_rec_type;
      l_trx_header_tbl ar_invoice_api_pub.trx_header_tbl_type;
      l_trx_lines_tbl ar_invoice_api_pub.trx_line_tbl_type;
      l_trx_dist_tbl ar_invoice_api_pub.trx_dist_tbl_type;
      l_trx_salescredits_tbl ar_invoice_api_pub.trx_salescredits_tbl_type;
      l_customer_trx_id number;
      cnt number;
      v_context varchar2(100);

      fnd_global.apps_initialize ( user_id => 1110
      ,resp_id => 50460
      ,resp_appl_id => 222

      -- Populate header information.
      l_trx_header_tbl(1).trx_header_id :=210003;
      -- l_trx_header_tbl(1).trx_number :='12300';
      l_trx_header_tbl(1).bill_to_customer_id :=4040;
      l_trx_header_tbl(1).cust_trx_type_id :=1;
      l_trx_header_tbl(1).primary_salesrep_id :=100000040;

      -- Populate batch source information.
      l_batch_source_rec.batch_source_id := -1;

      -- Populate line 1 information.
      l_trx_lines_tbl(1).trx_header_id :=210003;
      l_trx_lines_tbl(1).trx_line_id :=190003;
      l_trx_lines_tbl(1).line_number :=1;
      l_trx_lines_tbl(1).description :='Test';
      l_trx_lines_tbl(1).quantity_invoiced :=10;
      l_trx_lines_tbl(1).unit_selling_price :=120;
      l_trx_lines_tbl(1).line_type :='LINE';

      -- Populate Distribution Informationa
      l_trx_dist_tbl(1).trx_dist_id :=190003;
      l_trx_dist_tbl(1).trx_header_id :=210003;
      l_trx_dist_tbl(1).trx_LINE_ID :=190003;
      l_trx_dist_tbl(1).ACCOUNT_CLASS :='REV';
      l_trx_dist_tbl(1).AMOUNT :=1200;
      l_trx_dist_tbl(1).CODE_COMBINATION_ID :=2021;

      -- CAll the api
      AR_INVOICE_API_PUB.create_single_invoice( p_api_version => 1.0,
      p_batch_source_rec => l_batch_source_rec,
      p_trx_header_tbl => l_trx_header_tbl,
      p_trx_lines_tbl => l_trx_lines_tbl,
      p_trx_dist_tbl => l_trx_dist_tbl,
      p_trx_salescredits_tbl => l_trx_salescredits_tbl,
      x_customer_trx_id => l_customer_trx_id,
      x_return_status => l_return_status,
      x_msg_count => l_msg_count,
      x_msg_data => l_msg_data

      DBMS_OUTPUT.PUT_LINE('l_return_status : '||l_return_status);

      --IF l_return_status = 'S' THEN
      --dbms_output.put_line('unexpected errors found!');
      IF l_return_status = fnd_api.g_ret_sts_error OR
      l_return_status = fnd_api.g_ret_sts_unexp_error THEN
      dbms_output.put_line('unexpected errors found!');
      SELECT count(*)
      Into cnt
      From ar_trx_errors_gt;
      IF cnt = 0 THEN
      dbms_output.put_line ( 'Customer Trx id '|| l_customer_trx_id);
      dbms_output.put_line ( 'Transaction not Created, Please check ar_trx_errors_gt table');
      END IF;

      END IF;

      Suheeb Ali
        • 1. Re: Please correct the receivable account assignment  while using API
          Through the program, you are populating Revenue account in the distribution, but not the Receivable or Tax Account. In that case, these accounts will be taken care by auto accounting. Generally it is defined for each transaction type.
          Receivables --> Setup --> Transaction --> Transaction types

          If it is not defined in Transaction Type level, then it must be defined for each customer.

          But in case auto accounting is not enabled, and as you are using API, you have to pass atleast REV and REC account details (in case there is no TAX line). That will resolve the issue.

          Kunal Nandy