Search This Blog

Sunday, May 20, 2018

Oracle AR Receipt API apps r12

  
PROCEDURE POS_CREATE_RECEIPT
(
P_POS_ID VARCHAR2,
p_org_id number,
p_receipt_amount            NUMBER,
p_receipt_method_id number,
p_receipt_number varchar2,
p_activity number default 7256,
p_status out varchar2
,p_receipt_id out number
) AS
    --parameters
    l_receipt_amount            NUMBER := p_receipt_amount;--600;
    v_receipt_method_id number := p_receipt_method_id;--28083;
    v_receipt_number varchar2(200) := p_receipt_number;--'12313';
        l_org_id                    NUMBER := p_org_id;--1770;--FND_PROFILE.VALUE('ORG_ID') ;
    --local Variables
    g_loc                       NUMBER :=0;
    g_msg                       VARCHAR2(500);
    l_error_description         VARCHAR2 (2000) := NULL;
    g_sysdate                   DATE  := SYSDATE;
    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_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_rcpt_method_name          VARCHAR2(20);
    l_customer_trx_id           NUMBER ;
     p_attribute_rec                  AR_RECEIPT_API_PUB.attribute_rec_type;
    
BEGIN
 

    l_msg_count           := 0;
    l_data_txt            := NULL;
    l_msg_index_num       := NULL;
    l_gl_date_count       := 0;
    l_currency_code       := 'AED';
    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      := NULL;
    p_attribute_rec.ATTRIBUTE5 := '1';   
   
    --FND_GLOBAL.APPS_INITIALIZE(2605, 52306, 222);
     FND_GLOBAL.APPS_INITIALIZE(FND_PROFILE.VALUE('USER_ID'),
     FND_PROFILE.VALUE('RESP_ID'),
     FND_PROFILE.VALUE('RESP_APPL_ID'));
     MO_GLOBAL.SET_POLICY_CONTEXT('S',l_org_id); --FND_PROFILE.VALUE('ORG_ID')
   
    dbms_output.put_line('before calling api ');

    -- Call Api to create receipt
    AR_RECEIPT_API_PUB.CREATE_MISC( 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_amount            => l_receipt_amount,     -- receipt amount
                                    p_receipt_number    => v_receipt_number ,--'1234567',
                                    p_receivables_trx_id => p_activity, --Activity
                                    p_receipt_date      => SYSDATE,
                                    --p_maturity_date     => SYSDATE + 30,
                                    p_gl_date           => SYSDATE,
                                    p_receipt_method_id => v_receipt_method_id,
                                    p_org_id              => l_org_id,
                                    p_attribute_record       => p_attribute_rec,
                                    p_misc_receipt_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 ');
    p_receipt_id := l_receipt_id;
    p_status := l_return_status;
    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);
        UPDATE XXFUJ_POS_H
        SET RECEIPT_ID = l_receipt_id
        WHERE POS_ID = P_POS_ID;
        COMMIT;
    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 NULL;
        dbms_output.put_line('Error in procedure '||SQLERRM);
END ;  

2 comments:

  1. This comment has been removed by the author.

    ReplyDelete
  2. This was so Good Post! kpmg online bookkeeping tool Thank you so much for sharing this pretty post, it was so good to read and useful to improve my knowledge as updated one, keep blogging

    ReplyDelete