0% found this document useful (0 votes)
117 views

Receipts Migration Oracle Apps

This document contains the code for an Oracle stored procedure that processes receipts from a staging table and inserts them into an EBS application using an API. It loops through records, validates fields like customer, currency and receipt method, calls the API to create the receipt, handles success/failure, and updates the staging table status. Key steps include validation, API call, commit/rollback, error handling and status updates.

Uploaded by

smslca
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
117 views

Receipts Migration Oracle Apps

This document contains the code for an Oracle stored procedure that processes receipts from a staging table and inserts them into an EBS application using an API. It loops through records, validates fields like customer, currency and receipt method, calls the API to create the receipt, handles success/failure, and updates the staging table status. Key steps include validation, API call, commit/rollback, error handling and status updates.

Uploaded by

smslca
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CREATE OR REPLACE PACKAGE APPS.XX_RECEIPT_CREATE_PKG AS PROCEDURE XX_RECEIPT_CREATE_PROC(ERRBUF OUT VARCHAR2,RETCODE OUT NUMBER); END XX_RECEIPT_CREATE_PKG; / XX_RECEIPT_CREATE_PKG.

XX_RECEIPT_CREATE_PROC --============================================================================== ============ CREATE OR REPLACE PACKAGE BODY APPS.XX_RECEIPT_CREATE_PKG AS PROCEDURE XX_RECEIPT_CREATE_PROC(ERRBUF OUT VARCHAR2,RETCODE OUT NUMBER) IS p_api_version p_init_msg_list p_commit p_validation_level p_doc_sequence_value p_issuer_name p_issue_date p_issuer_bank_branch_id p_deposit_date x_return_status x_msg_count x_msg_data p_cr_id p_global_attribute_rec p_attribute_rec p_customer_number p_customer_site_use_id p_customer_name p_customer_id p_customer_receipt_reference p_receipt_date p_amount p_receipt_number p_receipt_method_id p_receipt_method_name p_currency_code p_gl_date qb_transaction_num p_exchange_rate p_exchange_rate_type p_comments l_error_flag l_error_mesg l_concat_error_mesg l_rec_count l_rec_cnt_success l_rec_cnt_failed NUMBER; VARCHAR2(240); VARCHAR2(240); NUMBER; NUMBER; VARCHAR2(240); DATE; NUMBER; DATE; VARCHAR2(1); NUMBER; VARCHAR2(240); NUMBER; AR_RECEIPT_API_PUB.global_attribute_rec_type; AR_RECEIPT_API_PUB.attribute_rec_type; VARCHAR2(240); NUMBER; VARCHAR2(240); NUMBER; VARCHAR2(40); DATE; NUMBER; VARCHAR2(240); NUMBER; varchar2(250); VARCHAR2(10); DATE; --:='28-FEB-2010'; NUMBER; NUMBER; VARCHAR2(240); VARCHAR2(240); varchar2(1):='N'; varchar2(2000); varchar2(4000); number :=0; number:=0; number:=0;

-- VARIABLES TO CAPTURE VALIDATIONS L_CUST_ID L_CUST_SITE L_CURRENCY_CODE L_PERIOD_STATUS NUMBER; NUMBER; VARCHAR2(3); VARCHAR2(10);

