API to create Receipt on Oracle Receivables

This post I will show a API to create a receipt on oracle Receivables.

DECLARE

    l_error_description         VARCHAR2 (2000) := NULL;
    l_ar_receipt_succ_count     NUMBER:= 0;
    l_ar_receipt_err_count      NUMBER:= 0;
    l_ar_receipt_tot_count      NUMBER:= 0;
    l_msg_index_num             NUMBER:= 1;
    l_msg_count                 NUMBER;
    l_data_txt                  VARCHAR2(1000);
    l_msg_data                  VARCHAR2(1000);
    l_apl_return_status         VARCHAR2 (1);
    l_apl_msg_count             NUMBER;
    l_apl_msg_data              VARCHAR2 (240);
    l_org_id                    NUMBER;
    l_gl_date_count             NUMBER;
    l_functional_currency       fnd_currencies.currency_code%TYPE;
    l_conv_type                 gl_daily_conversion_types.conversion_type%TYPE;
    l_conv_rate                 gl_daily_rates.conversion_rate%TYPE;
    l_cust_account_id           hz_cust_accounts.cust_account_id%TYPE;
    l_receipt_id                ar_cash_receipts_all.cash_receipt_id%TYPE;
    l_return_status             VARCHAR2(10);
    l_currency_code             fnd_currencies.currency_code%TYPE;
    l_cust_bank_acct_id         NUMBER;
    l_receipt_number            NUMBER ;
    l_receipt_amount            NUMBER;
    l_rcpt_method_name          VARCHAR2(200);
    l_customer_trx_id           NUMBER ;
    
BEGIN
  
    l_msg_count           := 0;
    l_data_txt            := NULL;
    l_msg_index_num       := NULL;
    l_gl_date_count       := 0;
    l_currency_code       := 'BRL';
    l_functional_currency := NULL;
    l_conv_type           := NULL;
    l_conv_rate           := NULL;
    l_receipt_id          := NULL;
    l_return_status       := NULL;
    l_msg_data            := NULL;
    l_receipt_number      := 123;
    l_receipt_amount      := 130000;
    l_rcpt_method_name    := 'BAIXA MANUAL BANCO BRASIL';
    l_org_id              := 81;
    
    FND_GLOBAL.apps_initialize(1139, 20678, 222);
    MO_GLOBAL.set_policy_context('S',81);
    MO_GLOBAL.init ('AR');
    
     

    -- Call Api to create receipt
    AR_RECEIPT_API_PUB.create_cash( p_api_version                   => 1.0,
                                    p_init_msg_list                 => fnd_api.g_true, 
                                    p_commit                        => fnd_api.g_false, 
                                    p_validation_level              => FND_API.g_valid_level_full, 
                                    p_currency_code                 => l_currency_code, 
                                    p_exchange_rate_type            => NULL,
                                    p_exchange_rate                 => NULL,
                                    p_exchange_rate_date            => NULL,
                                    p_amount                        => 1000,
                                    p_receipt_number                => 123, 
                                    p_receipt_date                  => SYSDATE, 
                                    p_maturity_date                 => SYSDATE, 
                                    p_gl_date                       => SYSDATE,
                                    p_customer_name                 => 'GASPA%',
                                    p_customer_number               => '931',
                                    p_comments                      => 'Teste Importacao via API',
                                    p_location                      => NULL,
                                    p_customer_bank_account_num     => NULL,
                                    p_customer_bank_account_name    => NULL, 
                                    p_remittance_bank_account_id    => 10021,
                                    p_receipt_method_name           => l_rcpt_method_name,
                                    p_org_id                        => l_org_id,
                                    p_cr_id                         => l_receipt_id,
                                    x_return_status                 => l_return_status,
                                    x_msg_count                     => l_msg_count, 
                                    x_msg_data                      => l_msg_data );
    
    DBMS_OUTPUT.PUT_LINE('called api ');
    IF (l_return_status = 'S') THEN
        DBMS_OUTPUT.PUT_LINE('Calling Api AR_RECEIPT_API_PUB.CREATE_CASH success -- >' ||l_return_status ||' Receipt Id > '||l_receipt_id); 
  
    ELSE
        DBMS_OUTPUT.PUT_LINE('Error in Calling Receipt API:');
        
        FOR i IN 1 .. l_msg_count
        LOOP
            FND_MSG_PUB.GET(p_msg_index => i, p_encoded => 'F', p_data => l_data_txt, p_msg_index_out => l_msg_index_num );         
            l_error_description := SUBSTR(l_error_description||l_data_txt,1,400);
            DBMS_OUTPUT.PUT_LINE( l_error_description);
        END LOOP;
          
    END IF;

    COMMIT;
    
EXCEPTION WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE('Error in procedure '||SQLERRM);
END ;

This API will create on receipt.

Sem título

Deixe uma resposta

Powered by WordPress.com. Tema: Baskerville 2 por Anders Noren

Acima ↑

%d blogueiros gostam disto: