P. 1
Oracle Apps_ Updating Price List Lines - API Approach

Oracle Apps_ Updating Price List Lines - API Approach

|Views: 98|Likes:
Published by Raj

More info:

Published by: Raj on Sep 09, 2011
Copyright:Attribution Non-commercial


Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less






Report Abuse

Next Blog»

Create Blog

Sign In

Oracle Apps
Disclaimer :- ---------------------------------------------------- Opinions expressed in this blog are entirely my own and do not reflect the position of my employer, Oracle or any other corporation. I'm NOT responsible for any damages in whatever form caused by the usage of the content of this blog. I created this Blog to share my knowledge, especially with Oracle Application ERP...
pow er ed by

FOLLOWERS Join this site
w ith Google Friend Connect


Updating Price List Lines - API Approach
Script for Updating Price List Lines :Issue :- Ne e d to update unit price of ite m s which are in give n Price List ans having unit price as $9999999.

Members (4)

Already a member? Sign in

Process Followed :- First e nd date all the line s in Q P_LIST_LINES which falls unde r above conditions and the n inse rt ne w re cords in Q P_LIST_LINES.


A PI Used :- qp_price _list_pub.proce ss_price _list(Both for Inse rt and Update )

▼ 2011 (4) ► May (2) ▼ January (2) Concurrent Program Information Updating Price List Lines - API Approach
Steps Followed :1. C re ate a staging table to store Ite m _Id, Ne w Unit_Price , Transaction_ID, Status and Errror_Me ssage . 2. C re ate d a synonym , se que nce , trigge r and inde x on staging table . 3. Validate d Ite m s Ids give n (For Duplicate R e cords, Null R e cords and e x iste nce of ite m ids) in the data file ). 4. Se nd List_He ade r_Id, List_Line _Id, Pricing_Attribute _Id and fie ld that has to be update d (In this e x am ple , e nd_date _active ) and ope ration should be qp_globals.g_opr_update.


================================================================ =========== Staging Table , Synonym, Sequence, Trigger Creation SET serverout on size 1000000 CL SCR; PROMPT +------------------------------------------------------------------------+ PROMPT Execution of script starts PROMPT +------------------------------------------------------------------------+ --drop table lss_unit_price_stg; CREATE TABLE lss_unit_price_stg( transaction_id_stg NUMBER NOT NULL ,status_stg VARCHAR2(2) ,item_id NUMBER ,unit_price NUMBER ,error_message VARCHAR2(2000) ); --drop synonym lss_unit_price_stg; CREATE SY NONY M lss_unit_price_stg FOR lss.lss_unit_price_stg;

Vamsi Mantripragada View my complete profile