L_RECEIPT_METHOD_ID NUMBER; L_METHOD_CODE VARCHAR2(60); L_PERIOD VARCHAR2(10); l_CUST_ACCT_SITE_ID number; L_cust_number number; cursor c1 is select * from XX_RECEIPTS_STG where STATUS_CODE='N'; BEGIN FOR C_REC IN C1 LOOP L_ERROR_FLAG L_ERROR_MESG L_CONCAT_ERROR_MESG L_CUST_ID L_CUST_SITE L_CURRENCY_CODE L_PERIOD_STATUS L_RECEIPT_METHOD_ID L_METHOD_CODE l_rec_count:=l_rec_count+1; --- to get cutomer id BEGIN MO_GLOBAL.INIT('AR'); SELECT CUSTOMER_ID,CUSTOMER_NUMBER INTO L_CUST_ID,L_cust_num ber FROM AR_customers WHERE upper(TRIM(substr(CUSTOMER_NAME,1,6)))=upper(TRIM(su bstr(C_REC.CUSTOMER_NAME,1,6))); fnd_file.put_line(fnd_file.log,'CUSTOMER-NUMBER: ' L_cust_ number); exception WHEN NO_DATA_FOUND THEN l_error_mesg:='customer Is Not Existing' '/'; l_concat_error_mesg:=l_concat_error_mesg l_error_mesg ; FND_FILE.PUT_LINE ( fnd_file.LOG,l_error_mesg); l_error_flag:='Y'; WHEN OTHERS THEN l_error_mesg:= SUBSTR(SQLERRM,1,255); FND_FILE.PUT_LINE ( fnd_file.LOG,l_error_mesg); l_concat_error_mesg:=l_concat_error_mesg '~' l_error_mesg; l_error_flag:='Y'; end; :='N'; := NULL; := NULL; := NULL; := NULL; := NULL; := NULL; := NULL; := NULL;

-- to get bill to address id begin SELECT HCSUA.SITE_USE_ID INTO L_CUST_SITE FROM hz_cust_acct_sites_all HCASA, hz_cust_site_uses_all HCSUA WHERE cust_account_id=(SELECT cust_account_id FROM hz_cust_accounts HCA, hz_parties HP WHERE account_number=L_cust_number AND hp.party_id=hca.party_id) AND hcasa.cust_acct_site_id=hcsua.cust_acct_site_id AND site_use_code='BILL_TO' and HCSUA.STATUS='A' and rownum=1; fnd_file.put_line(fnd_file.log,'BILL TO: ' L_CUST_SITE ); exception WHEN NO_DATA_FOUND THEN l_error_mesg:=l_error_mesg 'Cust Account Site id BILL_TO Is Not Exi sting' '/'; l_concat_error_mesg:=l_concat_error_mesg l_error_mesg; FND_FILE.PUT_LINE ( fnd_file.LOG,l_error_mesg); l_error_flag:='Y'; WHEN OTHERS THEN l_error_mesg:= SUBSTR(SQLERRM,1,255); FND_FILE.PUT_LINE ( fnd_file.LOG,l_error_mesg); l_concat_error_mesg:=l_concat_error_mesg '~' l_error_mesg; l_error_flag:='Y'; end; DBMS_OUTPUT.PUT_LINE('BILL TO ADDRESS ID' L_CUST_SITE);

-- ===================================================== -- CURRENCY VALIDATION STARTS --- ===================================================== FND_FILE.PUT_LINE ( fnd_file.LOG,'Currency Validation - Starts '); BEGIN SELECT CURRENCY_CODE INTO L_CURRENCY_CODE FROM FND_CURRENCIES WHERE UPPER(CURRENCY_CODE)=UPPER(TRIM(C_REC.CURRENCY_CODE)) AND ENABLED_FLAG='Y'; EXCEPTION WHEN NO_DATA_FOUND THEN l_error_mesg:='Currency not Defined in EBS'; l_concat_error_mesg:=l_concat_error_mesg l_error_mesg; FND_FILE.PUT_LINE ( fnd_file.LOG,l_error_mesg); l_error_flag:='Y';

