API to create transacions on Oracle Receivables

Hi, this post I will show how to create transactions on Oracle Receivables at API.

DECLARE 
l_return_status VARCHAR2(1);
l_msg_count NUMBER;
l_msg_data VARCHAR2(2000);
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;
v_trx_header_Id NUMBER;
v_trx_line_id NUMBER;

BEGIN

SELECT ra_customer_trx_s.NEXTVAL
INTO v_trx_header_Id
FROM DUAL;


SELECT ra_customer_trx_lines_s.NEXTVAL
INTO v_trx_line_id
FROM DUAL; 


MO_GLOBAL.SET_POLICY_CONTEXT('S',81);
MO_GLOBAL.set_org_context (81, NULL, 'ONT');
MO_GLOBAL.init ('ONT'); 
FND_GLOBAL.apps_initialize(1133,20678,222); -- pass in user_id, responsibility_id, and resp_appl_id

l_batch_source_rec.batch_source_id := 1001;
l_trx_header_tbl(1).trx_header_id := v_trx_header_Id;
l_trx_header_tbl(1).trx_date := SYSDATE;
l_trx_header_tbl(1).trx_currency := 'BRL';
l_trx_header_tbl(1).cust_trx_type_id := 2000;
l_trx_header_tbl(1).bill_to_customer_id := 4044;
l_trx_header_tbl(1).term_id := 4;
l_trx_header_tbl(1).finance_charges := 'N';
l_trx_header_tbl(1).status_trx := 'OP';
l_trx_header_tbl(1).printing_option := 'PRI';
l_trx_header_tbl(1).ship_to_customer_id := 4044;
l_trx_lines_tbl(1).trx_header_id := v_trx_header_Id;
l_trx_lines_tbl(1).trx_line_id := v_trx_line_Id;
l_trx_lines_tbl(1).line_number := 1;
l_trx_lines_tbl(1).inventory_item_id := 5006;
-- l_trx_lines_tbl(1).description := 'CAST IRON GRILL-325*485MM';
l_trx_lines_tbl(1).quantity_invoiced := 10;
l_trx_lines_tbl(1).unit_selling_price := 100; --Price
l_trx_lines_tbl(1).uom_code := 'KG';
l_trx_lines_tbl(1).line_type := 'LINE';
-- l_trx_lines_tbl(1).ship_to_customer_id := 4044;
l_trx_lines_tbl(1).warehouse_id := 162;
l_trx_dist_tbl(1).trx_dist_id := NULL;
l_trx_dist_tbl(1).trx_line_id := NULL;
l_trx_dist_tbl(1).account_class := 'REV';
l_trx_dist_tbl(1).percent := 100;
l_trx_dist_tbl(1).code_combination_id := 2001;


AR_INVOICE_API_PUB.create_invoice (p_api_version => 1.0
,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;
End;

Sem título

Deixe uma resposta

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

Acima ↑

%d blogueiros gostam disto: