2 Replies Latest reply on Dec 6, 2017 7:17 AM by 1579693

    AR Auto Invoice API

    1579693

      Hi All ,

              I want to create AR auto invoice through API . Does anyone have a working  API regarding this . I have tried google , there are many APIs but they didnt work for me  .

        • 1. Re: AR Auto Invoice API
          Bashar.

          Hi,

           

          It depends on how you use them and your setup.

          What errors did you encounter?

           

          Regards,

          Bashar

          • 2. Re: AR Auto Invoice API
            1579693

            Hi Bashar ,

            CREATE OR REPLACE procedure APPS.xx_ar_invoice_api

            is

                    l_return_status         varchar2(1);

                    l_msg_count             number;

                    l_msg_data              varchar2(2000);

                    l_err_msg                varchar2 (500) ;

            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_cust_trx_id           number;

             

             

            BEGIN

                   dbms_output.put_line('START');

            begin

              MO_GLOBAL.SET_POLICY_CONTEXT('S',102);

            end;

                  

              fnd_global.apps_initialize(1110,20678,222);

             

             

              l_batch_source_rec.batch_source_id :=  1001;

              l_trx_header_tbl(1).trx_header_id  :=  999887766;

              l_trx_header_tbl(1).trx_number := trim('006334344');

              l_trx_header_tbl(1).trx_date := '31-OCT-2017';

              l_trx_header_tbl(1).gl_date := '31-OCT-2017';

              l_trx_header_tbl(1).trx_class := trim('INV');

              l_trx_header_tbl(1).trx_currency   :=  'PKR';

              l_trx_header_tbl(1).cust_trx_type_id :=  1000;

              l_trx_header_tbl(1).bill_to_customer_id :=  124316;

              l_trx_header_tbl(1).term_id    :=  5;

            --  l_trx_header_tbl(1).finance_charges  :=  'N';

            --  l_trx_header_tbl(1).status_trx   :=  'OP';

              l_trx_header_tbl(1).printing_option :=  'NOT';

              --l_trx_header_tbl(1).reference_number :=  '1111';

              l_trx_lines_tbl(1).trx_header_id :=  999887766;

              l_trx_lines_tbl(1).trx_line_id   :=  887886677;

              l_trx_lines_tbl(1).line_number   :=  1;

            --  l_trx_lines_tbl(1).inventory_item_id  :=  692;

               l_trx_lines_tbl(1).description :=  'VICTORIA CHARM (PINK)';

            l_trx_lines_tbl(1).quantity_invoiced   :=  3;

            l_trx_lines_tbl(1).unit_selling_price :=  525;   --Price

            l_trx_lines_tbl(1).uom_code    :=  'NOS';

            l_trx_lines_tbl(1).line_type   :=  'LINE';

            -- l_trx_dist_tbl(1).trx_dist_id  :=  101;

            -- l_trx_dist_tbl(1).trx_line_id  :=  101;

            l_trx_dist_tbl(1).ACCOUNT_CLASS := 'REV';

            l_trx_dist_tbl(1).percent     := 100;

            l_trx_dist_tbl(1).CODE_COMBINATION_ID := 2006;

                  

            --Here we call the API to create Invoice with the stored values

             

             

             

             

                AR_INVOICE_API_PUB.create_invoice

                (p_api_version          => 1.0

                --,p_commit               => 'T'

                ,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_return_status        => l_return_status

                ,x_msg_count            => l_msg_count

                ,x_msg_data             => l_msg_data

                );

              

                dbms_output.put_line('Created:'||l_msg_data||l_return_status);

             

             

                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(l_return_status||':'||sqlerrm);

                Else

                    dbms_output.put_line(l_return_status||':'||sqlerrm);

                    If (ar_invoice_api_pub.g_api_outputs.batch_id IS NOT NULL) Then

                        Dbms_output.put_line('Invoice(s) suceessfully created!') ;

                        Dbms_output.put_line('Batch ID: ' || ar_invoice_api_pub.g_api_outputs.batch_id);

                        Dbms_output.put_line('customer_trx_id: ' || l_cust_trx_id);

                    Else

                        Dbms_output.put_line(sqlerrm);

                    End If;

                end if;

                commit;

             

             

            exception

               when others

               then

                  l_err_msg := sqlerrm;

                  dbms_output.put_line ('Main Exception: ' || l_err_msg);

             

             

             

             

            End;

             

            i am using this and its not returning anything .

             

            Thanks

            Talal