WHEN OTHERS THEN l_error_mesg:= SUBSTR(SQLERRM,1,255); FND_FILE.PUT_LINE ( fnd_file.LOG,l_error_mesg); l_concat_error_mesg:=l_concat_error_mesg '~' l_error_mesg; l_error_flag:='Y'; END; dbms_output.put_line('Currency is ' L_CURRENCY_CODE); FND_FILE.PUT_LINE ( fnd_file.LOG,'Currency is ' L_CURRENCY_CODE); FND_FILE.PUT_LINE ( fnd_file.LOG,'Currency Validation - Ends '); -- ===================================================== -- CURRENCY VALIDATION ENDS --- ===================================================== -- ==================================================== -- FETCHIING RECEIPT METHOD ID STARTS -- ==================================================== FND_FILE.PUT_LINE ( fnd_file.LOG,'Fetching Receipt Method ID Starts '); BEGIN SELECT ARM.RECEIPT_METHOD_ID INTO L_RECEIPT_METHOD_ID FROM AR_RECEIPT_METHODS ARM WHERE UPPER(TRIM(ARM.NAME))=UPPER(TRIM(C_REC.PAYMENT_METHOD_NAME)) AND ARM.END_DATE IS NULL; EXCEPTION WHEN NO_DATA_FOUND THEN l_error_mesg:='RECEIPT METHOD IS NOT DEFINED IN EBS'; l_concat_error_mesg:=l_concat_error_mesg l_error_mesg; FND_FILE.PUT_LINE ( fnd_file.LOG,l_error_mesg); l_error_flag:='Y'; WHEN OTHERS THEN l_error_mesg:= SUBSTR(SQLERRM,1,255); FND_FILE.PUT_LINE ( fnd_file.LOG,l_error_mesg); l_concat_error_mesg:=l_concat_error_mesg '~' l_error_mesg; l_error_flag:='Y'; END; FND_FILE.PUT_LINE ( fnd_file.LOG,'RECEIPT Method Validation - Ends ' 'METHO D ID IS ' L_RECEIPT_METHOD_ID ' For Method ' L_METHOD_CODE); -- ==================================================== -- FETCHIING RECEIPT METHOD ID ENDS -- ==================================================== FND_FILE.PUT_LINE ( fnd_file.LOG,'ASSIGNING VALUES TO API VARIABLES '); BEGIN IF l_error_flag ='N' THEN

p_amount p_receipt_number p_receipt_method_id p_receipt_method_name p_customer_id p_customer_number --p_customer_name p_currency_code p_receipt_date p_gl_date p_customer_site_use_id p_customer_receipt_reference --p_exchange_rate --p_exchange_rate_type p_receipt_date --p_comments

:= := := := := :=

c_rec.RECEIPT_AMOUNT; c_rec.RECEIPT_NUMBER; l_receipt_method_id; c_rec.PAYMENT_METHOD_NAME; l_cust_id; c_rec.CUSTOMER_NUMBER; := c_rec.CUSTOMER_NAME; := l_currency_code; := c_rec.receipt_date; := '31-OCT-2010'; := l_cust_site; := c_rec.RECEIPT_NUMBER; :=c_rec.EXCHANGE_RATE; :=c_rec.EXCHANGE_RATE_TYPE; :=c_rec.RECEIPT_DATE; :=c_rec.COMMENTS;

FND_FILE.PUT_LINE ( fnd_file.LOG,'STARTING API'); AR_RECEIPT_API_PUB.Create_cash ( p_api_version ,p_init_msg_list ,p_commit ,p_currency_code ,p_amount ,p_receipt_number ,p_receipt_date ,p_gl_date ,p_customer_id -,p_customer_number ,p_customer_site_use_id --,p_receipt_method_id ,p_receipt_method_name ,p_exchange_rate ,p_exchange_rate_type ,p_comments -- ,p_doc_sequence_value ,p_customer_receipt_reference ,x_return_status ,x_msg_count ,x_msg_data ,p_cr_id => => => => => => => => => 1.0 FND_API.G_TRUE FND_API.G_TRUE p_currency_code p_amount p_receipt_number p_receipt_date p_gl_date p_customer_id => p_customer_number => p_customer_site_use_id => l_receipt_method_id => p_receipt_method_name => p_exchange_rate => p_exchange_rate_type => p_comments => NULL; => p_customer_receipt_reference => x_return_status => x_msg_count => x_msg_data => p_cr_id

);

