149:
150: COMMIT;
151:
152: IF lv_msc_tp_coll_window = 0 THEN
153: DELETE MSC_COMPANY_ID_LID WHERE SR_INSTANCE_ID= p_instance_id;
154: DELETE MSC_COMPANY_SITE_ID_LID WHERE SR_INSTANCE_ID= p_instance_id;
155: END IF;
156:
157:
195: EXECUTE IMMEDIATE lv_sql_stmt1 USING v_sr_instance_id;
196:
197: COMMIT;
198: IF lv_msc_tp_coll_window = 0 THEN
199: DELETE MSC_COMPANY_ID_LID WHERE SR_INSTANCE_ID= p_instance_id;
200: DELETE MSC_COMPANY_SITE_ID_LID WHERE SR_INSTANCE_ID= p_instance_id;
201: END IF;
202:
203: -- ======================================================================================
239: p_last_collection_id );
240: COMMIT;
241:
242: -- ======================================================================================
243: -- Populate msc_company_id_lid table with new Company information
244: -- ======================================================================================
245:
246: LOG_MESSAGE('Populating msc_company_id_lid');
247: POPULATE_COMPANY_ID_LID;
242: -- ======================================================================================
243: -- Populate msc_company_id_lid table with new Company information
244: -- ======================================================================================
245:
246: LOG_MESSAGE('Populating msc_company_id_lid');
247: POPULATE_COMPANY_ID_LID;
248: COMMIT;
249:
250: -- ======================================================================================
454: END CREATE_NEW_COMPANIES;
455:
456: PROCEDURE POPULATE_COMPANY_ID_LID IS
457:
458: -- Cursor for msc_company_id_lid
459: CURSOR newCompLidRecords IS
460: select distinct
461: mst.sr_instance_id sr_instance_id,
462: nvl(mst.company_id, -1) sr_company_id,
472: select mcil.sr_instance_id,
473: mcil.sr_company_id,
474: mcil.partner_type,
475: mcil.company_id
476: from msc_company_id_lid mcil;
477:
478: a_sr_instance_id number_arr;
479: a_sr_company_id number_arr;
480: a_partner_type number_arr;
492: close newCompLidRecords;
493:
494:
495: LOG_MESSAGE('No. of company_id_lid records = '||a_sr_instance_id.COUNT);
496: -- Populate msc_company_id_lid table
497: -- Perform this step only if some data is fetched
498: BEGIN
499: IF a_sr_instance_id.COUNT > 0 THEN
500:
498: BEGIN
499: IF a_sr_instance_id.COUNT > 0 THEN
500:
501: FORALL i IN 1..a_sr_instance_id.COUNT
502: insert into msc_company_id_lid
503: ( sr_instance_id,
504: sr_company_id,
505: partner_type,
506: company_id
512: a_company_id(i)
513: );
514: END IF;
515: EXCEPTION WHEN OTHERS THEN
516: LOG_MESSAGE('Error while uploading msc_company_id_lid table');
517:
518: LOG_MESSAGE('========================================');
519: FND_MESSAGE.SET_NAME('MSC', 'MSC_X_COMP_LID_ERR');
520: FND_MESSAGE.SET_TOKEN('PROCEDURE', 'POPULATE_COMPANY_ID_LID');
517:
518: LOG_MESSAGE('========================================');
519: FND_MESSAGE.SET_NAME('MSC', 'MSC_X_COMP_LID_ERR');
520: FND_MESSAGE.SET_TOKEN('PROCEDURE', 'POPULATE_COMPANY_ID_LID');
521: FND_MESSAGE.SET_TOKEN('TABLE', 'MSC_COMPANY_ID_LID');
522: LOG_MESSAGE(FND_MESSAGE.GET);
523:
524: LOG_MESSAGE(SQLERRM);
525:
529:
530: -- Commit the transaction
531: COMMIT;
532: --Bug 5155944: Analysing the table to improve performance
533: msc_analyse_tables_pk.analyse_table( 'MSC_COMPANY_ID_LID');
534:
535:
536: END POPULATE_COMPANY_ID_LID;
537:
639:
640: select mcil.company_id company_id,
641: mstp.LOCATION company_site_name
642: from msc_st_trading_partner_sites mstp,
643: msc_company_id_lid mcil
644: where
645: -- Make sure that the Trading partner is defined as Company
646: mstp.sr_tp_id = mcil.sr_company_id
647: and mstp.sr_instance_id = mcil.sr_instance_id
657: -- Add sites from msc_trading_partner_sites for Suppliers.
658: SELECT mcil.company_id company_id,
659: mstp.tp_site_code company_site_name
660: from msc_st_trading_partner_sites mstp,
661: msc_company_id_lid mcil
662: where
663: -- Make sure that the Trading partner is defined as Company
664: mstp.sr_tp_id = mcil.sr_company_id
665: and mstp.sr_instance_id = mcil.sr_instance_id
754: mst.sr_tp_id sr_company_site_id,
755: mst.partner_type partner_type,
756: mcs.company_site_id
757: from msc_st_trading_partners mst,
758: msc_company_id_lid mcil,
759: msc_company_sites mcs
760: where nvl(mst.company_id, -1) = mcil.sr_company_id
761: and mst.sr_instance_id = mcil.sr_instance_id
762: and mst.partner_type = mcil.partner_type
778: mtps.sr_tp_site_id sr_company_site_id,
779: mtps.partner_type,
780: mcs.company_site_id
781: from msc_st_trading_partner_sites mtps,
782: msc_company_id_lid mcil,
783: msc_company_sites mcs
784: where mtps.sr_instance_id = mcil.sr_instance_id
785: and mtps.sr_instance_id = v_sr_instance_id
786: and mtps.sr_tp_id = mcil.sr_company_id
1195: select ROWIDTOCHAR(msis.rowid),
1196: mcil.company_id,
1197: -99
1198: from msc_st_item_suppliers msis,
1199: msc_company_id_lid mcil
1200: where msis.supplier_id = mcil.sr_company_id
1201: and msis.sr_instance_id = mcil.sr_instance_id
1202: and mcil.partner_type = G_SUPPLIER
1203: and msis.sr_instance_id = p_instance_id
1207: select ROWIDTOCHAR(msis.rowid),
1208: mcil.company_id,
1209: mcsil.company_site_id
1210: from msc_st_item_suppliers msis,
1211: msc_company_id_lid mcil,
1212: msc_company_site_id_lid mcsil
1213: where msis.supplier_id = mcil.sr_company_id
1214: and msis.sr_instance_id = mcil.sr_instance_id
1215: and mcil.partner_type = G_SUPPLIER
1229: select ROWIDTOCHAR(msic.rowid),
1230: mcil.company_id,
1231: -99
1232: from msc_st_item_customers msic,
1233: msc_company_id_lid mcil
1234: where msic.customer_id = mcil.sr_company_id
1235: and msic.sr_instance_id = mcil.sr_instance_id
1236: and mcil.partner_type = G_CUSTOMER
1237: and msic.sr_instance_id = p_instance_id
1241: select ROWIDTOCHAR(msic.rowid),
1242: mcil.company_id,
1243: mcsil.company_site_id
1244: from msc_st_item_customers msic,
1245: msc_company_id_lid mcil,
1246: msc_company_site_id_lid mcsil
1247: where msic.customer_id = mcil.sr_company_id
1248: and msic.sr_instance_id = mcil.sr_instance_id
1249: and mcil.partner_type = G_CUSTOMER
1588: select DISTINCT mtp.partner_id,
1589: mcr.relationship_id
1590: from msc_trading_partners mtp,
1591: msc_tp_id_lid mtil,
1592: msc_company_id_lid mcil,
1593: msc_company_relationships mcr
1594: where mtp.partner_id = mtil.tp_id
1595: and mtil.sr_instance_id = p_instance_id
1596: and mtil.sr_tp_id = mcil.sr_company_id
2173: mscu.email_address email_address,
2174: mscu.fax fax
2175: from msc_st_company_users mscu,
2176: fnd_user fu,
2177: msc_company_id_lid mcil
2178: where mscu.sr_instance_id = p_sr_instance_id
2179: and UPPER(mscu.user_name) = fu.user_name
2180: and mscu.sr_company_id = mcil.sr_company_id
2181: and mscu.sr_instance_id = mcil.sr_instance_id
2208: mscu.sr_instance_id sr_instance_id,
2209: mcil.company_id company_id
2210: from msc_st_company_users mscu,
2211: fnd_user fu,
2212: msc_company_id_lid mcil
2213: where mscu.sr_instance_id = p_sr_instance_id
2214: and UPPER(mscu.user_name) = fu.user_name
2215: and mscu.sr_company_id = mcil.sr_company_id
2216: and mscu.sr_instance_id = mcil.sr_instance_id