Friday, July 5, 2013

Register a Receivables API as a Concurrent Request

Applies to:

Oracle Receivables - Version 11.5.10.0 and later
Information in this document applies to any platform.
Checked for relevance on 23-May-2013
Receipt, Transaction, Customer API


Goal

Register a Receivables Application Programming Interface (API) as a Concurrent Request.

Solution

After successfully running a Receivables API from SQL, you are ready to register the API inside Oracle Applications.  In order to register the API inside Oracle Applications as concurrent request you need to implement following changes:
1.  Save the API as a PL/SQL store procedure:
Implement the necessary changes to your API to save it as stored procedure.  Be sure you pass the right IN/OUT parameters to the API.  For instance,  the following code shows a PL/SQL procedure to create a cash receipt using API AR_RECEIPT_API_PUB.create_cash. You can review the code below to give you an idea of how to implement something similar for other APIs:
CREATE OR REPLACE PROCEDURE  rr_create_cash (
out_errbuf_s  OUT VARCHAR2,
       out_errnum_n OUT NUMBER,
       l_amount  IN NUMBER,
       l_receipt_number  IN VARCHAR2,
       l_customer_number  IN VARCHAR2
)
IS
    l_return_status  VARCHAR2(1);
    l_msg_count  NUMBER;
    l_msg_data  VARCHAR2(240);
    l_count  NUMBER;
    l_cash_receipt_id  NUMBER;
    l_msg_data_out  VARCHAR2(240);
    l_mesg  VARCHAR2(240);
    p_count  NUMBER;
    l_currency_code  VARCHAR2(5);
    l_receipt_date  DATE;
    l_gl_date  DATE;
    l_receipt_method_id  NUMBER;
BEGIN
    fnd_file.put_line(fnd_file.log, '---------- START ------------------ ');
    fnd_file.put_line(fnd_file.log, 'Parameters ');
    fnd_file.put_line(fnd_file.log, 'l_amount '||l_amount);
    fnd_file.put_line(fnd_file.log, 'l_receipt_number '||l_receipt_number);
    fnd_file.put_line(fnd_file.log, 'l_customer_number '||l_customer_number);
    /*------------------------------------+
    |  Setting value to input parameters  |
    +------------------------------------*/
    l_currency_code  := 'USD';
    l_receipt_date  := TRUNC(SYSDATE);
    l_gl_date  := TRUNC(SYSDATE);
    l_receipt_method_id  := 1365;
    out_errnum_n := 0;
    /*------------------------------------+
    |  Calling to the API       |
    +------------------------------------*/
    fnd_file.put_line(fnd_file.log, '---------- Before calling API ------------------ ');
    BEGIN
        AR_RECEIPT_API_PUB.create_cash
        ( p_api_version => 1.0,
        p_init_msg_list => FND_API.G_TRUE,
        p_commit => FND_API.G_TRUE,
        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,
        p_currency_code => l_currency_code,
        p_amount => l_amount,
        p_receipt_number => l_receipt_number,
        p_receipt_date => l_receipt_date,
        p_gl_date => l_gl_date,
        p_customer_number => l_customer_number,
        p_receipt_method_id => l_receipt_method_id,
        p_cr_id => l_cash_receipt_id );
        /*------------------------------------+
        |  Error handling              |
        +------------------------------------*/
        DBMS_OUTPUT.put_line('Return status ' || l_return_status );
        DBMS_OUTPUT.put_line('Message count ' || l_msg_count);
        out_errnum_n := l_msg_count;
        fnd_file.put_line(fnd_file.log, out_errnum_n);
        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;
        DBMS_OUTPUT.put_line('Cash Receipt ID ' ||  l_cash_receipt_id);
        out_errbuf_s := l_msg_data;
        fnd_file.put_line(fnd_file.log, out_errbuf_s);
        fnd_file.put_line(fnd_file.log, 'Cash Receipt ID ' ||  l_cash_receipt_id);
    END;
    EXCEPTION
        WHEN OTHERS THEN
            out_errbuf_s := 'UNEXP_ERR in rr_create_cash: '||SQLERRM;
            out_errnum_n := 1;
            fnd_file.put_line(fnd_file.log, out_errbuf_s);
            dbms_output.put_line(out_errbuf_s);
END;
/
Please notice that the calling program context (fnd_global.apps_initialize) is not included as part of the stored procedure code. This is because the context is initialized when you connect to Oracle Applications using your username and responsibility.
2.  Register a new executable and concurrent program using System Administrator.
2.1.  Register a new executable. 
    • Responsibility: System Administrator
      Navigation: Concurrent > Program > Executable.
    • Define a new executable using Execution Method = PL/SQL Store Procedure.
 
2.2.  Register a new concurrent program.
    • Responsibility: System Administrator
      Navigation: Concurrent  > Program > Define
    • Define a new concurrent program and assign the executable created in step 2.1.
Click on the Parameters button and list the parameters for your API.  These are the IN parameters defined for the PL/SQL store procedure created in step 1.
    • Responsibility: System Administrator
    • Navigation:  Concurrent > Program > Define > Parameters
In order to make the new concurrent program available from any Receivables responsibility you need to add your new concurrent program in the Request Group form.
  • Responsibility: System Administrator
  • Navigation:  Security > Responsibility > Request
3.  Now you are ready to run the Receivables API as a concurrent request:
  • Responsibility: Receivables Manager
  • Navigation:  Control > Request > Run

1 comment:

  1. Easy "water hack" burns 2 lbs OVERNIGHT

    Well over 160 thousand men and women are hacking their diet with a simple and secret "liquid hack" to lose 2lbs each night while they sleep.

    It is easy and works all the time.

    Here's how you can do it yourself:

    1) Go grab a clear glass and fill it with water half full

    2) Proceed to follow this awesome hack

    and become 2lbs lighter the very next day!

    ReplyDelete