FND_FILE.PUT_LINE ( fnd_file.LOG,'API ENDS '); IF (x_return_status = 'S') THEN COMMIT; l_rec_cnt_success:=l_rec_cnt_success+1; FND_FILE.PUT_LINE ( fnd_file.LOG,'API SUCCESSFULLY COMPLETED '); FND_FILE.PUT_LINE ( fnd_file.LOG,'Return Status = ' SUBSTR (x_return_statu s,1,255));

FND_FILE.PUT_LINE ( fnd_file.LOG,'Message Data = ' x_msg_data); FND_FILE.PUT_LINE ( fnd_file.LOG,'CASH RECEIPT ID IS ' P_CR_ID); FND_FILE.PUT_LINE ( fnd_file.LOG,'========================================== =============='); FND_FILE.PUT_LINE ( fnd_file.LOG,' '); FND_FILE.PUT_LINE ( fnd_file.LOG,'========================================== =============='); UPDATE XX_RECEIPTS_STG SET STATUS_CODE='R' WHERE RECEIPT_NUMBER=C_REC.RECEIPT_NUMBER; dbms_output.put_line('SUCCESS'); dbms_output.put_line('Return Status tus,1,255)); dbms_output.put_line('Message Count dbms_output.put_line('Message Data dbms_output.put_line('p_cr_id ELSE --ROLLBACK; l_rec_cnt_failed:=l_rec_cnt_failed+1; FND_FILE.PUT_LINE ( fnd_file.LOG,'API FAILED '); FND_FILE.PUT_LINE ( fnd_file.LOG,'Return Status eturn_status,1,255)); FND_FILE.PUT_LINE ( fnd_file.LOG,'Message Data dbms_output.put_line('x_return_status'); -- UPDATING STAGING TABLES UPDATE XX_RECEIPTS_STG SET STATUS_CODE='E' --CREATE_ERROR_MESG = X_MSG_DATA --'API FAILED ' ' ' 'With Following Error ' ' ' x_msg_data) WHERE RECEIPT_NUMBER=C_REC.RECEIPT_NUMBER; dbms_output.put_line('Return Status dbms_output.put_line('Message Count dbms_output.put_line('Message Data = ' SUBSTR (x_return_status,1,255)); = ' TO_CHAR(x_msg_count )); = ' SUBSTR (x_msg_data,1,255)); = ' = ' SUBSTR (x_r x_msg_data); = ' SUBSTR (x_return_sta

= ' x_msg_count); = ' x_msg_data); = ' p_cr_id);

dbms_output.put_line(APPS.FND_MSG_PUB.Get ( p_msg_index => APPS.FND_MSG_PUB.G _LAST,p_encoded=> APPS.FND_API.G_FALSE)); IF x_msg_count >=0 THEN FOR I IN 1..10 LOOP dbms_output.put_line(I '. ' SUBSTR (FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255)); FND_FILE.PUT_LINE ( fnd_file.LOG,SUBSTR (FND_MSG_PUB.Get(p_encoded => FND_API.G_FALSE ), 1, 255)); END LOOP; END IF; END IF;

ELSE FND_FILE.PUT_LINE ( fnd_file.LOG,'ERROR FLAG IS ' l_error_flag ' ' l_conca t_error_mesg); UPDATE XX_RECEIPTS_STG SET STATUS_CODE='E'--,CREATE_ERROR_MESG =L_CONCAT_ERROR_MESG,RECEIPT_CREA TED='N' --'API FAILED ' ' ' 'With Following Error ' ' ' x_msg_data) WHERE RECEIPT_NUMBER=C_REC.RECEIPT_NUMBER; END IF; END; END LOOP; dbms_output.put_line('Total Record Count Is ' l_rec_count); FND_FILE.PUT_LINE(FND_FILE.LOG,' No of Records Read _count); FND_FILE.PUT_LINE(FND_FILE.LOG,' No of Records Successfully Completed _cnt_success); FND_FILE.PUT_LINE(FND_FILE.LOG, 'No of Records Errored Out _cnt_failed); END XX_RECEIPT_CREATE_PROC; END XX_RECEIPT_CREATE_PKG; / ' l_rec ' l_rec ' l_rec

You might also like