status_stg FROM DUAL. END. :NEW. / =============================== Package Body CREATE OR REPLACE PACKAGE BODY lss_unit_price_update_pkg IS PROCEDURE unit_price_validate (p_list_header_id IN NUMBER) IS l_error_msg VARCHAR2 (3000). 'VE').NEXTVAL. CURSOR item_stg_cur IS SELECT item_id. END IF. CREATE UNIQUE INDEX lss_unit_price_stg_ui ON lss_unit_price_stg(transaction_id_stg).--drop index lss_unit_price_stg_ui. -. 'N' INTO :NEW. --drop sequence lss_unit_price_stg_s1. END lss_unit_price_update_pkg. CREATE SEQUENCE lss_unit_price_stg_s1 START WITH 1 INCREMENT BY 1. PROCEDURE unit_price_load (p_list_header_id IN NUMBER).transaction_id_stg. CURSOR dup_item_cur IS SELECT item_id FROM lss_unit_price_stg GROUP BY item_id HAVING COUNT (*) > 1. / ============================ Package Specification CREATE OR REPLACE PACKAGE lss_unit_price_update_pkg IS PROCEDURE unit_price_validate (p_list_header_id IN NUMBER). .Creation Of Trigger CREATE OR REPLACE TRIGGER lss_unit_price_stg_trg BEFORE INSERT ON lss_unit_price_stg FOR EACH ROW BEGIN IF :NEW.transaction_id_stg IS NULL THEN SELECT lss_unit_price_stg_s1. l_item_id NUMBER. transaction_id_stg FROM lss_unit_price_stg WHERE status_stg IN ('N'.

END.item_id.Validating Item_Id FOR item_stg_rec IN item_stg_cur LOOP BEGIN SELECT DISTINCT inventory_item_id INTO l_item_id FROM qp_list_lines WHERE 1 = 1 AND list_header_id = p_list_header_id --AND operand = 9999999 --AND end_date_active IS NULL AND inventory_item_id = item_stg_rec. error_message = error_message || l_error_msg WHERE item_id = dup_item_rec.item_id.Validating for Duplicate records FOR dup_item_rec IN dup_item_cur LOOP BEGIN l_error_msg := 'Duplicate Item Id . END LOOP.put_line ('Vallidating ItemID').item_id ). UPDATE lss_unit_price_stg SET status_stg = 'VE'. DBMS_OUTPUT. EXCEPTION WHEN OTHERS THEN l_error_msg := 'Inventory Item Id Not Found' || SQLERRM || '. COMMIT.put_line ( 'Error While updating Staging Table for the Item(Duplicate)' || dup_item_rec.. END LOOP. EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT. COMMIT. UPDATE lss_unit_price_stg SET status_stg = 'VE'.'.put_line ('Vallidating Duplicate Records'). -..item_id.CURSOR item_nul_cur IS SELECT transaction_id_stg FROM lss_unit_price_stg WHERE item_id IS NULL. DBMS_OUTPUT.'.Validating Null Item Ids . BEGIN -. -. END. error_message = error_message || l_error_msg WHERE 1 = 1 AND item_id = item_stg_rec.

COMMIT. END.put_line ('Exception while updating staging table for successfully calidated records' ). gpr_price_list_line_tbl qp_price_list_pub. COMMIT. gpr_price_list_line_val_tbl qp_price_list_pub. gpr_qualifiers_val_tbl qp_qualifier_rules_pub.price_list_line_val_tbl_type.transaction_id_stg ).transaction_id_stg. gpr_msg_data VARCHAR2 (2000).price_list_line_tbl_type. l_pricing_attribute_id NUMBER..'. END LOOP. gpr_qualifiers_tbl qp_qualifier_rules_pub. UPDATE lss_unit_price_stg SET status_stg = 'VE'.qualifiers_tbl_type. gpr_pricing_attr_tbl qp_price_list_pub.pricing_attr_tbl_type. gpr_msg_count NUMBER := 0.price_list_rec_type. END unit_price_validate. l_msg_data VARCHAR2 (2000). gpr_price_list_rec qp_price_list_pub. gpr_price_list_val_rec qp_price_list_pub. l_msg_count NUMBER.FOR item_nul_rec IN item_nul_cur LOOP BEGIN l_error_msg := 'Given Item Id is Null . PROCEDURE unit_price_load (p_list_header_id IN NUMBER) AS pl_code VARCHAR2 (2000). DBMS_OUTPUT.put_line ('Vallidating D'). l_list_line_id NUMBER.price_list_val_rec_type. l_msg_dummy VARCHAR2 (2000). l_price NUMBER.put_line ( 'Error While updating Staging Table for the Transaction(NULL)' || item_nul_rec. EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT. gpr_return_status VARCHAR2 (10) := NULL. l_item_id NUMBER. l_output VARCHAR2 (2000). . error_message = error_message || l_error_msg WHERE transaction_id_stg = item_nul_rec. l_count NUMBER. BEGIN UPDATE lss_unit_price_stg SET status_stg = 'V' WHERE status_stg = 'N' AND error_message IS NULL.qualifiers_val_tbl_type. END. EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.

CURSOR item_stg_cur IS SELECT item_id. transaction_id_stg FROM lss_unit_price_stg WHERE status_stg = 'V'. BEGIN SELECT application_id. ppr_qualifiers_tbl qp_qualifier_rules_pub. ppr_qualifiers_val_tbl qp_qualifier_rules_pub. EXCEPTION WHEN NO_DATA_FOUND THEN v_userid := NULL. END.pricing_attr_val_tbl_type. ppr_price_list_line_tbl qp_price_list_pub.pricing_attr_tbl_type. k NUMBER := 0. BEGIN SELECT MAX (login_id) INTO v_loginid FROM fnd_logins WHERE 1 = 1 AND user_id = v_userid. v_loginid NUMBER. END. responsibility_id INTO v_applid. v_respid FROM fnd_responsibility_tl WHERE responsibility_name LIKE 'Oracle Pricing Manager'. j NUMBER := 0. ppr_price_list_rec qp_price_list_pub. EXCEPTION WHEN NO_DATA_FOUND THEN v_loginid := NULL. ppr_price_list_line_val_tbl qp_price_list_pub. ppr_pricing_attr_val_tbl qp_price_list_pub. i NUMBER := 1. END. v_userid NUMBER. BEGIN SELECT user_id INTO v_userid FROM fnd_user WHERE user_name LIKE 'XXXX'.gpr_pricing_attr_val_tbl qp_price_list_pub. .price_list_line_tbl_type.set_org_context (141).put_line (p_list_header_id). BEGIN DBMS_OUTPUT. BEGIN fnd_client_info.price_list_line_val_tbl_type.price_list_val_rec_type.pricing_attr_val_tbl_type. ppr_pricing_attr_tbl qp_price_list_pub.qualifiers_tbl_type. EXCEPTION WHEN NO_DATA_FOUND THEN v_applid := NULL.price_list_rec_type. v_respid NUMBER.qualifiers_val_tbl_type. v_applid NUMBER. ppr_price_list_val_rec qp_price_list_pub.

list_line_id.NAME := 'Test_Price_List_API_990'.pricing_attribute_id := l_pricing_attribute_id.operation := qp_globals. gpr_price_list_rec.item_id.end_date_active := NULL.v_respid := NULL. END.process_price_list (p_api_version_number => 1.g_opr_update. SELECT qpll. x_msg_count => gpr_msg_count. p_price_list_rec => gpr_price_list_rec. x_pricing_attr_tbl => ppr_pricing_attr_tbl. gpr_pricing_attr_tbl (k).pricing_attribute_id. x_pricing_attr_val_tbl => ppr_pricing_attr_val_tbl -. gpr_price_list_line_tbl (k). fnd_global. l_pricing_attribute_id. gpr_price_list_line_tbl (k). BEGIN qp_price_list_pub.g_false.operation := qp_globals. x_return_status => gpr_return_status. p_price_list_line_tbl => gpr_price_list_line_tbl.last_updated_by := v_userid.list_header_id := p_list_header_id. x_price_list_rec => ppr_price_list_rec. gpr_pricing_attr_tbl (k). l_item_id FROM qp_list_lines qpll.list_line_id = qppa. v_applid).last_update_login := v_loginid. gpr_price_list_line_tbl (k). x_qualifiers_val_tbl => ppr_qualifiers_val_tbl.Prod .list_type_code := 'PRL'. x_qualifiers_tbl => ppr_qualifiers_tbl.g_false. x_price_list_line_tbl => ppr_price_list_line_tbl. k := 1. FOR item_stg_rec IN item_stg_cur LOOP BEGIN DBMS_OUTPUT. x_msg_data => gpr_msg_data.list_line_id AND qpll. pl_code := NULL.inventory_item_id = item_stg_rec. gpr_price_list_rec.list_line_id := l_list_line_id.g_false. gpr_price_list_line_tbl (k).inventory_item_id INTO l_list_line_id. p_pricing_attr_tbl => gpr_pricing_attr_tbl. x_price_list_val_rec => ppr_price_list_val_rec.description := 'Test_Price_List_API_990'. x_price_list_line_val_tbl => ppr_price_list_line_val_tbl.put_line ('Retrieving The Price List'). v_respid.currency_code := 'USD'. gpr_pricing_attr_tbl. gpr_pricing_attr_tbl (k).product_attr_value := TO_CHAR (l_item_id). qp_pricing_attributes qppa WHERE qpll. gpr_price_list_rec.operation := qp_globals. qpll. qppa. gpr_price_list_rec. gpr_price_list_line_tbl (k).DELETE. p_commit => fnd_api. gpr_price_list_rec. DBMS_OUTPUT. gpr_pricing_attr_tbl (k).list_line_id := l_list_line_id.list_header_id = p_list_header_id AND qpll. p_return_values => fnd_api. gpr_price_list_rec.put_line ('Entered Loop').apps_initialize (v_userid.g_opr_update.g_opr_update. p_init_msg_list => fnd_api.

put_line ( 'Price List line : ' || gpr_pricing_attr_tbl (k).transaction_id_stg. IF gpr_return_status <> 'S' THEN oe_msg_pub.get (k. DBMS_OUTPUT. BEGIN UPDATE lss_unit_price_stg SET status_stg = 'L' WHERE transaction_id_stg = item_stg_rec. BEGIN UPDATE lss_unit_price_stg SET status_stg = 'LE'.put_line ('The Price List Line' || k || 'is inserted' ). error_message = error_message || 'Unknown Exception . COMMIT. DBMS_OUTPUT.' WHERE transaction_id_stg = item_stg_rec. gpr_msg_data.).' WHERE transaction_id_stg = item_stg_rec. END. END IF. DBMS_OUTPUT. fnd_api. END.. l_output := (TO_CHAR (k) || ': ' || l_msg_data). EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.put_line ( 'Excpetion when updating Staging table for Item(Updated Item)' || l_item_id ).put_line (l_output).transaction_id_stg.product_attr_value ).put_line ( 'Excpetion when updating Staging table for Item(Update Failed)' || l_item_id ). EXCEPTION WHEN OTHERS . error_message = error_message || l_output || '. EXCEPTION WHEN OTHERS THEN BEGIN UPDATE lss_unit_price_stg SET status_stg = 'LE'.. l_msg_dummy ).g_false. EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT.transaction_id_stg.

NAME )... EXCEPTION WHEN OTHERS THEN DBMS_OUTPUT. END LOOP. DBMS_OUTPUT. END.put_line (SQLERRM).. END unit_price_load. / Posted by Vamsi Mantripragada at 12:11 AM 0 0 comments: Post a Comment Com m ent as: Select profile. Post Comment Preview Newer Post Subscribe to: Post Comments (Atom) Home DAILY CALENDAR ..put_line (SQLERRM).').THEN DBMS_OUTPUT. END. DBMS_OUTPUT.put_line ( 'Price List Name : ' || gpr_price_list_rec. DBMS_OUTPUT. END lss_unit_price_update_pkg. END.put_line ( 'Excpetion when updating Staging table for Item(Update Failed)' || l_item_id ).put_line ('Error Processing The Price List.

.Vamsi Mantripraga All Rights Reserved. Picture Window template.tripadvisor.Embed Blogger Slideshow C reate Stunning Travel Slideshow In A Minute. Its Free & Easy To Share! tripwow. Powered by Blogger.com /slide show Su 4 11 18 25 5 12 19 26 M 6 13 20 27 Tu September 2011 W 1 7 8 14 15 21 22 28 29 Th 2 9 16 23 30 F 3 10 17 24 Sa Copyright © 2011 .

You're Reading a Free Preview

/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->