Join the OracleApps88 Telegram group @OracleApps88to get more information on Oracle EBS R12/Oracle Fusion applications.

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.

Wednesday, September 14, 2011

Create AR Invoice using API

Validations in AR Invoice:

AR Transaction Type Validation
:
Check if the Transaction type provided in data file is defined in AR transaction types(RA_CUST_TRX_TYPES_ALL)

Transaction Batch Source Validation:
Check if the source provided in data file is defined in AR transaction Batch source (RA_BATCH_SOURCES_ALL).

Invoice Currency Validation:
Check if the currency provided in data file is defined in AR Currency (FND_CURRENCIES).

Customer
Validation:
Check if the Bill to Customer Number Ship to Customer Number Bill to Custom Location Ship to Customer Location provided in the data file is defined in AR Customer(ra_customers).

Primary Sales Representative Validation
:
Sales representative number to be hardcode to -3 for No Sales Credit.

Term Name
:
Check if the Term name provided in the data file is defined in Payment terms (RA_TERMS)

Validate Sales Credit Type
:
Sales Credit to hardcode to Quota Sales Credit

Inventory Item Validation
:
Check if the Item provided in data file is defined in Inventory Items (MTL_SYSTEM_ITEMS).

Unit of Measurement validation
:
Check if the UOM provided is defined in MTL_UNITS_OF_MEASURE Table

Invoice Tax Code Validation
:
Check if the Tax Code provided in data file is defined in AR_VAT_TAX_ALL_B Table.

Invoice GL Date Validation
:
Check if the GL Data of provided invoices is in open period.Used ARP_UTIL.IS_GL_DATE_VALID API to validate.

Example Program:
CREATE OR REPLACE procedure APPS.xx_ar_invoice_api
is
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;

BEGIN
begin
MO_GLOBAL.SET_POLICY_CONTEXT('S',82);
end;
fnd_global.apps_initialize(1090,20678,222);

l_batch_source_rec.batch_source_id := 1001;
l_trx_header_tbl(1).trx_header_id := 9898;
l_trx_header_tbl(1).trx_date := sysdate;
l_trx_header_tbl(1).trx_currency := 'AED';
l_trx_header_tbl(1).cust_trx_type_id := 1000;
l_trx_header_tbl(1).bill_to_customer_id := 1139;
l_trx_header_tbl(1).term_id := 1000;
l_trx_header_tbl(1).finance_charges := 'N';
l_trx_header_tbl(1).status_trx := 'OP';
l_trx_header_tbl(1).printing_option := 'NOT';
--l_trx_header_tbl(1).reference_number := '1111';
l_trx_lines_tbl(1).trx_header_id := 9898;
l_trx_lines_tbl(1).trx_line_id := 101;
l_trx_lines_tbl(1).line_number := 1;
l_trx_lines_tbl(1).inventory_item_id := 1185;
-- l_trx_lines_tbl(1).description := 'CAST IRON
GRILL-325*485MM';
l_trx_lines_tbl(1).quantity_invoiced := 3;
l_trx_lines_tbl(1).unit_selling_price := 525; --Price
l_trx_lines_tbl(1).uom_code := 'EAC';
l_trx_lines_tbl(1).line_type := 'LINE';
l_trx_dist_tbl(1).trx_dist_id := 101;
l_trx_dist_tbl(1).trx_line_id := 101;
l_trx_dist_tbl(1).ACCOUNT_CLASS := 'REV';
l_trx_dist_tbl(1).percent := 100;
l_trx_dist_tbl(1).CODE_COMBINATION_ID := 1012;
--Here we call the API to create Invoice with the stored values


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

No comments:

Post a Comment

If you are facing any issues while copying the Code/Script or any issues with Posts, Please send a mail to OracleApp88@Yahoo.com or message me at @apps88 or +91 905 957 4321 in telegram.
Best Blogger TipsGet Flower Effect