Tuesday 18 September 2012

Oracle Receivables Deposits API

begin
mo_global.set_policy_context('S','85'); -- pass the org id value
end;
______________________________________________________________________
DECLARE
l_return_status VARCHAR2(1);
l_msg_count NUMBER;
l_msg_data VARCHAR2(240);
l_count NUMBER;
l_new_trx_number ra_customer_trx.trx_number%type;
l_new_customer_trx_id ra_customer_trx.customer_trx_id%type;
l_new_customer_trx_line_id ra_customer_trx_lines.customer_trx_line_id%type;
l_new_rowid VARCHAR2(240);
l_new_status VARCHAR2(240);
BEGIN
fnd_global.apps_initialize (user_id => 1438,resp_id =>50801,resp_appl_id => 222);
--Standard API parameters
ar_deposit_api_pub.CREATE_DEPOSIT(
p_api_version => 1.0,
p_init_msg_list => FND_API.G_TRUE,
p_deposit_date => trunc(sysdate),
p_currency_code => 'GBP',
p_amount => 10000,
p_batch_source_id => 1141,
p_cust_trx_type_id => 1080,
p_class => 'DEP',
p_bill_to_customer_id => 27042,
p_start_date_commitment => sysdate,
p_description => 'Migration Testing',
p_remit_to_address_id => 1060,
p_commit => FND_API.G_TRUE,
X_new_trx_number =>l_new_trx_number,
X_new_customer_trx_id =>l_new_customer_trx_id,
X_new_customer_trx_line_id =>l_new_customer_trx_line_id,
X_new_rowid =>l_new_rowid,
x_return_status => l_return_status,
x_msg_count => l_msg_count,
x_msg_data => l_msg_data ) ;
IF l_msg_count = 1 Then
-- There is one message raised by the API, so it has been sent out.
dbms_output.put_line('l_msg_data 'l_msg_data);
ELSIF l_msg_count > 1 Then
--The messages on the stack are more than one, so call them in a loop.
--And print the messages
LOOP
IF nvl(l_count,0) < l_msg_count THEN
l_count := nvl(l_count,0) +1 ;
l_msg_data := FND_MSG_PUB.Get(FND_MSG_PUB.G_NEXT,FND_API.G_FALSE);
IF l_count = 1 THEN
dbms_output.put_line('l_msg_data 1 'l_msg_data);
ELSIF l_count = 2 THEN
dbms_output.put_line('l_msg_data 2 'l_msg_data);
ELSIF l_count = 3 THEN
dbms_output.put_line('l_msg_data 3 'l_msg_data);
ELSIF l_count = 4 THEN
dbms_output.put_line('l_msg_data 4 'l_msg_data);
ELSIF l_count = 5 THEN
dbms_output.put_line('l_msg_data 5 'l_msg_data);
ELSIF l_count = 6 THEN
dbms_output.put_line('l_msg_data 6 'l_msg_data);
END IF;
dbms_output.put_line('l_msg_data 'to_char(l_count)': 'l_msg_data);
ELSE
EXIT;
END IF;
END LOOP;
END IF;
Commit;
END;

1 comment:

  1. Hi Anil,

    I am using the above script to create a deposit invoice for a service contract and I am trying it print the invoice number. However the log file show both the trx number and error messages as below. When queried with the transaction number, there is no invoice created.

    anonymous block completed
    L_NEW_TRX_NUMBER: 600003214
    L_NEW_CUSTOMER_TRX_ID: 20421085
    L_NEW_CUSTOMER_TRX_LINE_ID: 42840597
    l_msg_data 1: Document sequence does not exist for the current document even though profile option Sequential Numbering is set to Partially Used.
    l_msg_data 2: The deposit did not successfully post.
    l_msg_data 3: ORA-20001: APP-AR-42536: This transaction is associated with at least one invalid or end-dated GL account. Please correct the account.





    Can you please let me know what might be going wrong.

    Thanks,
    Swarna.

    ReplyDelete