[Home] [Help]
PACKAGE BODY: APPS.ICX_POR_EXT_ITEM
Source
1 PACKAGE BODY ICX_POR_EXT_ITEM AS
2 /* $Header: ICXEXTIB.pls 120.1.12000000.2 2007/04/17 07:43:43 adjain ship $*/
3
4 --------------------------------------------------------------
5 -- Global Constants --
6 --------------------------------------------------------------
7 -- Item found status
8 CACHE_MATCH PLS_INTEGER := 0; -- Match previous price row
9 PRICE_MATCH PLS_INTEGER := 1; -- Match item of price row
10 CACHE_PRICE_MATCH PLS_INTEGER := 2; -- both cache_match and price_match
11 ITEM_MATCH PLS_INTEGER := 3; -- Find old item
12 NEW_ITEM PLS_INTEGER := 4; -- New item
13 NEW_GA_ITEM PLS_INTEGER := 5; -- New item
14 DELETE_PRICE PLS_INTEGER := 6; -- Delete price row
15
16 --------------------------------------------------------------
17 -- Global Variables --
18 --------------------------------------------------------------
19 gCategorySetId NUMBER;
20 gValidateFlag VARCHAR2(1);
21 gStructureId NUMBER;
22 gExtractImageDet VARCHAR2(1) := 'Y';
23 gTransactionCount PLS_INTEGER := 0;
24 gPriceRowCount PLS_INTEGER := 0;
25 gTotalCount PLS_INTEGER := 0;
26 gMultiOrgFlag VARCHAR2(1); --Bug # 3865316
27
28 --------------------------------------------------------------
29 -- Cursors and Types --
30 --------------------------------------------------------------
31 TYPE tPriceRow IS RECORD (
32 document_type NUMBER,
33 last_update_date DATE,
34 org_id NUMBER,
35 supplier_id NUMBER,
36 supplier icx_cat_items_b.supplier%TYPE,
37 supplier_site_code icx_cat_item_prices.supplier_site_code%TYPE,
38 supplier_part_num icx_cat_items_b.supplier_part_num%TYPE,
39 internal_item_id NUMBER,
40 internal_item_num icx_cat_items_b.internal_item_num%TYPE,
41 inventory_organization_id NUMBER,
42 item_source_type icx_cat_items_tlp.item_source_type%TYPE,
43 item_search_type icx_cat_items_tlp.search_type%TYPE,
44 mtl_category_id NUMBER,
45 category_key icx_cat_categories_tl.key%TYPE,
46 description icx_cat_items_tlp.description%TYPE,
47 picture icx_cat_items_tlp.picture%TYPE,
48 picture_url icx_cat_items_tlp.picture_url%TYPE,
49 price_type icx_cat_item_prices.price_type%TYPE,
50 asl_id NUMBER,
51 supplier_site_id NUMBER,
52 contract_id NUMBER,
53 contract_line_id NUMBER,
54 template_id icx_cat_item_prices.template_id%TYPE,
55 template_line_id NUMBER,
56 price_search_type icx_cat_item_prices.search_type%TYPE,
57 --FPJ FPSL Extractor Changes
58 --unit_price column will hold amount for items with Fixed Price Services line_type
59 --For all other items it will hold price
60 unit_price NUMBER,
61 --FPJ FPSL Extractor Changes
62 value_basis icx_cat_item_prices.value_basis%TYPE,
63 purchase_basis icx_cat_item_prices.purchase_basis%TYPE,
64 allow_price_override_flag icx_cat_item_prices.allow_price_override_flag%TYPE,
65 not_to_exceed_price NUMBER,
66 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
67 suggested_quantity NUMBER,
68 -- FPJ Bug# 3110297 jingyu Add negotiated flag
69 negotiated_by_preparer_flag icx_cat_item_prices.negotiated_by_preparer_flag%TYPE,
70 currency icx_cat_item_prices.currency%TYPE,
71 unit_of_measure icx_cat_item_prices.unit_of_measure%TYPE,
72 functional_price NUMBER,
73 contract_num icx_cat_item_prices.contract_num%TYPE,
74 contract_line_num NUMBER,
75 manufacturer ICX_CAT_ITEMS_TLP.manufacturer%TYPE,
76 manufacturer_part_num ICX_CAT_ITEMS_TLP.manufacturer_part_num%TYPE,
77 rate_type ICX_CAT_ITEM_PRICES.rate_type%TYPE,
78 rate_date DATE,
79 rate NUMBER,
80 supplier_number ICX_CAT_ITEM_PRICES.supplier_number%TYPE,
81 supplier_contact_id NUMBER,
82 item_revision ICX_CAT_ITEM_PRICES.item_revision%TYPE,
83 line_type_id NUMBER,
84 buyer_id NUMBER,
85 global_agreement_flag VARCHAR2(1),
86 status NUMBER,
87 primary_category_id NUMBER,
88 primary_category_name icx_cat_categories_tl.category_name%TYPE,
89 template_category_id NUMBER,
90 price_rt_item_id NUMBER,
91 price_internal_item_id NUMBER,
92 price_supplier_id NUMBER,
93 price_supplier_part_num icx_cat_items_b.supplier_part_num%TYPE,
94 price_contract_line_id NUMBER,
95 price_mtl_category_id NUMBER,
96 match_primary_category_id NUMBER,
97 rt_item_id NUMBER,
98 local_rt_item_id NUMBER,
99 match_template_flag VARCHAR2(1),
100 active_flag VARCHAR2(1),
101 price_rowid VARCHAR2(30) );
102
103 TYPE tCursorType IS REF CURSOR;
104 gCurrentPrice tPriceRow;
105
106 TYPE tItemRecord IS RECORD (
107 org_id NUMBER,
108 internal_item_id NUMBER,
109 internal_item_num ICX_CAT_ITEMS_B.internal_item_num%TYPE,
110 supplier_id NUMBER,
111 supplier ICX_CAT_ITEMS_B.supplier%TYPE,
112 supplier_part_num ICX_CAT_ITEMS_B.supplier_part_num%TYPE,
113 contract_line_id NUMBER,
114 rt_item_id NUMBER,
115 hash_value NUMBER);
116
117 TYPE tItemCache IS TABLE OF tItemRecord
118 INDEX BY BINARY_INTEGER;
119
120 TYPE tFoundItemRecord IS RECORD (
121 rt_item_id NUMBER,
122 primary_category_id NUMBER,
123 match_template_flag VARCHAR2(1));
124
125 TYPE tFoundItemCursor IS REF CURSOR RETURN tFoundItemRecord;
126
127 --------------------------------------------------------------
128 -- Caches --
129 --------------------------------------------------------------
130 gItemCache tItemCache;
131 gHashBase PLS_INTEGER;
132 gHashSize PLS_INTEGER;
133
134 --------------------------------------------------------------
135 -- Global PL/SQL Tables --
136 --------------------------------------------------------------
137 -- Update ICX_CAT_ITEM_PRICES
138 gUPRtItemIds DBMS_SQL.NUMBER_TABLE;
139 gUPPriceTypes DBMS_SQL.VARCHAR2_TABLE;
140 gUPAslIds DBMS_SQL.NUMBER_TABLE;
141 gUPSupplierSiteIds DBMS_SQL.NUMBER_TABLE;
142 gUPContractIds DBMS_SQL.NUMBER_TABLE;
143 gUPContractLineIds DBMS_SQL.NUMBER_TABLE;
144 gUPTemplateIds DBMS_SQL.VARCHAR2_TABLE;
145 gUPTemplateLineIds DBMS_SQL.NUMBER_TABLE;
146 gUPInventoryItemIds DBMS_SQL.NUMBER_TABLE;
147 gUPMtlCategoryIds DBMS_SQL.NUMBER_TABLE;
148 gUPOrgIds DBMS_SQL.NUMBER_TABLE;
149 gUPSearchTypes DBMS_SQL.VARCHAR2_TABLE;
150 gUPUnitPrices DBMS_SQL.NUMBER_TABLE;
151 --FPJ FPSL Extractor Changes
152 gUPValueBasis DBMS_SQL.VARCHAR2_TABLE;
153 gUPPurchaseBasis DBMS_SQL.VARCHAR2_TABLE;
154 gUPAllowPriceOverrideFlag DBMS_SQL.VARCHAR2_TABLE;
155 gUPNotToExceedPrice DBMS_SQL.NUMBER_TABLE;
156 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
157 gUPSuggestedQuantities DBMS_SQL.NUMBER_TABLE;
158 -- FPJ Bug# 3110297 jingyu Add negotiated flag
159 gUPNegotiatedFlag DBMS_SQL.VARCHAR2_TABLE;
160 gUPCurrencys DBMS_SQL.VARCHAR2_TABLE;
161 gUPUnitOfMeasures DBMS_SQL.VARCHAR2_TABLE;
162 gUPFunctionalPrices DBMS_SQL.NUMBER_TABLE;
163 gUPSupplierSiteCodes DBMS_SQL.VARCHAR2_TABLE;
164 gUPContractNums DBMS_SQL.VARCHAR2_TABLE;
165 gUPContractLineNums DBMS_SQL.NUMBER_TABLE;
166 gUpRateTypes DBMS_SQL.VARCHAR2_TABLE;
167 gUpRateDates DBMS_SQL.DATE_TABLE;
168 gUpRates DBMS_SQL.NUMBER_TABLE;
169 gUpSupplierNumbers DBMS_SQL.VARCHAR2_TABLE;
170 gUpSupplierContactIds DBMS_SQL.NUMBER_TABLE;
171 gUpItemRevisions DBMS_SQL.VARCHAR2_TABLE;
172 gUpLineTypeIds DBMS_SQL.NUMBER_TABLE;
173 gUpBuyerIds DBMS_SQL.NUMBER_TABLE;
174 gUPPriceRowIds DBMS_SQL.UROWID_TABLE;
175 gUPActiveFlags DBMS_SQL.VARCHAR2_TABLE;
176 gUPLastUpdateDates DBMS_SQL.DATE_TABLE;
177
178
179 -- Update ICX_CAT_ITEM_PRICES for global agreements
180 gUPGRtItemIds DBMS_SQL.NUMBER_TABLE;
181 gUPGContractIds DBMS_SQL.NUMBER_TABLE;
182 gUPGContractLineIds DBMS_SQL.NUMBER_TABLE;
183 gUPGInventoryItemIds DBMS_SQL.NUMBER_TABLE;
184 gUPGMtlCategoryIds DBMS_SQL.NUMBER_TABLE;
185 gUPGSearchTypes DBMS_SQL.VARCHAR2_TABLE;
186 gUPGUnitPrices DBMS_SQL.NUMBER_TABLE;
187 --FPJ FPSL Extractor Changes
188 gUPGValueBasis DBMS_SQL.VARCHAR2_TABLE;
189 gUPGPurchaseBasis DBMS_SQL.VARCHAR2_TABLE;
190 gUPGAllowPriceOverrideFlag DBMS_SQL.VARCHAR2_TABLE;
191 gUPGNotToExceedPrice DBMS_SQL.NUMBER_TABLE;
192 -- FPJ Bug# 3110297 jingyu Add negotiated flag
193 gUPGNegotiatedFlag DBMS_SQL.VARCHAR2_TABLE;
194 gUPGLineTypeIds DBMS_SQL.NUMBER_TABLE;
195 gUPGCurrencys DBMS_SQL.VARCHAR2_TABLE;
196 gUPGUnitOfMeasures DBMS_SQL.VARCHAR2_TABLE;
197 gUPGFunctionalPrices DBMS_SQL.NUMBER_TABLE;
198
199 -- Insert ICX_CAT_ITEM_PRICES
200 gIPRtItemIds DBMS_SQL.NUMBER_TABLE;
201 gIPPriceTypes DBMS_SQL.VARCHAR2_TABLE;
202 gIPAslIds DBMS_SQL.NUMBER_TABLE;
203 gIPSupplierSiteIds DBMS_SQL.NUMBER_TABLE;
204 gIPContractIds DBMS_SQL.NUMBER_TABLE;
205 gIPContractLineIds DBMS_SQL.NUMBER_TABLE;
206 gIPTemplateIds DBMS_SQL.VARCHAR2_TABLE;
207 gIPTemplateLineIds DBMS_SQL.NUMBER_TABLE;
208 gIPInventoryItemIds DBMS_SQL.NUMBER_TABLE;
209 gIPMtlCategoryIds DBMS_SQL.NUMBER_TABLE;
210 gIPOrgIds DBMS_SQL.NUMBER_TABLE;
211 gIPSearchTypes DBMS_SQL.VARCHAR2_TABLE;
212 gIPUnitPrices DBMS_SQL.NUMBER_TABLE;
213 --FPJ FPSL Extractor Changes
214 gIPValueBasis DBMS_SQL.VARCHAR2_TABLE;
215 gIPPurchaseBasis DBMS_SQL.VARCHAR2_TABLE;
216 gIPAllowPriceOverrideFlag DBMS_SQL.VARCHAR2_TABLE;
217 gIPNotToExceedPrice DBMS_SQL.NUMBER_TABLE;
218 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
219 gIPSuggestedQuantities DBMS_SQL.NUMBER_TABLE;
220 -- FPJ Bug# 3110297 jingyu Add negotiated flag
221 gIPNegotiatedFlag DBMS_SQL.VARCHAR2_TABLE;
222 gIPCurrencys DBMS_SQL.VARCHAR2_TABLE;
223 gIPUnitOfMeasures DBMS_SQL.VARCHAR2_TABLE;
224 gIPFunctionalPrices DBMS_SQL.NUMBER_TABLE;
225 gIPSupplierSiteCodes DBMS_SQL.VARCHAR2_TABLE;
226 gIPContractNums DBMS_SQL.VARCHAR2_TABLE;
227 gIPContractLineNums DBMS_SQL.NUMBER_TABLE;
228 gIpRateTypes DBMS_SQL.VARCHAR2_TABLE;
229 gIpRateDates DBMS_SQL.DATE_TABLE;
230 gIpRates DBMS_SQL.NUMBER_TABLE;
231 gIpSupplierNumbers DBMS_SQL.VARCHAR2_TABLE;
232 gIpSupplierContactIds DBMS_SQL.NUMBER_TABLE;
233 gIpItemRevisions DBMS_SQL.VARCHAR2_TABLE;
234 gIpLineTypeIds DBMS_SQL.NUMBER_TABLE;
235 gIpBuyerIds DBMS_SQL.NUMBER_TABLE;
236 gIPActiveFlags DBMS_SQL.VARCHAR2_TABLE;
237 gIPLastUpdateDates DBMS_SQL.DATE_TABLE;
238
239 -- Insert ICX_CAT_ITEMS_B
240 gIBRtItemIds DBMS_SQL.NUMBER_TABLE;
241 gIBOrgIds DBMS_SQL.NUMBER_TABLE;
242 gIBSupplierIds DBMS_SQL.NUMBER_TABLE;
243 gIBSuppliers DBMS_SQL.VARCHAR2_TABLE;
244 gIBSupplierPartNums DBMS_SQL.VARCHAR2_TABLE;
245 gIBInternalItemIds DBMS_SQL.NUMBER_TABLE;
246 gIBInternalItemNums DBMS_SQL.VARCHAR2_TABLE;
247
248 -- Update ICX_CAT_ITEMS_B
249 gUBRtItemIds DBMS_SQL.NUMBER_TABLE;
250 gUBInternalItemNums DBMS_SQL.VARCHAR2_TABLE;
251 gUBExtractorUpdatedFlags DBMS_SQL.VARCHAR2_TABLE;
252 gUBJobNumbers DBMS_SQL.NUMBER_TABLE;
253
254 -- Insert ICX_CAT_ITEMS_TLP
255 gITRtItemIds DBMS_SQL.NUMBER_TABLE;
256 gITLanguages DBMS_SQL.VARCHAR2_TABLE;
257 gITOrgIds DBMS_SQL.NUMBER_TABLE;
258 gITSupplierIds DBMS_SQL.NUMBER_TABLE;
259 gITItemSourceTypes DBMS_SQL.VARCHAR2_TABLE;
260 gITSearchTypes DBMS_SQL.VARCHAR2_TABLE;
261 gITPrimaryCategoryIds DBMS_SQL.NUMBER_TABLE;
262 gITPrimaryCategoryNames DBMS_SQL.VARCHAR2_TABLE;
263 gITInternalItemIds DBMS_SQL.NUMBER_TABLE;
264 gITInternalItemNums DBMS_SQL.VARCHAR2_TABLE;
265 gITSuppliers DBMS_SQL.VARCHAR2_TABLE;
266 gITSupplierPartNums DBMS_SQL.VARCHAR2_TABLE;
267 gITDescriptions DBMS_SQL.VARCHAR2_TABLE;
268 gITPictures DBMS_SQL.VARCHAR2_TABLE;
269 gITPictureURLs DBMS_SQL.VARCHAR2_TABLE;
270 gITManufacturers DBMS_SQL.VARCHAR2_TABLE;
271 gITManufacturerPartNums DBMS_SQL.VARCHAR2_TABLE;
272
273 -- Update ICX_CAT_ITEMS_TLP
274 gUTRtItemIds DBMS_SQL.NUMBER_TABLE;
275 gUTLanguages DBMS_SQL.VARCHAR2_TABLE;
276 gUTItemSourceTypes DBMS_SQL.VARCHAR2_TABLE;
277 gUTSearchTypes DBMS_SQL.VARCHAR2_TABLE;
278 gUTPrimaryCategoryIds DBMS_SQL.NUMBER_TABLE;
279 gUTPrimaryCategoryNames DBMS_SQL.VARCHAR2_TABLE;
280 gUTInternalItemNums DBMS_SQL.VARCHAR2_TABLE;
281 gUTDescriptions DBMS_SQL.VARCHAR2_TABLE;
282 gUTPictures DBMS_SQL.VARCHAR2_TABLE;
283 gUTPictureURLs DBMS_SQL.VARCHAR2_TABLE;
284 gUTManufacturers DBMS_SQL.VARCHAR2_TABLE;
285 gUTManufacturerPartNums DBMS_SQL.VARCHAR2_TABLE;
286
287 -- Insert ICX_CAT_CATEGORY_ITEMS
288 gICRtItemIds DBMS_SQL.NUMBER_TABLE;
289 gICRtCategoryIds DBMS_SQL.NUMBER_TABLE;
290
291 -- Update ICX_CAT_CATEGORY_ITEMS
292 gUCRtItemIds DBMS_SQL.NUMBER_TABLE;
293 gUCRtCategoryIds DBMS_SQL.NUMBER_TABLE;
294 gUCOldRtCategoryIds DBMS_SQL.NUMBER_TABLE;
295
296 -- Insert ICX_CAT_EXT_ITEMS_TLP
297 gIERtItemIds DBMS_SQL.NUMBER_TABLE;
298 -- bug 2925403
299 gIELanguages DBMS_SQL.VARCHAR2_TABLE;
300 gIEOrgIds DBMS_SQL.NUMBER_TABLE;
301 gIERtCategoryIds DBMS_SQL.NUMBER_TABLE;
302
303 -- Update ICX_CAT_EXT_ITEMS_TLP
304 gUERtItemIds DBMS_SQL.NUMBER_TABLE;
305 -- bug 2925403
306 gUELanguages DBMS_SQL.VARCHAR2_TABLE;
307 gUERtCategoryIds DBMS_SQL.NUMBER_TABLE;
308 gUEOldRtCategoryIds DBMS_SQL.NUMBER_TABLE;
309
310 -- Insert temporary table to cleanup item
311 gCIRtItemIds DBMS_SQL.NUMBER_TABLE;
312
313 -- Insert temporary table to update global agreement
314 gUGAContractIds DBMS_SQL.NUMBER_TABLE;
315 gUGAContractLineIds DBMS_SQL.NUMBER_TABLE;
316
317 -- Insert temporary table to set active_flag
318 gTARtItemIds DBMS_SQL.NUMBER_TABLE;
319 gTAInvItemIds DBMS_SQL.NUMBER_TABLE;
320 gTAInvOrgIds DBMS_SQL.NUMBER_TABLE;
321
322 -- Delete Item Prices
323 gDPRowIds DBMS_SQL.UROWID_TABLE;
324 gDPTemplateCategoryIds DBMS_SQL.NUMBER_TABLE;
325 gDPRtItemIds DBMS_SQL.NUMBER_TABLE;
326 gDPInventoryItemIds DBMS_SQL.NUMBER_TABLE;
327 gDPOrgIds DBMS_SQL.NUMBER_TABLE;
328 gDPLocalRtItemIds DBMS_SQL.NUMBER_TABLE;
329
330 -- Delete Item Prices for global agreement
331 gDPGContractIds DBMS_SQL.NUMBER_TABLE;
332 gDPGContractLineIds DBMS_SQL.NUMBER_TABLE;
333
334 -- Delete Item
335 gDIPurchasingItemIds DBMS_SQL.NUMBER_TABLE;
336 gDIPurchasingOrgIds DBMS_SQL.NUMBER_TABLE;
337 gDINullPriceItemIds DBMS_SQL.NUMBER_TABLE;
338 gDINullPriceOrgIds DBMS_SQL.NUMBER_TABLE;
339 gDIInternalItemIds DBMS_SQL.NUMBER_TABLE;
340 gDIInternalOrgIds DBMS_SQL.NUMBER_TABLE;
341
342 -- Delete Item without price
343 gDIRtItemIds DBMS_SQL.NUMBER_TABLE;
344
345 -- Set active flag
346 gSAPriceTypes DBMS_SQL.VARCHAR2_TABLE;
347 gSARtItemIds DBMS_SQL.NUMBER_TABLE;
348 gSARowIds DBMS_SQL.UROWID_TABLE;
349 gSAActiveFlags DBMS_SQL.VARCHAR2_TABLE;
350
351 -- Set item source type
352 gSIITRtItemIds DBMS_SQL.NUMBER_TABLE;
353 gSITRtItemIds DBMS_SQL.NUMBER_TABLE;
354
355 -- Update ICX_CAT_ITEM_PRICES for local global agreements
356 gUPGASupplierSiteIds DBMS_SQL.NUMBER_TABLE;
357 gUPGAContractIds DBMS_SQL.NUMBER_TABLE;
358 gUPGAContractLineIds DBMS_SQL.NUMBER_TABLE;
359 gUPGAFunctionalPrices DBMS_SQL.NUMBER_TABLE;
360 gUPGASupplierSiteCodes DBMS_SQL.VARCHAR2_TABLE;
361 -- bug 2912717: populate line_type, rate info. for GA
362 gUPGALineTypeIds DBMS_SQL.NUMBER_TABLE;
363 gUPGARateTypes DBMS_SQL.VARCHAR2_TABLE;
364 gUPGARateDates DBMS_SQL.DATE_TABLE;
365 gUPGARates DBMS_SQL.NUMBER_TABLE;
366 -- bug 3298502: Enabled Org Ids
367 gUPGAOrgIds DBMS_SQL.NUMBER_TABLE;
368
369 -- Insert ICX_CAT_ITEM_PRICES for local global agreements
370 gIPGARtItemIds DBMS_SQL.NUMBER_TABLE;
371 gIPGALocalRtItemIds DBMS_SQL.NUMBER_TABLE;
372 gIPGASupplierSiteIds DBMS_SQL.NUMBER_TABLE;
373 gIPGAContractIds DBMS_SQL.NUMBER_TABLE;
374 gIPGAContractLineIds DBMS_SQL.NUMBER_TABLE;
375 gIPGAInventoryItemIds DBMS_SQL.NUMBER_TABLE;
376 gIPGAMtlCategoryIds DBMS_SQL.NUMBER_TABLE;
377 gIPGAOrgIds DBMS_SQL.NUMBER_TABLE;
378 gIPGAUnitPrices DBMS_SQL.NUMBER_TABLE;
379 --FPJ FPSL Extractor Changes
380 gIPGAValueBasis DBMS_SQL.VARCHAR2_TABLE;
381 gIPGAPurchaseBasis DBMS_SQL.VARCHAR2_TABLE;
382 gIPGAAllowPriceOverrideFlag DBMS_SQL.VARCHAR2_TABLE;
383 gIPGANotToExceedPrice DBMS_SQL.NUMBER_TABLE;
384 -- FPJ Bug# 3110297 jingyu Add negotiated flag
385 gIPGANegotiatedFlag DBMS_SQL.VARCHAR2_TABLE;
386 gIPGACurrencys DBMS_SQL.VARCHAR2_TABLE;
387 gIPGAUnitOfMeasures DBMS_SQL.VARCHAR2_TABLE;
388 gIPGAFunctionalPrices DBMS_SQL.NUMBER_TABLE;
389 gIPGASupplierSiteCodes DBMS_SQL.VARCHAR2_TABLE;
390 gIPGAContractNums DBMS_SQL.VARCHAR2_TABLE;
391 gIPGAContractLineNums DBMS_SQL.NUMBER_TABLE;
392 -- bug 2912717: populate line_type, rate info. for GA
393 gIPGALineTypeIds DBMS_SQL.NUMBER_TABLE;
394 gIPGARateTypes DBMS_SQL.VARCHAR2_TABLE;
395 gIPGARateDates DBMS_SQL.DATE_TABLE;
396 gIPGARates DBMS_SQL.NUMBER_TABLE;
397
398 -- Set local rt_item_id for local global agreements
399 gSLRRowIds DBMS_SQL.UROWID_TABLE;
400 gSLRALocalRtItemIds DBMS_SQL.NUMBER_TABLE;
401
402 gSetTemplateLastRunDate BOOLEAN := TRUE;
403
404 --------------------------------------------------------------
405 -- Clear PL/SQL Tables --
406 --------------------------------------------------------------
407 PROCEDURE clearTables(pMode IN VARCHAR2) IS
408 BEGIN
409 IF (pMode IN ('ALL', 'UPDATE_PRICES')) THEN
410 -- Update ICX_CAT_ITEM_PRICES
411 gUPRtItemIds.DELETE;
412 gUPPriceTypes.DELETE;
413 gUPAslIds.DELETE;
414 gUPSupplierSiteIds.DELETE;
415 gUPContractIds.DELETE;
416 gUPContractLineIds.DELETE;
417 gUPTemplateIds.DELETE;
418 gUPTemplateLineIds.DELETE;
419 gUPInventoryItemIds.DELETE;
420 gUPMtlCategoryIds.DELETE;
421 gUPOrgIds.DELETE;
422 gUPSearchTypes.DELETE;
423 gUPUnitPrices.DELETE;
424 --FPJ FPSL Extractor Changes
425 gUPValueBasis.DELETE;
426 gUPPurchaseBasis.DELETE;
427 gUPAllowPriceOverrideFlag.DELETE;
428 gUPNotToExceedPrice.DELETE;
429 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
430 gUPSuggestedQuantities.DELETE;
431 -- FPJ Bug# 3110297 jingyu Add negotiated flag
432 gUPNegotiatedFlag.DELETE;
433 gUPCurrencys.DELETE;
434 gUPUnitOfMeasures.DELETE;
435 gUPFunctionalPrices.DELETE;
436 gUPSupplierSiteCodes.DELETE;
437 gUPContractNums.DELETE;
438 gUPContractLineNums.DELETE;
439 gUpRateTypes.DELETE;
440 gUpRateDates.DELETE;
441 gUpRates.DELETE;
442 gUpSupplierNumbers.DELETE;
443 gUpSupplierContactIds.DELETE;
444 gUpItemRevisions.DELETE;
445 gUpLineTypeIds.DELETE;
446 gUpBuyerIds.DELETE;
447 gUPPriceRowIds.DELETE;
448 gUPActiveFlags.DELETE;
449 gUPLastUpdateDates.DELETE;
450
451 END IF;
452
453 IF (pMode IN ('ALL', 'UPDATE_PRICES_G')) THEN
454 -- Update ICX_CAT_ITEM_PRICES for global agreements
455 gUPGRtItemIds.DELETE;
456 gUPGContractIds.DELETE;
457 gUPGContractLineIds.DELETE;
458 gUPGInventoryItemIds.DELETE;
459 gUPGMtlCategoryIds.DELETE;
460 gUPGSearchTypes.DELETE;
461 gUPGUnitPrices.DELETE;
462 --FPJ FPSL Extractor Changes
463 gUPGValueBasis.DELETE;
464 gUPGPurchaseBasis.DELETE;
465 gUPGAllowPriceOverrideFlag.DELETE;
466 gUPGNotToExceedPrice.DELETE;
467 -- FPJ Bug# 3110297 jingyu Add negotiated flag
468 gUPGNegotiatedFlag.DELETE;
469 gUPGLineTypeIds.DELETE;
470 gUPGCurrencys.DELETE;
471 gUPGUnitOfMeasures.DELETE;
472 gUPGFunctionalPrices.DELETE;
473 END IF;
474
475 IF (pMode IN ('ALL', 'INSERT_PRICES')) THEN
476 -- Insert ICX_CAT_ITEM_PRICES
477 gIPRtItemIds.DELETE;
478 gIPPriceTypes.DELETE;
479 gIPAslIds.DELETE;
480 gIPSupplierSiteIds.DELETE;
481 gIPContractIds.DELETE;
482 gIPContractLineIds.DELETE;
483 gIPTemplateIds.DELETE;
484 gIPTemplateLineIds.DELETE;
485 gIPInventoryItemIds.DELETE;
486 gIPMtlCategoryIds.DELETE;
487 gIPOrgIds.DELETE;
488 gIPSearchTypes.DELETE;
489 gIPUnitPrices.DELETE;
490 --FPJ FPSL Extractor Changes
491 gIPValueBasis.DELETE;
492 gIPPurchaseBasis.DELETE;
493 gIPAllowPriceOverrideFlag.DELETE;
494 gIPNotToExceedPrice.DELETE;
495 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
496 gIPSuggestedQuantities.DELETE;
497 -- FPJ Bug# 3110297 jingyu Add negotiated flag
498 gIPNegotiatedFlag.DELETE;
499 gIPCurrencys.DELETE;
500 gIPUnitOfMeasures.DELETE;
501 gIPFunctionalPrices.DELETE;
502 gIPSupplierSiteCodes.DELETE;
503 gIPContractNums.DELETE;
504 gIPContractLineNums.DELETE;
505 gIpRateTypes.DELETE;
506 gIpRateDates.DELETE;
507 gIpRates.DELETE;
508 gIpSupplierNumbers.DELETE;
509 gIpSupplierContactIds.DELETE;
510 gIpItemRevisions.DELETE;
511 gIpLineTypeIds.DELETE;
512 gIpBuyerIds.DELETE;
513 gIPActiveFlags.DELETE;
514 gIPLastUpdateDates.DELETE;
515 END IF;
516
517 IF (pMode IN ('ALL', 'INSERT_ITEMS_B')) THEN
518 -- Insert ICX_CAT_ITEMS_B
519 gIBRtItemIds.DELETE;
520 gIBOrgIds.DELETE;
521 gIBSupplierIds.DELETE;
522 gIBSuppliers.DELETE;
523 gIBSupplierPartNums.DELETE;
524 gIBInternalItemIds.DELETE;
525 gIBInternalItemNums.DELETE;
526 END IF;
527
528 IF (pMode IN ('ALL', 'UPDATE_ITEMS_B')) THEN
529 -- Update ICX_CAT_ITEMS_B
530 gUBRtItemIds.DELETE;
531 gUBInternalItemNums.DELETE;
532 gUBExtractorUpdatedFlags.DELETE;
533 gUBJobNumbers.DELETE;
534 END IF;
535
536 IF (pMode IN ('ALL', 'INSERT_ITEMS_TLP')) THEN
537 -- Insert ICX_CAT_ITEMS_TLP
538 gITRtItemIds.DELETE;
539 gITLanguages.DELETE;
540 gITOrgIds.DELETE;
541 gITSupplierIds.DELETE;
542 gITItemSourceTypes.DELETE;
543 gITSearchTypes.DELETE;
544 gITPrimaryCategoryIds.DELETE;
545 gITPrimaryCategoryNames.DELETE;
546 gITInternalItemIds.DELETE;
547 gITInternalItemNums.DELETE;
548 gITSuppliers.DELETE;
549 gITSupplierPartNums.DELETE;
550 gITDescriptions.DELETE;
551 gITPictures.DELETE;
552 gITPictureURLs.DELETE;
553 gITManufacturers.DELETE;
554 gITManufacturerPartNums.DELETE;
555 END IF;
556
557 IF (pMode IN ('ALL', 'UPDATE_ITEMS_TLP')) THEN
558 -- Update ICX_CAT_ITEMS_TLP
559 gUTRtItemIds.DELETE;
560 gUTLanguages.DELETE;
561 gUTItemSourceTypes.DELETE;
562 gUTSearchTypes.DELETE;
563 gUTPrimaryCategoryIds.DELETE;
564 gUTPrimaryCategoryNames.DELETE;
565 gUTInternalItemNums.DELETE;
566 gUTDescriptions.DELETE;
567 gUTPictures.DELETE;
568 gUTPictureURLs.DELETE;
569 gUTManufacturers.DELETE;
570 gUTManufacturerPartNums.DELETE;
571 END IF;
572
573 IF (pMode IN ('ALL', 'INSERT_CATEGORY_ITEMS')) THEN
574 -- Insert ICX_CAT_CATEGORY_ITEMS
575 gICRtItemIds.DELETE;
576 gICRtCategoryIds.DELETE;
577 END IF;
578
579 IF (pMode IN ('ALL', 'UPDATE_CATEGORY_ITEMS')) THEN
580 -- Update ICX_CAT_CATEGORY_ITEMS
581 gUCRtItemIds.DELETE;
582 gUCRtCategoryIds.DELETE;
583 gUCOldRtCategoryIds.DELETE;
584 END IF;
585
586 IF (pMode IN ('ALL', 'INSERT_EXT_ITEMS')) THEN
587 -- Insert ICX_CAT_EXT_ITEMS_TLP
588 gIERtItemIds.DELETE;
589 gIELanguages.DELETE;
590 gIEOrgIds.DELETE;
591 gIERtCategoryIds.DELETE;
592 END IF;
593
594 IF (pMode IN ('ALL', 'UPDATE_EXT_ITEMS')) THEN
595 -- Update ICX_CAT_EXT_ITEMS_TLP
596 gUERtItemIds.DELETE;
597 gUELanguages.DELETE;
598 gUERtCategoryIds.DELETE;
599 gUEOldRtCategoryIds.DELETE;
600 END IF;
601
602 IF (pMode IN ('ALL', 'DELETE_ITEM_PRICE')) THEN
603 -- Delete Item Price
604 gDPRowIds.DELETE;
605 gDPTemplateCategoryIds.DELETE;
606 gDPRtItemIds.DELETE;
607 gDPInventoryItemIds.DELETE;
608 gDPOrgIds.DELETE;
609 gDPLocalRtItemIds.DELETE;
610 END IF;
611
612 IF (pMode IN ('ALL', 'DELETE_ITEM_PRICE_GA')) THEN
613 -- Delete Item Price for global agreement
614 gDPGContractIds.DELETE;
615 gDPGContractLineIds.DELETE;
616 END IF;
617
618 IF (pMode IN ('ALL', 'DELETE_PURCHASING_ITEM')) THEN
619 -- Delete Purchasing Item
620 gDIPurchasingItemIds.DELETE;
621 gDIPurchasingOrgIds.DELETE;
622 END IF;
623
624 IF (pMode IN ('ALL', 'DELETE_NULL_PRICE_ITEM')) THEN
625 -- Delete Null Price Item
626 gDINullPriceItemIds.DELETE;
627 gDINullPriceOrgIds.DELETE;
628 END IF;
629
630 IF (pMode IN ('ALL', 'DELETE_INTERNAL_ITEM')) THEN
631 -- Delete Internal Item
632 gDIInternalItemIds.DELETE;
633 gDIInternalOrgIds.DELETE;
634 END IF;
635
636 IF (pMode IN ('ALL', 'TOUCH_CLEANUP_ITEM')) THEN
637 -- Insert temporary table to cleanup item
638 gCIRtItemIds.DELETE;
639 END IF;
640
641 IF (pMode IN ('ALL', 'TOUCH_UPDATED_GA')) THEN
642 -- Insert temporary table to update global agreement
643 gUGAContractIds.DELETE;
644 gUGAContractLineIds.DELETE;
645 END IF;
646
647 IF (pMode IN ('ALL', 'TOUCH_ACTIVE_FLAG')) THEN
648 -- Insert temporary table to set active_flag
649 gTARtItemIds.DELETE;
650 END IF;
651
652 IF (pMode IN ('ALL', 'TOUCH_ACTIVE_FLAG_INV')) THEN
653 -- Insert temporary table to set active_flag
654 gTAInvItemIds.DELETE;
655 gTAInvOrgIds.DELETE;
656 END IF;
657
658 IF (pMode IN ('ALL', 'DELETE_ITEM_NOPRICE')) THEN
659 -- Delete Items without price
660 gDIRtItemIds.DELETE;
661 END IF;
662
663 IF (pMode IN ('ALL', 'SET_ACTIVE_FLAG')) THEN
664 -- Set ICX_CAT_ITEM_PRICES.active_flag
665 gSAPriceTypes.DELETE;
666 gSARtItemIds.DELETE;
667 gSARowIds.DELETE;
668 gSAActiveFlags.DELETE;
669 END IF;
670
671 IF (pMode IN ('ALL', 'UPDATE_PRICES_GA')) THEN
672 -- Update ICX_CAT_ITEM_PRICES for local global agreements
673 gUPGASupplierSiteIds.DELETE;
674 gUPGAContractIds.DELETE;
675 gUPGAContractLineIds.DELETE;
676 gUPGAFunctionalPrices.DELETE;
677 gUPGASupplierSiteCodes.DELETE;
678 -- bug 2912717: populate line_type, rate info. for GA
679 gUPGALineTypeIds.DELETE;
680 gUPGARateTypes.DELETE;
681 gUPGARateDates.DELETE;
682 gUPGARates.DELETE;
683 -- bug 3298502: Enabled Org Ids
684 gUPGAOrgIds.DELETE;
685 END IF;
686
687 IF (pMode IN ('ALL', 'INSERT_PRICES_GA')) THEN
688 -- Insert ICX_CAT_ITEM_PRICES for local global agreements
689 gIPGARtItemIds.DELETE;
690 gIPGALocalRtItemIds.DELETE;
691 gIPGASupplierSiteIds.DELETE;
692 gIPGAContractIds.DELETE;
693 gIPGAContractLineIds.DELETE;
694 gIPGAInventoryItemIds.DELETE;
695 gIPGAMtlCategoryIds.DELETE;
696 gIPGAOrgIds.DELETE;
697 gIPGAUnitPrices.DELETE;
698 --FPJ FPSL Extractor Changes
699 gIPGAValueBasis.DELETE;
700 gIPGAPurchaseBasis.DELETE;
701 gIPGAAllowPriceOverrideFlag.DELETE;
702 gIPGANotToExceedPrice.DELETE;
703 -- FPJ Bug# 3110297 jingyu Add negotiated flag
704 gIPGANegotiatedFlag.DELETE;
705 gIPGACurrencys.DELETE;
706 gIPGAUnitOfMeasures.DELETE;
707 gIPGAFunctionalPrices.DELETE;
708 gIPGASupplierSiteCodes.DELETE;
709 gIPGAContractNums.DELETE;
710 gIPGAContractLineNums.DELETE;
711 -- bug 2912717: populate line_type, rate info. for GA
712 gIPGALineTypeIds.DELETE;
713 gIPGARateTypes.DELETE;
714 gIPGARateDates.DELETE;
715 gIPGARates.DELETE;
716 END IF;
717
718 IF (pMode IN ('ALL', 'SET_LOCAL_RT_ITEM_ID')) THEN
719 -- Set local rt_item_id for local global agreements
720 gSLRRowIds.DELETE;
721 gSLRALocalRtItemIds.DELETE;
722 END IF;
723 END;
724
725 --------------------------------------------------------------
726 -- Snap Shots --
727 --------------------------------------------------------------
728 FUNCTION snapShot(pIndex IN PLS_INTEGER,
729 pMode IN VARCHAR2) RETURN varchar2 IS
730 xShot varchar2(4000) := 'SnapShot('||pMode||')['||pIndex||']--';
731 BEGIN
732 IF (pMode = 'UPDATE_PRICES') THEN
733 -- Update ICX_CAT_ITEM_PRICES
734 xShot := xShot || ' gUPRtItemIds: ' ||
735 ICX_POR_EXT_UTL.getTableElement(gUPRtItemIds, pIndex) || ', ';
736 xShot := xShot || ' gUPPriceTypes: ' ||
737 ICX_POR_EXT_UTL.getTableElement(gUPPriceTypes, pIndex) || ', ';
738 xShot := xShot || ' gUPAslIds: ' ||
739 ICX_POR_EXT_UTL.getTableElement(gUPAslIds, pIndex) || ', ';
740 xShot := xShot || ' gUPSupplierSiteIds: ' ||
741 ICX_POR_EXT_UTL.getTableElement(gUPSupplierSiteIds, pIndex) || ', ';
742 xShot := xShot || ' gUPContractIds: ' ||
743 ICX_POR_EXT_UTL.getTableElement(gUPContractIds, pIndex) || ', ';
744 xShot := xShot || ' gUPContractLineIds: ' ||
745 ICX_POR_EXT_UTL.getTableElement(gUPContractLineIds, pIndex) || ', ';
746 xShot := xShot || ' gUPTemplateIds: ' ||
747 ICX_POR_EXT_UTL.getTableElement(gUPTemplateIds, pIndex) || ', ';
748 xShot := xShot || ' gUPTemplateLineIds: ' ||
749 ICX_POR_EXT_UTL.getTableElement(gUPTemplateLineIds, pIndex) || ', ';
750 xShot := xShot || ' gUPInventoryItemIds: ' ||
751 ICX_POR_EXT_UTL.getTableElement(gUPInventoryItemIds, pIndex) || ', ';
752 xShot := xShot || ' gUPMtlCategoryIds: ' ||
753 ICX_POR_EXT_UTL.getTableElement(gUPMtlCategoryIds, pIndex) || ', ';
754 xShot := xShot || ' gUPOrgIds: ' ||
755 ICX_POR_EXT_UTL.getTableElement(gUPOrgIds, pIndex) || ', ';
756 xShot := xShot || ' gUPSearchTypes: ' ||
757 ICX_POR_EXT_UTL.getTableElement(gUPSearchTypes, pIndex) || ', ';
758 xShot := xShot || ' gUPUnitPrices: ' ||
759 ICX_POR_EXT_UTL.getTableElement(gUPUnitPrices, pIndex) || ', ';
760 --FPJ FPSL Extractor Changes
761 xShot := xShot || ' gUPValueBasis: ' ||
762 ICX_POR_EXT_UTL.getTableElement(gUPValueBasis, pIndex) || ', ';
763 xShot := xShot || ' gUPPurchaseBasis: ' ||
764 ICX_POR_EXT_UTL.getTableElement(gUPPurchaseBasis, pIndex) || ', ';
765 xShot := xShot || ' gUPAllowPriceOverrideFlag: ' ||
766 ICX_POR_EXT_UTL.getTableElement(gUPAllowPriceOverrideFlag, pIndex)||', ';
767 xShot := xShot || ' gUPNotToExceedPrice: ' ||
768 ICX_POR_EXT_UTL.getTableElement(gUPNotToExceedPrice, pIndex) || ', ';
769 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
770 xShot := xShot || ' gUPSuggestedQuantities: ' ||
771 ICX_POR_EXT_UTL.getTableElement(gUPSuggestedQuantities, pIndex) || ', ';
772 -- FPJ Bug# 3110297 jingyu Add negotiated flag
773 xShot := xShot || ' gUPNegotiatedFlag: ' ||
774 ICX_POR_EXT_UTL.getTableElement(gUPNegotiatedFlag, pIndex) || ', ';
775 xShot := xShot || ' gUPCurrencys: ' ||
776 ICX_POR_EXT_UTL.getTableElement(gUPCurrencys, pIndex) || ', ';
777 xShot := xShot || ' gUPUnitOfMeasures: ' ||
778 ICX_POR_EXT_UTL.getTableElement(gUPUnitOfMeasures, pIndex) || ', ';
779 xShot := xShot || ' gUPFunctionalPrices: ' ||
780 ICX_POR_EXT_UTL.getTableElement(gUPFunctionalPrices, pIndex) || ', ';
781 xShot := xShot || ' gUPSupplierSiteCodes: ' ||
782 ICX_POR_EXT_UTL.getTableElement(gUPSupplierSiteCodes, pIndex) || ', ';
783 xShot := xShot || ' gUPContractNums: ' ||
784 ICX_POR_EXT_UTL.getTableElement(gUPContractNums, pIndex) || ', ';
785 xShot := xShot || ' gUPContractLineNums: ' ||
786 ICX_POR_EXT_UTL.getTableElement(gUPContractLineNums, pIndex) || ', ';
787 xShot := xShot || ' gUpRateTypes: ' ||
788 ICX_POR_EXT_UTL.getTableElement(gUpRateTypes, pIndex) || ', ';
789 xShot := xShot || ' gUpRateDates: ' ||
790 ICX_POR_EXT_UTL.getTableElement(gUpRateDates, pIndex) || ', ';
791 xShot := xShot || ' gUpRates: ' ||
792 ICX_POR_EXT_UTL.getTableElement(gUpRates, pIndex) || ', ';
793 xShot := xShot || ' gUpSupplierNumbers: ' ||
794 ICX_POR_EXT_UTL.getTableElement(gUpSupplierNumbers, pIndex) || ', ';
795 xShot := xShot || ' gUpSupplierContactIds: ' ||
796 ICX_POR_EXT_UTL.getTableElement(gUpSupplierContactIds, pIndex) || ', ';
797 xShot := xShot || ' gUpItemRevisions: ' ||
798 ICX_POR_EXT_UTL.getTableElement(gUpItemRevisions, pIndex) || ', ';
799 xShot := xShot || ' gUpLineTypeIds: ' ||
800 ICX_POR_EXT_UTL.getTableElement(gUpLineTypeIds, pIndex) || ', ';
801 xShot := xShot || ' gUpBuyerIds: ' ||
802 ICX_POR_EXT_UTL.getTableElement(gUpBuyerIds, pIndex) || ', ';
803 xShot := xShot || ' gUPPriceRowIds: ' ||
804 ICX_POR_EXT_UTL.getTableElement(gUPPriceRowIds, pIndex);
805 xShot := xShot || ' gUPLastUpdateDates: ' ||
806 ICX_POR_EXT_UTL.getTableElement(gUPLastUpdateDates, pIndex);
807 ELSIF (pMode = 'UPDATE_PRICES_G') THEN
808 -- Update ICX_CAT_ITEM_PRICES for global agreements
809 xShot := xShot || ' gUPGRtItemIds: ' ||
810 ICX_POR_EXT_UTL.getTableElement(gUPGRtItemIds, pIndex) || ', ';
811 xShot := xShot || ' gUPGContractIds: ' ||
812 ICX_POR_EXT_UTL.getTableElement(gUPGContractIds, pIndex) || ', ';
813 xShot := xShot || ' gUPGContractLineIds: ' ||
814 ICX_POR_EXT_UTL.getTableElement(gUPGContractLineIds, pIndex) || ', ';
815 xShot := xShot || ' gUPGInventoryItemIds: ' ||
816 ICX_POR_EXT_UTL.getTableElement(gUPGInventoryItemIds, pIndex) || ', ';
817 xShot := xShot || ' gUPGMtlCategoryIds: ' ||
818 ICX_POR_EXT_UTL.getTableElement(gUPGMtlCategoryIds, pIndex) || ', ';
819 xShot := xShot || ' gUPGSearchTypes: ' ||
820 ICX_POR_EXT_UTL.getTableElement(gUPGSearchTypes, pIndex) || ', ';
821 xShot := xShot || ' gUPGUnitPrices: ' ||
822 ICX_POR_EXT_UTL.getTableElement(gUPGUnitPrices, pIndex) || ', ';
823 --FPJ FPSL Extractor Changes
824 xShot := xShot || ' gUPGValueBasis: ' ||
825 ICX_POR_EXT_UTL.getTableElement(gUPGValueBasis, pIndex) || ', ';
826 xShot := xShot || ' gUPGPurchaseBasis: ' ||
827 ICX_POR_EXT_UTL.getTableElement(gUPGPurchaseBasis, pIndex) || ', ';
828 xShot := xShot || ' gUPGAllowPriceOverrideFlag: ' ||
829 ICX_POR_EXT_UTL.getTableElement(gUPGAllowPriceOverrideFlag, pIndex)||', ';
830 xShot := xShot || ' gUPGNotToExceedPrice: ' ||
831 ICX_POR_EXT_UTL.getTableElement(gUPGNotToExceedPrice, pIndex) || ', ';
832 -- FPJ Bug# 3110297 jingyu Add negotiated flag
833 xShot := xShot || ' gUPGNegotiatedFlag: ' ||
834 ICX_POR_EXT_UTL.getTableElement(gUPGNegotiatedFlag, pIndex) || ', ';
835 xShot := xShot || ' gUPGLineTypeIds: ' ||
836 ICX_POR_EXT_UTL.getTableElement(gUPGLineTypeIds, pIndex) || ', ';
837 xShot := xShot || ' gUPGCurrencys: ' ||
838 ICX_POR_EXT_UTL.getTableElement(gUPGCurrencys, pIndex) || ', ';
839 xShot := xShot || ' gUPGUnitOfMeasures: ' ||
840 ICX_POR_EXT_UTL.getTableElement(gUPGUnitOfMeasures, pIndex) || ', ';
841 xShot := xShot || ' gUPGFunctionalPrices: ' ||
842 ICX_POR_EXT_UTL.getTableElement(gUPGFunctionalPrices, pIndex);
843 ELSIF (pMode = 'INSERT_PRICES') THEN
844 -- Insert ICX_CAT_ITEM_PRICES
845 xShot := xShot || ' gIPRtItemIds: ' ||
846 ICX_POR_EXT_UTL.getTableElement(gIPRtItemIds, pIndex) || ', ';
847 xShot := xShot || ' gIPPriceTypes: ' ||
848 ICX_POR_EXT_UTL.getTableElement(gIPPriceTypes, pIndex) || ', ';
849 xShot := xShot || ' gIPAslIds: ' ||
850 ICX_POR_EXT_UTL.getTableElement(gIPAslIds, pIndex) || ', ';
851 xShot := xShot || ' gIPSupplierSiteIds: ' ||
852 ICX_POR_EXT_UTL.getTableElement(gIPSupplierSiteIds, pIndex) || ', ';
853 xShot := xShot || ' gIPContractIds: ' ||
854 ICX_POR_EXT_UTL.getTableElement(gIPContractIds, pIndex) || ', ';
855 xShot := xShot || ' gIPContractLineIds: ' ||
856 ICX_POR_EXT_UTL.getTableElement(gIPContractLineIds, pIndex) || ', ';
857 xShot := xShot || ' gIPTemplateIds: ' ||
858 ICX_POR_EXT_UTL.getTableElement(gIPTemplateIds, pIndex) || ', ';
859 xShot := xShot || ' gIPTemplateLineIds: ' ||
860 ICX_POR_EXT_UTL.getTableElement(gIPTemplateLineIds, pIndex) || ', ';
861 xShot := xShot || ' gIPInventoryItemIds: ' ||
862 ICX_POR_EXT_UTL.getTableElement(gIPInventoryItemIds, pIndex) || ', ';
863 xShot := xShot || ' gIPMtlCategoryIds: ' ||
864 ICX_POR_EXT_UTL.getTableElement(gIPMtlCategoryIds, pIndex) || ', ';
865 xShot := xShot || ' gIPOrgIds: ' ||
866 ICX_POR_EXT_UTL.getTableElement(gIPOrgIds, pIndex) || ', ';
867 xShot := xShot || ' gIPSearchTypes: ' ||
868 ICX_POR_EXT_UTL.getTableElement(gIPSearchTypes, pIndex) || ', ';
869 xShot := xShot || ' gIPUnitPrices: ' ||
870 ICX_POR_EXT_UTL.getTableElement(gIPUnitPrices, pIndex) || ', ';
871 --FPJ FPSL Extractor Changes
872 xShot := xShot || ' gIPValueBasis: ' ||
873 ICX_POR_EXT_UTL.getTableElement(gIPValueBasis, pIndex) || ', ';
874 xShot := xShot || ' gIPPurchaseBasis: ' ||
875 ICX_POR_EXT_UTL.getTableElement(gIPPurchaseBasis, pIndex) || ', ';
876 xShot := xShot || ' gIPAllowPriceOverrideFlag: ' ||
877 ICX_POR_EXT_UTL.getTableElement(gIPAllowPriceOverrideFlag, pIndex)||', ';
878 xShot := xShot || ' gIPNotToExceedPrice: ' ||
879 ICX_POR_EXT_UTL.getTableElement(gIPNotToExceedPrice, pIndex) || ', ';
880 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
881 xShot := xShot || ' gIPSuggestedQuantities: ' ||
882 ICX_POR_EXT_UTL.getTableElement(gIPSuggestedQuantities, pIndex) || ', ';
883 -- FPJ Bug# 3110297 jingyu Add negotiated flag
884 xShot := xShot || ' gIPNegotiatedFlag: ' ||
885 ICX_POR_EXT_UTL.getTableElement(gIPNegotiatedFlag, pIndex) || ', ';
886 xShot := xShot || ' gIPCurrencys: ' ||
887 ICX_POR_EXT_UTL.getTableElement(gIPCurrencys, pIndex) || ', ';
888 xShot := xShot || ' gIPUnitOfMeasures: ' ||
889 ICX_POR_EXT_UTL.getTableElement(gIPUnitOfMeasures, pIndex) || ', ';
890 xShot := xShot || ' gIPFunctionalPrices: ' ||
891 ICX_POR_EXT_UTL.getTableElement(gIPFunctionalPrices, pIndex) || ', ';
892 xShot := xShot || ' gIPSupplierSiteCodes: ' ||
893 ICX_POR_EXT_UTL.getTableElement(gIPSupplierSiteCodes, pIndex) || ', ';
894 xShot := xShot || ' gIPContractNums: ' ||
895 ICX_POR_EXT_UTL.getTableElement(gIPContractNums, pIndex) || ', ';
896 xShot := xShot || ' gIPContractLineNums: ' ||
897 ICX_POR_EXT_UTL.getTableElement(gIPContractLineNums, pIndex) || ', ';
898 xShot := xShot || ' gIpRateTypes: ' ||
899 ICX_POR_EXT_UTL.getTableElement(gIpRateTypes, pIndex) || ', ';
900 xShot := xShot || ' gIpRateDates: ' ||
901 ICX_POR_EXT_UTL.getTableElement(gIpRateDates, pIndex) || ', ';
902 xShot := xShot || ' gIpRates: ' ||
903 ICX_POR_EXT_UTL.getTableElement(gIpRates, pIndex) || ', ';
904 xShot := xShot || ' gIpSupplierNumbers: ' ||
905 ICX_POR_EXT_UTL.getTableElement(gIpSupplierNumbers, pIndex) || ', ';
906 xShot := xShot || ' gIpSupplierContactIds: ' ||
907 ICX_POR_EXT_UTL.getTableElement(gIpSupplierContactIds, pIndex) || ', ';
908 xShot := xShot || ' gIpItemRevisions: ' ||
909 ICX_POR_EXT_UTL.getTableElement(gIpItemRevisions, pIndex) || ', ';
910 xShot := xShot || ' gIpLineTypeIds: ' ||
911 ICX_POR_EXT_UTL.getTableElement(gIpLineTypeIds, pIndex) || ', ';
912 xShot := xShot || ' gIpBuyerIds: ' ||
913 ICX_POR_EXT_UTL.getTableElement(gIpBuyerIds, pIndex) || ', ';
914 xShot := xShot || ' gIPActiveFlags: ' ||
915 ICX_POR_EXT_UTL.getTableElement(gIPActiveFlags, pIndex);
916 xShot := xShot || ' gIPLastUpdateDates: ' ||
917 ICX_POR_EXT_UTL.getTableElement(gIPLastUpdateDates, pIndex);
918 ELSIF (pMode = 'INSERT_ITEMS_B') THEN
919 -- Insert ICX_CAT_ITEMS_B
920 xShot := xShot || ' gIBRtItemIds: ' ||
921 ICX_POR_EXT_UTL.getTableElement(gIBRtItemIds, pIndex) || ', ';
922 xShot := xShot || ' gIBOrgIds: ' ||
923 ICX_POR_EXT_UTL.getTableElement(gIBOrgIds, pIndex) || ', ';
924 xShot := xShot || ' gIBSupplierIds: ' ||
925 ICX_POR_EXT_UTL.getTableElement(gIBSupplierIds, pIndex) || ', ';
926 xShot := xShot || ' gIBSuppliers: ' ||
927 ICX_POR_EXT_UTL.getTableElement(gIBSuppliers, pIndex) || ', ';
928 xShot := xShot || ' gIBSupplierPartNums: ' ||
929 ICX_POR_EXT_UTL.getTableElement(gIBSupplierPartNums, pIndex) || ', ';
930 xShot := xShot || ' gIBInternalItemIds: ' ||
931 ICX_POR_EXT_UTL.getTableElement(gIBInternalItemIds, pIndex) || ', ';
932 xShot := xShot || ' gIBInternalItemNums: ' ||
933 ICX_POR_EXT_UTL.getTableElement(gIBInternalItemNums, pIndex) || ', ';
934 ELSIF (pMode = 'UPDATE_ITEMS_B') THEN
935 -- Update ICX_CAT_ITEMS_B
936 xShot := xShot || ' gUBRtItemIds: ' ||
937 ICX_POR_EXT_UTL.getTableElement(gUBRtItemIds, pIndex) || ', ';
938 xShot := xShot || ' gUBInternalItemNums: ' ||
939 ICX_POR_EXT_UTL.getTableElement(gUBInternalItemNums, pIndex) || ', ';
940 xShot := xShot || ' gUBExtractorUpdatedFlags: ' ||
941 ICX_POR_EXT_UTL.getTableElement(gUBExtractorUpdatedFlags, pIndex) || ', ';
942 xShot := xShot || ' gUBJobNumbers: ' ||
943 ICX_POR_EXT_UTL.getTableElement(gUBJobNumbers, pIndex);
944 ELSIF (pMode = 'INSERT_ITEMS_TLP') THEN
945 -- Insert ICX_CAT_ITEMS_TLP
946 xShot := xShot || ' gITRtItemIds: ' ||
947 ICX_POR_EXT_UTL.getTableElement(gITRtItemIds, pIndex) || ', ';
948 xShot := xShot || ' gITLanguages: ' ||
949 ICX_POR_EXT_UTL.getTableElement(gITLanguages, pIndex) || ', ';
950 xShot := xShot || ' gITOrgIds: ' ||
951 ICX_POR_EXT_UTL.getTableElement(gITOrgIds, pIndex) || ', ';
952 xShot := xShot || ' gITSupplierIds: ' ||
953 ICX_POR_EXT_UTL.getTableElement(gITSupplierIds, pIndex) || ', ';
954 xShot := xShot || ' gITItemSourceTypes: ' ||
955 ICX_POR_EXT_UTL.getTableElement(gITItemSourceTypes, pIndex) || ', ';
956 xShot := xShot || ' gITSearchTypes: ' ||
957 ICX_POR_EXT_UTL.getTableElement(gITSearchTypes, pIndex) || ', ';
958 xShot := xShot || ' gITPrimaryCategoryIds: ' ||
959 ICX_POR_EXT_UTL.getTableElement(gITPrimaryCategoryIds, pIndex) || ', ';
960 xShot := xShot || ' gITPrimaryCategoryNames: ' ||
961 ICX_POR_EXT_UTL.getTableElement(gITPrimaryCategoryNames, pIndex) || ', ';
962 xShot := xShot || ' gITInternalItemIds: ' ||
963 ICX_POR_EXT_UTL.getTableElement(gITInternalItemIds, pIndex) || ', ';
964 xShot := xShot || ' gITInternalItemNums: ' ||
965 ICX_POR_EXT_UTL.getTableElement(gITInternalItemNums, pIndex) || ', ';
966 xShot := xShot || ' gITSuppliers: ' ||
967 ICX_POR_EXT_UTL.getTableElement(gITSuppliers, pIndex) || ', ';
968 xShot := xShot || ' gITSupplierPartNums: ' ||
969 ICX_POR_EXT_UTL.getTableElement(gITSupplierPartNums, pIndex) || ', ';
970 xShot := xShot || ' gITDescriptions: ' ||
971 ICX_POR_EXT_UTL.getTableElement(gITDescriptions, pIndex) || ', ';
972 xShot := xShot || ' gITPictures: ' ||
973 ICX_POR_EXT_UTL.getTableElement(gITPictures, pIndex) || ', ';
974 xShot := xShot || ' gITPictureURLs: ' ||
975 ICX_POR_EXT_UTL.getTableElement(gITPictureURLs, pIndex) || ', ';
976 xShot := xShot || ' gITManufacturers: ' ||
977 ICX_POR_EXT_UTL.getTableElement(gITManufacturers, pIndex) || ', ';
978 xShot := xShot || ' gITManufacturerPartNums: ' ||
979 ICX_POR_EXT_UTL.getTableElement(gITManufacturerPartNums, pIndex);
980 ELSIF (pMode = 'UPDATE_ITEMS_TLP') THEN
981 -- Update ICX_CAT_ITEMS_TLP
982 xShot := xShot || ' gUTRtItemIds: ' ||
983 ICX_POR_EXT_UTL.getTableElement(gUTRtItemIds, pIndex) || ', ';
984 xShot := xShot || ' gUTLanguages: ' ||
985 ICX_POR_EXT_UTL.getTableElement(gUTLanguages, pIndex) || ', ';
986 xShot := xShot || ' gUTItemSourceTypes: ' ||
987 ICX_POR_EXT_UTL.getTableElement(gUTItemSourceTypes, pIndex) || ', ';
988 xShot := xShot || ' gUTSearchTypes: ' ||
989 ICX_POR_EXT_UTL.getTableElement(gUTSearchTypes, pIndex) || ', ';
990 xShot := xShot || ' gUTPrimaryCategoryIds: ' ||
991 ICX_POR_EXT_UTL.getTableElement(gUTPrimaryCategoryIds, pIndex) || ', ';
992 xShot := xShot || ' gUTPrimaryCategoryNames: ' ||
993 ICX_POR_EXT_UTL.getTableElement(gUTPrimaryCategoryNames, pIndex) || ', ';
994 xShot := xShot || ' gUTInternalItemNums: ' ||
995 ICX_POR_EXT_UTL.getTableElement(gUTInternalItemNums, pIndex) || ', ';
996 xShot := xShot || ' gUTDescriptions: ' ||
997 ICX_POR_EXT_UTL.getTableElement(gUTDescriptions, pIndex) || ', ';
998 xShot := xShot || ' gUTPictures: ' ||
999 ICX_POR_EXT_UTL.getTableElement(gUTPictures, pIndex) || ', ';
1000 xShot := xShot || ' gUTPictureURLs: ' ||
1001 ICX_POR_EXT_UTL.getTableElement(gUTPictureURLs, pIndex) || ', ';
1002 xShot := xShot || ' gUTManufacturers: ' ||
1003 ICX_POR_EXT_UTL.getTableElement(gUTManufacturers, pIndex) || ', ';
1004 xShot := xShot || ' gUTManufacturerPartNums: ' ||
1005 ICX_POR_EXT_UTL.getTableElement(gUTManufacturerPartNums, pIndex);
1006 ELSIF (pMode = 'INSERT_CATEGORY_ITEMS') THEN
1007 -- Insert ICX_CAT_CATEGORY_ITEMS
1008 xShot := xShot || ' gICRtItemIds: ' ||
1009 ICX_POR_EXT_UTL.getTableElement(gICRtItemIds, pIndex) || ', ';
1010 xShot := xShot || ' gICRtCategoryIds: ' ||
1011 ICX_POR_EXT_UTL.getTableElement(gICRtCategoryIds, pIndex);
1012 ELSIF (pMode = 'UPDATE_CATEGORY_ITEMS') THEN
1013 -- Update ICX_CAT_CATEGORY_ITEMS
1014 xShot := xShot || ' gUCRtItemIds: ' ||
1015 ICX_POR_EXT_UTL.getTableElement(gUCRtItemIds, pIndex) || ', ';
1016 xShot := xShot || ' gUCRtCategoryIds: ' ||
1017 ICX_POR_EXT_UTL.getTableElement(gUCRtCategoryIds, pIndex) || ', ';
1018 xShot := xShot || ' gUCOldRtCategoryIds: ' ||
1019 ICX_POR_EXT_UTL.getTableElement(gUCOldRtCategoryIds, pIndex);
1020 ELSIF (pMode = 'INSERT_EXT_ITEMS') THEN
1021 -- Insert ICX_CAT_EXT_ITEMS_TLP
1022 xShot := xShot || ' gIERtItemIds: ' ||
1023 ICX_POR_EXT_UTL.getTableElement(gIERtItemIds, pIndex) || ', ';
1024 xShot := xShot || ' gIEOrgIds: ' ||
1025 ICX_POR_EXT_UTL.getTableElement(gIEOrgIds, pIndex) || ', ';
1026 xShot := xShot || ' gIERtCategoryIds: ' ||
1027 ICX_POR_EXT_UTL.getTableElement(gIERtCategoryIds, pIndex);
1028 ELSIF (pMode = 'UPDATE_EXT_ITEMS') THEN
1029 -- Update ICX_CAT_EXT_ITEMS_TLP
1030 xShot := xShot || ' gUERtItemIds: ' ||
1031 ICX_POR_EXT_UTL.getTableElement(gUERtItemIds, pIndex) || ', ';
1032 xShot := xShot || ' gUERtCategoryIds: ' ||
1033 ICX_POR_EXT_UTL.getTableElement(gUERtCategoryIds, pIndex) || ', ';
1034 xShot := xShot || ' gUEOldRtCategoryIds: ' ||
1035 ICX_POR_EXT_UTL.getTableElement(gUEOldRtCategoryIds, pIndex);
1036 ELSIF (pMode = 'DELETE_ITEM_PRICE') THEN
1037 -- Delete Item Price
1038 xShot := xShot || ' gDPRowIds: ' ||
1039 ICX_POR_EXT_UTL.getTableElement(gDPRowIds, pIndex) || ', ';
1040 xShot := xShot || ' gDPTemplateCategoryIds: ' ||
1041 ICX_POR_EXT_UTL.getTableElement(gDPTemplateCategoryIds, pIndex) || ', ';
1042 xShot := xShot || ' gDPRtItemIds: ' ||
1043 ICX_POR_EXT_UTL.getTableElement(gDPRtItemIds, pIndex) || ', ';
1044 xShot := xShot || ' gDPInventoryItemIds: ' ||
1045 ICX_POR_EXT_UTL.getTableElement(gDPInventoryItemIds, pIndex) || ', ';
1046 xShot := xShot || ' gDPOrgIds: ' ||
1047 ICX_POR_EXT_UTL.getTableElement(gDPOrgIds, pIndex) || ', ';
1048 xShot := xShot || ' gDPLocalRtItemIds: ' ||
1049 ICX_POR_EXT_UTL.getTableElement(gDPLocalRtItemIds, pIndex);
1050 ELSIF (pMode = 'DELETE_ITEM_PRICE_GA') THEN
1051 -- Delete Item Price fro global agreement
1052 xShot := xShot || ' gDPGContractIds: ' ||
1053 ICX_POR_EXT_UTL.getTableElement(gDPGContractIds, pIndex)||', ';
1054 xShot := xShot || ' gDPGContractLineIds: ' ||
1055 ICX_POR_EXT_UTL.getTableElement(gDPGContractLineIds, pIndex);
1056 ELSIF (pMode = 'DELETE_PURCHASING_ITEM') THEN
1057 -- Delete Item
1058 xShot := xShot || ' gDIPurchasingItemIds: ' ||
1059 ICX_POR_EXT_UTL.getTableElement(gDIPurchasingItemIds, pIndex) || ', ';
1060 xShot := xShot || ' gDIPurchasingOrgIds: ' ||
1061 ICX_POR_EXT_UTL.getTableElement(gDIPurchasingOrgIds, pIndex) || ', ';
1062 ELSIF (pMode = 'DELETE_NULL_PRICE_ITEM') THEN
1063 xShot := xShot || ' gDINullPriceItemIds: ' ||
1064 ICX_POR_EXT_UTL.getTableElement(gDINullPriceItemIds, pIndex) || ', ';
1065 xShot := xShot || ' gDINullPriceOrgIds: ' ||
1066 ICX_POR_EXT_UTL.getTableElement(gDINullPriceOrgIds, pIndex) || ', ';
1067 ELSIF (pMode = 'DELETE_INTERNAL_ITEM') THEN
1068 xShot := xShot || ' gDIInternalItemIds: ' ||
1069 ICX_POR_EXT_UTL.getTableElement(gDIInternalItemIds, pIndex) || ', ';
1070 xShot := xShot || ' gDIInternalOrgIds: ' ||
1071 ICX_POR_EXT_UTL.getTableElement(gDIInternalOrgIds, pIndex);
1072 ELSIF (pMode = 'TOUCH_CLEANUP_ITEM') THEN
1073 -- Insert temporary table to cleanup item
1074 xShot := xShot || ' gCIRtItemIds: ' ||
1075 ICX_POR_EXT_UTL.getTableElement(gCIRtItemIds, pIndex);
1076 ELSIF (pMode = 'TOUCH_UPDATED_GA') THEN
1077 -- Insert temporary table to update global agreement
1078 xShot := xShot || ' gUGAContractIds: ' ||
1079 ICX_POR_EXT_UTL.getTableElement(gUGAContractIds, pIndex)||', ';
1080 xShot := xShot || ' gUGAContractLineIds: ' ||
1081 ICX_POR_EXT_UTL.getTableElement(gUGAContractLineIds, pIndex)||', ';
1082 ELSIF (pMode = 'TOUCH_ACTIVE_FLAG') THEN
1083 -- Insert temporary table to set active_flag
1084 xShot := xShot || ' gTARtItemIds: ' ||
1085 ICX_POR_EXT_UTL.getTableElement(gTARtItemIds, pIndex);
1086 ELSIF (pMode = 'TOUCH_ACTIVE_FLAG_INV') THEN
1087 -- Insert temporary table to set active_flag
1088 xShot := xShot || ' gTAInvItemIds: ' ||
1089 ICX_POR_EXT_UTL.getTableElement(gTAInvItemIds, pIndex) || ', ';
1090 xShot := xShot || ' gTAInvOrgIds: ' ||
1091 ICX_POR_EXT_UTL.getTableElement(gTAInvOrgIds, pIndex);
1092 ELSIF (pMode = 'DELETE_ITEM_NOPRICE') THEN
1093 -- Delete Items without price
1094 xShot := xShot || ' gDIRtItemIds: ' ||
1095 ICX_POR_EXT_UTL.getTableElement(gDIRtItemIds, pIndex);
1096 ELSIF (pMode = 'UPDATE_PRICES_GA') THEN
1097 -- Update ICX_CAT_ITEM_PRICES for local global agreements
1098 xShot := xShot || ' gUPGASupplierSiteIds: ' ||
1099 ICX_POR_EXT_UTL.getTableElement(gUPGASupplierSiteIds, pIndex) || ', ';
1100 xShot := xShot || ' gUPGAContractIds: ' ||
1101 ICX_POR_EXT_UTL.getTableElement(gUPGAContractIds, pIndex) || ', ';
1102 xShot := xShot || ' gUPGAContractLineIds: ' ||
1103 ICX_POR_EXT_UTL.getTableElement(gUPGAContractLineIds, pIndex) || ', ';
1104 xShot := xShot || ' gUPGAFunctionalPrices: ' ||
1105 ICX_POR_EXT_UTL.getTableElement(gUPGAFunctionalPrices, pIndex) || ', ';
1106 xShot := xShot || ' gUPGASupplierSiteCodes: ' ||
1107 ICX_POR_EXT_UTL.getTableElement(gUPGASupplierSiteCodes, pIndex);
1108 xShot := xShot || ' gUPGAOrgIds: ' ||
1109 ICX_POR_EXT_UTL.getTableElement(gUPGAOrgIds, pIndex);
1110 ELSIF (pMode = 'INSERT_PRICES_GA') THEN
1111 -- Insert ICX_CAT_ITEM_PRICES for local global agreements
1112 xShot := xShot || ' gIPGARtItemIds: ' ||
1113 ICX_POR_EXT_UTL.getTableElement(gIPGARtItemIds, pIndex) || ', ';
1114 xShot := xShot || ' gIPGALocalRtItemIds: ' ||
1115 ICX_POR_EXT_UTL.getTableElement(gIPGALocalRtItemIds, pIndex) || ', ';
1116 xShot := xShot || ' gIPGASupplierSiteIds: ' ||
1117 ICX_POR_EXT_UTL.getTableElement(gIPGASupplierSiteIds, pIndex) || ', ';
1118 xShot := xShot || ' gIPGAContractIds: ' ||
1119 ICX_POR_EXT_UTL.getTableElement(gIPGAContractIds, pIndex) || ', ';
1120 xShot := xShot || ' gIPGAContractLineIds: ' ||
1121 ICX_POR_EXT_UTL.getTableElement(gIPGAContractLineIds, pIndex) || ', ';
1122 xShot := xShot || ' gIPGAInventoryItemIds: ' ||
1123 ICX_POR_EXT_UTL.getTableElement(gIPGAInventoryItemIds, pIndex) || ', ';
1124 xShot := xShot || ' gIPGAMtlCategoryIds: ' ||
1125 ICX_POR_EXT_UTL.getTableElement(gIPGAMtlCategoryIds, pIndex) || ', ';
1126 xShot := xShot || ' gIPGAOrgIds: ' ||
1127 ICX_POR_EXT_UTL.getTableElement(gIPGAOrgIds, pIndex) || ', ';
1128 xShot := xShot || ' gIPGAUnitPrices: ' ||
1129 ICX_POR_EXT_UTL.getTableElement(gIPGAUnitPrices, pIndex) || ', ';
1130 --FPJ FPSL Extractor Changes
1131 xShot := xShot || ' gIPGAValueBasis: ' ||
1132 ICX_POR_EXT_UTL.getTableElement(gIPGAValueBasis, pIndex) || ', ';
1133 xShot := xShot || ' gIPGAPurchaseBasis: ' ||
1134 ICX_POR_EXT_UTL.getTableElement(gIPGAPurchaseBasis, pIndex) || ', ';
1135 xShot := xShot || ' gIPGAAllowPriceOverrideFlag: ' ||
1136 ICX_POR_EXT_UTL.getTableElement(gIPGAAllowPriceOverrideFlag, pIndex)||', ';
1137 xShot := xShot || ' gIPGANotToExceedPrice: ' ||
1138 ICX_POR_EXT_UTL.getTableElement(gIPGANotToExceedPrice, pIndex) || ', ';
1139 -- FPJ Bug# 3110297 jingyu Add negotiated flag
1140 xShot := xShot || ' gIPGANegotiatedFlag: ' ||
1141 ICX_POR_EXT_UTL.getTableElement(gIPGANegotiatedFlag, pIndex) || ', ';
1142 xShot := xShot || ' gIPGALineTypeIds: ' ||
1143 ICX_POR_EXT_UTL.getTableElement(gIPGALineTypeIds, pIndex) || ', ';
1144 xShot := xShot || ' gIPGACurrencys: ' ||
1145 ICX_POR_EXT_UTL.getTableElement(gIPGACurrencys, pIndex) || ', ';
1146 xShot := xShot || ' gIPGAUnitOfMeasures: ' ||
1147 ICX_POR_EXT_UTL.getTableElement(gIPGAUnitOfMeasures, pIndex) || ', ';
1148 xShot := xShot || ' gIPGAFunctionalPrices: ' ||
1149 ICX_POR_EXT_UTL.getTableElement(gIPGAFunctionalPrices, pIndex) || ', ';
1150 xShot := xShot || ' gIPGASupplierSiteCodes: ' ||
1151 ICX_POR_EXT_UTL.getTableElement(gIPGASupplierSiteCodes, pIndex) || ', ';
1152 xShot := xShot || ' gIPGAContractNums: ' ||
1153 ICX_POR_EXT_UTL.getTableElement(gIPGAContractNums, pIndex) || ', ';
1154 xShot := xShot || ' gIPGAContractLineNums: ' ||
1155 ICX_POR_EXT_UTL.getTableElement(gIPGAContractLineNums, pIndex);
1156 ELSIF (pMode = 'SET_LOCAL_RT_ITEM_ID') THEN
1157 -- Set local rt_item_id for local global agreements
1158 xShot := xShot || ' gSLRRowIds: ' ||
1159 ICX_POR_EXT_UTL.getTableElement(gSLRRowIds, pIndex) || ', ';
1160 xShot := xShot || ' gSLRALocalRtItemIds: ' ||
1161 ICX_POR_EXT_UTL.getTableElement(gSLRALocalRtItemIds, pIndex);
1162 ELSIF (pMode = 'SET_ACTIVE_FLAG') THEN
1163 -- Set ICX_CAT_ITEM_PRICES.active_flag
1164 xShot := xShot || ' gSAPriceTypes: ' ||
1165 ICX_POR_EXT_UTL.getTableElement(gSAPriceTypes, pIndex) || ', ';
1166 xShot := xShot || ' gSARtItemIds: ' ||
1167 ICX_POR_EXT_UTL.getTableElement(gSARtItemIds, pIndex);
1168 xShot := xShot || ' gSARowIds: ' ||
1169 ICX_POR_EXT_UTL.getTableElement(gSARowIds, pIndex) || ', ';
1170 xShot := xShot || ' gSAActiveFlags: ' ||
1171 ICX_POR_EXT_UTL.getTableElement(gSAActiveFlags, pIndex) || ', ';
1172 END IF;
1173
1174 RETURN xShot;
1175 END snapShot;
1176
1177 FUNCTION getDocumentType(pPriceType IN VARCHAR2)
1178 RETURN VARCHAR2
1179 IS
1180 xDocumentType NUMBER;
1181 BEGIN
1182 IF pPriceType = 'TEMPLATE' THEN
1183 xDocumentType := TEMPLATE_TYPE;
1184 ELSIF pPriceType IN ('BLANKET', 'QUOTATION') THEN
1185 xDocumentType := CONTRACT_TYPE;
1186 ELSIF pPriceType = 'ASL' THEN
1187 xDocumentType := ASL_TYPE;
1188 ELSIF pPriceType = 'PURCHASING_ITEM' THEN
1189 xDocumentType := PURCHASING_ITEM_TYPE;
1190 ELSIF pPriceType = 'INTERNAL_TEMPLATE' THEN
1191 xDocumentType := INTERNAL_TEMPLATE_TYPE;
1192 ELSIF pPriceType = 'INTERNAL_ITEM' THEN
1193 xDocumentType := INTERNAL_ITEM_TYPE;
1194 ELSIF pPriceType = 'BULKLOAD' THEN
1195 xDocumentType := BULKLOAD_TYPE;
1196 ELSIF pPriceType = 'GLOBAL_AGREEMENT' THEN
1197 xDocumentType := GLOBAL_AGREEMENT_TYPE;
1198 END IF;
1199
1200 RETURN xDocumentType;
1201 END getDocumentType;
1202
1203 FUNCTION getDocumentTypeString(pDocumentType IN NUMBER)
1204 RETURN VARCHAR2
1205 IS
1206 xDocumentTypeStr VARCHAR2(80);
1207 BEGIN
1208 IF pDocumentType = TEMPLATE_TYPE THEN
1209 xDocumentTypeStr := 'TEMPLATE';
1210 ELSIF pDocumentType = CONTRACT_TYPE THEN
1211 xDocumentTypeStr := 'CONTRACT';
1212 ELSIF pDocumentType = ASL_TYPE THEN
1213 xDocumentTypeStr := 'ASL';
1214 ELSIF pDocumentType = PURCHASING_ITEM_TYPE THEN
1215 xDocumentTypeStr := 'PURCHASING_ITEM';
1216 ELSIF pDocumentType = INTERNAL_TEMPLATE_TYPE THEN
1217 xDocumentTypeStr := 'INTERNAL_TEMPLATE';
1218 ELSIF pDocumentType = INTERNAL_ITEM_TYPE THEN
1219 xDocumentTypeStr := 'INTERNAL_ITEM';
1220 ELSIF pDocumentType = BULKLOAD_TYPE THEN
1221 xDocumentTypeStr := 'BULKLOAD';
1222 ELSIF pDocumentType = GLOBAL_AGREEMENT_TYPE THEN
1223 xDocumentTypeStr := 'GLOBAL_AGREEMENT';
1224 END IF;
1225
1226 RETURN xDocumentTypeStr;
1227 END getDocumentTypeString;
1228
1229 FUNCTION getItemStatusString(pItemStatus IN NUMBER)
1230 RETURN VARCHAR2
1231 IS
1232 xItemStatusStr VARCHAR2(80);
1233 BEGIN
1234 IF pItemStatus = CACHE_MATCH THEN
1235 xItemStatusStr := 'CACHE_MATCH';
1236 ELSIF pItemStatus = PRICE_MATCH THEN
1237 xItemStatusStr := 'PRICE_MATCH';
1238 ELSIF pItemStatus = CACHE_PRICE_MATCH THEN
1239 xItemStatusStr := 'CACHE_PRICE_MATCH';
1240 ELSIF pItemStatus = ITEM_MATCH THEN
1241 xItemStatusStr := 'ITEM_MATCH';
1242 ELSIF pItemStatus = NEW_ITEM THEN
1243 xItemStatusStr := 'NEW_ITEM';
1244 ELSIF pItemStatus = NEW_GA_ITEM THEN
1245 xItemStatusStr := 'NEW_GA_ITEM';
1246 ELSIF pItemStatus = DELETE_PRICE THEN
1247 xItemStatusStr := 'DELETE_PRICE';
1248 END IF;
1249
1250 RETURN xItemStatusStr;
1251 END getItemStatusString;
1252
1253 FUNCTION snapShotItemRecord(pItem IN tItemRecord)
1254 RETURN VARCHAR2
1255 IS
1256 xShot VARCHAR2(2000) := 'Item';
1257 BEGIN
1258
1259 xShot := xShot || '[org_id: ' || pItem.org_id ||
1260 ', internal_item_id: ' || pItem.internal_item_id ||
1261 ', internal_item_num: ' || pItem.internal_item_num ||
1262 ', supplier_id: ' || pItem.supplier_id ||
1263 ', supplier: ' || pItem.supplier ||
1264 ', supplier_part_num: ' || pItem.supplier_part_num ||
1265 ', contract_line_id: ' || pItem.contract_line_id ||
1266 ', rt_item_id: ' || pItem.rt_item_id ||
1267 ', hash_value: ' || pItem.hash_value || ']';
1268
1269 RETURN xShot;
1270 END snapShotItemRecord;
1271
1272 FUNCTION snapShotPriceRow RETURN VARCHAR2
1273 IS
1274 xShot VARCHAR2(4000) := 'PriceRow';
1275 BEGIN
1276
1277 xShot := xShot || '[document_type: ' ||
1278 getDocumentTypeString(gCurrentPrice.document_type) ||
1279 ', last_update_date: ' || gCurrentPrice.last_update_date ||
1280 ', org_id: ' || gCurrentPrice.org_id ||
1281 ', supplier_id: ' || gCurrentPrice.supplier_id ||
1282 ', supplier: ' || gCurrentPrice.supplier ||
1283 ', supplier_site_code: ' || gCurrentPrice.supplier_site_code ||
1284 ', supplier_part_num: ' || gCurrentPrice.supplier_part_num ||
1285 ', internal_item_id: ' || gCurrentPrice.internal_item_id ||
1286 ', internal_item_num: ' || gCurrentPrice.internal_item_num ||
1287 ', inventory_organization_id: ' || gCurrentPrice.inventory_organization_id ||
1288 ', item_source_type: ' || gCurrentPrice.item_source_type ||
1289 ', item_search_type: ' || gCurrentPrice.item_search_type ||
1290 ', mtl_category_id: ' || gCurrentPrice.mtl_category_id ||
1291 ', category_key: ' || gCurrentPrice.category_key ||
1292 ', description: ' || gCurrentPrice.description ||
1293 ', picture: ' || gCurrentPrice.picture ||
1294 ', picture_url: ' || gCurrentPrice.picture_url ||
1295 ', price_type: ' || gCurrentPrice.price_type ||
1296 ', asl_id: ' || gCurrentPrice.asl_id ||
1297 ', supplier_site_id: ' || gCurrentPrice.supplier_site_id ||
1298 ', contract_id: ' || gCurrentPrice.contract_id ||
1299 ', contract_line_id: ' || gCurrentPrice.contract_line_id ||
1300 ', template_id: ' || gCurrentPrice.template_id ||
1301 ', template_line_id: ' || gCurrentPrice.template_line_id ||
1302 ', price_search_type: ' || gCurrentPrice.price_search_type ||
1303 ', unit_price: ' || gCurrentPrice.unit_price ||
1304 --FPJ FPSL Extractor Changes
1305 ', value_basis: ' || gCurrentPrice.value_basis ||
1306 ', purchase_basis: ' || gCurrentPrice.purchase_basis ||
1307 ', allow_price_override_flag: ' || gCurrentPrice.allow_price_override_flag ||
1308 ', not_to_exceed_price: ' || gCurrentPrice.not_to_exceed_price ||
1309 ', line_type_id: ' || gCurrentPrice.line_type_id ||
1310 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
1311 ', suggested_quantity: ' || gCurrentPrice.suggested_quantity ||
1312 -- FPJ Bug# 3110297 jingyu Add negotiated flag
1313 ', negotiated_by_preparer_flag: ' || gCurrentPrice.negotiated_by_preparer_flag ||
1314 ', currency: ' || gCurrentPrice.currency ||
1315 ', unit_of_measure: ' || gCurrentPrice.unit_of_measure ||
1316 ', functional_price: ' || gCurrentPrice.functional_price ||
1317 ', contract_num: ' || gCurrentPrice.contract_num ||
1318 ', contract_line_num: ' || gCurrentPrice.contract_line_num ||
1319 ', global_agreement_flag: ' || gCurrentPrice.global_agreement_flag ||
1320 ', status: ' || ICX_POR_EXT_DIAG.getStatusString(gCurrentPrice.status) ||
1321 ', primary_category_id: ' || gCurrentPrice.primary_category_id ||
1322 ', primary_category_name: ' || gCurrentPrice.primary_category_name ||
1323 ', template_category_id: ' || gCurrentPrice.template_category_id ||
1324 ', price_rt_item_id: ' || gCurrentPrice.price_rt_item_id ||
1325 ', price_internal_item_id: ' || gCurrentPrice.price_internal_item_id ||
1326 ', price_supplier_id: ' || gCurrentPrice.price_supplier_id ||
1327 ', price_supplier_part_num: ' || gCurrentPrice.price_supplier_part_num ||
1328 ', price_contract_line_id: ' || gCurrentPrice.price_contract_line_id ||
1329 ', price_mtl_category_id: ' || gCurrentPrice.price_mtl_category_id ||
1330 ', match_primary_category_id: '||gCurrentPrice.match_primary_category_id||
1331 ', rt_item_id: ' || gCurrentPrice.rt_item_id ||
1332 ', local_rt_item_id: ' || gCurrentPrice.local_rt_item_id ||
1333 ', match_template_flag: ' || gCurrentPrice.match_template_flag ||
1334 ', active_flag: ' || gCurrentPrice.active_flag ||
1335 ', price_rowid: ' || gCurrentPrice.price_rowid || ']';
1336
1337 RETURN xShot;
1338 END snapShotPriceRow;
1339
1340 FUNCTION getPriceReport RETURN VARCHAR2
1341 IS
1342 BEGIN
1343 RETURN ICX_POR_EXT_DIAG.getPriceReport(
1344 gCurrentPrice.document_type,
1345 gCurrentPrice.org_id,
1346 gCurrentPrice.inventory_organization_id,
1347 gCurrentPrice.status,
1348 gCurrentPrice.contract_num,
1349 gCurrentPrice.internal_item_num,
1350 gCurrentPrice.description,
1351 gCurrentPrice.supplier_site_code,
1352 gCurrentPrice.template_id,
1353 gCurrentPrice.supplier,
1354 gCurrentPrice.supplier_part_num);
1355 END getPriceReport;
1356
1357 --------------------------------------------------------------
1358 -- Functions to get active flag, description, else --
1359 --------------------------------------------------------------
1360 FUNCTION getActiveFlag(p_price_type IN VARCHAR2,
1361 p_price_row_id IN ROWID)
1362 RETURN VARCHAR2
1363 IS
1364 xActiveFlag VARCHAR2(1) := 'N';
1365 BEGIN
1366 IF p_price_type = 'PURCHASING_ITEM' THEN
1367 SELECT 'N'
1368 INTO xActiveFlag
1369 FROM icx_cat_item_prices p
1370 WHERE p.rowid = p_price_row_id
1371 AND EXISTS (SELECT 'documents'
1372 FROM icx_cat_item_prices p2
1373 WHERE p.org_id = p2.org_id
1374 AND p.inventory_item_id = p2.inventory_item_id
1375 AND p2.price_type IN ('TEMPLATE', 'BLANKET',
1376 'QUOTATION', 'GLOBAL_AGREEMENT',
1377 'ASL', 'BULKLOAD', 'CONTRACT'));
1378 ELSIF p_price_type = 'ASL' THEN
1379 SELECT 'N'
1380 INTO xActiveFlag
1381 FROM icx_cat_item_prices p
1382 WHERE p.rowid = p_price_row_id
1383 AND (EXISTS (SELECT 'documents'
1384 FROM icx_cat_item_prices p2
1385 WHERE p.rt_item_id = p2.rt_item_id
1386 AND p2.price_type IN ('TEMPLATE', 'BLANKET',
1387 'QUOTATION', 'BULKLOAD',
1388 'CONTRACT')) OR
1389 EXISTS (SELECT 'global agreements'
1390 FROM icx_cat_item_prices p2
1391 WHERE p.rt_item_id = p2.local_rt_item_id
1392 AND p2.price_type = 'GLOBAL_AGREEMENT'));
1393 ELSIF p_price_type IN ('BULKLOAD', 'CONTRACT') THEN
1394 SELECT 'N'
1395 INTO xActiveFlag
1396 FROM icx_cat_item_prices p
1397 WHERE p.rowid = p_price_row_id
1398 AND (EXISTS (SELECT 'documents'
1399 FROM icx_cat_item_prices p2
1400 WHERE p.rt_item_id = p2.rt_item_id
1401 AND p2.price_type IN ('TEMPLATE', 'BLANKET',
1402 'QUOTATION')) OR
1403 EXISTS (SELECT 'global agreements'
1404 FROM icx_cat_item_prices p2
1405 WHERE p.rt_item_id = p2.local_rt_item_id
1406 AND p2.price_type = 'GLOBAL_AGREEMENT'));
1407 ELSIF p_price_type = 'TEMPLATE' THEN
1408 SELECT 'N'
1409 INTO xActiveFlag
1410 FROM icx_cat_item_prices p
1411 WHERE p.rowid = p_price_row_id
1412 AND ((p.contract_line_id <> -2 AND
1413 EXISTS (SELECT 'recently updated templates with same contract'
1414 FROM icx_cat_item_prices p2
1415 WHERE p.rt_item_id = p2.rt_item_id
1416 AND p.contract_line_id = p2.contract_line_id
1417 AND p.supplier_site_id = p2.supplier_site_id
1418 AND p2.price_type = 'TEMPLATE'
1419 AND p2.rowid <> p.rowid
1420 AND ((p2.last_update_date > p.last_update_date) OR
1421 (p2.last_update_date = p.last_update_date AND
1422 EXISTS (SELECT 'exists'
1423 FROM po_reqexpress_lines_all r1,
1424 po_reqexpress_lines_all r2
1425 WHERE r2.express_name = p2.template_id
1426 AND r2.sequence_num = p2. template_line_id
1427 AND nvl(r2.org_id, -2) = p2.org_id
1428 AND r1.express_name = p.template_id
1429 AND r1.sequence_num = p. template_line_id
1430 AND nvl(r1.org_id, -2) = p.org_id
1431 AND r2.last_update_date > r1.last_update_date))))) OR
1432 (p.contract_line_id = -2 AND
1433 (EXISTS (SELECT 'contracts'
1434 FROM icx_cat_item_prices p2
1435 WHERE p.rt_item_id = p2.rt_item_id
1436 AND p2.contract_line_id <> -2) OR
1437 EXISTS (SELECT 'recently updated templates'
1438 FROM icx_cat_item_prices p2
1439 WHERE p.rt_item_id = p2.rt_item_id
1440 AND p2.contract_line_id = -2
1441 AND p.supplier_site_id = p2.supplier_site_id
1442 AND p2.price_type = 'TEMPLATE'
1443 AND p2.rowid <> p.rowid
1444 AND ((p2.last_update_date > p.last_update_date) OR
1445 (p2.last_update_date = p.last_update_date AND
1446 EXISTS (SELECT 'exists'
1447 FROM po_reqexpress_lines_all r1,
1448 po_reqexpress_lines_all r2
1449 WHERE r2.express_name = p2.template_id
1450 AND r2.sequence_num = p2. template_line_id
1451 AND nvl(r2.org_id, -2) = p2.org_id
1452 AND r1.express_name = p.template_id
1453 AND r1.sequence_num = p. template_line_id
1454 AND nvl(r1.org_id, -2) = p.org_id
1455 AND r2.last_update_date > r1.last_update_date)))))) OR
1456 EXISTS (SELECT 'global agreements'
1457 FROM icx_cat_item_prices p2
1458 WHERE p.rt_item_id = p2.local_rt_item_id
1459 AND p2.price_type = 'GLOBAL_AGREEMENT'));
1460 ELSIF p_price_type IN ('BLANKET', 'QUOTATION') THEN
1461 SELECT 'N'
1462 INTO xActiveFlag
1463 FROM icx_cat_item_prices p
1464 WHERE p.rowid = p_price_row_id
1465 AND EXISTS (SELECT 'template with same contract'
1466 FROM icx_cat_item_prices p2
1467 WHERE p.rt_item_id = p2.rt_item_id
1468 AND p.contract_line_id = p2.contract_line_id
1469 AND p2.price_type = 'TEMPLATE');
1470 ELSIF p_price_type = 'INTERNAL_ITEM' THEN
1471 SELECT 'N'
1472 INTO xActiveFlag
1473 FROM icx_cat_item_prices p
1474 WHERE p.rowid = p_price_row_id
1475 AND EXISTS (SELECT 'internal templates'
1476 FROM icx_cat_item_prices p2
1477 WHERE p.rt_item_id = p2.rt_item_id
1478 AND p2.price_type = 'INTERNAL_TEMPLATE');
1479 ELSIF p_price_type = 'INTERNAL_TEMPLATE' THEN
1480 SELECT 'N'
1481 INTO xActiveFlag
1482 FROM icx_cat_item_prices p
1483 WHERE p.rowid = p_price_row_id
1484 AND EXISTS (SELECT 'recently updated internal templates'
1485 FROM icx_cat_item_prices p2
1486 WHERE p.rt_item_id = p2.rt_item_id
1487 AND p2.price_type = 'INTERNAL_TEMPLATE'
1488 AND p2.rowid <> p.rowid
1489 --Bug 4349235
1490 AND ((p2.last_update_date > p.last_update_date) OR
1491 (p2.last_update_date = p.last_update_date AND
1492 EXISTS (SELECT 'exists'
1493 FROM po_reqexpress_lines_all r1,
1494 po_reqexpress_lines_all r2
1495 WHERE r2.express_name = p2.template_id
1496 AND r2.sequence_num = p2. template_line_id
1497 AND nvl(r2.org_id, -2) = p2.org_id
1498 AND r1.express_name = p.template_id
1499 AND r1.sequence_num = p. template_line_id
1500 AND nvl(r1.org_id, -2) = p.org_id
1501 AND ((r2.last_update_date > r1.last_update_date)
1502 OR
1503 (r2.last_update_date = r1.last_update_date AND p2.rowid > p.rowid))))));
1504 --Bug 4349235-End
1505 ELSIF p_price_type = 'GLOBAL_AGREEMENT' THEN
1506 xActiveFlag := 'Y';
1507 END IF;
1508
1509 RETURN xActiveFlag;
1510 EXCEPTION
1511 WHEN NO_DATA_FOUND THEN
1512 RETURN 'Y';
1513 END getActiveFlag;
1514
1515 PROCEDURE setActivePriceItemAttributes
1516 IS
1517 xUPItemRtItemIds DBMS_SQL.NUMBER_TABLE;
1518 xUPItemDescriptions DBMS_SQL.VARCHAR2_TABLE;
1519 xUPItemPictures DBMS_SQL.VARCHAR2_TABLE;
1520 xUPItemPictureUrls DBMS_SQL.VARCHAR2_TABLE;
1521
1522 xErrLoc PLS_INTEGER := 100;
1523 xString VARCHAR2(4000) := NULL;
1524 xTestMode VARCHAR2(1);
1525 cActivePriceItemAttributes TCursorType;
1526
1527 xDBVersion NUMBER := ICX_POR_EXT_UTL.getDatabaseVersion;
1528
1529 BEGIN
1530
1531 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
1532 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
1533 'Enter setActivePriceItemAttributes()');
1534 END IF;
1535 xTestMode := ICX_POR_EXT_TEST.gTestMode;
1536 xErrLoc := 100;
1537 xString :=
1538 'SELECT p.rt_item_id, t.item_description, ' ||
1539 ' null, null ' ;
1540 IF (xTestMode = 'Y') THEN
1541 xString := xString ||
1542 'FROM ipo_reqexpress_lines_all t, ' ;
1543 ELSE
1544 xString := xString ||
1545 'FROM po_reqexpress_lines_all t, ' ;
1546 END IF;
1547 xString := xString ||
1548 ' icx_cat_item_prices p, ' ||
1549 ' icx_cat_extract_gt i ' ||
1550 'WHERE NVL(t.org_id, -2) = p.org_id ' ||
1551 ' AND t.express_name = p.template_id ' ||
1552 ' AND t.sequence_num = p.template_line_id ' ||
1553 ' AND i.type = ''ACTIVE_FLAG'' ' ||
1554 ' AND p.active_flag = ''Y'' ' ||
1555 ' AND p.rt_item_id = i.rt_item_id ' ||
1556 ' AND p.price_type IN (''TEMPLATE'', ''INTERNAL_TEMPLATE'') ' ||
1557 'UNION ALL ' ||
1558 'SELECT p.rt_item_id, t.item_description, ' ||
1559 ' NVL(t.attribute13, t.attribute14), t.Attribute14 ' ;
1560 IF (xTestMode = 'Y') THEN
1561 xString := xString ||
1562 'FROM ipo_lines_all t, ' ;
1563 ELSE
1564 xString := xString ||
1565 'FROM po_lines_all t, ' ;
1566 END IF;
1567 xString := xString ||
1568 ' icx_cat_item_prices p, ' ||
1569 ' icx_cat_extract_gt i ' ||
1570 'WHERE NVL(t.org_id, -2) = p.org_id ' ||
1571 ' AND t.po_line_id = p.contract_line_id ' ||
1572 ' AND i.type = ''ACTIVE_FLAG'' ' ||
1573 ' AND p.active_flag = ''Y'' ' ||
1574 ' AND p.rt_item_id = i.rt_item_id ' ||
1575 ' AND p.price_type IN (''BLANKET'', ''GLOBAL_AGREEMENT'', ''QUOTATION'') ' ||
1576 'UNION ALL ' ||
1577 'SELECT p.rt_item_id, mitl.description, ' ||
1578 ' null, null ' ;
1579 IF (xTestMode = 'Y') THEN
1580 xString := xString ||
1581 'FROM ipo_approved_supplier_list t, ' ||
1582 ' imtl_system_items_tl mitl, ' ||
1583 ' ifinancials_system_params_all fsp, ' ;
1584 ELSE
1585 xString := xString ||
1586 'FROM po_approved_supplier_list t, ' ||
1587 ' mtl_system_items_tl mitl, ' ||
1588 ' financials_system_params_all fsp, ' ;
1589 END IF;
1590 xString := xString ||
1591 ' fnd_languages lang, ' ||
1592 ' icx_cat_item_prices p, ' ||
1593 ' icx_cat_extract_gt i ' ||
1594 'WHERE NVL(fsp.org_id, -2) = p.org_id ' ||
1595 ' AND t.asl_id = p.asl_id ' ||
1596 ' AND t.owning_organization_id = fsp.inventory_organization_id ' ||
1597 ' AND t.item_id = mitl.inventory_item_id ' ||
1598 ' AND t.owning_organization_id = mitl.organization_id ' ||
1599 ' AND mitl.language = lang.language_code ' ||
1600 ' AND lang.installed_flag = ''B'' ' ||
1601 ' AND i.type = ''ACTIVE_FLAG'' ' ||
1602 ' AND p.active_flag = ''Y'' ' ||
1603 ' AND p.rt_item_id = i.rt_item_id ' ||
1604 ' AND p.price_type = ''ASL'' ' ||
1605 'UNION ALL ' ||
1606 'SELECT p.rt_item_id, t.description, ' ||
1607 ' null, null ' ;
1608 IF (xTestMode = 'Y') THEN
1609 xString := xString ||
1610 'FROM imtl_system_items_tl t, ' ||
1611 ' ifinancials_system_params_all fsp, ' ;
1612 ELSE
1613 xString := xString ||
1614 'FROM mtl_system_items_tl t, ' ||
1615 ' financials_system_params_all fsp, ' ;
1616 END IF;
1617 xString := xString ||
1618 ' fnd_languages lang, ' ||
1619 ' icx_cat_item_prices p, ' ||
1620 ' icx_cat_extract_gt i ' ||
1621 'WHERE NVL(fsp.org_id, -2) = p.org_id ' ||
1622 ' AND t.inventory_item_id = p.inventory_item_id ' ||
1623 ' AND t.organization_id = fsp.inventory_organization_id ' ||
1624 ' AND t.language = lang.language_code ' ||
1625 ' AND lang.installed_flag = ''B'' ' ||
1626 ' AND i.type = ''ACTIVE_FLAG'' ' ||
1627 ' AND p.active_flag = ''Y'' ' ||
1628 ' AND p.rt_item_id = i.rt_item_id ' ||
1629 ' AND p.price_type IN (''PURCHASING_ITEM'', ''INTERNAL_ITEM'') ';
1630
1631 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
1632 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
1633 'SQL Stmt for cActivePriceItemAttributes: '|| xString);
1634 END IF;
1635
1636 OPEN cActivePriceItemAttributes FOR xString;
1637
1638 LOOP
1639
1640 IF (xDBVersion < 9.0) THEN
1641 xErrLoc := 150;
1642 EXIT WHEN cActivePriceItemAttributes%NOTFOUND;
1643 -- Oracle 8i doesn't support BULK Collect from dynamic SQL
1644 xErrLoc := 151;
1645 FOR i IN 1..ICX_POR_EXT_UTL.gCommitSize LOOP
1646 FETCH cActivePriceItemAttributes INTO
1647 xUPItemRtItemIds(i),
1648 xUPItemDescriptions(i),
1649 xUPItemPictures(i),
1650 xUPItemPictureUrls(i);
1651 EXIT WHEN cActivePriceItemAttributes%NOTFOUND;
1652 END LOOP;
1653 ELSE
1654 xErrLoc := 200;
1655 FETCH cActivePriceItemAttributes
1656 BULK COLLECT INTO
1657 xUPItemRtItemIds, xUPItemDescriptions,
1658 xUPItemPictures, xUPItemPictureUrls
1659 LIMIT ICX_POR_EXT_UTL.gCommitSize;
1660 EXIT WHEN xUPItemRtItemIds.COUNT = 0;
1661 END IF;
1662
1663 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
1664 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
1665 'Count of RtItemIds, Descriptions, Pictures and PictureUrls:'
1666 ||to_char(xUPItemRtItemIds.COUNT) ||', '
1667 ||to_char(xUPItemDescriptions.COUNT) ||', '
1668 ||to_char(xUPItemPictures.COUNT) ||', '
1669 ||to_char(xUPItemPictureUrls.COUNT) ||', ');
1670 END IF;
1671
1672 xErrLoc := 300;
1673 IF gExtractImageDet = 'Y' THEN
1674 FORALL i IN 1..xUPItemRtItemIds.COUNT
1675 UPDATE icx_cat_items_tlp
1676 SET description = xUPItemDescriptions(i),
1677 picture = xUPItemPictures(i),
1678 picture_url = xUPItemPictureUrls(i),
1679 thumbnail_image = xUPItemPictures(i),
1680 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
1681 last_update_date = SYSDATE,
1682 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
1683 request_id = ICX_POR_EXTRACTOR.gRequestId,
1684 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
1685 program_id = ICX_POR_EXTRACTOR.gProgramId,
1686 program_update_date = SYSDATE
1687 WHERE rt_item_id = xUPItemRtItemIds(i)
1688 AND language = ICX_POR_EXTRACTOR.gBaseLang;
1689
1690 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
1691 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
1692 'gExtractImageDet:'||gExtractImageDet ||
1693 ', sql%rowcount:' ||to_char(sql%rowcount));
1694 END IF;
1695 ELSE
1696 FORALL i IN 1..xUPItemRtItemIds.COUNT
1697 UPDATE icx_cat_items_tlp
1698 SET description = xUPItemDescriptions(i),
1699 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
1700 last_update_date = SYSDATE,
1701 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
1702 request_id = ICX_POR_EXTRACTOR.gRequestId,
1703 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
1704 program_id = ICX_POR_EXTRACTOR.gProgramId,
1705 program_update_date = SYSDATE
1706 WHERE rt_item_id = xUPItemRtItemIds(i)
1707 AND language = ICX_POR_EXTRACTOR.gBaseLang;
1708
1709 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
1710 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
1711 'gExtractImageDet:'||gExtractImageDet ||
1712 ', sql%rowcount:' ||to_char(sql%rowcount));
1713 END IF;
1714 END IF;
1715
1716 ICX_POR_EXT_UTL.extAFCommit;
1717 END LOOP;
1718
1719 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
1720 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
1721 'Done setActivePriceItemAttributes()');
1722 END IF;
1723 EXCEPTION
1724 when others then
1725 ICX_POR_EXT_UTL.extRollback;
1726 IF (cActivePriceItemAttributes%ISOPEN) THEN
1727 CLOSE cActivePriceItemAttributes;
1728 END IF;
1729 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.setActivePriceItemAttributes -'||
1730 xErrLoc||' '||SQLERRM);
1731
1732 raise ICX_POR_EXT_UTL.gException;
1733
1734 END setActivePriceItemAttributes;
1735
1736
1737 FUNCTION getItemActiveFlag(p_inventory_item_id IN NUMBER,
1738 p_org_id IN NUMBER)
1739 RETURN VARCHAR2
1740 IS
1741 xActiveFlag VARCHAR2(1) := 'N';
1742 BEGIN
1743 SELECT 'N'
1744 INTO xActiveFlag
1745 FROM dual
1746 WHERE EXISTS (SELECT 'documents'
1747 FROM icx_cat_item_prices p
1748 WHERE p.org_id = p_org_id
1749 AND p.inventory_item_id = p_inventory_item_id
1750 AND p.price_type IN ('TEMPLATE', 'BLANKET',
1751 'QUOTATION', 'GLOBAL_AGREEMENT',
1752 'ASL', 'BULKLOAD'));
1753
1754 RETURN xActiveFlag;
1755 EXCEPTION
1756 WHEN NO_DATA_FOUND THEN
1757 RETURN 'Y';
1758 END getItemActiveFlag;
1759
1760 FUNCTION getItemSourceType(p_price_type IN VARCHAR2,
1761 p_inventory_item_id IN NUMBER,
1762 p_purchasing_enabled_flag IN VARCHAR2,
1763 p_outside_operation_flag IN VARCHAR2,
1764 p_list_price_per_unit IN NUMBER,
1765 p_load_master_item IN VARCHAR2,
1766 p_internal_order_enabled_flag IN VARCHAR2,
1767 p_load_internal_item IN VARCHAR2)
1768 RETURN VARCHAR2
1769 IS
1770 xItemSourceType VARCHAR2(20) := 'SUPPLIER';
1771 BEGIN
1772 IF p_inventory_item_id IS NULL THEN
1773 xItemSourceType := 'SUPPLIER';
1774 ELSIF p_price_type IN ('TEMPLATE', 'CONTRACT', 'ASL', 'PURCHASING_ITEM') THEN
1775 IF (p_load_internal_item = 'Y' AND
1776 p_internal_order_enabled_flag = 'Y')
1777 THEN
1778 xItemSourceType := 'BOTH';
1779 ELSE
1780 xItemSourceType := 'SUPPLIER';
1781 END IF;
1782 ELSIF p_price_type IN ('INTERNAL_TEMPLATE', 'INTERNAL_ITEM') THEN
1783 IF (p_load_master_item = 'Y' AND
1784 p_purchasing_enabled_flag = 'Y' AND
1785 NVL(p_outside_operation_flag, 'N') <> 'Y' AND
1786 p_list_price_per_unit IS NOT NULL)
1787 THEN
1788 xItemSourceType := 'BOTH';
1789 ELSE
1790 xItemSourceType := 'INTERNAL';
1791 END IF;
1792 END IF;
1793
1794 RETURN xItemSourceType;
1795 END getItemSourceType;
1796
1797 FUNCTION getSearchType(p_price_type IN VARCHAR2,
1798 p_inventory_item_id IN NUMBER,
1799 p_purchasing_enabled_flag IN VARCHAR2,
1800 p_outside_operation_flag IN VARCHAR2,
1801 p_list_price_per_unit IN NUMBER,
1802 p_load_master_item IN VARCHAR2,
1803 p_internal_order_enabled_flag IN VARCHAR2,
1804 p_load_internal_item IN VARCHAR2)
1805 RETURN VARCHAR2
1806 IS
1807 xSearchType VARCHAR2(20) := 'SUPPLIER';
1808 BEGIN
1809 IF p_inventory_item_id IS NULL THEN
1810 xSearchType := 'SUPPLIER';
1811 ELSIF p_price_type IN ('TEMPLATE', 'CONTRACT', 'ASL', 'PURCHASING_ITEM') THEN
1812 xSearchType := 'SUPPLIER';
1813 ELSIF p_price_type IN ('INTERNAL_TEMPLATE', 'INTERNAL_ITEM') THEN
1814 IF (p_load_master_item = 'Y' AND
1815 p_purchasing_enabled_flag = 'Y' AND
1816 NVL(p_outside_operation_flag, 'N') <> 'Y' AND
1817 p_list_price_per_unit IS NOT NULL)
1818 THEN
1819 xSearchType := 'SUPPLIER';
1820 ELSE
1821 xSearchType := 'INTERNAL';
1822 END IF;
1823 END IF;
1824
1825 RETURN xSearchType;
1826 END getSearchType;
1827
1828 FUNCTION getMatchTempalteFlag(p_price_type IN VARCHAR2,
1829 p_rt_item_id IN NUMBER,
1830 p_template_id IN VARCHAR2)
1831 RETURN VARCHAR2
1832 IS
1833 xMatchTempalteFlag VARCHAR2(1) := 'Y';
1834 BEGIN
1835 IF p_price_type IN ('TEMPLATE', 'INTERNAL_TEMPLATE') THEN
1836 SELECT 'Y'
1837 INTO xMatchTempalteFlag
1838 FROM icx_cat_item_prices
1839 WHERE rt_item_id = p_rt_item_id
1840 AND template_id = p_template_id
1841 AND rownum = 1;
1842 ELSE
1843 xMatchTempalteFlag := 'Y';
1844 END IF;
1845
1846 RETURN xMatchTempalteFlag;
1847 EXCEPTION
1848 WHEN NO_DATA_FOUND THEN
1849 RETURN 'N';
1850 END getMatchTempalteFlag;
1851
1852 -- This function is only used by bulk loader code
1853 -- It returns 'Y' -- Active
1854 -- 'N' -- Inactive
1855 -- 'A' -- ASL price should be reset
1856 FUNCTION getBulkLoadActiveFlag(p_action IN VARCHAR2,
1857 p_rt_item_id IN NUMBER)
1858 RETURN VARCHAR2
1859 IS
1860 xActiveFlag VARCHAR2(1) := 'N';
1861 xPriceType icx_cat_item_prices.price_type%TYPE;
1862 BEGIN
1863 IF p_action = 'DELETE' THEN
1864 -- If an active bulkload price is deleted, should set
1865 -- ASL back to active
1866 SELECT 'A'
1867 INTO xActiveFlag
1868 FROM dual
1869 WHERE EXISTS (SELECT 'ASL prices'
1870 FROM icx_cat_item_prices
1871 WHERE rt_item_id = p_rt_item_id
1872 AND price_type = 'ASL')
1873 AND NOT EXISTS (SELECT 'Contract/template prices'
1874 FROM icx_cat_item_prices
1875 WHERE rt_item_id = p_rt_item_id
1876 AND price_type IN ('TEMPLATE', 'BLANKET',
1877 'QUOTATION',
1878 'GLOBAL_AGREEMENT'));
1879 ELSE
1880 SELECT price_type
1881 INTO xPriceType
1882 FROM icx_cat_item_prices p
1883 WHERE p.active_flag = 'Y'
1884 AND (p.rt_item_id = p_rt_item_id OR
1885 (p.local_rt_item_id = p_rt_item_id AND
1886 p.price_type = 'GLOBAL_AGREEMENT'))
1887 AND rownum = 1;
1888
1889 IF xPriceType IN ('TEMPLATE', 'BLANKET',
1890 'QUOTATION', 'GLOBAL_AGREEMENT')
1891 THEN
1892 xActiveFlag := 'N';
1893 ELSIF xPriceType = 'ASL' THEN
1894 xActiveFlag := 'A';
1895 ELSE
1896 xActiveFlag := 'Y';
1897 END IF;
1898 END IF;
1899
1900 RETURN xActiveFlag;
1901 EXCEPTION
1902 WHEN NO_DATA_FOUND THEN
1903 RETURN 'Y';
1904 END getBulkLoadActiveFlag;
1905
1906 --------------------------------------------------------------
1907 -- Process Caching Data --
1908 --------------------------------------------------------------
1909 PROCEDURE clearCache IS
1910 BEGIN
1911 gItemCache.DELETE;
1912 END clearCache;
1913
1914 PROCEDURE setHashRange(pHashBase IN NUMBER,
1915 pHashSize IN NUMBER) IS
1916 xErrLoc PLS_INTEGER := 100;
1917 BEGIN
1918 xErrLoc := 100;
1919 clearCache;
1920 gHashBase := pHashBase;
1921 gHashSize := pHashSize;
1922 END setHashRange;
1923
1924 PROCEDURE initCaches IS
1925 xErrLoc PLS_INTEGER := 100;
1926 xHashSize PLS_INTEGER;
1927 BEGIN
1928 xErrLoc := 100;
1929 -- Caculate hash size based on gCommitSize, but at least 1024
1930 -- A power of 2 for the hash_size parameter is best
1931 xHashSize := GREATEST(POWER(2,ROUND(LOG(2,ICX_POR_EXT_UTL.gCommitSize*10))),
1932 POWER(2, 10));
1933 xErrLoc := 200;
1934 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
1935 'Cache hash size is ' || xHashSize);
1936 setHashRange(1, xHashSize);
1937 END initCaches;
1938
1939 -- A hash value based on the input string. For example,
1940 -- to get a hash value on a string where the hash value
1941 -- should be between 1000 and 3047, use 1000 as the base
1942 -- value and 2048 as the hash_size value. Using a power
1943 -- of 2 for the hash_size parameter works best.
1944 FUNCTION getHashValue(pHashString IN VARCHAR2)
1945 RETURN NUMBER
1946 IS
1947 xErrLoc PLS_INTEGER := 100;
1948 BEGIN
1949 xErrLoc := 100;
1950 RETURN DBMS_UTILITY.get_hash_value(pHashString,
1951 gHashBase,
1952 gHashSize);
1953 END getHashValue;
1954
1955 FUNCTION findItemCache(pItem IN OUT NOCOPY tItemRecord)
1956 RETURN BOOLEAN
1957 IS
1958 xErrLoc PLS_INTEGER := 100;
1959 xHashString VARCHAR2(2000);
1960 xHashValue PLS_INTEGER;
1961 xItem tItemRecord;
1962 BEGIN
1963 xErrLoc := 100;
1964 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
1965 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
1966 'Enter findItemCache()');
1967 END IF;
1968
1969 IF pItem.hash_value > NULL_NUMBER THEN
1970 RETURN TRUE;
1971 END IF;
1972
1973 -- One-time item with null supplier or spn, only template can have
1974 -- this situation. We always return false.
1975 -- pcreddy : Bug # 3213218
1976 IF (pItem.internal_item_id = NULL_NUMBER AND
1977 (pItem.supplier_id = NULL_NUMBER OR
1978 pItem.supplier_part_num = TO_CHAR(NULL_NUMBER)))
1979 THEN
1980 pItem.hash_value := NULL_NUMBER;
1981 RETURN FALSE;
1982 END IF;
1983
1984 xHashString := pItem.org_id || pItem.internal_item_num ||
1985 pItem.supplier || pItem.supplier_part_num ||
1986 pItem.contract_line_id;
1987
1988 xErrLoc := 200;
1989 xHashValue := getHashValue(xHashString);
1990
1991 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
1992 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
1993 'Hash value for ' || xHashString || ' is: ' || xHashValue);
1994 END IF;
1995
1996 xErrLoc := 300;
1997 WHILE (TRUE) LOOP
1998 -- It is impossible to have cache full, so we don't need
1999 -- to worry about caching replacement
2000 IF gItemCache.EXISTS(xHashValue) THEN
2001 xItem := gItemCache(xHashValue);
2002 xErrLoc := 320;
2003 -- All NULL value is replace by NULL_NUMBER
2004 IF (xItem.org_id = pItem.org_id AND
2005 xItem.internal_item_id = pItem.internal_item_id AND
2006 xItem.supplier_id = pItem.supplier_id AND
2007 xItem.supplier_part_num = pItem.supplier_part_num AND
2008 xItem.contract_line_id = pItem.contract_line_id)
2009 THEN
2010 pItem.rt_item_id := xItem.rt_item_id;
2011 pItem.hash_value := xItem.hash_value;
2012 RETURN TRUE;
2013 ELSE
2014 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.INFO_LEVEL THEN
2015 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.INFO_LEVEL,
2016 'Hash collision-' || xHashValue || '-: [' ||
2017 xHashString || '] ' || snapShotItemRecord(xItem));
2018 END IF;
2019 xHashValue := xHashValue + 1;
2020 END IF;
2021 ELSE
2022 pItem.hash_value := xHashValue;
2023 RETURN FALSE;
2024 END IF;
2025 END LOOP;
2026
2027 RETURN FALSE;
2028 EXCEPTION
2029 when others then
2030 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.findItemCache-'||
2031 xErrLoc||' '||SQLERRM);
2032 raise ICX_POR_EXT_UTL.gException;
2033 END findItemCache;
2034
2035 PROCEDURE putItemCache(pItem IN tItemRecord) IS
2036 xErrLoc PLS_INTEGER := 100;
2037 BEGIN
2038 xErrLoc := 100;
2039 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
2040 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2041 'Enter putItemCache()');
2042 END IF;
2043
2044 IF (pItem.hash_value = NULL_NUMBER OR
2045 pItem.rt_item_id = NULL_NUMBER)
2046 THEN
2047 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.ERROR_LEVEL,
2048 'Should not cache item without caculating hash value and ' ||
2049 'assigning rt_item_id');
2050 RETURN;
2051 END IF;
2052
2053 xErrLoc := 200;
2054 gItemCache(pItem.hash_value) := pItem;
2055 EXCEPTION
2056 when others then
2057 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.putItemCache-'||
2058 xErrLoc||' '||SQLERRM);
2059 raise ICX_POR_EXT_UTL.gException;
2060 END putItemCache;
2061
2062 --------------------------------------------------------------
2063 -- Process Batch Data --
2064 --------------------------------------------------------------
2065 -- Process batch data
2066 PROCEDURE processBatchData(pMode IN VARCHAR2) IS
2067 xErrLoc PLS_INTEGER := 100;
2068 xActionMode VARCHAR2(80);
2069 xContinue BOOLEAN := TRUE;
2070 xRtItemIds DBMS_SQL.NUMBER_TABLE;
2071 BEGIN
2072 xErrLoc := 100;
2073 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
2074 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2075 'Enter processBatchData(' || pMode || ')-gTransactionCount: ' ||
2076 gTransactionCount);
2077 END IF;
2078
2079 IF (pMode = 'OUTLOOP' OR
2080 gTransactionCount >= ICX_POR_EXT_UTL.gCommitSize)
2081 THEN
2082 xErrLoc := 200;
2083 gTransactionCount := 0;
2084
2085 xActionMode := 'UPDATE_PRICES';
2086 -- Update ICX_CAT_ITEM_PRICES
2087 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2088 FOR i in 1..gUPRtItemIds.COUNT LOOP
2089 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2090 snapShot(i, xActionMode));
2091 END LOOP;
2092 END IF;
2093 FORALL i IN 1..gUPRtItemIds.COUNT
2094 UPDATE icx_cat_item_prices
2095 SET rt_item_id = gUPRtItemIds(i),
2096 price_type = gUPPriceTypes(i),
2097 active_flag = gUPActiveFlags(i),
2098 object_version_number = object_version_number + 1,
2099 asl_id = gUPAslIds(i),
2100 supplier_site_id = gUPSupplierSiteIds(i),
2101 contract_id = gUPContractIds(i),
2102 contract_line_id = gUPContractLineIds(i),
2103 template_id = gUPTemplateIds(i),
2104 template_line_id = gUPTemplateLineIds(i),
2105 inventory_item_id = gUPInventoryItemIds(i),
2106 mtl_category_id = gUPMtlCategoryIds(i),
2107 org_id = gUPOrgIds(i),
2108 search_type = gUPSearchTypes(i),
2109 unit_price = gUPUnitPrices(i),
2110 --FPJ FPSL Extractor Changes
2111 value_basis = gUPValueBasis(i),
2112 purchase_basis = gUPPurchaseBasis(i),
2113 allow_price_override_flag = gUPAllowPriceOverrideFlag(i),
2114 not_to_exceed_price = gUPNotToExceedPrice(i),
2115 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
2116 suggested_quantity = gUPSuggestedQuantities(i),
2117 -- FPJ Bug# 3110297 jingyu Add negotiated flag
2118 negotiated_by_preparer_flag = gUPNegotiatedFlag(i),
2119 currency = gUPCurrencys(i),
2120 unit_of_measure = gUPUnitOfMeasures(i),
2121 functional_price = gUPFunctionalPrices(i),
2122 supplier_site_code = gUPSupplierSiteCodes(i),
2123 contract_num = gUPContractNums(i),
2124 contract_line_num = gUPContractLineNums(i),
2125 rate_type = gUpRateTypes(i),
2126 rate_date = gUpRateDates(i),
2127 rate = gUpRates(i),
2128 supplier_number = gUpSupplierNumbers(i),
2129 supplier_contact_id = gUpSupplierContactIds(i),
2130 item_revision = gUpItemRevisions(i),
2131 line_type_id = gUpLineTypeIds(i),
2132 buyer_id = gUpBuyerIds(i),
2133 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
2134 last_update_date = gUPLastUpdateDates(i),
2135 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
2136 -- Bug#3352834
2137 request_id = ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID,
2138 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
2139 program_id = ICX_POR_EXTRACTOR.gProgramId,
2140 program_update_date = SYSDATE
2141 WHERE rowid = gUPPriceRowIds(i);
2142
2143 clearTables(xActionMode);
2144
2145 xErrLoc := 210;
2146 xActionMode := 'UPDATE_PRICES_G';
2147 -- Update ICX_CAT_ITEM_PRICES for global agreements
2148 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2149 FOR i in 1..gUPGRtItemIds.COUNT LOOP
2150 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2151 snapShot(i, xActionMode));
2152 END LOOP;
2153 END IF;
2154 FORALL i IN 1..gUPGRtItemIds.COUNT
2155 UPDATE icx_cat_item_prices
2156 SET rt_item_id = gUPGRtItemIds(i),
2157 object_version_number = object_version_number + 1,
2158 inventory_item_id = gUPGInventoryItemIds(i),
2159 mtl_category_id = gUPGMtlCategoryIds(i),
2160 search_type = gUPGSearchTypes(i),
2161 unit_price = gUPGUnitPrices(i),
2162 --FPJ FPSL Extractor Changes
2163 value_basis = gUPGValueBasis(i),
2164 purchase_basis = gUPGPurchaseBasis(i),
2165 allow_price_override_flag = gUPGAllowPriceOverrideFlag(i),
2166 not_to_exceed_price = gUPGNotToExceedPrice(i),
2167 -- FPJ Bug# 3110297 jingyu Add negotiated flag
2168 negotiated_by_preparer_flag = gUPGNegotiatedFlag(i),
2169 line_type_id = gUPGLineTypeIds(i),
2170 currency = gUPGCurrencys(i),
2171 unit_of_measure = gUPGUnitOfMeasures(i),
2172 functional_price = gUPGFunctionalPrices(i),
2173 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
2174 last_update_date = SYSDATE,
2175 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
2176 -- Bug#3352834
2177 request_id = ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID,
2178 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
2179 program_id = ICX_POR_EXTRACTOR.gProgramId,
2180 program_update_date = SYSDATE
2181 WHERE contract_id = gUPGContractIds(i)
2182 AND contract_line_id = gUPGContractLineIds(i)
2183 AND price_type = 'GLOBAL_AGREEMENT';
2184
2185 clearTables(xActionMode);
2186
2187 xErrLoc := 220;
2188 xActionMode := 'INSERT_PRICES';
2189 -- Insert ICX_CAT_ITEM_PRICES
2190 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2191 FOR i in 1..gIPRtItemIds.COUNT LOOP
2192 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2193 snapShot(i, xActionMode));
2194 END LOOP;
2195 END IF;
2196 FORALL i IN 1..gIPRtItemIds.COUNT
2197 INSERT INTO icx_cat_item_prices
2198 (rt_item_id, price_type,
2199 active_flag, object_version_number,
2200 asl_id, supplier_site_id,
2201 contract_id, contract_line_id,
2202 template_id, template_line_id,
2203 inventory_item_id, mtl_category_id,
2204 org_id, search_type, unit_price,
2205 --FPJ FPSL Extractor Changes
2206 value_basis, purchase_basis,
2207 allow_price_override_flag, not_to_exceed_price,
2208 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
2209 suggested_quantity,
2210 -- FPJ Bug# 3110297 jingyu Add negotiated flag
2211 negotiated_by_preparer_flag,
2212 currency, unit_of_measure,
2213 functional_price, supplier_site_code,
2214 contract_num, contract_line_num,
2215 rate_type, rate_date, rate,
2216 supplier_number, supplier_contact_id,
2217 item_revision, line_type_id, buyer_id,
2218 price_list_id, last_update_login,
2219 last_updated_by, last_update_date,
2220 created_by, creation_date, request_id,
2221 program_application_id, program_id, program_update_date)
2222 VALUES
2223 (gIPRtItemIds(i), gIPPriceTypes(i),
2224 gIPActiveFlags(i), 1,
2225 gIPAslIds(i), gIPSupplierSiteIds(i),
2226 gIPContractIds(i), gIPContractLineIds(i),
2227 gIPTemplateIds(i), gIPTemplateLineIds(i),
2228 gIPInventoryItemIds(i), gIPMtlCategoryIds(i),
2229 gIPOrgIds(i), gIPSearchTypes(i), gIPUnitPrices(i),
2230 --FPJ FPSL Extractor Changes
2231 gIPValueBasis(i), gIPPurchaseBasis(i),
2232 gIPAllowPriceOverrideFlag(i), gIPNotToExceedPrice(i),
2233 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
2234 gIPSuggestedQuantities(i),
2235 -- FPJ Bug# 3110297 jingyu Add negotiated flag
2236 gIPNegotiatedFlag(i),
2237 gIPCurrencys(i), gIPUnitOfMeasures(i),
2238 gIPFunctionalPrices(i), gIPSupplierSiteCodes(i),
2239 gIPContractNums(i), gIPContractLineNums(i),
2240 gIpRateTypes(i), gIpRateDates(i), gIpRates(i),
2241 gIpSupplierNumbers(i), gIpSupplierContactIds(i),
2242 gIpItemRevisions(i), gIpLineTypeIds(i), gIpBuyerIds(i),
2243 NULL, ICX_POR_EXTRACTOR.gLoginId,
2244 ICX_POR_EXTRACTOR.gUserId, gIPLastUpdateDates(i),
2245 ICX_POR_EXTRACTOR.gUserId, SYSDATE,
2246 -- Bug#3352834
2247 ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID,
2248 ICX_POR_EXTRACTOR.gProgramApplicationId,
2249 ICX_POR_EXTRACTOR.gProgramId, SYSDATE);
2250
2251 clearTables(xActionMode);
2252
2253 xErrLoc := 240;
2254 xActionMode := 'INSERT_ITEMS_B';
2255 -- Insert ICX_CAT_ITEMS_B
2256 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2257 FOR i in 1..gIBRtItemIds.COUNT LOOP
2258 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2259 snapShot(i, xActionMode));
2260 END LOOP;
2261 END IF;
2262 FORALL i IN 1..gIBRtItemIds.COUNT
2263 INSERT INTO icx_cat_items_b
2264 (rt_item_id, object_version_number, org_id,
2265 supplier_id, supplier, supplier_part_num,
2266 supplier_part_auxid, internal_item_id, internal_item_num,
2267 extractor_updated_flag, catalog_name,
2268 last_update_login, last_updated_by, last_update_date,
2269 created_by, creation_date, request_id,
2270 program_application_id, program_id, program_update_date)
2271 VALUES
2272 (gIBRtItemIds(i), 1, gIBOrgIds(i),
2273 gIBSupplierIds(i), gIBSuppliers(i), gIBSupplierPartNums(i),
2274 '##NULL##', gIBInternalItemIds(i), gIBInternalItemNums(i),
2275 'Y', NULL,
2276 ICX_POR_EXTRACTOR.gLoginId, ICX_POR_EXTRACTOR.gUserId, SYSDATE,
2277 ICX_POR_EXTRACTOR.gUserId, SYSDATE, ICX_POR_EXTRACTOR.gRequestId,
2278 ICX_POR_EXTRACTOR.gProgramApplicationId,
2279 ICX_POR_EXTRACTOR.gProgramId, SYSDATE);
2280
2281 clearTables(xActionMode);
2282
2283 xErrLoc := 260;
2284 xActionMode := 'UPDATE_ITEMS_B';
2285 -- Update ICX_CAT_ITEMS_B
2286 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2287 FOR i in 1..gUBRtItemIds.COUNT LOOP
2288 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2289 snapShot(i, xActionMode));
2290 END LOOP;
2291 END IF;
2292 FORALL i IN 1..gUBRtItemIds.COUNT
2293 UPDATE icx_cat_items_b
2294 SET object_version_number = object_version_number + 1,
2295 extractor_updated_flag = gUBExtractorUpdatedFlags(i),
2296 supplier_part_auxid = '##NULL##',
2297 internal_item_num = gUBInternalItemNums(i),
2298 catalog_name = NULL,
2299 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
2300 last_update_date = SYSDATE,
2301 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
2302 request_id = ICX_POR_EXTRACTOR.gRequestId,
2303 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
2304 program_id = ICX_POR_EXTRACTOR.gProgramId,
2305 program_update_date = SYSDATE
2306 WHERE rt_item_id = gUBRtItemIds(i);
2307
2308 clearTables(xActionMode);
2309
2310 xErrLoc := 280;
2311 xActionMode := 'INSERT_ITEMS_TLP';
2312 -- Insert ICX_CAT_ITEMS_TLP
2313 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2314 FOR i in 1..gITRtItemIds.COUNT LOOP
2315 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2316 snapShot(i, xActionMode));
2317 END LOOP;
2318 END IF;
2319 IF gExtractImageDet = 'Y' THEN
2320 FORALL i IN 1..gITRtItemIds.COUNT
2321 INSERT INTO icx_cat_items_tlp
2322 (rt_item_id, language, org_id,
2323 supplier_id, item_source_type, search_type,
2324 primary_category_id, primary_category_name,
2325 internal_item_id, internal_item_num,
2326 supplier, supplier_part_num, supplier_part_auxid, manufacturer,
2327 manufacturer_part_num, description, comments, alias,
2328 picture, picture_url, thumbnail_image,
2329 attachment_url, long_description,
2330 unspsc_code, availability, lead_time, item_type,
2331 ctx_desc, last_update_login, last_updated_by, last_update_date,
2332 created_by, creation_date, request_id,
2333 program_application_id, program_id, program_update_date)
2334 VALUES
2335 (gITRtItemIds(i), gITLanguages(i), gITOrgIds(i),
2336 gITSupplierIds(i), gITItemSourceTypes(i), gITSearchTypes(i),
2337 gITPrimaryCategoryIds(i), gITPrimaryCategoryNames(i),
2338 gITInternalItemIds(i), gITInternalItemNums(i),
2339 gITSuppliers(i), gITSupplierPartNums(i), '##NULL##', gITManufacturers(i),
2340 gITManufacturerPartNums(i), gITDescriptions(i), NULL, NULL,
2341 gITPictures(i), gITPictureURLs(i), gITPictures(i), NULL, NULL,
2342 NULL, NULL, NULL, NULL,
2343 NULL, ICX_POR_EXTRACTOR.gLoginId,
2344 ICX_POR_EXTRACTOR.gUserId, SYSDATE,
2345 ICX_POR_EXTRACTOR.gUserId, SYSDATE, ICX_POR_EXTRACTOR.gRequestId,
2346 ICX_POR_EXTRACTOR.gProgramApplicationId,
2347 ICX_POR_EXTRACTOR.gProgramId, SYSDATE);
2348 ELSE
2349 FORALL i IN 1..gITRtItemIds.COUNT
2350 INSERT INTO icx_cat_items_tlp
2351 (rt_item_id, language, org_id,
2352 supplier_id, item_source_type, search_type,
2353 primary_category_id, primary_category_name,
2354 internal_item_id, internal_item_num,
2355 supplier, supplier_part_num, supplier_part_auxid, manufacturer,
2356 manufacturer_part_num, description, comments, alias,
2357 attachment_url, long_description,
2358 unspsc_code, availability, lead_time, item_type,
2359 ctx_desc, last_update_login, last_updated_by, last_update_date,
2360 created_by, creation_date, request_id,
2361 program_application_id, program_id, program_update_date)
2362 VALUES
2363 (gITRtItemIds(i), gITLanguages(i), gITOrgIds(i),
2364 gITSupplierIds(i), gITItemSourceTypes(i), gITSearchTypes(i),
2365 gITPrimaryCategoryIds(i), gITPrimaryCategoryNames(i),
2366 gITInternalItemIds(i), gITInternalItemNums(i),
2367 gITSuppliers(i), gITSupplierPartNums(i), '##NULL##', gITManufacturers(i),
2368 gITManufacturerPartNums(i), gITDescriptions(i), NULL, NULL,
2369 NULL, NULL,
2370 NULL, NULL, NULL, NULL,
2371 NULL, ICX_POR_EXTRACTOR.gLoginId,
2372 ICX_POR_EXTRACTOR.gUserId, SYSDATE,
2373 ICX_POR_EXTRACTOR.gUserId, SYSDATE, ICX_POR_EXTRACTOR.gRequestId,
2374 ICX_POR_EXTRACTOR.gProgramApplicationId,
2375 ICX_POR_EXTRACTOR.gProgramId, SYSDATE);
2376 END IF;
2377
2378 clearTables(xActionMode);
2379
2380 xErrLoc := 290;
2381 xActionMode := 'UPDATE_ITEMS_TLP';
2382 -- Update ICX_CAT_ITEMS_TLP
2383 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2384 FOR i in 1..gUTRtItemIds.COUNT LOOP
2385 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2386 snapShot(i, xActionMode));
2387 END LOOP;
2388 END IF;
2389 IF gExtractImageDet = 'Y' THEN
2390 FORALL i IN 1..gUTRtItemIds.COUNT
2391 UPDATE icx_cat_items_tlp
2392 SET item_source_type = gUTItemSourceTypes(i),
2393 search_type = gUTSearchTypes(i),
2394 primary_category_id = gUTPrimaryCategoryIds(i),
2395 primary_category_name = gUTPrimaryCategoryNames(i),
2396 internal_item_num = gUTInternalItemNums(i),
2397 description = gUTDescriptions(i),
2398 picture = gUTPictures(i),
2399 picture_url = gUTPictureURLs(i),
2400 supplier_part_auxid = '##NULL##',
2401 --manufacturer = gUTManufacturers(i),
2402 --manufacturer_part_num = gUTManufacturerPartNums(i),
2403 thumbnail_image = gUTPictures(i),
2404 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
2405 last_update_date = SYSDATE,
2406 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
2407 request_id = ICX_POR_EXTRACTOR.gRequestId,
2408 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
2409 program_id = ICX_POR_EXTRACTOR.gProgramId,
2410 program_update_date = SYSDATE
2411 WHERE rt_item_id = gUTRtItemIds(i)
2412 AND language = gUTLanguages(i);
2413 ELSE
2414 FORALL i IN 1..gUTRtItemIds.COUNT
2415 UPDATE icx_cat_items_tlp
2416 SET item_source_type = gUTItemSourceTypes(i),
2417 search_type = gUTSearchTypes(i),
2418 primary_category_id = gUTPrimaryCategoryIds(i),
2419 primary_category_name = gUTPrimaryCategoryNames(i),
2420 internal_item_num = gUTInternalItemNums(i),
2421 description = gUTDescriptions(i),
2422 supplier_part_auxid = '##NULL##',
2423 --manufacturer = gUTManufacturers(i),
2424 --manufacturer_part_num = gUTManufacturerPartNums(i),
2425 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
2426 last_update_date = SYSDATE,
2427 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
2428 request_id = ICX_POR_EXTRACTOR.gRequestId,
2429 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
2430 program_id = ICX_POR_EXTRACTOR.gProgramId,
2431 program_update_date = SYSDATE
2432 WHERE rt_item_id = gUTRtItemIds(i)
2433 AND language = gUTLanguages(i);
2434 END IF;
2435
2436 clearTables(xActionMode);
2437
2438 xErrLoc := 300;
2439 xActionMode := 'INSERT_CATEGORY_ITEMS';
2440 -- Insert ICX_CAT_CATEGORY_ITEMS
2441 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2442 FOR i in 1..gICRtItemIds.COUNT LOOP
2443 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2444 snapShot(i, xActionMode));
2445 END LOOP;
2446 END IF;
2447 FORALL i IN 1..gICRtItemIds.COUNT
2448 INSERT INTO icx_cat_category_items
2449 (rt_item_id, rt_category_id,
2450 last_update_login, last_updated_by, last_update_date,
2451 created_by, creation_date, request_id,
2452 program_application_id, program_id, program_update_date)
2453 VALUES
2454 (gICRtItemIds(i), gICRtCategoryIds(i),
2455 ICX_POR_EXTRACTOR.gLoginId, ICX_POR_EXTRACTOR.gUserId, SYSDATE,
2456 ICX_POR_EXTRACTOR.gUserId, SYSDATE, ICX_POR_EXTRACTOR.gRequestId,
2457 ICX_POR_EXTRACTOR.gProgramApplicationId,
2458 ICX_POR_EXTRACTOR.gProgramId, SYSDATE);
2459
2460 clearTables(xActionMode);
2461
2462 xErrLoc := 320;
2463 xActionMode := 'UPDATE_CATEGORY_ITEMS';
2464 -- Update ICX_CAT_CATEGORY_ITEMS
2465 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2466 FOR i in 1..gUCRtItemIds.COUNT LOOP
2467 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2468 snapShot(i, xActionMode));
2469 END LOOP;
2470 END IF;
2471 FORALL i IN 1..gUCRtItemIds.COUNT
2472 UPDATE icx_cat_category_items
2473 SET rt_category_id = gUCRtCategoryIds(i),
2474 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
2475 last_update_date = SYSDATE,
2476 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
2477 request_id = ICX_POR_EXTRACTOR.gRequestId,
2478 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
2479 program_id = ICX_POR_EXTRACTOR.gProgramId,
2480 program_update_date = SYSDATE
2481 WHERE rt_item_id = gUCRtItemIds(i)
2482 AND rt_category_id = gUCOldRtCategoryIds(i);
2483
2484 clearTables(xActionMode);
2485
2486 xErrLoc := 340;
2487 xActionMode := 'INSERT_EXT_ITEMS';
2488 -- Insert ICX_CAT_EXT_ITEMS_TLP
2489 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2490 FOR i in 1..gIERtItemIds.COUNT LOOP
2491 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2492 snapShot(i, xActionMode));
2493 END LOOP;
2494 END IF;
2495 FORALL i IN 1..gIERtItemIds.COUNT
2496 INSERT INTO icx_cat_ext_items_tlp
2497 (rt_item_id, language, org_id,
2498 rt_category_id, primary_flag,
2499 last_update_login, last_updated_by, last_update_date,
2500 created_by, creation_date, request_id,
2501 program_application_id, program_id, program_update_date)
2502 -- bug 2925403
2503 -- SELECT
2504 VALUES
2505 -- gIERtItemIds(i), language_code, gIEOrgIds(i),
2506 (gIERtItemIds(i), gIELanguages(i), gIEOrgIds(i),
2507 gIERtCategoryIds(i), 'Y',
2508 ICX_POR_EXTRACTOR.gLoginId, ICX_POR_EXTRACTOR.gUserId, SYSDATE,
2509 ICX_POR_EXTRACTOR.gUserId, SYSDATE, ICX_POR_EXTRACTOR.gRequestId,
2510 ICX_POR_EXTRACTOR.gProgramApplicationId,
2511 ICX_POR_EXTRACTOR.gProgramId, SYSDATE);
2512 -- bug 2925403
2513 -- FROM fnd_languages
2514 -- WHERE installed_flag IN ('B', 'I');
2515
2516 clearTables(xActionMode);
2517
2518 xErrLoc := 360;
2519 xActionMode := 'UPDATE_EXT_ITEMS';
2520 -- Update ICX_CAT_EXT_ITEMS_TLP
2521 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2522 FOR i in 1..gUERtItemIds.COUNT LOOP
2523 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2524 snapShot(i, xActionMode));
2525 END LOOP;
2526 END IF;
2527 FORALL i IN 1..gUERtItemIds.COUNT
2528 UPDATE icx_cat_ext_items_tlp
2529 SET rt_category_id = gUERtCategoryIds(i),
2530 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
2531 last_update_date = SYSDATE,
2532 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
2533 request_id = ICX_POR_EXTRACTOR.gRequestId,
2534 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
2535 program_id = ICX_POR_EXTRACTOR.gProgramId,
2536 program_update_date = SYSDATE
2537 WHERE rt_item_id = gUERtItemIds(i)
2538 -- bug 2925403
2539 AND language = gUELanguages(i)
2540 AND rt_category_id = gUEOldRtCategoryIds(i);
2541
2542 clearTables(xActionMode);
2543
2544 xErrLoc := 380;
2545 xActionMode := 'DELETE_ITEM_PRICE';
2546 -- Delete Item Price
2547 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2548 FOR i in 1..gDPRowIds.COUNT LOOP
2549 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2550 snapShot(i, xActionMode));
2551 END LOOP;
2552 END IF;
2553 FORALL i IN 1..gDPRowIds.COUNT
2554 DELETE FROM icx_cat_item_prices
2555 WHERE rowid = gDPRowIds(i);
2556
2557 xErrLoc := 390;
2558 FORALL i IN 1..gDPTemplateCategoryIds.COUNT
2559 DELETE FROM icx_cat_category_items
2560 WHERE rt_category_id = gDPTemplateCategoryIds(i)
2561 AND rt_item_id = gDPRtItemIds(i);
2562 clearTables(xActionMode);
2563
2564 xErrLoc := 395;
2565 xActionMode := 'DELETE_ITEM_PRICE_GA';
2566 -- Delete Item Price
2567 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2568 FOR i in 1..gDPGContractLineIds.COUNT LOOP
2569 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2570 snapShot(i, xActionMode));
2571 END LOOP;
2572 END IF;
2573 xRtItemIds.DELETE;
2574 FORALL i IN 1..gDPGContractLineIds.COUNT
2575 DELETE FROM icx_cat_item_prices
2576 WHERE contract_id = gDPGContractIds(i)
2577 AND contract_line_id = gDPGContractLineIds(i)
2578 AND price_type = 'GLOBAL_AGREEMENT'
2579 RETURNING local_rt_item_id BULK COLLECT INTO xRtItemIds;
2580 xErrLoc := 398;
2581 -- Need to reset active_flag for all local rt_item_ids
2582 -- NOTE: we use local_rt_item_id to store local rt_item_id
2583 FORALL i IN 1..xRtItemIds.COUNT
2584 INSERT INTO icx_cat_extract_gt
2585 (rt_item_id, type)
2586 VALUES (xRtItemIds(i), 'ACTIVE_FLAG');
2587 clearTables(xActionMode);
2588
2589 xErrLoc := 400;
2590 xActionMode := 'UPDATE_PRICES_GA';
2591 -- Update ICX_CAT_ITEM_PRICES for local global agreements
2592 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2593 FOR i in 1..gUPGAContractLineIds.COUNT LOOP
2594 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2595 snapShot(i, xActionMode));
2596 END LOOP;
2597 END IF;
2598 FORALL i IN 1..gUPGAContractLineIds.COUNT
2599 UPDATE icx_cat_item_prices
2600 SET object_version_number = object_version_number + 1,
2601 functional_price = gUPGAFunctionalPrices(i),
2602 supplier_site_id = gUPGASupplierSiteIds(i),
2603 supplier_site_code = gUPGASupplierSiteCodes(i),
2604 -- bug 2912717: populate line_type, rate info. for GA
2605 line_type_id = gUPGALineTypeIds(i),
2606 rate_type = gUPGARateTypes(i),
2607 rate_date = gUPGARateDates(i),
2608 rate = gUPGARates(i),
2609 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
2610 last_update_date = SYSDATE,
2611 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
2612 -- Bug#3352834
2613 request_id = ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID,
2614 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
2615 program_id = ICX_POR_EXTRACTOR.gProgramId,
2616 program_update_date = SYSDATE
2617 WHERE contract_id = gUPGAContractIds(i)
2618 AND contract_line_id = gUPGAContractLineIds(i)
2619 -- bug 3298502 : Enabled Org Ids
2620 AND org_id = gUPGAOrgIds(i)
2621 AND price_type = 'GLOBAL_AGREEMENT';
2622 clearTables(xActionMode);
2623
2624 xErrLoc := 420;
2625 xActionMode := 'INSERT_PRICES_GA';
2626 -- Insert ICX_CAT_ITEM_PRICES for local global agreements
2627 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2628 FOR i in 1..gIPGAContractLineIds.COUNT LOOP
2629 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2630 snapShot(i, xActionMode));
2631 END LOOP;
2632 END IF;
2633 FORALL i IN 1..gIPGAContractLineIds.COUNT
2634 INSERT INTO icx_cat_item_prices
2635 (rt_item_id, price_type,
2636 active_flag, object_version_number,
2637 asl_id, supplier_site_id,
2638 contract_id, contract_line_id,
2639 template_id, template_line_id,
2640 inventory_item_id, mtl_category_id,
2641 org_id, search_type, unit_price,
2642 --FPJ FPSL Extractor Changes
2643 value_basis, purchase_basis,
2644 allow_price_override_flag, not_to_exceed_price,
2645 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
2646 suggested_quantity,
2647 -- FPJ Bug# 3110297 jingyu Add negotiated flag
2648 negotiated_by_preparer_flag,
2649 currency, unit_of_measure,
2650 functional_price, supplier_site_code,
2651 contract_num, contract_line_num,
2652 -- bug 2912717: populate line_type, rate info. for GA
2653 line_type_id, rate_type, rate_date, rate,
2654 local_rt_item_id,
2655 price_list_id, last_update_login,
2656 last_updated_by, last_update_date,
2657 created_by, creation_date, request_id,
2658 program_application_id, program_id, program_update_date)
2659 VALUES
2660 (gIPGARtItemIds(i), 'GLOBAL_AGREEMENT',
2661 'Y', 1,
2662 NULL_NUMBER, gIPGASupplierSiteIds(i),
2663 gIPGAContractIds(i), gIPGAContractLineIds(i),
2664 NULL_NUMBER, NULL_NUMBER,
2665 gIPGAInventoryItemIds(i), gIPGAMtlCategoryIds(i),
2666 gIPGAOrgIds(i), 'SUPPLIER', gIPGAUnitPrices(i),
2667 --FPJ FPSL Extractor Changes
2668 gIPGAValueBasis(i), gIPGAPurchaseBasis(i),
2669 gIPGAAllowPriceOverrideFlag(i), gIPGANotToExceedPrice(i),
2670 --FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
2671 NULL,
2672 -- FPJ Bug# 3110297 jingyu Add negotiated flag
2673 gIPGANegotiatedFlag(i),
2674 gIPGACurrencys(i), gIPGAUnitOfMeasures(i),
2675 gIPGAFunctionalPrices(i), gIPGASupplierSiteCodes(i),
2676 gIPGAContractNums(i), gIPGAContractLineNums(i),
2677 -- bug 2912717: populate line_type_id for GA
2678 gIPGALineTypeIds(i),
2679 gIPGARateTypes(i), gIPGARateDates(i), gIPGARates(i),
2680 -- Use local_rt_item_id to store local rt_item_id
2681 gIPGALocalRtItemIds(i),
2682 NULL, ICX_POR_EXTRACTOR.gLoginId,
2683 ICX_POR_EXTRACTOR.gUserId, SYSDATE,
2684 ICX_POR_EXTRACTOR.gUserId, SYSDATE,
2685 -- Bug#3352834
2686 ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID,
2687 ICX_POR_EXTRACTOR.gProgramApplicationId,
2688 ICX_POR_EXTRACTOR.gProgramId, SYSDATE);
2689
2690 FORALL i IN 1..gIPGARtItemIds.COUNT
2691 UPDATE icx_cat_items_tlp
2692 SET request_id = ICX_POR_EXTRACTOR.gRequestId
2693 WHERE rt_item_id = gIPGARtItemIds(i);
2694
2695 clearTables(xActionMode);
2696
2697 xErrLoc := 440;
2698 xActionMode := 'SET_LOCAL_RT_ITEM_ID';
2699 -- Set local rt_item_id for local global agreements
2700 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2701 FOR i in 1..gSLRRowIds.COUNT LOOP
2702 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2703 snapShot(i, xActionMode));
2704 END LOOP;
2705 END IF;
2706 -- NOTE: we use local_rt_item_id to store local rt_item_id
2707 FORALL i IN 1..gSLRRowIds.COUNT
2708 UPDATE icx_cat_item_prices
2709 SET local_rt_item_id = gSLRALocalRtItemIds(i)
2710 WHERE rowid = gSLRRowIds(i);
2711 clearTables(xActionMode);
2712
2713 xErrLoc := 450;
2714 xActionMode := 'TOUCH_CLEANUP_ITEM';
2715 -- Insert temporary table to cleanup items
2716 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2717 FOR i in 1..gCIRtItemIds.COUNT LOOP
2718 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2719 snapShot(i, xActionMode));
2720 END LOOP;
2721 END IF;
2722 FORALL i IN 1..gCIRtItemIds.COUNT
2723 INSERT INTO icx_cat_extract_gt
2724 (rt_item_id, type)
2725 VALUES (gCIRtItemIds(i), 'CLEANUP_ITEM');
2726 clearTables(xActionMode);
2727
2728 xErrLoc := 460;
2729 xActionMode := 'TOUCH_UPDATED_GA';
2730 -- Insert temporary table to set updated GAs
2731 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2732 FOR i in 1..gUGAContractIds.COUNT LOOP
2733 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2734 snapShot(i, xActionMode));
2735 END LOOP;
2736 END IF;
2737 FORALL i IN 1..gUGAContractIds.COUNT
2738 INSERT INTO icx_cat_extract_ga_gt
2739 (contract_id, contract_line_id)
2740 VALUES (gUGAContractIds(i), gUGAContractLineIds(i));
2741 clearTables(xActionMode);
2742
2743 xErrLoc := 500;
2744 xActionMode := 'TOUCH_ACTIVE_FLAG';
2745 -- Insert temporary table to set active_flag
2746 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2747 FOR i in 1..gTARtItemIds.COUNT LOOP
2748 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2749 snapShot(i, xActionMode));
2750 END LOOP;
2751 END IF;
2752 FORALL i IN 1..gTARtItemIds.COUNT
2753 INSERT INTO icx_cat_extract_gt
2754 (rt_item_id, type)
2755 VALUES (gTARtItemIds(i), 'ACTIVE_FLAG');
2756 clearTables(xActionMode);
2757
2758 xErrLoc := 510;
2759 xActionMode := 'TOUCH_ACTIVE_FLAG_INV';
2760 -- Insert temporary table to set active_flag
2761 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2762 FOR i in 1..gTAInvItemIds.COUNT LOOP
2763 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2764 snapShot(i, xActionMode));
2765 END LOOP;
2766 END IF;
2767 FORALL i IN 1..gTAInvItemIds.COUNT
2768 INSERT INTO icx_cat_extract_gt
2769 (rt_item_id, type)
2770 SELECT rt_item_id, 'ACTIVE_FLAG'
2771 FROM icx_cat_items_b
2772 WHERE internal_item_id = gTAInvItemIds(i)
2773 AND org_id = NVL(gTAInvOrgIds(i), org_id)
2774 AND supplier IS NULL;
2775 clearTables(xActionMode);
2776
2777 xErrLoc := 520;
2778 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
2779 'Processed records: ' || gPriceRowCount);
2780 ICX_POR_EXT_UTL.extAFCommit;
2781
2782 -- Need to clear the caches after commit
2783 clearCache;
2784 END IF; -- gTransactionCount >= ICX_POR_EXT_UTL.gCommitSize
2785
2786 xActionMode := 'DELETE_PURCHASING_ITEM';
2787 -- Delete Item
2788 IF (pMode = 'OUTLOOP' OR
2789 gDIPurchasingItemIds.COUNT >= ICX_POR_EXT_UTL.gCommitSize)
2790 THEN
2791 xErrLoc := 540;
2792 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2793 FOR i in 1..gDIPurchasingItemIds.COUNT LOOP
2794 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2795 snapShot(i, xActionMode));
2796 END LOOP;
2797 END IF;
2798
2799 xContinue := TRUE;
2800 WHILE xContinue LOOP
2801 xRtItemIds.DELETE;
2802 FORALL i IN 1..gDIPurchasingItemIds.COUNT
2803 DELETE FROM icx_cat_item_prices
2804 WHERE inventory_item_id = gDIPurchasingItemIds(i)
2805 AND org_id = gDIPurchasingOrgIds(i)
2806 AND (search_type = 'SUPPLIER' OR
2807 price_type = 'PURCHASING_ITEM')
2808 AND rownum <= ICX_POR_EXT_UTL.gCommitSize
2809 RETURNING rt_item_id BULK COLLECT INTO xRtItemIds;
2810
2811 IF (SQL%ROWCOUNT < ICX_POR_EXT_UTL.gCommitSize) THEN
2812 xContinue := FALSE;
2813 END IF;
2814
2815 xErrLoc := 545;
2816 -- Insert temporary table to cleanup items
2817 FORALL i IN 1..xRtItemIds.COUNT
2818 INSERT INTO icx_cat_extract_gt
2819 (rt_item_id, type)
2820 VALUES (xRtItemIds(i), 'CLEANUP_ITEM');
2821
2822 xErrLoc := 550;
2823 -- If there is any bulkloaded item, should set active_flag
2824 FORALL i IN 1..xRtItemIds.COUNT
2825 UPDATE icx_cat_item_prices
2826 SET active_flag = 'Y'
2827 WHERE rt_item_id = xRtItemIds(i)
2828 AND price_type IN ('BULKLOAD', 'CONTRACT');
2829
2830 xErrLoc := 555;
2831 FORALL i IN 1..xRtItemIds.COUNT
2832 DELETE FROM icx_cat_category_items ci
2833 WHERE rt_item_id = xRtItemIds(i)
2834 AND EXISTS (SELECT 'template header'
2835 FROM icx_cat_categories_tl c
2836 WHERE c.rt_category_id = ci.rt_category_id
2837 AND c.type = ICX_POR_EXT_CLASS.TEMPLATE_HEADER_TYPE);
2838
2839 xErrLoc := 560;
2840 ICX_POR_EXT_UTL.extAFCommit;
2841 END LOOP;
2842
2843 clearTables(xActionMode);
2844 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
2845 'Processed records: ' || gPriceRowCount);
2846 END IF;
2847
2848 xActionMode := 'DELETE_NULL_PRICE_ITEM';
2849 IF (pMode = 'OUTLOOP' OR
2850 gDINullPriceItemIds.COUNT >= ICX_POR_EXT_UTL.gCommitSize)
2851 THEN
2852 xErrLoc := 580;
2853 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2854 FOR i in 1..gDIPurchasingItemIds.COUNT LOOP
2855 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2856 snapShot(i, xActionMode));
2857 END LOOP;
2858 END IF;
2859
2860 xContinue := TRUE;
2861 WHILE xContinue LOOP
2862 xRtItemIds.DELETE;
2863 FORALL i IN 1..gDINullPriceItemIds.COUNT
2864 DELETE FROM icx_cat_item_prices
2865 WHERE inventory_item_id = gDINullPriceItemIds(i)
2866 AND org_id = gDINullPriceOrgIds(i)
2867 AND price_type IN ('ASL', 'PURCHASING_ITEM')
2868 AND rownum <= ICX_POR_EXT_UTL.gCommitSize
2869 RETURNING rt_item_id BULK COLLECT INTO xRtItemIds;
2870
2871 xErrLoc := 590;
2872 -- Insert temporary table to cleanup items
2873 FORALL i IN 1..xRtItemIds.COUNT
2874 INSERT INTO icx_cat_extract_gt
2875 (rt_item_id, type)
2876 VALUES (xRtItemIds(i), 'CLEANUP_ITEM');
2877
2878 IF (SQL%ROWCOUNT < ICX_POR_EXT_UTL.gCommitSize) THEN
2879 xContinue := FALSE;
2880 END IF;
2881
2882 xErrLoc := 600;
2883 ICX_POR_EXT_UTL.extAFCommit;
2884 END LOOP;
2885
2886 clearTables(xActionMode);
2887 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
2888 'Processed records: ' || gPriceRowCount);
2889 END IF;
2890
2891 xActionMode := 'DELETE_INTERNAL_ITEM';
2892 IF (pMode = 'OUTLOOP' OR
2893 gDIInternalItemIds.COUNT >= ICX_POR_EXT_UTL.gCommitSize)
2894 THEN
2895 xErrLoc := 620;
2896 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
2897 FOR i in 1..gDIPurchasingItemIds.COUNT LOOP
2898 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2899 snapShot(i, xActionMode));
2900 END LOOP;
2901 END IF;
2902
2903 xContinue := TRUE;
2904 WHILE xContinue LOOP
2905 xRtItemIds.DELETE;
2906 FORALL i IN 1..gDIInternalItemIds.COUNT
2907 DELETE FROM icx_cat_item_prices
2908 WHERE inventory_item_id = gDIInternalItemIds(i)
2909 AND org_id = gDIInternalOrgIds(i)
2910 AND search_type = 'INTERNAL'
2911 AND rownum <= ICX_POR_EXT_UTL.gCommitSize
2912 RETURNING rt_item_id BULK COLLECT INTO xRtItemIds;
2913
2914 xErrLoc := 630;
2915 -- Insert temporary table to cleanup items
2916 FORALL i IN 1..xRtItemIds.COUNT
2917 INSERT INTO icx_cat_extract_gt
2918 (rt_item_id, type)
2919 VALUES (xRtItemIds(i), 'CLEANUP_ITEM');
2920
2921 IF (SQL%ROWCOUNT < ICX_POR_EXT_UTL.gCommitSize) THEN
2922 xContinue := FALSE;
2923 END IF;
2924
2925 xErrLoc := 640;
2926 ICX_POR_EXT_UTL.extAFCommit;
2927 END LOOP;
2928
2929 clearTables(xActionMode);
2930 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
2931 'Processed records: ' || gPriceRowCount);
2932 END IF;
2933
2934 xErrLoc := 800;
2935 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
2936 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2937 'Leave processBatchData()');
2938 END IF;
2939 EXCEPTION
2940 when ICX_POR_EXT_UTL.gException then
2941 -- rollback;
2942 ICX_POR_EXT_UTL.extRollback;
2943
2944 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.processBatchData-'||
2945 xErrLoc);
2946 raise ICX_POR_EXT_UTL.gException;
2947 when others then
2948 -- rollback;
2949 ICX_POR_EXT_UTL.extRollback;
2950
2951 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.processBatchData-'||
2952 xErrLoc||' '||SQLERRM);
2953 ICX_POR_EXT_UTL.pushError(snapShot(SQL%ROWCOUNT+1, xActionMode));
2954 raise ICX_POR_EXT_UTL.gException;
2955 END processBatchData;
2956
2957 --------------------------------------------------------------
2958 -- Search Updated Price Rows Procedures --
2959 --------------------------------------------------------------
2960 FUNCTION openItemCursor RETURN tFoundItemCursor
2961 IS
2962 xErrLoc PLS_INTEGER := 100;
2963 xFoundItemCur tFoundItemCursor;
2964 BEGIN
2965 xErrLoc := 100;
2966 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
2967 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
2968 'Enter openItemCursor()');
2969 END IF;
2970
2971 -- Inventory item with documents
2972 IF (gCurrentPrice.document_type IN (TEMPLATE_TYPE,
2973 CONTRACT_TYPE,
2974 ASL_TYPE) AND
2975 gCurrentPrice.internal_item_id <> NULL_NUMBER)
2976 THEN
2977 xErrLoc := 200;
2978 OPEN xFoundItemCur FOR
2979 SELECT i.rt_item_id,
2980 t.primary_category_id,
2981 ICX_POR_EXT_ITEM.getMatchTempalteFlag(gCurrentPrice.price_type,
2982 i.rt_item_id,
2983 gCurrentPrice.template_id) match_template_flag
2984 FROM icx_cat_items_b i,
2985 icx_cat_items_tlp t
2986 WHERE i.internal_item_id = gCurrentPrice.internal_item_id
2987 AND i.org_id = gCurrentPrice.org_id
2988 AND (i.supplier IS NULL AND gCurrentPrice.supplier IS NULL OR
2989 i.supplier = gCurrentPrice.supplier)
2990 AND (i.supplier_part_num IS NULL AND
2991 gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER) OR
2992 i.supplier_part_num = gCurrentPrice.supplier_part_num)
2993 AND t.rt_item_id = i.rt_item_id
2994 AND rownum = 1
2995 UNION ALL
2996 SELECT p.local_rt_item_id,
2997 TO_NUMBER(NULL_NUMBER) primary_category_id, -- for Global Agreement match
2998 'N' match_template_flag
2999 FROM icx_cat_items_b i,
3000 icx_cat_item_prices p
3001 WHERE i.internal_item_id = gCurrentPrice.internal_item_id
3002 AND (i.supplier IS NULL AND gCurrentPrice.supplier IS NULL OR
3003 i.supplier = gCurrentPrice.supplier)
3004 AND (i.supplier_part_num IS NULL AND
3005 gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER) OR
3006 i.supplier_part_num = gCurrentPrice.supplier_part_num)
3007 AND p.rt_item_id = i.rt_item_id
3008 AND p.price_type = 'GLOBAL_AGREEMENT'
3009 AND p.org_id = gCurrentPrice.org_id
3010 AND rownum = 1;
3011
3012 RETURN xFoundItemCur;
3013 END IF;
3014
3015 -- Inventory item without documents
3016 IF gCurrentPrice.document_type IN (PURCHASING_ITEM_TYPE,
3017 INTERNAL_TEMPLATE_TYPE,
3018 INTERNAL_ITEM_TYPE)
3019 THEN
3020 xErrLoc := 300;
3021 OPEN xFoundItemCur FOR
3022 SELECT p.rt_item_id,
3023 t.primary_category_id,
3024 ICX_POR_EXT_ITEM.getMatchTempalteFlag(gCurrentPrice.price_type,
3025 p.rt_item_id,
3026 gCurrentPrice.template_id) match_template_flag
3027 FROM icx_cat_item_prices p,
3028 icx_cat_items_tlp t
3029 WHERE p.inventory_item_id = gCurrentPrice.internal_item_id
3030 AND p.org_id = gCurrentPrice.org_id
3031 AND p.price_type IN ('PURCHASING_ITEM',
3032 'INTERNAL_TEMPLATE',
3033 'INTERNAL_ITEM')
3034 AND t.rt_item_id = p.rt_item_id
3035 AND rownum = 1;
3036 RETURN xFoundItemCur;
3037 END IF;
3038
3039 -- One-time item with not null supplier/spn
3040 IF (gCurrentPrice.internal_item_id = NULL_NUMBER AND
3041 gCurrentPrice.document_type IN (TEMPLATE_TYPE, CONTRACT_TYPE) AND
3042 gCurrentPrice.supplier IS NOT NULL AND
3043 gCurrentPrice.supplier_part_num <> TO_CHAR(NULL_NUMBER))
3044 THEN
3045 xErrLoc := 400;
3046 OPEN xFoundItemCur FOR
3047 SELECT i.rt_item_id,
3048 t.primary_category_id,
3049 ICX_POR_EXT_ITEM.getMatchTempalteFlag(gCurrentPrice.price_type,
3050 i.rt_item_id,
3051 gCurrentPrice.template_id) match_template_flag
3052 FROM icx_cat_items_b i,
3053 icx_cat_items_tlp t
3054 WHERE i.internal_item_id IS NULL
3055 AND i.org_id = gCurrentPrice.org_id
3056 AND i.supplier = gCurrentPrice.supplier
3057 AND i.supplier_part_num = gCurrentPrice.supplier_part_num
3058 AND i.supplier_part_auxid = '##NULL##'
3059 AND t.rt_item_id = i.rt_item_id
3060 AND rownum = 1
3061 UNION ALL
3062 SELECT p.local_rt_item_id,
3063 TO_NUMBER(NULL_NUMBER) primary_category_id,
3064 'N' match_template_flag
3065 FROM icx_cat_items_b i,
3066 icx_cat_item_prices p
3067 WHERE i.internal_item_id IS NULL
3068 AND i.supplier = gCurrentPrice.supplier
3069 AND i.supplier_part_num = gCurrentPrice.supplier_part_num
3070 AND i.supplier_part_auxid = '##NULL##'
3071 AND p.rt_item_id = i.rt_item_id
3072 AND p.price_type = 'GLOBAL_AGREEMENT'
3073 AND p.org_id = gCurrentPrice.org_id
3074 AND rownum = 1;
3075 RETURN xFoundItemCur;
3076 END IF;
3077
3078 -- One-time item with null supplier or spn
3079 IF (gCurrentPrice.internal_item_id = NULL_NUMBER AND
3080 gCurrentPrice.document_type IN (TEMPLATE_TYPE, CONTRACT_TYPE) AND
3081 (gCurrentPrice.supplier IS NULL OR
3082 gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER)))
3083 THEN
3084 xErrLoc := 500;
3085 OPEN xFoundItemCur FOR
3086 SELECT p.rt_item_id,
3087 t.primary_category_id,
3088 ICX_POR_EXT_ITEM.getMatchTempalteFlag(gCurrentPrice.price_type,
3089 p.rt_item_id,
3090 gCurrentPrice.template_id) match_template_flag
3091 FROM icx_cat_item_prices p,
3092 icx_cat_items_tlp t
3093 WHERE p.inventory_item_id IS NULL
3094 AND p.org_id = gCurrentPrice.org_id
3095 AND p.contract_id = gCurrentPrice.contract_id
3096 AND p.contract_line_id = gCurrentPrice.contract_line_id
3097 AND EXISTS (SELECT 'item with same supplier/supplier_part_num'
3098 FROM icx_cat_items_b i
3099 WHERE i.rt_item_id = p.rt_item_id
3100 AND i.org_id = p.org_id
3101 AND (i.supplier IS NULL AND
3102 gCurrentPrice.supplier IS NULL OR
3103 i.supplier = gCurrentPrice.supplier)
3104 AND (i.supplier_part_num IS NULL AND
3105 gCurrentPrice.supplier_part_num =
3106 TO_CHAR(NULL_NUMBER) OR
3107 i.supplier_part_num = gCurrentPrice.supplier_part_num))
3108 AND t.rt_item_id = p.rt_item_id
3109 AND rownum = 1
3110 UNION ALL
3111 SELECT p.local_rt_item_id,
3112 TO_NUMBER(NULL_NUMBER) primary_category_id,
3113 'N' match_template_flag
3114 FROM icx_cat_item_prices p
3115 WHERE p.inventory_item_id IS NULL
3116 AND p.org_id = gCurrentPrice.org_id
3117 AND p.contract_id = gCurrentPrice.contract_id
3118 AND p.contract_line_id = gCurrentPrice.contract_line_id
3119 AND p.price_type = 'GLOBAL_AGREEMENT'
3120 AND EXISTS (SELECT 'item with same supplier/supplier_part_num'
3121 FROM icx_cat_items_b i
3122 WHERE i.rt_item_id = p.rt_item_id
3123 AND (i.supplier IS NULL AND
3124 gCurrentPrice.supplier IS NULL OR
3125 i.supplier = gCurrentPrice.supplier)
3126 AND (i.supplier_part_num IS NULL AND
3127 gCurrentPrice.supplier_part_num =
3128 TO_CHAR(NULL_NUMBER) OR
3129 i.supplier_part_num = gCurrentPrice.supplier_part_num))
3130 AND rownum = 1;
3131 RETURN xFoundItemCur;
3132 END IF;
3133
3134 -- Inventory item for global agreement
3135 IF (gCurrentPrice.document_type = GLOBAL_AGREEMENT_TYPE AND
3136 gCurrentPrice.internal_item_id <> NULL_NUMBER)
3137 THEN
3138 xErrLoc := 600;
3139 OPEN xFoundItemCur FOR
3140 SELECT i.rt_item_id,
3141 TO_NUMBER(NULL) primary_category_id,
3142 TO_CHAR(NULL) match_template_flag
3143 FROM icx_cat_items_b i
3144 WHERE i.internal_item_id = gCurrentPrice.internal_item_id
3145 AND i.org_id = gCurrentPrice.org_id
3146 AND (i.supplier IS NULL AND gCurrentPrice.supplier IS NULL OR
3147 i.supplier = gCurrentPrice.supplier)
3148 AND (i.supplier_part_num IS NULL AND
3149 gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER) OR
3150 i.supplier_part_num = gCurrentPrice.supplier_part_num)
3151 AND rownum = 1;
3152 RETURN xFoundItemCur;
3153 END IF;
3154
3155 -- One-time item with not null supplier/spn for global agreement
3156 IF (gCurrentPrice.internal_item_id = NULL_NUMBER AND
3157 gCurrentPrice.document_type = GLOBAL_AGREEMENT_TYPE AND
3158 gCurrentPrice.supplier IS NOT NULL AND
3159 gCurrentPrice.supplier_part_num <> TO_CHAR(NULL_NUMBER))
3160 THEN
3161 xErrLoc := 700;
3162 OPEN xFoundItemCur FOR
3163 SELECT i.rt_item_id,
3164 TO_NUMBER(NULL) primary_category_id,
3165 TO_CHAR(NULL) match_template_flag
3166 FROM icx_cat_items_b i
3167 WHERE i.internal_item_id IS NULL
3168 AND i.org_id = gCurrentPrice.org_id
3169 AND i.supplier = gCurrentPrice.supplier
3170 AND i.supplier_part_num = gCurrentPrice.supplier_part_num
3171 AND i.supplier_part_auxid = '##NULL##'
3172 AND rownum = 1;
3173 RETURN xFoundItemCur;
3174 END IF;
3175
3176 -- One-time item with null supplier or spn for global agreement
3177 xErrLoc := 700;
3178 -- Otherwise
3179 OPEN xFoundItemCur FOR
3180 SELECT p.rt_item_id,
3181 TO_NUMBER(NULL) primary_category_id,
3182 TO_CHAR(NULL) match_template_flag
3183 FROM icx_cat_item_prices p
3184 WHERE p.inventory_item_id IS NULL
3185 AND p.org_id = gCurrentPrice.org_id
3186 AND p.contract_id = gCurrentPrice.contract_id
3187 AND p.contract_line_id = gCurrentPrice.contract_line_id
3188 AND EXISTS (SELECT 'item with same supplier/supplier_part_num'
3189 FROM icx_cat_items_b i
3190 WHERE i.rt_item_id = p.rt_item_id
3191 AND i.org_id = p.org_id
3192 AND (i.supplier IS NULL AND
3193 gCurrentPrice.supplier IS NULL OR
3194 i.supplier = gCurrentPrice.supplier)
3195 AND (i.supplier_part_num IS NULL AND
3196 gCurrentPrice.supplier_part_num =
3197 TO_CHAR(NULL_NUMBER) OR
3198 i.supplier_part_num = gCurrentPrice.supplier_part_num))
3199 AND rownum = 1;
3200
3201 RETURN xFoundItemCur;
3202
3203 EXCEPTION
3204 when others then
3205 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM-openItemCursor-'||
3206 xErrLoc||' '||SQLERRM);
3207 raise ICX_POR_EXT_UTL.gException;
3208 END openItemCursor;
3209
3210 -- Find item record based on Item Uniqueness Rules
3211 --
3212 -- Inventory Item:
3213 -- * org_id, internal_item_id, supplier_id, supplier_part_num
3214 -- * Check bulkloaded items: org_id, supplier_id,
3215 -- supplier_part_num (Note: supplier_part_auxid = '##NULL##')
3216 --
3217 -- [Note: Purchasing master item, internal template, and internal
3218 -- master item have NULL supplier and supplier_part_num,
3219 -- they share same rt_item_id based on org_id/internal_item_id]
3220 --
3221 -- One-time Item
3222 -- * org_id, supplier_id, supplier_part_num
3223 -- * IF either supplier_id or supplier_part_num IS NULL
3224 -- THEN
3225 -- org_id, supplier_id, supplier_part_num, contract_line_id
3226 -- END IF;
3227 -- * Don't check bulkloaded items
3228 --
3229 -- We use local_rt_item_id to store subscribing org rt_item_id
3230 -- based on item uniqueness criteria from global agreement
3231 -- For instance: we have a global agreemnt defined in org 101,
3232 -- and enabled in org 102, 103; in org 102, there are two ASLs;
3233 -- in org 103, there is one ASL.
3234 --
3235 -- ICX_CAT_ITEMS_B | ICX_CAT_ITEM_PRICES
3236 -- -------------------------------+------------------------------
3237 -- ID | ITEM | SUP | SPN | ORG | ID | ORG | ACTIVE | LOCAL ID
3238 -- -------------------------------+------------------------------
3239 -- GA: 01 | I1 | s1 | spn1| 101 | 01 | 101 | 'Y' |
3240 -- | 01 | 102 | 'Y' | 02
3241 -- | 01 | 103 | 'Y' | 04
3242 -- ASL: 02 | I1 | s1 | spn1| 102 | 02 | 102 | 'N' |
3243 -- ASL: 03 | I1 | s1 | spn2| 102 | 03 | 102 | 'N' |
3244 -- ASL: 04 | I1 | s1 | spn1| 103 | 04 | 102 | 'N' |
3245 --
3246 FUNCTION findItemRecord RETURN PLS_INTEGER
3247 -- CACHE_PRICE_MATCH, CACHE_MATCH, PRICE_MATCH, ITEM_MATCH, NEW_ITEM, NEW_GA_ITEM
3248 IS
3249 xErrLoc PLS_INTEGER := 100;
3250 xItem tItemRecord;
3251 xFoundItemCur tFoundItemCursor;
3252 xFoundItem tFoundItemRecord;
3253 xStatus PLS_INTEGER := NULL_NUMBER;
3254 xRtItemId NUMBER;
3255 BEGIN
3256 xErrLoc := 100;
3257 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
3258 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
3259 'Enter findItemRecord()');
3260 END IF;
3261
3262 -- Check if Category/Template Header is extracted
3263 IF (gCurrentPrice.document_type <> GLOBAL_AGREEMENT_TYPE AND
3264 gCurrentPrice.primary_category_id IS NULL)
3265 THEN
3266 gCurrentPrice.status := ICX_POR_EXT_DIAG.CATEGORY_NOT_EXTRACTED;
3267 ELSIF (gCurrentPrice.document_type IN (TEMPLATE_TYPE,
3268 INTERNAL_TEMPLATE_TYPE) AND
3269 gCurrentPrice.template_category_id IS NULL)
3270 THEN
3271 IF gCurrentPrice.status = ICX_POR_EXT_DIAG.VALID_FOR_EXTRACT THEN
3272 -- Don't set template line last run date so that after classification
3273 -- extraction is run, this template line will still be picked up.
3274 gSetTemplateLastRunDate := FALSE;
3275 END IF;
3276 gCurrentPrice.status := ICX_POR_EXT_DIAG.TEMPLATE_HEADER_NOT_EXTRACTED;
3277 END IF;
3278
3279 IF ICX_POR_EXT_DIAG.isValidExtPrice(
3280 gCurrentPrice.document_type, gCurrentPrice.status,
3281 ICX_POR_EXTRACTOR.gLoaderValue.load_contracts,
3282 ICX_POR_EXTRACTOR.gLoaderValue.load_template_lines,
3283 ICX_POR_EXTRACTOR.gLoaderValue.load_item_master,
3284 ICX_POR_EXTRACTOR.gLoaderValue.load_internal_item) = 0
3285 THEN
3286 xErrLoc := 150;
3287 -- Report analysis message here
3288 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.ANLYS_LEVEL THEN
3289 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.ANLYS_LEVEL,
3290 getPriceReport);
3291 END IF;
3292 RETURN DELETE_PRICE;
3293 END IF;
3294
3295 -- Check cache
3296 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3297 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3298 'Check from cache');
3299 END IF;
3300 xItem.org_id := gCurrentPrice.org_id;
3301 xItem.internal_item_id := gCurrentPrice.internal_item_id;
3302 xItem.internal_item_num := gCurrentPrice.internal_item_num;
3303 xItem.supplier_id := gCurrentPrice.supplier_id;
3304 xItem.supplier := gCurrentPrice.supplier;
3305 xItem.supplier_part_num := gCurrentPrice.supplier_part_num;
3306 IF (gCurrentPrice.internal_item_id = NULL_NUMBER AND
3307 (gCurrentPrice.supplier_id = NULL_NUMBER OR
3308 gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER)))
3309 THEN
3310 xItem.contract_line_id := gCurrentPrice.contract_line_id;
3311 ELSE
3312 xItem.contract_line_id := NULL_NUMBER;
3313 END IF;
3314 xItem.rt_item_id := NULL_NUMBER;
3315 xItem.hash_value := NULL_NUMBER;
3316
3317 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3318 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3319 snapShotItemRecord(xItem));
3320 END IF;
3321
3322 xErrLoc := 200;
3323 IF findItemCache(xItem) THEN
3324 xErrLoc := 200;
3325 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3326 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3327 'found from cache: ' || snapShotItemRecord(xItem));
3328 END IF;
3329 gCurrentPrice.rt_item_id := xItem.rt_item_id;
3330 xErrLoc := 220;
3331 xStatus := CACHE_MATCH;
3332 END IF;
3333
3334 xErrLoc := 300;
3335 -- Check item record associated with price row
3336 IF (gCurrentPrice.price_rt_item_id IS NOT NULL AND
3337 ((gCurrentPrice.internal_item_id <> NULL_NUMBER AND
3338 -- inventory item
3339 gCurrentPrice.internal_item_id = gCurrentPrice.price_internal_item_id AND
3340 gCurrentPrice.supplier_id = gCurrentPrice.price_supplier_id AND
3341 gCurrentPrice.supplier_part_num = gCurrentPrice.price_supplier_part_num) OR
3342 (gCurrentPrice.internal_item_id = NULL_NUMBER AND
3343 -- one-time item
3344 gCurrentPrice.supplier_id = gCurrentPrice.price_supplier_id AND
3345 gCurrentPrice.supplier_part_num = gCurrentPrice.price_supplier_part_num AND
3346 (gCurrentPrice.supplier_id <> NULL_NUMBER AND
3347 gCurrentPrice.supplier_part_num<> TO_CHAR(NULL_NUMBER) OR
3348 (gCurrentPrice.contract_line_id <> NULL_NUMBER AND
3349 gCurrentPrice.contract_line_id = gCurrentPrice.price_contract_line_id)))))
3350 THEN
3351 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3352 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3353 'Old item record is matched with the price row');
3354 END IF;
3355 xErrLoc := 340;
3356 gCurrentPrice.rt_item_id := gCurrentPrice.price_rt_item_id;
3357
3358 IF xStatus = CACHE_MATCH THEN
3359 xStatus := CACHE_PRICE_MATCH;
3360 ELSE
3361 xStatus := PRICE_MATCH;
3362 END IF;
3363 END IF;
3364
3365 IF (xStatus = NULL_NUMBER) THEN
3366 xErrLoc := 400;
3367 -- One-time item with null supplier or spn, only template can have
3368 -- this situation. We always create new item for this.
3369 -- pcreddy : Bug # 3213218
3370 IF (gCurrentPrice.internal_item_id = NULL_NUMBER AND
3371 gCurrentPrice.document_type = TEMPLATE_TYPE AND
3372 (gCurrentPrice.supplier IS NULL OR
3373 gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER)))
3374 THEN
3375 xErrLoc := 620;
3376 SELECT icx_por_itemid.nextval
3377 INTO xRtItemId
3378 FROM dual;
3379 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3380 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3381 'Create new rt_item_id: ' || xRtItemId);
3382 END IF;
3383 xErrLoc := 640;
3384 gCurrentPrice.rt_item_id := xRtItemId;
3385 RETURN NEW_ITEM;
3386 END IF;
3387
3388 -- check the database
3389 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3390 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3391 'Check from database');
3392 END IF;
3393
3394 -- Construct query to search database
3395 xFoundItemCur := openItemCursor;
3396
3397 xErrLoc := 420;
3398 FETCH xFoundItemCur INTO xFoundItem;
3399 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3400 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3401 'xFoundItem[rt_item_id: ' || xFoundItem.rt_item_id ||
3402 ', primary_category_id: ' || xFoundItem.primary_category_id ||
3403 ', match_template_flag: ' || xFoundItem.match_template_flag ||
3404 ']');
3405 END IF;
3406
3407 xErrLoc := 440;
3408 -- Do NOT reclaim rt_item_id of purchasing items and bulkloaded items.
3409 -- 1. If multiple documents refer same inventory item, one of them
3410 -- gets the rt_item_id of purchasing item. If that document is
3411 -- expired, it is hard to relocate the rt_item_id.
3412 -- 2. If multiple documents refer same supplier/supplier part num,
3413 -- one of them gets the rt_item_id of bulkloaded item. If that
3414 -- document is expired, it is hard to relocate the rt_item_id.
3415
3416 -- Found database match
3417 IF xFoundItem.rt_item_id IS NOT NULL THEN
3418 xErrLoc := 520;
3419 gCurrentPrice.rt_item_id := xFoundItem.rt_item_id;
3420 gCurrentPrice.match_primary_category_id := xFoundItem.primary_category_id;
3421 gCurrentPrice.match_template_flag := xFoundItem.match_template_flag;
3422
3423 IF (xFoundItem.primary_category_id <> NULL_NUMBER OR
3424 gCurrentPrice.document_type = GLOBAL_AGREEMENT_TYPE)
3425 THEN
3426 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3427 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3428 'Find matched item record from database: ' ||
3429 gCurrentPrice.rt_item_id);
3430 END IF;
3431 xErrLoc := 540;
3432 xStatus := ITEM_MATCH;
3433 ELSE
3434 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3435 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3436 'Find matched local item record with global agreement from database: ' ||
3437 gCurrentPrice.rt_item_id);
3438 END IF;
3439 xErrLoc := 560;
3440 -- We reuse local_rt_item_id from global agreement, but still need
3441 -- to create all item records, so we have NEW_GA_ITEM status
3442 xStatus := NEW_GA_ITEM;
3443 END IF;
3444 ELSE
3445 xErrLoc := 600;
3446 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3447 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3448 'Item record not found');
3449 END IF;
3450
3451 xErrLoc := 620;
3452 SELECT icx_por_itemid.nextval
3453 INTO xRtItemId
3454 FROM dual;
3455 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3456 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3457 'Create new rt_item_id: ' || xRtItemId);
3458 END IF;
3459 xErrLoc := 640;
3460 gCurrentPrice.rt_item_id := xRtItemId;
3461 xStatus := NEW_ITEM;
3462 END IF;
3463
3464 END IF;
3465
3466 xErrLoc := 700;
3467 IF xStatus NOT IN (CACHE_MATCH, CACHE_PRICE_MATCH) THEN
3468 xItem.rt_item_id := gCurrentPrice.rt_item_id;
3469 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3470 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3471 'Put item into cache: ' || snapShotItemRecord(xItem));
3472 END IF;
3473 putItemCache(xItem);
3474 END IF;
3475
3476 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
3477 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
3478 'Leave findItemRecord()');
3479 END IF;
3480 RETURN xStatus;
3481 EXCEPTION
3482 when ICX_POR_EXT_UTL.gException then
3483 -- rollback;
3484 ICX_POR_EXT_UTL.extRollback;
3485
3486 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM-findItemRecord-'||
3487 xErrLoc);
3488 raise ICX_POR_EXT_UTL.gException;
3489 when others then
3490 -- rollback;
3491 ICX_POR_EXT_UTL.extRollback;
3492
3493 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM-findItemRecord-'||
3494 xErrLoc||' '||SQLERRM);
3495 ICX_POR_EXT_UTL.pushError(snapShotPriceRow);
3496 raise ICX_POR_EXT_UTL.gException;
3497 END findItemRecord;
3498
3499 --------------------------------------------------------------
3500 -- Process Updated Price Rows Procedures --
3501 --------------------------------------------------------------
3502 PROCEDURE updateItemPrices IS
3503 xErrLoc PLS_INTEGER := 100;
3504 xIndex PLS_INTEGER := 0;
3505 BEGIN
3506 xErrLoc := 100;
3507 gTransactionCount := gTransactionCount + 1;
3508 xIndex := gUPRtItemIds.COUNT + 1;
3509 gUPRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3510 gUPPriceTypes(xIndex) := gCurrentPrice.price_type;
3511 gUPAslIds(xIndex) := gCurrentPrice.asl_id;
3512 gUPSupplierSiteIds(xIndex) := gCurrentPrice.supplier_site_id;
3513 gUPContractIds(xIndex) := gCurrentPrice.contract_id;
3514 gUPContractLineIds(xIndex) := gCurrentPrice.contract_line_id;
3515 gUPTemplateIds(xIndex) := gCurrentPrice.template_id;
3516 gUPTemplateLineIds(xIndex) := gCurrentPrice.template_line_id;
3517 gUPInventoryItemIds(xIndex) := gCurrentPrice.internal_item_id;
3518 gUPMtlCategoryIds(xIndex) := gCurrentPrice.mtl_category_id;
3519 gUPOrgIds(xIndex) := gCurrentPrice.org_id;
3520 gUPSearchTypes(xIndex) := gCurrentPrice.price_search_type;
3521 gUPUnitPrices(xIndex) := gCurrentPrice.unit_price;
3522 --FPJ FPSL Extractor Changes
3523 gUPValueBasis(xIndex) := gCurrentPrice.value_basis;
3524 gUPPurchaseBasis(xIndex) := gCurrentPrice.purchase_basis;
3525 gUPAllowPriceOverrideFlag(xIndex) := gCurrentPrice.allow_price_override_flag;
3526 gUPNotToExceedPrice(xIndex) := gCurrentPrice.not_to_exceed_price;
3527 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
3528 gUPSuggestedQuantities(xIndex) := gCurrentPrice.suggested_quantity;
3529 -- FPJ Bug# 3110297 jingyu Add negotiated flag
3530 gUPNegotiatedFlag(xIndex) := gCurrentPrice.negotiated_by_preparer_flag;
3531 gUPCurrencys(xIndex) := gCurrentPrice.currency;
3532 gUPUnitOfMeasures(xIndex) := gCurrentPrice.unit_of_measure;
3533 gUPFunctionalPrices(xIndex) := gCurrentPrice.functional_price;
3534 gUPSupplierSiteCodes(xIndex) := gCurrentPrice.supplier_site_code;
3535 gUPContractNums(xIndex) := gCurrentPrice.contract_num;
3536 gUPContractLineNums(xIndex) := gCurrentPrice.contract_line_num;
3537 gUpRateTypes(xIndex) := gCurrentPrice.rate_type;
3538 gUpRateDates(xIndex) := gCurrentPrice.rate_date;
3539 gUpRates(xIndex) := gCurrentPrice.rate;
3540 gUpSupplierNumbers(xIndex) := gCurrentPrice.supplier_number;
3541 gUpSupplierContactIds(xIndex) := gCurrentPrice.supplier_contact_id;
3542 gUpItemRevisions(xIndex) := gCurrentPrice.item_revision;
3543 gUpLineTypeIds(xIndex) := gCurrentPrice.line_type_id;
3544 gUpBuyerIds(xIndex) := gCurrentPrice.buyer_id;
3545 gUPPriceRowIds(xIndex) := gCurrentPrice.price_rowid;
3546 gUPActiveFlags(xIndex) := gCurrentPrice.active_flag;
3547 gUPLastUpdateDates(xIndex) := gCurrentPrice.last_update_date;
3548
3549 xErrLoc := 300;
3550 IF gCurrentPrice.global_agreement_flag = 'Y' THEN
3551 gTransactionCount := gTransactionCount + 1;
3552 xIndex := gUPGRtItemIds.COUNT + 1;
3553 gUPGRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3554 gUPGContractIds(xIndex) := gCurrentPrice.contract_id;
3555 gUPGContractLineIds(xIndex) := gCurrentPrice.contract_line_id;
3556 gUPGInventoryItemIds(xIndex) := gCurrentPrice.internal_item_id;
3557 gUPGMtlCategoryIds(xIndex) := gCurrentPrice.mtl_category_id;
3558 gUPGSearchTypes(xIndex) := gCurrentPrice.price_search_type;
3559 gUPGUnitPrices(xIndex) := gCurrentPrice.unit_price;
3560 --FPJ FPSL Extractor Changes
3561 gUPGValueBasis(xIndex) := gCurrentPrice.value_basis;
3562 gUPGPurchaseBasis(xIndex) := gCurrentPrice.purchase_basis;
3563 gUPGAllowPriceOverrideFlag(xIndex) := gCurrentPrice.allow_price_override_flag;
3564 gUPGNotToExceedPrice(xIndex) := gCurrentPrice.not_to_exceed_price;
3565 -- FPJ Bug# 3110297 jingyu Add negotiated flag
3566 gUPGNegotiatedFlag(xIndex) := gCurrentPrice.negotiated_by_preparer_flag;
3567 gUPGLineTypeIds(xIndex) := gCurrentPrice.line_type_id;
3568 gUPGCurrencys(xIndex) := gCurrentPrice.currency;
3569 gUPGUnitOfMeasures(xIndex) := gCurrentPrice.unit_of_measure;
3570 gUPGFunctionalPrices(xIndex) := gCurrentPrice.functional_price;
3571 END IF;
3572
3573 xErrLoc := 400;
3574 EXCEPTION
3575 when others then
3576 ICX_POR_EXT_UTL.extRollback;
3577 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.updateItemPrices-'||
3578 xErrLoc||' '||SQLERRM);
3579 raise ICX_POR_EXT_UTL.gException;
3580 END updateItemPrices;
3581
3582 PROCEDURE insertItemPrices IS
3583 xErrLoc PLS_INTEGER := 100;
3584 xIndex PLS_INTEGER := 0;
3585 BEGIN
3586 xErrLoc := 100;
3587 gTransactionCount := gTransactionCount + 1;
3588 xIndex := gIPRtItemIds.COUNT + 1;
3589 gIPRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3590 gIPPriceTypes(xIndex) := gCurrentPrice.price_type;
3591 gIPAslIds(xIndex) := gCurrentPrice.asl_id;
3592 gIPSupplierSiteIds(xIndex) := gCurrentPrice.supplier_site_id;
3593 gIPContractIds(xIndex) := gCurrentPrice.contract_id;
3594 gIPContractLineIds(xIndex) := gCurrentPrice.contract_line_id;
3595 gIPTemplateIds(xIndex) := gCurrentPrice.template_id;
3596 gIPTemplateLineIds(xIndex) := gCurrentPrice.template_line_id;
3597 gIPInventoryItemIds(xIndex) := gCurrentPrice.internal_item_id;
3598 gIPMtlCategoryIds(xIndex) := gCurrentPrice.mtl_category_id;
3599 gIPOrgIds(xIndex) := gCurrentPrice.org_id;
3600 gIPSearchTypes(xIndex) := gCurrentPrice.price_search_type;
3601 gIPUnitPrices(xIndex) := gCurrentPrice.unit_price;
3602 --FPJ FPSL Extractor Changes
3603 gIPValueBasis(xIndex) := gCurrentPrice.value_basis;
3604 gIPPurchaseBasis(xIndex) := gCurrentPrice.purchase_basis;
3605 gIPAllowPriceOverrideFlag(xIndex) := gCurrentPrice.allow_price_override_flag;
3606 gIPNotToExceedPrice(xIndex) := gCurrentPrice.not_to_exceed_price;
3607 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
3608 gIPSuggestedQuantities(xIndex) := gCurrentPrice.suggested_quantity;
3609 -- FPJ Bug# 3110297 jingyu Add negotiated flag
3610 gIPNegotiatedFlag(xIndex) := gCurrentPrice.negotiated_by_preparer_flag;
3611 gIPCurrencys(xIndex) := gCurrentPrice.currency;
3612 gIPUnitOfMeasures(xIndex) := gCurrentPrice.unit_of_measure;
3613 gIPFunctionalPrices(xIndex) := gCurrentPrice.functional_price;
3614 gIPSupplierSiteCodes(xIndex) := gCurrentPrice.supplier_site_code;
3615 gIPContractNums(xIndex) := gCurrentPrice.contract_num;
3616 gIPContractLineNums(xIndex) := gCurrentPrice.contract_line_num;
3617 gIPRateTypes(xIndex) := gCurrentPrice.rate_type;
3618 gIPRateDates(xIndex) := gCurrentPrice.rate_date;
3619 gIPRates(xIndex) := gCurrentPrice.rate;
3620 gIPSupplierNumbers(xIndex) := gCurrentPrice.supplier_number;
3621 gIPSupplierContactIds(xIndex) := gCurrentPrice.supplier_contact_id;
3622 gIPItemRevisions(xIndex) := gCurrentPrice.item_revision;
3623 gIPLineTypeIds(xIndex) := gCurrentPrice.line_type_id;
3624 gIPBuyerIds(xIndex) := gCurrentPrice.buyer_id;
3625 gIPActiveFlags(xIndex) := gCurrentPrice.active_flag;
3626 gIPLastUpdateDates(xIndex) := gCurrentPrice.last_update_date;
3627
3628 xErrLoc := 400;
3629 EXCEPTION
3630 when others then
3631 ICX_POR_EXT_UTL.extRollback;
3632 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.insertItemPrices-'||
3633 xErrLoc||' '||SQLERRM);
3634 raise ICX_POR_EXT_UTL.gException;
3635 END insertItemPrices;
3636
3637 PROCEDURE insertItemsB IS
3638 xErrLoc PLS_INTEGER := 100;
3639 xIndex PLS_INTEGER := 0;
3640 BEGIN
3641 xErrLoc := 100;
3642 gTransactionCount := gTransactionCount + 1;
3643 xIndex := gIBRtItemIds.COUNT + 1;
3644 gIBRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3645 gIBOrgIds(xIndex) := gCurrentPrice.org_id;
3646 gIBSuppliers(xIndex) := gCurrentPrice.supplier;
3647 gIBSupplierIds(xIndex) := gCurrentPrice.supplier_id;
3648 IF gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER) THEN
3649 gIBSupplierPartNums(xIndex) := NULL;
3650 ELSE
3651 gIBSupplierPartNums(xIndex) := gCurrentPrice.supplier_part_num;
3652 END IF;
3653 IF gCurrentPrice.internal_item_id = NULL_NUMBER THEN
3654 gIBInternalItemIds(xIndex) := NULL;
3655 ELSE
3656 gIBInternalItemIds(xIndex) := gCurrentPrice.internal_item_id;
3657 END IF;
3658 gIBInternalItemNums(xIndex) := gCurrentPrice.internal_item_num;
3659
3660 xErrLoc := 400;
3661 EXCEPTION
3662 when others then
3663 ICX_POR_EXT_UTL.extRollback;
3664 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.insertItemsB-'||
3665 xErrLoc||' '||SQLERRM);
3666 raise ICX_POR_EXT_UTL.gException;
3667 END insertItemsB;
3668
3669 PROCEDURE updateItemsB IS
3670 xErrLoc PLS_INTEGER := 100;
3671 xIndex PLS_INTEGER := 0;
3672 BEGIN
3673 xErrLoc := 100;
3674 gTransactionCount := gTransactionCount + 1;
3675
3676 xErrLoc := 200;
3677 xIndex := gUBRtItemIds.COUNT + 1;
3678 gUBRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3679 gUBInternalItemNums(xIndex) := gCurrentPrice.internal_item_num;
3680 gUBExtractorUpdatedFlags(xIndex) := 'Y';
3681 gUBJobNumbers(xIndex) := ICX_POR_EXTRACTOR.gJobNum;
3682 xErrLoc := 400;
3683 EXCEPTION
3684 when others then
3685 ICX_POR_EXT_UTL.extRollback;
3686 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.updateItemsB-'||
3687 xErrLoc||' '||SQLERRM);
3688 raise ICX_POR_EXT_UTL.gException;
3689 END updateItemsB;
3690
3691 PROCEDURE insertItemsTLP IS
3692 xString VARCHAR2(2000);
3693 cTranslations tCursorType;
3694 xCategoryName ICX_CAT_ITEMS_TLP.primary_category_name%TYPE;
3695 xDescription ICX_CAT_ITEMS_TLP.description%TYPE;
3696 xLanguage ICX_CAT_ITEMS_TLP.language%TYPE;
3697 xErrLoc PLS_INTEGER := 100;
3698 xIndex PLS_INTEGER := 0;
3699
3700 BEGIN
3701 xErrLoc := 100;
3702 IF gCurrentPrice.internal_item_id <> NULL_NUMBER THEN
3703 -- Docuements with inventory Items
3704 xErrLoc := 200;
3705 xString :=
3706 'SELECT m.description, ' ||
3707 'm.language, ' ||
3708 'ctl.category_name ';
3709 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
3710 xString := xString ||
3711 'FROM imtl_system_items_tl m, ';
3712 ELSE
3713 xString := xString ||
3714 'FROM mtl_system_items_tl m, ';
3715 END IF;
3716 xString := xString || 'icx_cat_categories_tl ctl ';
3717 --Bug#3004696: language=source_lan is necessary so that
3718 -- only translated items are extracted. pseudo translated items
3719 -- are not extracted. e.g. Item created in english, but rows get added to
3720 -- other installed langs. extract the item only in english
3721 xString := xString ||
3722 'WHERE m.inventory_item_id = :internal_item_id ' ||
3723 'AND m.organization_id = :inventory_organization_id ' ||
3724 'AND ctl.rt_category_id = :ctl_category_id ' ||
3725 'AND ctl.language = m.language ' ||
3726 'AND m.language = m.source_lang ' ||
3727 'AND m.language IN (SELECT language_code ' ||
3728 'FROM fnd_languages ' ||
3729 'WHERE installed_flag IN (''B'', ''I'')) ';
3730
3731 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3732 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3733 'Query for translation: ' || xString);
3734 END IF;
3735
3736 xErrLoc := 200;
3737 OPEN cTranslations FOR xString
3738 USING gCurrentPrice.internal_item_id,
3739 gCurrentPrice.inventory_organization_id,
3740 gCurrentPrice.primary_category_id;
3741
3742 LOOP
3743 FETCH cTranslations INTO xDescription, xLanguage,
3744 xCategoryName;
3745 EXIT WHEN cTranslations%NOTFOUND;
3746
3747
3748 xErrLoc := 240;
3749 gTransactionCount := gTransactionCount + 1;
3750 xIndex := gITRtItemIds.COUNT + 1;
3751 gITRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3752 gITLanguages(xIndex) := xLanguage;
3753
3754 gITOrgIds(xIndex) := gCurrentPrice.org_id;
3755 gITItemSourceTypes(xIndex) := gCurrentPrice.item_source_type;
3756 gITSearchTypes(xIndex) := gCurrentPrice.item_search_type;
3757 gITPrimaryCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
3758 gITPrimaryCategoryNames(xIndex) := xCategoryName;
3759 gITInternalItemNums(xIndex) := gCurrentPrice.internal_item_num;
3760 gITSuppliers(xIndex) := gCurrentPrice.supplier;
3761 gITSupplierIds(xIndex) := gCurrentPrice.supplier_id;
3762 IF gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER) THEN
3763 gITSupplierPartNums(xIndex) := NULL;
3764 ELSE
3765 gITSupplierPartNums(xIndex) := gCurrentPrice.supplier_part_num;
3766 END IF;
3767 IF gCurrentPrice.internal_item_id = NULL_NUMBER THEN
3768 gITInternalItemIds(xIndex) := NULL;
3769 ELSE
3770 gITInternalItemIds(xIndex) := gCurrentPrice.internal_item_id;
3771 END IF;
3772 IF (gCurrentPrice.document_type NOT IN (PURCHASING_ITEM_TYPE,
3773 INTERNAL_ITEM_TYPE)
3774 /*Bug#5909923 Start - Wrong description shown for installed langauge*/
3775 -- AND xLanguage = ICX_POR_EXTRACTOR.gBaseLang
3776 /*Bug#5909923 End*/
3777 )
3778 THEN
3779 -- Purchasing/Internal Template, Contract, ASL
3780 xDescription := gCurrentPrice.description;
3781 END IF;
3782 gITDescriptions(xIndex) := xDescription;
3783 gITPictures(xIndex) := gCurrentPrice.picture;
3784 gITPictureURLs(xIndex) := gCurrentPrice.picture_url;
3785 gITManufacturers(xIndex) := gCurrentPrice.manufacturer;
3786 gITManufacturerPartNums(xIndex) := gCurrentPrice.manufacturer_part_num;
3787 END LOOP;
3788 xErrLoc := 280;
3789 CLOSE cTranslations;
3790 ELSE
3791 -- One-time items
3792 xErrLoc := 300;
3793 -- Bug # 3991430
3794 -- New column is added in the ICX_POR_LOADER_VALUES table to extract one time item in all the installed languages
3795 xString := 'SELECT language_code ' || 'FROM fnd_languages ' || 'WHERE installed_flag IN (''B''';
3796
3797 IF ICX_POR_EXTRACTOR.gLoaderValue.load_onetimeitems_all_langs = 'Y' THEN
3798 xString := xString || ', ''I'')';
3799 ELSE
3800 xString := xString || ')';
3801 END IF;
3802 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3803 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3804 'Query for translation : ' || xString);
3805 END IF;
3806 OPEN cTranslations FOR xString;
3807 LOOP
3808 FETCH cTranslations INTO xLanguage;
3809 EXIT WHEN cTranslations%NOTFOUND;
3810
3811 gTransactionCount := gTransactionCount + 1;
3812 xIndex := gITRtItemIds.COUNT + 1;
3813 gITRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3814 gITLanguages(xIndex) := xLanguage; -- ICX_POR_EXTRACTOR.gBaseLang;
3815 gITOrgIds(xIndex) := gCurrentPrice.org_id;
3816 gITItemSourceTypes(xIndex) := gCurrentPrice.item_source_type;
3817 gITSearchTypes(xIndex) := gCurrentPrice.item_search_type;
3818 gITPrimaryCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
3819 gITPrimaryCategoryNames(xIndex) := gCurrentPrice.primary_category_name;
3820 gITInternalItemNums(xIndex) := gCurrentPrice.internal_item_num;
3821 gITSuppliers(xIndex) := gCurrentPrice.supplier;
3822 gITSupplierIds(xIndex) := gCurrentPrice.supplier_id;
3823 IF gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER) THEN
3824 gITSupplierPartNums(xIndex) := NULL;
3825 ELSE
3826 gITSupplierPartNums(xIndex) := gCurrentPrice.supplier_part_num;
3827 END IF;
3828 gITInternalItemIds(xIndex) := NULL;
3829 gITDescriptions(xIndex) := gCurrentPrice.description;
3830 gITPictures(xIndex) := gCurrentPrice.picture;
3831 gITPictureURLs(xIndex) := gCurrentPrice.picture_url;
3832 gITManufacturers(xIndex) := gCurrentPrice.manufacturer;
3833 gITManufacturerPartNums(xIndex) := gCurrentPrice.manufacturer_part_num;
3834 END LOOP;
3835 xErrLoc := 320;
3836 CLOSE cTranslations;
3837 -- End of Bug # 3991430
3838 END IF;
3839 xErrLoc := 400;
3840 EXCEPTION
3841 when others then
3842 ICX_POR_EXT_UTL.extRollback;
3843 IF (cTranslations%ISOPEN) THEN
3844 CLOSE cTranslations;
3845 END IF;
3846
3847 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.insertItemsTLP-'||
3848 xErrLoc||' '||SQLERRM);
3849 raise ICX_POR_EXT_UTL.gException;
3850 END insertItemsTLP;
3851
3852 PROCEDURE updateItemsTLP IS
3853 xString VARCHAR2(2000);
3854 cTranslations tCursorType;
3855 xDescription ICX_CAT_ITEMS_TLP.description%TYPE;
3856 xLanguage ICX_CAT_ITEMS_TLP.language%TYPE;
3857 xCategoryName ICX_CAT_ITEMS_TLP.primary_category_name%TYPE;
3858 xRtItemId NUMBER;
3859 xErrLoc PLS_INTEGER := 100;
3860 xIndex PLS_INTEGER := 0;
3861 BEGIN
3862 xErrLoc := 100;
3863 IF gCurrentPrice.internal_item_id <> NULL_NUMBER THEN
3864 -- Docuements with inventory Items
3865 xErrLoc := 150;
3866 xString :=
3867 'SELECT m.description, ' ||
3868 'm.language, ' ||
3869 'ctl.category_name, ' ||
3870 't.rt_item_id ';
3871 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
3872 xString := xString ||
3873 'FROM imtl_system_items_tl m, ';
3874 ELSE
3875 xString := xString ||
3876 'FROM mtl_system_items_tl m, ' ;
3877 END IF;
3878
3879 xString := xString || 'icx_cat_categories_tl ctl, ';
3880 --Bug#3004696: language=source_lan is necessary so that
3881 -- only translated items are extracted. pseudo translated items
3882 -- are not extracted. e.g. Item created in english, but rows get added to
3883 -- other installed langs. extract the item only in english
3884 xString := xString ||
3885 'icx_cat_items_tlp t ' ||
3886 'WHERE m.inventory_item_id = :internal_item_id ' ||
3887 'AND m.organization_id = :inventory_organization_id ' ||
3888 'AND ctl.rt_category_id = :ctl_category_id ' ||
3889 'AND ctl.language = m.language ' ||
3890 'AND m.language = m.source_lang ' ||
3891 'AND m.language IN (SELECT language_code ' ||
3892 'FROM fnd_languages ' ||
3893 'WHERE installed_flag IN (''B'', ''I'')) ' ||
3894 'AND m.language = t.language (+) ' ||
3895 'AND t.rt_item_id (+) = :rt_item_id';
3896
3897 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3898 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3899 'Query for translation: ' || xString);
3900 END IF;
3901
3902 xErrLoc := 200;
3903 OPEN cTranslations FOR xString
3904 USING gCurrentPrice.internal_item_id,
3905 gCurrentPrice.inventory_organization_id,
3906 gCurrentPrice.primary_category_id,
3907 gCurrentPrice.rt_item_id;
3908
3909 LOOP
3910 FETCH cTranslations INTO xDescription, xLanguage, xCategoryName, xRtItemId;
3911 EXIT WHEN cTranslations%NOTFOUND;
3912
3913 xErrLoc := 210;
3914 IF (xRtItemId IS NULL) THEN
3915 -- No such translation exists
3916 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3917 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3918 'No translation for ' || xLanguage);
3919 END IF;
3920 xErrLoc := 220;
3921 gTransactionCount := gTransactionCount + 1;
3922 xIndex := gITRtItemIds.COUNT + 1;
3923 gITRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3924 gITLanguages(xIndex) := xLanguage;
3925 gITOrgIds(xIndex) := gCurrentPrice.org_id;
3926 gITItemSourceTypes(xIndex) := gCurrentPrice.item_source_type;
3927 gITSearchTypes(xIndex) := gCurrentPrice.item_search_type;
3928 gITPrimaryCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
3929 gITPrimaryCategoryNames(xIndex) := xCategoryName;
3930 gITInternalItemNums(xIndex) := gCurrentPrice.internal_item_num;
3931 gITSuppliers(xIndex) := gCurrentPrice.supplier;
3932 gITSupplierIds(xIndex) := gCurrentPrice.supplier_id;
3933 IF gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER) THEN
3934 gITSupplierPartNums(xIndex) := NULL;
3935 ELSE
3936 gITSupplierPartNums(xIndex) := gCurrentPrice.supplier_part_num;
3937 END IF;
3938 IF gCurrentPrice.internal_item_id = NULL_NUMBER THEN
3939 gITInternalItemIds(xIndex) := NULL;
3940 ELSE
3941 gITInternalItemIds(xIndex) := gCurrentPrice.internal_item_id;
3942 END IF;
3943 gITDescriptions(xIndex) := xDescription;
3944 gITPictures(xIndex) := gCurrentPrice.picture;
3945 gITPictureURLs(xIndex) := gCurrentPrice.picture_url;
3946 gITManufacturers(xIndex) := gCurrentPrice.manufacturer;
3947 gITManufacturerPartNums(xIndex) := gCurrentPrice.manufacturer_part_num;
3948 ELSE
3949 xErrLoc := 240;
3950 gTransactionCount := gTransactionCount + 1;
3951 xIndex := gUTRtItemIds.COUNT + 1;
3952 gUTRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
3953 gUTLanguages(xIndex) := xLanguage;
3954 gUTItemSourceTypes(xIndex) := gCurrentPrice.item_source_type;
3955 gUTSearchTypes(xIndex) := gCurrentPrice.item_search_type;
3956 gUTPrimaryCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
3957 gUTPrimaryCategoryNames(xIndex) := xCategoryName;
3958 gUTInternalItemNums(xIndex) := gCurrentPrice.internal_item_num;
3959 IF (gCurrentPrice.document_type NOT IN (PURCHASING_ITEM_TYPE,
3960 INTERNAL_ITEM_TYPE) AND
3961 xLanguage = ICX_POR_EXTRACTOR.gBaseLang)
3962 THEN
3963 -- Purchasing/Internal Template, Contract, ASL
3964 xDescription := gCurrentPrice.description;
3965 END IF;
3966 gUTDescriptions(xIndex) := xDescription;
3967 gUTPictures(xIndex) := gCurrentPrice.picture;
3968 gUTPictureURLs(xIndex) := gCurrentPrice.picture_url;
3969 gUTManufacturers(xIndex) := gCurrentPrice.manufacturer;
3970 gUTManufacturerPartNums(xIndex) := gCurrentPrice.manufacturer_part_num;
3971 END IF;
3972 END LOOP;
3973 xErrLoc := 280;
3974 CLOSE cTranslations;
3975 ELSE
3976 -- One-time items
3977 -- Bug # 3991340
3978 xString := 'SELECT f.language_code, i.rt_item_id ' ||
3979 'FROM fnd_languages f, icx_cat_items_tlp i ' ||
3980 'WHERE ' ||
3981 'f.language_code = i.language(+) AND ' ||
3982 'i.rt_item_id(+) = :rt_item_id AND ' ||
3983 'f.installed_flag IN (''B''';
3984
3985 IF ICX_POR_EXTRACTOR.gLoaderValue.load_onetimeitems_all_langs = 'Y' THEN
3986 xString := xString || ', ''I'')';
3987 ELSE
3988 xString := xString || ')';
3989 END IF;
3990
3991 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
3992 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
3993 'Query for translation: ' || xString);
3994 END IF;
3995
3996 OPEN cTranslations FOR xString
3997 USING gCurrentPrice.rt_item_id;
3998
3999 LOOP
4000 FETCH cTranslations INTO xLanguage, xRtItemId;
4001 EXIT WHEN cTranslations%NOTFOUND;
4002
4003 IF (xRtItemId IS NULL) THEN
4004 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
4005 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
4006 'No translation for ' || xLanguage);
4007 END IF;
4008
4009 xErrLoc := 300;
4010 gTransactionCount := gTransactionCount + 1;
4011 xIndex := gITRtItemIds.COUNT + 1;
4012 gITRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4013 gITLanguages(xIndex) := xLanguage;
4014 gITOrgIds(xIndex) := gCurrentPrice.org_id;
4015 gITItemSourceTypes(xIndex) := gCurrentPrice.item_source_type;
4016 gITSearchTypes(xIndex) := gCurrentPrice.item_search_type;
4017 gITPrimaryCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4018 gITPrimaryCategoryNames(xIndex) := gCurrentPrice.primary_category_name;
4019 gITInternalItemNums(xIndex) := gCurrentPrice.internal_item_num;
4020 gITSuppliers(xIndex) := gCurrentPrice.supplier;
4021 gITSupplierIds(xIndex) := gCurrentPrice.supplier_id;
4022
4023 IF gCurrentPrice.supplier_part_num = TO_CHAR(NULL_NUMBER) THEN
4024 gITSupplierPartNums(xIndex) := NULL;
4025 ELSE
4026 gITSupplierPartNums(xIndex) := gCurrentPrice.supplier_part_num;
4027 END IF;
4028
4029 gITInternalItemIds(xIndex) := NULL;
4030 gITDescriptions(xIndex) := gCurrentPrice.description;
4031 gITPictures(xIndex) := gCurrentPrice.picture;
4032 gITPictureURLs(xIndex) := gCurrentPrice.picture_url;
4033 gITManufacturers(xIndex) := gCurrentPrice.manufacturer;
4034 gITManufacturerPartNums(xIndex) := gCurrentPrice.manufacturer_part_num;
4035 ELSE
4036 xErrLoc := 320;
4037 gTransactionCount := gTransactionCount + 1;
4038 xIndex := gUTRtItemIds.COUNT + 1;
4039 gUTRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4040 gUTLanguages(xIndex) := xLanguage; -- ICX_POR_EXTRACTOR.gBaseLang;
4041 gUTItemSourceTypes(xIndex) := gCurrentPrice.item_source_type;
4042 gUTSearchTypes(xIndex) := gCurrentPrice.item_search_type;
4043 gUTPrimaryCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4044 gUTPrimaryCategoryNames(xIndex) := gCurrentPrice.primary_category_name;
4045 gUTInternalItemNums(xIndex) := gCurrentPrice.internal_item_num;
4046 gUTDescriptions(xIndex) := gCurrentPrice.description;
4047 gUTPictures(xIndex) := gCurrentPrice.picture;
4048 gUTPictureURLs(xIndex) := gCurrentPrice.picture_url;
4049 gUTManufacturers(xIndex) := gCurrentPrice.manufacturer;
4050 gUTManufacturerPartNums(xIndex) := gCurrentPrice.manufacturer_part_num;
4051 END IF;
4052 END LOOP;
4053 CLOSE cTranslations;
4054 -- End of Bug # 3991340
4055 END IF;
4056 xErrLoc := 400;
4057 EXCEPTION
4058 when others then
4059 ICX_POR_EXT_UTL.extRollback;
4060 IF (cTranslations%ISOPEN) THEN
4061 CLOSE cTranslations;
4062 END IF;
4063 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.updateItemsTLP-'||
4064 xErrLoc||' '||SQLERRM);
4065 raise ICX_POR_EXT_UTL.gException;
4066 END updateItemsTLP;
4067
4068 -- bug 2925403
4069 PROCEDURE insertExtItemsTLP IS
4070 xString VARCHAR2(2000);
4071 cTranslations tCursorType;
4072 xLanguage ICX_CAT_ITEMS_TLP.language%TYPE;
4073 xErrLoc PLS_INTEGER := 100;
4074 xIndex PLS_INTEGER := 0;
4075
4076 BEGIN
4077 xErrLoc := 100;
4078 IF gCurrentPrice.internal_item_id <> NULL_NUMBER THEN
4079 -- Docuements with inventory Items
4080 xErrLoc := 150;
4081 xString :=
4082 'SELECT m.language ';
4083 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
4084 xString := xString ||
4085 'FROM imtl_system_items_tl m ';
4086 ELSE
4087 xString := xString ||
4088 'FROM mtl_system_items_tl m ';
4089 END IF;
4090
4091 --Bug#3004696: language=source_lan is necessary so that
4092 -- only translated items are extracted. pseudo translated items
4093 -- are not extracted. e.g. Item created in english, but rows get added to
4094 -- other installed langs. extract the item only in english
4095 xString := xString ||
4096 'WHERE m.inventory_item_id = :internal_item_id ' ||
4097 'AND m.organization_id = :inventory_organization_id ' ||
4098 'AND m.language = m.source_lang ' ||
4099 'AND m.language IN (SELECT language_code ' ||
4100 'FROM fnd_languages ' ||
4101 'WHERE installed_flag IN (''B'', ''I'')) ';
4102
4103 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
4104 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
4105 'Query for translation: ' || xString);
4106 END IF;
4107
4108 xErrLoc := 200;
4109 OPEN cTranslations FOR xString
4110 USING gCurrentPrice.internal_item_id,
4111 gCurrentPrice.inventory_organization_id;
4112
4113 LOOP
4114 FETCH cTranslations INTO xLanguage;
4115 EXIT WHEN cTranslations%NOTFOUND;
4116
4117 xErrLoc := 240;
4118 gTransactionCount := gTransactionCount + 1;
4119 xIndex := gIERtItemIds.COUNT + 1;
4120 gIERtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4121 gIELanguages(xIndex) := xLanguage;
4122 gIEOrgIds(xIndex) := gCurrentPrice.org_id;
4123 gIERtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4124 END LOOP;
4125 xErrLoc := 280;
4126 CLOSE cTranslations;
4127 ELSE
4128 -- One-time items
4129 -- Bug # 3991340
4130
4131 xString :=
4132 'SELECT language_code ' ||
4133 'FROM fnd_languages ' ||
4134 'WHERE installed_flag IN (''B''';
4135
4136 IF ICX_POR_EXTRACTOR.gLoaderValue.load_onetimeitems_all_langs = 'Y' THEN
4137 xString := xString || ', ''I'')';
4138 ELSE
4139 xString := xString || ')';
4140 END IF;
4141 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
4142 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
4143 'Query for translation: ' || xString);
4144 END IF;
4145 OPEN cTranslations FOR xString;
4146 LOOP
4147 FETCH cTranslations INTO xLanguage;
4148 EXIT WHEN cTranslations%NOTFOUND;
4149 xErrLoc := 300;
4150 gTransactionCount := gTransactionCount + 1;
4151 xIndex := gIERtItemIds.COUNT + 1;
4152 gIERtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4153 gIELanguages(xIndex) := xLanguage; -- ICX_POR_EXTRACTOR.gBaseLang;
4154 gIEOrgIds(xIndex) := gCurrentPrice.org_id;
4155 gIERtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4156 END LOOP;
4157 xErrLoc := 320;
4158 CLOSE cTranslations;
4159 -- End Bug # 3991340
4160 END IF;
4161
4162 xErrLoc := 400;
4163 EXCEPTION
4164 when others then
4165 ICX_POR_EXT_UTL.extRollback;
4166 IF (cTranslations%ISOPEN) THEN
4167 CLOSE cTranslations;
4168 END IF;
4169
4170 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.insertExtItemsTLP-'||
4171 xErrLoc||' '||SQLERRM);
4172 raise ICX_POR_EXT_UTL.gException;
4173 END insertExtItemsTLP;
4174
4175 -- bug 2925403
4176 PROCEDURE updateExtItemsTLP IS
4177 xString VARCHAR2(2000);
4178 cTranslations tCursorType;
4179 xLanguage ICX_CAT_ITEMS_TLP.language%TYPE;
4180 xRtItemId NUMBER;
4181 xErrLoc PLS_INTEGER := 100;
4182 xIndex PLS_INTEGER := 0;
4183
4184 BEGIN
4185 xErrLoc := 100;
4186 IF gCurrentPrice.internal_item_id <> NULL_NUMBER THEN
4187 -- Docuements with inventory Items
4188 xErrLoc := 150;
4189 xString :=
4190 'SELECT m.language, ' ||
4191 't.rt_item_id ';
4192 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
4193 xString := xString ||
4194 'FROM imtl_system_items_tl m, ';
4195 ELSE
4196 xString := xString ||
4197 'FROM mtl_system_items_tl m, ';
4198 END IF;
4199
4200 --Bug#3004696: language=source_lan is necessary so that
4201 -- only translated items are extracted. pseudo translated items
4202 -- are not extracted. e.g. Item created in english, but rows get added to
4203 -- other installed langs. extract the item only in english
4204 xString := xString ||
4205 'icx_cat_ext_items_tlp t ' ||
4206 'WHERE m.inventory_item_id = :internal_item_id ' ||
4207 'AND m.organization_id = :inventory_organization_id ' ||
4208 'AND m.language = m.source_lang ' ||
4209 'AND m.language IN (SELECT language_code ' ||
4210 'FROM fnd_languages ' ||
4211 'WHERE installed_flag IN (''B'', ''I'')) ' ||
4212 'AND m.language = t.language (+) ' ||
4213 'AND t.rt_item_id (+) = :rt_item_id';
4214
4215 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
4216 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
4217 'Query for translation: ' || xString);
4218 END IF;
4219
4220 xErrLoc := 200;
4221 OPEN cTranslations FOR xString
4222 USING gCurrentPrice.internal_item_id,
4223 gCurrentPrice.inventory_organization_id,
4224 gCurrentPrice.rt_item_id;
4225
4226 LOOP
4227 FETCH cTranslations INTO xLanguage, xRtItemId;
4228 EXIT WHEN cTranslations%NOTFOUND;
4229
4230 xErrLoc := 210;
4231 IF (xRtItemId IS NULL) THEN
4232 -- No such translation exists
4233 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
4234 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
4235 'No translation for ' || xLanguage);
4236 END IF;
4237 xErrLoc := 220;
4238 gTransactionCount := gTransactionCount + 1;
4239 xIndex := gIERtItemIds.COUNT + 1;
4240 gIERtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4241 gIELanguages(xIndex) := xLanguage;
4242 gIEOrgIds(xIndex) := gCurrentPrice.org_id;
4243 gIERtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4244 ELSE
4245 xErrLoc := 240;
4246 IF (gCurrentPrice.match_primary_category_id <>
4247 gCurrentPrice.primary_category_id) THEN
4248 gTransactionCount := gTransactionCount + 1;
4249 xIndex := gUERtItemIds.COUNT + 1;
4250 gUERtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4251 gUELanguages(xIndex) := xLanguage;
4252 gUERtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4253 gUEOldRtCategoryIds(xIndex) :=
4254 gCurrentPrice.match_primary_category_id;
4255 END IF;
4256 END IF;
4257 END LOOP;
4258 xErrLoc := 280;
4259 CLOSE cTranslations;
4260 ELSE
4261 -- One-time items
4262 -- Bug # 3991340
4263 xString :=
4264 'SELECT f.language_code, i.rt_item_id ' ||
4265 'FROM fnd_languages f, icx_cat_ext_items_tlp i ' ||
4266 'WHERE ' ||
4267 'f.language_code = i.language(+) AND ' ||
4268 'i.rt_item_id(+) = :rt_item_id AND ' ||
4269 'f.installed_flag IN (''B''';
4270
4271 IF ICX_POR_EXTRACTOR.gLoaderValue.load_onetimeitems_all_langs = 'Y' THEN
4272 xString := xString || ', ''I'')';
4273 ELSE
4274 xString := xString || ')';
4275 END IF;
4276
4277 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
4278 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
4279 'Query for translation: ' || xString);
4280 END IF;
4281
4282 OPEN cTranslations FOR xString
4283 USING gCurrentPrice.rt_item_id;
4284
4285 LOOP
4286 FETCH cTranslations INTO xLanguage, xRtItemId;
4287 EXIT WHEN cTranslations%NOTFOUND;
4288
4289 xErrLoc := 300;
4290 IF (xRtItemId IS NULL) THEN
4291 -- No such translation exists
4292 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
4293 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
4294 'No translation for ' || xLanguage);
4295 END IF;
4296
4297 gTransactionCount := gTransactionCount + 1;
4298 xIndex := gIERtItemIds.COUNT + 1;
4299 gIERtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4300 gIELanguages(xIndex) := xLanguage;
4301 gIEOrgIds(xIndex) := gCurrentPrice.org_id;
4302 gIERtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4303 ELSE
4304 IF (gCurrentPrice.match_primary_category_id <>
4305 gCurrentPrice.primary_category_id) THEN
4306 gTransactionCount := gTransactionCount + 1;
4307 xIndex := gUERtItemIds.COUNT + 1;
4308 gUERtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4309 gUELanguages(xIndex) := xLanguage; --ICX_POR_EXTRACTOR.gBaseLang;
4310 gUERtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4311 gUEOldRtCategoryIds(xIndex) :=
4312 gCurrentPrice.match_primary_category_id;
4313 END IF;
4314 END IF;
4315 END LOOP;
4316 xErrLoc := 320;
4317 CLOSE cTranslations;
4318 -- End of Bug # 3991340
4319 END IF;
4320 xErrLoc := 400;
4321 EXCEPTION
4322 when others then
4323 ICX_POR_EXT_UTL.extRollback;
4324 IF (cTranslations%ISOPEN) THEN
4325 CLOSE cTranslations;
4326 END IF;
4327
4328 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.updateExtItemsTLP-'||
4329 xErrLoc||' '||SQLERRM);
4330 raise ICX_POR_EXT_UTL.gException;
4331 END updateExtItemsTLP;
4332
4333 PROCEDURE insertPrimaryCategoryItems IS
4334 xErrLoc PLS_INTEGER := 100;
4335 xIndex PLS_INTEGER := 0;
4336 BEGIN
4337 xErrLoc := 100;
4338 gTransactionCount := gTransactionCount + 1;
4339 xIndex := gICRtItemIds.COUNT + 1;
4340 gICRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4341 gICRtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4342
4343 /* bug 2925403
4344 -- ICX_CAT_EXT_ITEMS_TLP
4345 xErrLoc := 300;
4346 gTransactionCount := gTransactionCount +
4347 ICX_POR_EXTRACTOR.gInstalledLanguageCount;
4348 xIndex := gIERtItemIds.COUNT + 1;
4349 gIERtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4350 gIEOrgIds(xIndex) := gCurrentPrice.org_id;
4351 gIERtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4352 */
4353 EXCEPTION
4354 when others then
4355 ICX_POR_EXT_UTL.pushError(
4356 'ICX_POR_EXT_ITEM.insertPrimaryCategoryItems-'||
4357 xErrLoc||' '||SQLERRM);
4358 raise ICX_POR_EXT_UTL.gException;
4359 END insertPrimaryCategoryItems;
4360
4361 PROCEDURE updatePrimaryCategoryItems IS
4362 xErrLoc PLS_INTEGER := 100;
4363 xIndex PLS_INTEGER := 0;
4364 BEGIN
4365 xErrLoc := 100;
4366 gTransactionCount := gTransactionCount + 1;
4367 xIndex := gUCRtItemIds.COUNT + 1;
4368 gUCRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4369 gUCRtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4370 gUCOldRtCategoryIds(xIndex) := gCurrentPrice.match_primary_category_id;
4371
4372 /* bug 2925403
4373 -- ICX_CAT_EXT_ITEMS_TLP
4374 xErrLoc := 300;
4375 gTransactionCount := gTransactionCount +
4376 ICX_POR_EXTRACTOR.gInstalledLanguageCount;
4377 xIndex := gUERtItemIds.COUNT + 1;
4378 gUERtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4379 gUERtCategoryIds(xIndex) := gCurrentPrice.primary_category_id;
4380 gUEOldRtCategoryIds(xIndex) := gCurrentPrice.match_primary_category_id;
4381 */
4382 EXCEPTION
4383 when others then
4384 ICX_POR_EXT_UTL.pushError(
4385 'ICX_POR_EXT_ITEM.updatePrimaryCategoryItems-'||
4386 xErrLoc||' '||SQLERRM);
4387 raise ICX_POR_EXT_UTL.gException;
4388 END updatePrimaryCategoryItems;
4389
4390 PROCEDURE insertTemplateCategoryItems IS
4391 xErrLoc PLS_INTEGER := 100;
4392 xIndex PLS_INTEGER := 0;
4393 BEGIN
4394 xErrLoc := 100;
4395 gTransactionCount := gTransactionCount + 1;
4396 xIndex := gICRtItemIds.COUNT + 1;
4397 gICRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4398 gICRtCategoryIds(xIndex) := gCurrentPrice.template_category_id;
4399
4400 xErrLoc := 400;
4401 EXCEPTION
4402 when others then
4403 ICX_POR_EXT_UTL.pushError(
4404 'ICX_POR_EXT_ITEM.insertTemplateCategoryItems-'||
4405 xErrLoc||' '||SQLERRM);
4406 raise ICX_POR_EXT_UTL.gException;
4407 END insertTemplateCategoryItems;
4408
4409 PROCEDURE touchCleanupItem(pRtItemId IN NUMBER) IS
4410 xErrLoc PLS_INTEGER := 100;
4411 xIndex PLS_INTEGER := 0;
4412 BEGIN
4413 xErrLoc := 100;
4414 xIndex := gCIRtItemIds.COUNT + 1;
4415 gCIRtItemIds(xIndex) := pRtItemId;
4416 EXCEPTION
4417 when others then
4418 ICX_POR_EXT_UTL.pushError(
4419 'ICX_POR_EXT_ITEM.touchCleanupItem-'||
4420 xErrLoc||' '||SQLERRM);
4421 raise ICX_POR_EXT_UTL.gException;
4422 END touchCleanupItem;
4423
4424 PROCEDURE touchUpdatedGA(pContractId IN NUMBER,
4425 pContractLineId IN NUMBER)
4426 IS
4427 xErrLoc PLS_INTEGER := 100;
4428 xIndex PLS_INTEGER := 0;
4429 BEGIN
4430 xErrLoc := 100;
4431 xIndex := gUGAContractIds.COUNT + 1;
4432 gUGAContractIds(xIndex) := pContractId;
4433 gUGAContractLineIds(xIndex) := pContractLineId;
4434 EXCEPTION
4435 when others then
4436 ICX_POR_EXT_UTL.pushError(
4437 'ICX_POR_EXT_ITEM.touchUpdatedGA-'||
4438 xErrLoc||' '||SQLERRM);
4439 raise ICX_POR_EXT_UTL.gException;
4440 END touchUpdatedGA;
4441
4442 PROCEDURE touchRtItemActiveFlag(pRtItemId IN NUMBER) IS
4443 xErrLoc PLS_INTEGER := 100;
4444 xIndex PLS_INTEGER := 0;
4445 BEGIN
4446 xErrLoc := 100;
4447 xIndex := gTARtItemIds.COUNT + 1;
4448 gTARtItemIds(xIndex) := pRtItemId;
4449 EXCEPTION
4450 when others then
4451 ICX_POR_EXT_UTL.pushError(
4452 'ICX_POR_EXT_ITEM.touchRtItemActiveFlag-'||
4453 xErrLoc||' '||SQLERRM);
4454 raise ICX_POR_EXT_UTL.gException;
4455 END touchRtItemActiveFlag;
4456
4457 PROCEDURE touchInvItemActiveFlag IS
4458 xErrLoc PLS_INTEGER := 100;
4459 xIndex PLS_INTEGER := 0;
4460 BEGIN
4461 xErrLoc := 100;
4462 xIndex := gTAInvItemIds.COUNT + 1;
4463 gTAInvItemIds(xIndex) := gCurrentPrice.internal_item_id;
4464 IF gCurrentPrice.global_agreement_flag = 'Y' THEN
4465 gTAInvOrgIds(xIndex) := NULL;
4466 ELSE
4467 gTAInvOrgIds(xIndex) := gCurrentPrice.org_id;
4468 END IF;
4469 EXCEPTION
4470 when others then
4471 ICX_POR_EXT_UTL.pushError(
4472 'ICX_POR_EXT_ITEM.touchInvItemActiveFlag-'||
4473 xErrLoc||' '||SQLERRM);
4474 raise ICX_POR_EXT_UTL.gException;
4475 END touchInvItemActiveFlag;
4476
4477 PROCEDURE deleteItemPrices IS
4478 xErrLoc PLS_INTEGER := 100;
4479 xIndex PLS_INTEGER := 0;
4480 BEGIN
4481 xErrLoc := 100;
4482 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
4483 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
4484 'Enter deleteItemPrices()');
4485 END IF;
4486
4487 xErrLoc := 200;
4488 gTransactionCount := gTransactionCount + 1;
4489 xIndex := gDPRowIds.COUNT + 1;
4490 gDPRowIds(xIndex) := gCurrentPrice.price_rowid;
4491
4492 -- Delete template_header-item association
4493 xErrLoc := 300;
4494 IF gCurrentPrice.template_category_id IS NOT NULL THEN
4495 gTransactionCount := gTransactionCount + 1;
4496 xIndex := gDPTemplateCategoryIds.COUNT + 1;
4497 gDPTemplateCategoryIds(xIndex) := gCurrentPrice.template_category_id;
4498 gDPRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4499 END IF;
4500
4501 xErrLoc := 400;
4502 IF gCurrentPrice.global_agreement_flag = 'Y' THEN
4503 gTransactionCount := gTransactionCount + 1;
4504 xIndex := gDPGContractLineIds.COUNT + 1;
4505 gDPGContractIds(xIndex) := gCurrentPrice.contract_id;
4506 gDPGContractLineIds(xIndex) := gCurrentPrice.contract_line_id;
4507 END IF;
4508
4509 xErrLoc := 500;
4510 EXCEPTION
4511 when others then
4512 ICX_POR_EXT_UTL.extRollback;
4513 ICX_POR_EXT_UTL.pushError(
4514 'ICX_POR_EXT_ITEM.deleteItemPrices-'||
4515 xErrLoc||' '||SQLERRM);
4516 raise ICX_POR_EXT_UTL.gException;
4517 END deleteItemPrices;
4518
4519 PROCEDURE deleteItem IS
4520 xErrLoc PLS_INTEGER := 100;
4521 xIndex PLS_INTEGER := 0;
4522 BEGIN
4523 xErrLoc := 100;
4524 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
4525 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
4526 'Enter deleteItem()');
4527 END IF;
4528
4529 -- Delete all price rows from ICX_CAT_ITEM_PRICES for an inventory item.
4530
4531 IF gCurrentPrice.document_type = PURCHASING_ITEM_TYPE THEN
4532 IF (gCurrentPrice.status = ICX_POR_EXT_DIAG.UNPURCHASABLE_OUTSIDE) THEN
4533 xErrLoc := 200;
4534 xIndex := gDIPurchasingItemIds.COUNT + 1;
4535 gDIPurchasingItemIds(xIndex) := gCurrentPrice.internal_item_id;
4536 gDIPurchasingOrgIds(xIndex) := gCurrentPrice.org_id;
4537 ELSIF (gCurrentPrice.status = ICX_POR_EXT_DIAG.ITEM_NO_PRICE) THEN
4538 xErrLoc := 240;
4539 xIndex := gDINullPriceItemIds.COUNT + 1;
4540 gDINullPriceItemIds(xIndex) := gCurrentPrice.internal_item_id;
4541 gDINullPriceOrgIds(xIndex) := gCurrentPrice.org_id;
4542 END IF;
4543 ELSIF gCurrentPrice.document_type = INTERNAL_ITEM_TYPE THEN
4544 xErrLoc := 300;
4545 xIndex := gDIInternalItemIds.COUNT + 1;
4546 gDIInternalItemIds(xIndex) := gCurrentPrice.internal_item_id;
4547 gDIInternalOrgIds(xIndex) := gCurrentPrice.org_id;
4548 END IF;
4549
4550 xErrLoc := 400;
4551 EXCEPTION
4552 when others then
4553 ICX_POR_EXT_UTL.extRollback;
4554 ICX_POR_EXT_UTL.pushError(
4555 'ICX_POR_EXT_ITEM.deleteItem-'||
4556 xErrLoc||' '||SQLERRM);
4557 raise ICX_POR_EXT_UTL.gException;
4558 END deleteItem;
4559
4560 PROCEDURE updateItemPricesGA IS
4561 xErrLoc PLS_INTEGER := 100;
4562 xIndex PLS_INTEGER := 0;
4563 BEGIN
4564 xErrLoc := 100;
4565 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
4566 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
4567 'Enter updateItemPricesGA()');
4568 END IF;
4569
4570 xErrLoc := 200;
4571 gTransactionCount := gTransactionCount + 1;
4572 xIndex := gUPGAContractLineIds.COUNT + 1;
4573 gUPGAContractIds(xIndex) := gCurrentPrice.contract_id;
4574 gUPGAContractLineIds(xIndex) := gCurrentPrice.contract_line_id;
4575 gUPGAFunctionalPrices(xIndex) := gCurrentPrice.functional_price;
4576 gUPGASupplierSiteIds(xIndex) := gCurrentPrice.supplier_site_id;
4577 gUPGASupplierSiteCodes(xIndex) := gCurrentPrice.supplier_site_code;
4578 -- bug 2912717: populate line_type, rate info. for GA
4579 gUPGALineTypeIds(xIndex) := gCurrentPrice.line_type_id;
4580 gUPGARateTypes(xIndex) := gCurrentPrice.rate_type;
4581 gUPGARateDates(xIndex) := gCurrentPrice.rate_date;
4582 gUPGARates(xIndex) := gCurrentPrice.rate;
4583 -- bug 3298502: Populate Enabled Org Id
4584 gUPGAOrgIds(xIndex) := gCurrentPrice.org_id;
4585
4586 xErrLoc := 400;
4587 EXCEPTION
4588 when others then
4589 ICX_POR_EXT_UTL.extRollback;
4590 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.updateItemPricesGA-'||
4591 xErrLoc||' '||SQLERRM);
4592 raise ICX_POR_EXT_UTL.gException;
4593 END updateItemPricesGA;
4594
4595 PROCEDURE insertItemPricesGA IS
4596 xErrLoc PLS_INTEGER := 100;
4597 xIndex PLS_INTEGER := 0;
4598 BEGIN
4599 xErrLoc := 100;
4600 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
4601 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
4602 'Enter insertItemPricesGA()');
4603 END IF;
4604
4605 xErrLoc := 200;
4606 gTransactionCount := gTransactionCount + 1;
4607 xIndex := gIPGAContractLineIds.COUNT + 1;
4608 gIPGARtItemIds(xIndex) := gCurrentPrice.price_rt_item_id;
4609 gIPGALocalRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4610 gIPGASupplierSiteIds(xIndex) := gCurrentPrice.supplier_site_id;
4611 gIPGAContractIds(xIndex) := gCurrentPrice.contract_id;
4612 gIPGAContractLineIds(xIndex) := gCurrentPrice.contract_line_id;
4613 gIPGAInventoryItemIds(xIndex) := gCurrentPrice.internal_item_id;
4614 gIPGAMtlCategoryIds(xIndex) := gCurrentPrice.mtl_category_id;
4615 gIPGAOrgIds(xIndex) := gCurrentPrice.org_id;
4616 gIPGAUnitPrices(xIndex) := gCurrentPrice.unit_price;
4617 --FPJ FPSL Extractor Changes
4618 gIPGAValueBasis(xIndex) := gCurrentPrice.value_basis;
4619 gIPGAPurchaseBasis(xIndex) := gCurrentPrice.purchase_basis;
4620 gIPGAAllowPriceOverrideFlag(xIndex) := gCurrentPrice.allow_price_override_flag;
4621 gIPGANotToExceedPrice(xIndex) := gCurrentPrice.not_to_exceed_price;
4622 -- FPJ Bug# 3110297 jingyu Add negotiated flag
4623 gIPGANegotiatedFlag(xIndex) := gCurrentPrice.negotiated_by_preparer_flag;
4624 gIPGACurrencys(xIndex) := gCurrentPrice.currency;
4625 gIPGAUnitOfMeasures(xIndex) := gCurrentPrice.unit_of_measure;
4626 gIPGAFunctionalPrices(xIndex) := gCurrentPrice.functional_price;
4627 gIPGASupplierSiteCodes(xIndex) := gCurrentPrice.supplier_site_code;
4628 gIPGAContractNums(xIndex) := gCurrentPrice.contract_num;
4629 gIPGAContractLineNums(xIndex) := gCurrentPrice.contract_line_num;
4630 -- bug 2912717: populate line_type, rate info. for GA
4631 gIPGALineTypeIds(xIndex) := gCurrentPrice.line_type_id;
4632 gIPGARateTypes(xIndex) := gCurrentPrice.rate_type;
4633 gIPGARateDates(xIndex) := gCurrentPrice.rate_date;
4634 gIPGARates(xIndex) := gCurrentPrice.rate;
4635
4636 xErrLoc := 400;
4637 EXCEPTION
4638 when others then
4639 ICX_POR_EXT_UTL.extRollback;
4640 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.insertItemPricesGA-'||
4641 xErrLoc||' '||SQLERRM);
4642 raise ICX_POR_EXT_UTL.gException;
4643 END insertItemPricesGA;
4644
4645 PROCEDURE setLocalRtItemId IS
4646 xErrLoc PLS_INTEGER := 100;
4647 xIndex PLS_INTEGER := 0;
4648 BEGIN
4649 xErrLoc := 100;
4650 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
4651 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
4652 'Enter setLocalRtItemId()');
4653 END IF;
4654
4655 xErrLoc := 200;
4656 xIndex := gSLRRowIds.COUNT + 1;
4657 gSLRRowIds(xIndex) := gCurrentPrice.price_rowid;
4658 gSLRALocalRtItemIds(xIndex) := gCurrentPrice.rt_item_id;
4659
4660 xErrLoc := 500;
4661 EXCEPTION
4662 when others then
4663 ICX_POR_EXT_UTL.extRollback;
4664 ICX_POR_EXT_UTL.pushError(
4665 'ICX_POR_EXT_ITEM.setLocalRtItemId-'||
4666 xErrLoc||' '||SQLERRM);
4667 raise ICX_POR_EXT_UTL.gException;
4668 END setLocalRtItemId;
4669
4670 -- Process price row
4671 -- ___________________________________________________________
4672 -- | Match Price | Cache and Price Match |
4673 -- | | ---------------- |
4674 -- | |* update ICX_CAT_ITEM_PRICES |
4675 -- | |* Don't have to reset active_flag |
4676 -- | |_____________________________________________|
4677 -- | | Cache Match |
4678 -- | | ------------------- |
4679 -- | |* update ICX_CAT_ITEM_PRICES |
4680 -- | |* reset active_flag for both rt_item_id and |
4681 -- | | price_rt_item_id |
4682 -- | |* cleanup item for price_rt_item_id |
4683 -- | |* set item source for inventory_item_id |
4684 -- | |_____________________________________________|
4685 -- | | Price Match |
4686 -- | | ---------------- |
4687 -- | |* update ICX_CAT_ITEM_PRICES |
4688 -- | |* update ICX_CAT_ITEMS_B, ICX_CAT_ITEMS_TLP |
4689 -- | |* IF match_primary_category_id <> |
4690 -- | | primary_category_id |
4691 -- | | THEN update ICX_CAT_CATEGORY_ITEMS |
4692 -- | |* don't have to reset active_flag |
4693 -- | |_____________________________________________|
4694 -- | | Item Match |
4695 -- | | ---------- |
4696 -- | |* update ICX_CAT_ITEM_PRICES |
4697 -- | |* update ICX_CAT_ITEMS_B, ICX_CAT_ITEMS_TLP |
4698 -- | |* IF match_primary_category_id <> |
4699 -- | | primary_category_id |
4700 -- | | THEN update ICX_CAT_CATEGORY_ITEMS |
4701 -- | |* IF match_template_flag = 'N' |
4702 -- | | THEN create ICX_CAT_CATEGORY_ITEMS |
4703 -- | |* reset active_flag for both rt_item_id and |
4704 -- | | price_rt_item_id |
4705 -- | |* cleanup item for price_rt_item_id |
4706 -- | |* set item source for inventory_item_id |
4707 -- | |_____________________________________________|
4708 -- | | New Item |
4709 -- | | -------- |
4710 -- | |* update ICX_CAT_ITEM_PRICES |
4711 -- | |* create ICX_CAT_ITEMS_B, ICX_CAT_ITEMS_TLP |
4712 -- | |* create ICX_CAT_CATEGORY_ITEMS for |
4713 -- | | mtl_category_id |
4714 -- | |* IF template_id IS NOT NULL |
4715 -- | | THEN create ICX_CAT_CATEGORY_ITEMS |
4716 -- | |* set active_flag to 'Y |
4717 -- | |* reset active_flag for price_rt_item_id |
4718 -- | |* cleanup item for price_rt_item_id |
4719 -- | |* set item source for inventory_item_id |
4720 -- |_____________|_____________________________________________|
4721 -- | New Price | Item Match |
4722 -- | | ---------- |
4723 -- | |* create ICX_CAT_ITEM_PRICES |
4724 -- | |* update ICX_CAT_ITEMS_B, ICX_CAT_ITEMS_TLP |
4725 -- | |* IF match_primary_category_id <> |
4726 -- | | primary_category_id |
4727 -- | | THEN update ICX_CAT_CATEGORY_ITEMS |
4728 -- | | update ICX_CAT_ITEMS_TLP |
4729 -- | |* IF match_template_flag = 'N' |
4730 -- | | THEN create ICX_CAT_CATEGORY_ITEMS |
4731 -- | |* reset active_flag for rt_item_id |
4732 -- | |* set item source for inventory_item_id |
4733 -- | |_____________________________________________|
4734 -- | | New Item |
4735 -- | | -------- |
4736 -- | |* create ICX_CAT_ITEM_PRICES |
4737 -- | |* create ICX_CAT_ITEMS_B, ICX_CAT_ITEMS_TLP |
4738 -- | |* create ICX_CAT_CATEGORY_ITEMS for |
4739 -- | | mtl_category_id |
4740 -- | |* IF template_id IS NOT NULL |
4741 -- | | THEN create ICX_CAT_CATEGORY_ITEMS |
4742 -- | |* set active_flag to 'Y |
4743 -- | |* set item source for inventory_item_id |
4744 -- |_____________|_____________________________________________|
4745 -- | Delete Price|* delete ICX_CAT_ITEM_PRICES |
4746 -- | |* reset active_flag for price_rt_item_id |
4747 -- | |* cleanup item for price_rt_item_id |
4748 -- | |* set item source for inventory_item_id |
4749 -- |_____________|_____________________________________________|
4750
4751 PROCEDURE processPriceRow
4752 IS
4753 xErrLoc PLS_INTEGER := 100;
4754 xItemStatus PLS_INTEGER;
4755 BEGIN
4756
4757 xErrLoc := 100;
4758 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
4759 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
4760 'Enter processPriceRow()');
4761 END IF;
4762
4763 xItemStatus := findItemRecord;
4764
4765 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
4766 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
4767 'Process price for ' || snapShotPriceRow ||
4768 ', item status: ' || getItemStatusString(xItemStatus));
4769 END IF;
4770
4771 IF gCurrentPrice.document_type <> GLOBAL_AGREEMENT_TYPE THEN
4772 IF (xItemStatus = CACHE_PRICE_MATCH) THEN
4773 xErrLoc := 300;
4774 updateItemPrices;
4775 ELSIF (xItemStatus = CACHE_MATCH) THEN
4776 xErrLoc := 200;
4777 IF (gCurrentPrice.price_rowid IS NULL) THEN
4778 xErrLoc := 220;
4779 insertItemPrices;
4780 ELSE
4781 xErrLoc := 240;
4782 updateItemPrices;
4783 END IF;
4784 ELSIF (xItemStatus = PRICE_MATCH) THEN
4785 xErrLoc := 300;
4786 updateItemPrices;
4787 xErrLoc := 310;
4788 updateItemsB;
4789 xErrLoc := 320;
4790 updateItemsTLP;
4791 -- bug 2925403
4792 xErrLoc := 330;
4793 updateExtItemsTLP;
4794 xErrLoc := 340;
4795 IF (gCurrentPrice.match_primary_category_id <>
4796 gCurrentPrice.primary_category_id)
4797 THEN
4798 updatePrimaryCategoryItems;
4799 END IF;
4800 ELSIF (xItemStatus = ITEM_MATCH) THEN
4801 xErrLoc := 400;
4802 IF (gCurrentPrice.price_rowid IS NULL) THEN
4803 xErrLoc := 410;
4804 insertItemPrices;
4805 ELSE
4806 xErrLoc := 420;
4807 updateItemPrices;
4808 END IF;
4809 xErrLoc := 430;
4810 updateItemsB;
4811 xErrLoc := 440;
4812 updateItemsTLP;
4813 -- bug 2925403
4814 xErrLoc := 450;
4815 updateExtItemsTLP;
4816 xErrLoc := 460;
4817 IF (gCurrentPrice.match_primary_category_id <>
4818 gCurrentPrice.primary_category_id)
4819 THEN
4820 updatePrimaryCategoryItems;
4821 END IF;
4822 xErrLoc := 470;
4823 IF (gCurrentPrice.match_template_flag = 'N') THEN
4824 xErrLoc := 480;
4825 insertTemplateCategoryItems;
4826 END IF;
4827 ELSIF (xItemStatus IN (NEW_ITEM, NEW_GA_ITEM)) THEN
4828 xErrLoc := 500;
4829 -- Set active flag to 'Y'
4830 IF gCurrentPrice.document_type <> PURCHASING_ITEM_TYPE THEN
4831 IF xItemStatus = NEW_GA_ITEM THEN
4832 gCurrentPrice.active_flag := 'N';
4833 ELSE
4834 gCurrentPrice.active_flag := 'Y';
4835 END IF;
4836 END IF;
4837 IF (gCurrentPrice.price_rowid IS NULL) THEN
4838 xErrLoc := 510;
4839 insertItemPrices;
4840 ELSE
4841 xErrLoc := 520;
4842 updateItemPrices;
4843 END IF;
4844 xErrLoc := 530;
4845 insertItemsB;
4846 xErrLoc := 540;
4847 insertItemsTLP;
4848 -- bug 2925403
4849 xErrLoc := 550;
4850 insertExtItemsTLP;
4851 xErrLoc := 560;
4852 insertPrimaryCategoryItems;
4853 xErrLoc := 570;
4854 IF (gCurrentPrice.template_id <> TO_CHAR(NULL_NUMBER)) THEN
4855 xErrLoc := 580;
4856 insertTemplateCategoryItems;
4857 END IF;
4858 ELSIF (xItemStatus = DELETE_PRICE) THEN
4859 xErrLoc := 600;
4860 IF (gCurrentPrice.price_rowid IS NOT NULL) THEN
4861 IF gCurrentPrice.document_type NOT IN (PURCHASING_ITEM_TYPE,
4862 INTERNAL_ITEM_TYPE)
4863 THEN
4864 xErrLoc := 610;
4865 deleteItemPrices;
4866 ELSE
4867 xErrLoc := 620;
4868 deleteItem;
4869 END IF;
4870 END IF;
4871 END IF;
4872
4873 -- Set updated GA
4874 xErrLoc := 630;
4875 IF (gCurrentPrice.price_rowid IS NOT NULL AND
4876 gCurrentPrice.global_agreement_flag = 'Y' AND
4877 xItemStatus IN (CACHE_MATCH, NEW_ITEM, ITEM_MATCH))
4878 THEN
4879 touchUpdatedGA(gCurrentPrice.contract_id,
4880 gCurrentPrice.contract_line_id);
4881 END IF;
4882
4883 -- Cleanup Item
4884 xErrLoc := 670;
4885 IF (gCurrentPrice.price_rt_item_id IS NOT NULL AND
4886 xItemStatus IN (CACHE_MATCH, NEW_ITEM, NEW_GA_ITEM,
4887 ITEM_MATCH, DELETE_PRICE))
4888 THEN
4889 touchCleanupItem(gCurrentPrice.price_rt_item_id);
4890 END IF;
4891
4892 -- Reset active flag
4893 xErrLoc := 800;
4894 -- We need to reset actice_flag for purchasing item price row
4895 xErrLoc := 820;
4896 IF (gCurrentPrice.internal_item_id <> NULL_NUMBER AND
4897 gCurrentPrice.document_type NOT IN (INTERNAL_TEMPLATE_TYPE,
4898 PURCHASING_ITEM_TYPE,
4899 INTERNAL_ITEM_TYPE))
4900 THEN
4901 touchInvItemActiveFlag;
4902 END IF;
4903 xErrLoc := 840;
4904 IF xItemStatus IN (CACHE_MATCH, ITEM_MATCH) THEN
4905 -- We need to reset actice_flag for both rt_item_id
4906 -- and price_rt_item_id
4907 touchRtItemActiveFlag(gCurrentPrice.rt_item_id);
4908 IF gCurrentPrice.price_rt_item_id IS NOT NULL THEN
4909 touchRtItemActiveFlag(gCurrentPrice.price_rt_item_id);
4910 END IF;
4911 ELSIF xItemStatus IN (NEW_ITEM, NEW_GA_ITEM, DELETE_PRICE) THEN
4912 -- We need to reset actice_flag for price_rt_item_id
4913 IF gCurrentPrice.price_rt_item_id IS NOT NULL THEN
4914 touchRtItemActiveFlag(gCurrentPrice.price_rt_item_id);
4915 END IF;
4916 END IF;
4917
4918 -- Bug # 3420640 : pcreddy
4919 -- Set active flag if there is a update on template line.
4920 -- This scenario can occur when there are more than one template
4921 -- with the same item (copied from a blanket line)
4922 -- Bug 4349235 : vantani
4923 -- We need to touch the Active flag for 'INTERNAL_TEMPLATE_TYPE' also
4924 -- The fix is to add 'INTERNAL_TEMPLATE_TYPE' also in the AND condition
4925 -- Bug 4451213
4926 -- We need to touch the Active flag for 'INTERNAL_ITEM_TYPE'.
4927 IF (xItemStatus IN (PRICE_MATCH, CACHE_PRICE_MATCH) AND
4928 gCurrentPrice.document_type IN (TEMPLATE_TYPE,INTERNAL_TEMPLATE_TYPE,INTERNAL_ITEM_TYPE)) THEN
4929 touchRtItemActiveFlag(gCurrentPrice.rt_item_id);
4930 END IF;
4931 ELSE
4932 -- Process global agreements
4933 IF gCurrentPrice.price_type <> 'SET_ACTIVE_FLAG' THEN
4934 IF (xItemStatus = DELETE_PRICE) THEN
4935 IF (gCurrentPrice.price_rowid IS NOT NULL) THEN
4936 xErrLoc := 900;
4937 deleteItemPrices;
4938 END IF;
4939 ELSE
4940 IF (gCurrentPrice.price_rowid IS NOT NULL) THEN
4941 xErrLoc := 910;
4942 updateItemPricesGA;
4943 ELSE
4944 xErrLoc := 920;
4945 insertItemPricesGA;
4946 END IF;
4947 END IF;
4948 ELSE
4949 xErrLoc := 950;
4950 IF gCurrentPrice.local_rt_item_id <> gCurrentPrice.rt_item_id THEN
4951 -- Item uniqueness criteria for global agreement are changed
4952 setLocalRtItemId;
4953 END IF;
4954 END IF;
4955
4956 -- Reset active flag
4957 xErrLoc := 960;
4958 -- We need to reset actice_flag for purchasing item price row
4959 IF gCurrentPrice.internal_item_id <> NULL_NUMBER THEN
4960 touchInvItemActiveFlag;
4961 END IF;
4962 xErrLoc := 980;
4963 IF xItemStatus IN (ITEM_MATCH, NEW_ITEM, DELETE_PRICE) THEN
4964 -- We need to reset actice_flag for rt_item_id
4965 IF gCurrentPrice.rt_item_id IS NOT NULL THEN
4966 touchRtItemActiveFlag(gCurrentPrice.rt_item_id);
4967 END IF;
4968 END IF;
4969 IF gCurrentPrice.price_type = 'SET_ACTIVE_FLAG' THEN
4970 -- We need to reset actice_flag for local rt_item_id
4971 -- NOTE: we use local_rt_item_id to store local rt_item_id
4972 IF (gCurrentPrice.local_rt_item_id IS NOT NULL AND
4973 gCurrentPrice.local_rt_item_id <> gCurrentPrice.rt_item_id)
4974 THEN
4975 -- Item uniqueness criteria for global agreement are changed
4976 touchRtItemActiveFlag(gCurrentPrice.local_rt_item_id);
4977 END IF;
4978 END IF;
4979
4980 END IF;
4981
4982 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
4983 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
4984 'Leave processPriceRow()');
4985 END IF;
4986 xErrLoc := 900;
4987
4988 EXCEPTION
4989 when ICX_POR_EXT_UTL.gException then
4990 -- rollback;
4991 ICX_POR_EXT_UTL.extRollback;
4992
4993 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM-processPriceRow-'||
4994 xErrLoc);
4995 raise ICX_POR_EXT_UTL.gException;
4996 when others then
4997 -- rollback;
4998 ICX_POR_EXT_UTL.extRollback;
4999
5000 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM-processPriceRow-'||
5001 xErrLoc||' '||SQLERRM);
5002 ICX_POR_EXT_UTL.pushError(snapShotPriceRow);
5003 raise ICX_POR_EXT_UTL.gException;
5004 END processPriceRow;
5005
5006 --------------------------------------------------------------
5007 -- Main Procedures --
5008 --------------------------------------------------------------
5009 -- Extract updated documents
5010 --
5011 -- We can have the following different rice rows is:
5012 -- * Purchasing Templates with contract reference
5013 -- * Contracts
5014 -- * Purchasing Templates without contract reference
5015 -- * ASLs
5016 -- * Master Items (Purchasing or Internal)
5017 -- * Internal Templates
5018 --
5019 -- * One-time Templates with contract reference
5020 -- * One-time Contracts
5021 -- * One-time Templates without contract reference
5022 --
5023 --Bug#3277977
5024 --Added cSqlString variable, which will hold the sql string passed
5025 --from openPriceCursors so, that the cursor can be
5026 --opened in extractPriceRows with the sql String
5027 --Reason: the solution for
5028 --ORA-01555 is to close the cursor and reopen the cursor
5029 --Which should be done in extractPriceRows procedure, where the
5030 --cursor cUpdatedPriceRows is passed in.
5031 --If you try to reopen a cursor that is passed in as a parameter
5032 --it throws the error
5033 --PLS-00361: IN cursor 'CUPDATEDPRICEROWS' cannot be OPEN'ed
5034 --PROCEDURE extractPriceRows(cUpdatedPriceRows IN tCursorType) IS
5035 PROCEDURE extractPriceRows( cSqlString IN VARCHAR2) IS
5036 --Bug#3277977
5037 --Handle exception
5038 --ORA-01555: snapshot too old: rollback segment number with name "" too small
5039 snap_shot_too_old EXCEPTION;
5040 PRAGMA EXCEPTION_INIT(snap_shot_too_old, -1555);
5041 cUpdatedPriceRows tCursorType;
5042
5043 xErrLoc PLS_INTEGER := 100;
5044 l_document_type DBMS_SQL.NUMBER_TABLE;
5045 l_last_update_date DBMS_SQL.DATE_TABLE;
5046 l_org_id DBMS_SQL.NUMBER_TABLE;
5047 l_supplier_id DBMS_SQL.NUMBER_TABLE;
5048 l_supplier DBMS_SQL.VARCHAR2_TABLE;
5049 l_supplier_part_num DBMS_SQL.VARCHAR2_TABLE;
5050 l_internal_item_id DBMS_SQL.NUMBER_TABLE;
5051 l_mtl_category_id DBMS_SQL.NUMBER_TABLE;
5052 l_category_key DBMS_SQL.VARCHAR2_TABLE;
5053 l_description DBMS_SQL.VARCHAR2_TABLE;
5054 l_picture DBMS_SQL.VARCHAR2_TABLE;
5055 l_picture_url DBMS_SQL.VARCHAR2_TABLE;
5056 l_price_type DBMS_SQL.VARCHAR2_TABLE;
5057 l_asl_id DBMS_SQL.NUMBER_TABLE;
5058 l_supplier_site_id DBMS_SQL.NUMBER_TABLE;
5059 l_contract_id DBMS_SQL.NUMBER_TABLE;
5060 l_contract_line_id DBMS_SQL.NUMBER_TABLE;
5061 l_template_id DBMS_SQL.VARCHAR2_TABLE;
5062 l_template_line_id DBMS_SQL.NUMBER_TABLE;
5063 l_price_search_type DBMS_SQL.VARCHAR2_TABLE;
5064 l_unit_price DBMS_SQL.NUMBER_TABLE;
5065 --FPJ FPSL Extractor Changes
5066 l_value_basis DBMS_SQL.VARCHAR2_TABLE;
5067 l_purchase_basis DBMS_SQL.VARCHAR2_TABLE;
5068 l_allow_price_override_flag DBMS_SQL.VARCHAR2_TABLE;
5069 l_not_to_exceed_price DBMS_SQL.NUMBER_TABLE;
5070 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
5071 l_suggested_quantity DBMS_SQL.NUMBER_TABLE;
5072 -- FPJ Bug# 3110297 jingyu Add negotiated flag
5073 l_negotiated_by_preparer_flag DBMS_SQL.VARCHAR2_TABLE;
5074 l_currency DBMS_SQL.VARCHAR2_TABLE;
5075 l_unit_of_measure DBMS_SQL.VARCHAR2_TABLE;
5076 l_functional_price DBMS_SQL.NUMBER_TABLE;
5077 l_supplier_site_code DBMS_SQL.VARCHAR2_TABLE;
5078 l_contract_num DBMS_SQL.VARCHAR2_TABLE;
5079 l_contract_line_num DBMS_SQL.NUMBER_TABLE;
5080 l_manufacturer DBMS_SQL.VARCHAR2_TABLE;
5081 l_manufacturer_part_num DBMS_SQL.VARCHAR2_TABLE;
5082 l_rate_type DBMS_SQL.VARCHAR2_TABLE;
5083 l_rate_date DBMS_SQL.DATE_TABLE;
5084 l_rate DBMS_SQL.NUMBER_TABLE;
5085 l_supplier_number DBMS_SQL.VARCHAR2_TABLE;
5086 l_supplier_contact_id DBMS_SQL.NUMBER_TABLE;
5087 l_item_revision DBMS_SQL.VARCHAR2_TABLE;
5088 l_line_type_id DBMS_SQL.NUMBER_TABLE;
5089 l_buyer_id DBMS_SQL.NUMBER_TABLE;
5090 l_global_agreement_flag DBMS_SQL.VARCHAR2_TABLE;
5091 l_status DBMS_SQL.VARCHAR2_TABLE;
5092 l_internal_item_num DBMS_SQL.VARCHAR2_TABLE;
5093 l_inventory_organization_id DBMS_SQL.NUMBER_TABLE;
5094 l_item_source_type DBMS_SQL.VARCHAR2_TABLE;
5095 l_item_search_type DBMS_SQL.VARCHAR2_TABLE;
5096 l_primary_category_id DBMS_SQL.NUMBER_TABLE;
5097 l_primary_category_name DBMS_SQL.VARCHAR2_TABLE;
5098 l_template_category_id DBMS_SQL.NUMBER_TABLE;
5099 l_price_rt_item_id DBMS_SQL.NUMBER_TABLE;
5100 l_price_internal_item_id DBMS_SQL.NUMBER_TABLE;
5101 l_price_supplier_id DBMS_SQL.NUMBER_TABLE;
5102 l_price_supplier_part_num DBMS_SQL.VARCHAR2_TABLE;
5103 l_price_contract_line_id DBMS_SQL.NUMBER_TABLE;
5104 l_price_mtl_category_id DBMS_SQL.NUMBER_TABLE;
5105 l_match_primary_category_id DBMS_SQL.NUMBER_TABLE;
5106 l_rt_item_id DBMS_SQL.NUMBER_TABLE;
5107 l_local_rt_item_id DBMS_SQL.NUMBER_TABLE;
5108 l_match_template_flag DBMS_SQL.VARCHAR2_TABLE;
5109 l_active_flag DBMS_SQL.VARCHAR2_TABLE;
5110 l_price_rowid DBMS_SQL.UROWID_TABLE;
5111
5112 BEGIN
5113 xErrLoc := 100;
5114 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
5115 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
5116 'Enter extractPriceRows()');
5117 END IF;
5118
5119 xErrLoc := 150;
5120 clearTables('ALL');
5121 clearCache;
5122
5123 -- Set initial value
5124 gTransactionCount := 0;
5125 gPriceRowCount := 0;
5126
5127 xErrLoc := 170;
5128 --Bug#3277977
5129 --open the cursor with the sql string passed in
5130 open cUpdatedPriceRows for cSqlString;
5131 xErrLoc := 180;
5132 LOOP
5133 xErrLoc := 200;
5134 -- Since Oralce8i doesn't support fetch into a collection of records,
5135 -- we have to fetch into a bunch of tables.
5136 -- 9i code
5137 -- BULK COLLECT INTO xPriceRows
5138 l_document_type.DELETE;
5139 l_last_update_date.DELETE;
5140 l_org_id.DELETE;
5141 l_supplier_id.DELETE;
5142 l_supplier_part_num.DELETE;
5143 l_internal_item_id.DELETE;
5144 l_mtl_category_id.DELETE;
5145 l_category_key.DELETE;
5146 l_description.DELETE;
5147 l_picture.DELETE;
5148 l_picture_url.DELETE;
5149 l_price_type.DELETE;
5150 l_asl_id.DELETE;
5151 l_supplier_site_id.DELETE;
5152 l_contract_id.DELETE;
5153 l_contract_line_id.DELETE;
5154 l_template_id.DELETE;
5155 l_template_line_id.DELETE;
5156 l_price_search_type.DELETE;
5157 l_unit_price.DELETE;
5158 --FPJ FPSL Extractor Changes
5159 l_value_basis.DELETE;
5160 l_purchase_basis.DELETE;
5161 l_allow_price_override_flag.DELETE;
5162 l_not_to_exceed_price.DELETE;
5163 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
5164 l_suggested_quantity.DELETE;
5165 -- FPJ Bug# 3110297 jingyu Add negotiated flag
5166 l_negotiated_by_preparer_flag.DELETE;
5167 l_currency.DELETE;
5168 l_unit_of_measure.DELETE;
5169 l_functional_price.DELETE;
5170 l_contract_num.DELETE;
5171 l_contract_line_num.DELETE;
5172 l_manufacturer.DELETE;
5173 l_manufacturer_part_num.DELETE;
5174 l_rate_type.DELETE;
5175 l_rate_date.DELETE;
5176 l_rate.DELETE;
5177 l_supplier_number.DELETE;
5178 l_supplier_contact_id.DELETE;
5179 l_item_revision.DELETE;
5180 l_line_type_id.DELETE;
5181 l_buyer_id.DELETE;
5182 l_global_agreement_flag.DELETE;
5183 l_status.DELETE;
5184 l_supplier.DELETE;
5185 l_supplier_site_code.DELETE;
5186 l_internal_item_num.DELETE;
5187 l_inventory_organization_id.DELETE;
5188 l_item_source_type.DELETE;
5189 l_item_search_type.DELETE;
5190 l_primary_category_id.DELETE;
5191 l_primary_category_name.DELETE;
5192 l_template_category_id.DELETE;
5193 l_price_rt_item_id.DELETE;
5194 l_price_internal_item_id.DELETE;
5195 l_price_supplier_id.DELETE;
5196 l_price_supplier_part_num.DELETE;
5197 l_price_contract_line_id.DELETE;
5198 l_price_mtl_category_id.DELETE;
5199 l_match_primary_category_id.DELETE;
5200 l_rt_item_id.DELETE;
5201 l_local_rt_item_id.DELETE;
5202 l_match_template_flag.DELETE;
5203 l_active_flag.DELETE;
5204 l_price_rowid.DELETE;
5205
5206 xErrLoc := 220;
5207
5208 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.INFO_LEVEL THEN
5209 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.INFO_LEVEL,
5210 'Start to fetch price row');
5211 END IF;
5212 xErrLoc := 221;
5213 --Bug#3277977
5214 BEGIN
5215 xErrLoc := 222;
5216 IF (ICX_POR_EXT_UTL.getDatabaseVersion < 9.0) THEN
5217 xErrLoc := 150;
5218 EXIT WHEN cUpdatedPriceRows%NOTFOUND;
5219 -- Oracle 8i doesn't support BULK Collect from dynamic SQL
5220 xErrLoc := 151;
5221 FOR i IN 1..ICX_POR_EXT_UTL.gCommitSize LOOP
5222 FETCH cUpdatedPriceRows INTO
5223 l_document_type(i), l_last_update_date(i), l_org_id(i),
5224 l_supplier_id(i), l_supplier(i), l_supplier_site_code(i),
5225 l_supplier_part_num(i), l_internal_item_id(i), l_internal_item_num(i),
5226 l_inventory_organization_id(i), l_item_source_type(i), l_item_search_type(i),
5227 l_mtl_category_id(i), l_category_key(i), l_description(i),
5228 l_picture(i), l_picture_url(i), l_price_type(i),
5229 l_asl_id(i), l_supplier_site_id(i), l_contract_id(i),
5230 l_contract_line_id(i), l_template_id(i), l_template_line_id(i),
5231 l_price_search_type(i), l_unit_price(i),
5232 --FPJ FPSL Extractor Changes
5233 l_value_basis(i), l_purchase_basis(i),
5234 l_allow_price_override_flag(i), l_not_to_exceed_price(i),
5235 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
5236 l_suggested_quantity(i),
5237 -- FPJ Bug# 3110297 jingyu Add negotiated flag
5238 l_negotiated_by_preparer_flag(i),
5239 l_currency(i),
5240 l_unit_of_measure(i), l_functional_price(i), l_contract_num(i),
5241 l_contract_line_num(i), l_manufacturer(i), l_manufacturer_part_num(i),
5242 l_rate_type(i), l_rate_date(i), l_rate(i), l_supplier_number(i),
5243 l_supplier_contact_id(i), l_item_revision(i), l_line_type_id(i),
5244 l_buyer_id(i), l_global_agreement_flag(i), l_status(i),
5245 l_primary_category_id(i), l_primary_category_name(i), l_template_category_id(i),
5246 l_price_rt_item_id(i), l_price_internal_item_id(i), l_price_supplier_id(i),
5247 l_price_supplier_part_num(i), l_price_contract_line_id(i),
5248 l_price_mtl_category_id(i), l_match_primary_category_id(i), l_rt_item_id(i),
5249 l_local_rt_item_id(i), l_match_template_flag(i), l_active_flag(i), l_price_rowid(i);
5250 EXIT WHEN cUpdatedPriceRows%NOTFOUND;
5251 END LOOP;
5252 ELSE
5253 xErrLoc := 200;
5254 FETCH cUpdatedPriceRows
5255 BULK COLLECT INTO
5256 l_document_type, l_last_update_date, l_org_id,
5257 l_supplier_id, l_supplier, l_supplier_site_code,
5258 l_supplier_part_num, l_internal_item_id, l_internal_item_num,
5259 l_inventory_organization_id, l_item_source_type, l_item_search_type,
5260 l_mtl_category_id, l_category_key, l_description,
5261 l_picture, l_picture_url, l_price_type,
5262 l_asl_id, l_supplier_site_id, l_contract_id,
5263 l_contract_line_id, l_template_id, l_template_line_id,
5264 l_price_search_type, l_unit_price,
5265 --FPJ FPSL Extractor Changes
5266 l_value_basis, l_purchase_basis,
5267 l_allow_price_override_flag, l_not_to_exceed_price,
5268 -- new FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
5269 l_suggested_quantity,
5270 -- FPJ Bug# 3110297 jingyu Add negotiated flag
5271 l_negotiated_by_preparer_flag,
5272 l_currency,
5273 l_unit_of_measure, l_functional_price, l_contract_num,
5274 l_contract_line_num, l_manufacturer, l_manufacturer_part_num,
5275 l_rate_type, l_rate_date, l_rate, l_supplier_number,
5276 l_supplier_contact_id, l_item_revision, l_line_type_id,
5277 l_buyer_id, l_global_agreement_flag, l_status,
5278 l_primary_category_id, l_primary_category_name, l_template_category_id,
5279 l_price_rt_item_id, l_price_internal_item_id, l_price_supplier_id,
5280 l_price_supplier_part_num, l_price_contract_line_id,
5281 l_price_mtl_category_id, l_match_primary_category_id, l_rt_item_id,
5282 l_local_rt_item_id, l_match_template_flag, l_active_flag, l_price_rowid
5283 LIMIT ICX_POR_EXT_UTL.gCommitSize;
5284 EXIT WHEN l_document_type.COUNT = 0;
5285 END IF;
5286
5287 xErrLoc := 240;
5288 FOR i in 1..l_document_type.COUNT LOOP
5289 xErrLoc := 241;
5290 gCurrentPrice.document_type := l_document_type(i);
5291 gCurrentPrice.last_update_date := l_last_update_date(i);
5292 gCurrentPrice.org_id := l_org_id(i);
5293 gCurrentPrice.supplier_id := l_supplier_id(i);
5294 gCurrentPrice.supplier_part_num := l_supplier_part_num(i);
5295 gCurrentPrice.internal_item_id := l_internal_item_id(i);
5296 gCurrentPrice.mtl_category_id := l_mtl_category_id(i);
5297 gCurrentPrice.category_key := l_category_key(i);
5298 gCurrentPrice.description := l_description(i);
5299 gCurrentPrice.picture := l_picture(i);
5300 gCurrentPrice.picture_url := l_picture_url(i);
5301 gCurrentPrice.price_type := l_price_type(i);
5302 gCurrentPrice.asl_id := l_asl_id(i);
5303 gCurrentPrice.supplier_site_id := l_supplier_site_id(i);
5304 gCurrentPrice.contract_id := l_contract_id(i);
5305 gCurrentPrice.contract_line_id := l_contract_line_id(i);
5306 gCurrentPrice.template_id := l_template_id(i);
5307 gCurrentPrice.template_line_id := l_template_line_id(i);
5308 gCurrentPrice.price_search_type := l_price_search_type(i);
5309 gCurrentPrice.unit_price := l_unit_price(i);
5310 --FPJ FPSL Extractor Changes
5311 gCurrentPrice.value_basis := l_value_basis(i);
5312 gCurrentPrice.purchase_basis := l_purchase_basis(i);
5313 gCurrentPrice.allow_price_override_flag := l_allow_price_override_flag(i);
5314 gCurrentPrice.not_to_exceed_price := l_not_to_exceed_price(i);
5315 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
5316 gCurrentPrice.suggested_quantity := l_suggested_quantity(i);
5317 -- FPJ Bug# 3110297 jingyu Add negotiated flag
5318 gCurrentPrice.negotiated_by_preparer_flag := l_negotiated_by_preparer_flag(i);
5319 gCurrentPrice.currency := l_currency(i);
5320 gCurrentPrice.unit_of_measure := l_unit_of_measure(i);
5321 gCurrentPrice.functional_price := l_functional_price(i);
5322 gCurrentPrice.contract_num := l_contract_num(i);
5323 gCurrentPrice.contract_line_num := l_contract_line_num(i);
5324 gCurrentPrice.manufacturer := l_manufacturer(i);
5325 gCurrentPrice.manufacturer_part_num := l_manufacturer_part_num(i);
5326 gCurrentPrice.rate_type := l_rate_type(i);
5327 gCurrentPrice.rate_date := l_rate_date(i);
5328 gCurrentPrice.rate := l_rate(i);
5329 gCurrentPrice.supplier_number := l_supplier_number(i);
5330 gCurrentPrice.supplier_contact_id := l_supplier_contact_id(i);
5331 gCurrentPrice.item_revision := l_item_revision(i);
5332 gCurrentPrice.line_type_id := l_line_type_id(i);
5333 gCurrentPrice.buyer_id := l_buyer_id(i);
5334 gCurrentPrice.global_agreement_flag := l_global_agreement_flag(i);
5335 gCurrentPrice.status := l_status(i);
5336 gCurrentPrice.supplier := l_supplier(i);
5337 gCurrentPrice.supplier_site_code := l_supplier_site_code(i);
5338 gCurrentPrice.internal_item_num := l_internal_item_num(i);
5339 gCurrentPrice.inventory_organization_id := l_inventory_organization_id(i);
5340 gCurrentPrice.item_source_type := l_item_source_type(i);
5341 gCurrentPrice.item_search_type := l_item_search_type(i);
5342 gCurrentPrice.primary_category_id := l_primary_category_id(i);
5343 gCurrentPrice.primary_category_name := l_primary_category_name(i);
5344 gCurrentPrice.template_category_id := l_template_category_id(i);
5345 gCurrentPrice.price_rt_item_id := l_price_rt_item_id(i);
5346 gCurrentPrice.price_internal_item_id := l_price_internal_item_id(i);
5347 gCurrentPrice.price_supplier_id := l_price_supplier_id(i);
5348 gCurrentPrice.price_supplier_part_num := l_price_supplier_part_num(i);
5349 gCurrentPrice.price_contract_line_id := l_price_contract_line_id(i);
5350 gCurrentPrice.price_mtl_category_id := l_price_mtl_category_id(i);
5351 gCurrentPrice.match_primary_category_id := l_match_primary_category_id(i);
5352 gCurrentPrice.rt_item_id := l_rt_item_id(i);
5353 gCurrentPrice.local_rt_item_id := l_local_rt_item_id(i);
5354 gCurrentPrice.match_template_flag := l_match_template_flag(i);
5355 gCurrentPrice.active_flag := l_active_flag(i);
5356 gCurrentPrice.price_rowid := l_price_rowid(i);
5357
5358 xErrLoc := 250;
5359
5360 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
5361 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
5362 snapShotPriceRow);
5363 END IF;
5364 gPriceRowCount := gPriceRowCount + 1;
5365 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
5366 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
5367 'Processing price row: ' || gPriceRowCount);
5368 END IF;
5369
5370 xErrLoc := 260;
5371 processPriceRow;
5372
5373 xErrLoc := 280;
5374 processBatchData('INLOOP');
5375
5376 xErrLoc := 281;
5377 END LOOP;
5378
5379 --Bug#3277977
5380 xErrLoc := 282;
5381 EXCEPTION
5382 when snap_shot_too_old then
5383 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
5384 'ORA-01555: snapshot too old: caught at '||
5385 'ICX_POR_EXT_ITEM.extractPriceRows-'||xErrLoc ||
5386 ', Total processed price rows: ' || gPriceRowCount ||
5387 ', SQLERRM:' ||SQLERRM ||
5388 '; so close the cursor and reopen the cursor-');
5389 xErrLoc := 283;
5390 ICX_POR_EXT_UTL.extAFCommit;
5391 IF (cUpdatedPriceRows%ISOPEN) THEN
5392 xErrLoc := 284;
5393 CLOSE cUpdatedPriceRows;
5394 xErrLoc := 285;
5395 OPEN cUpdatedPriceRows for cSqlString;
5396 END IF;
5397 END;
5398
5399 xErrLoc := 286;
5400 END LOOP;
5401
5402 xErrLoc := 300;
5403 processBatchData('OUTLOOP');
5404
5405 xErrLoc := 350;
5406 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
5407 'Total processed price rows: ' || gPriceRowCount);
5408
5409 --Bug#3277977
5410 --Add the close cursor after checking if the cursor is open.
5411 xErrLoc := 400;
5412 IF (cUpdatedPriceRows%ISOPEN) THEN
5413 xErrLoc := 410;
5414 CLOSE cUpdatedPriceRows;
5415 END IF;
5416 xErrLoc := 500;
5417 EXCEPTION
5418 when ICX_POR_EXT_UTL.gException then
5419 ICX_POR_EXT_UTL.extRollback;
5420 IF (cUpdatedPriceRows%ISOPEN) THEN
5421 CLOSE cUpdatedPriceRows;
5422 END IF;
5423
5424 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.extractPriceRows-'||
5425 xErrLoc);
5426 raise ICX_POR_EXT_UTL.gException;
5427 when others then
5428 ICX_POR_EXT_UTL.extRollback;
5429 IF (cUpdatedPriceRows%ISOPEN) THEN
5430 CLOSE cUpdatedPriceRows;
5431 END IF;
5432 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.extractPriceRows-'||
5433 xErrLoc||
5434 ', Total processed price rows: ' || gPriceRowCount ||' '||SQLERRM);
5435
5436 raise ICX_POR_EXT_UTL.gException;
5437 END extractPriceRows;
5438
5439 -- Bug : 3345608
5440 --
5441 -- Function
5442 -- getRate
5443 --
5444 -- Purpose
5445 -- Returns the rate between the from currency and the functional
5446 -- currency of the set of books.
5447 --
5448 -- Arguments
5449 -- x_set_of_books_id Set of books id
5450 -- x_from_currency From currency
5451 -- x_conversion_date Conversion date
5452 -- x_conversion_type Conversion type
5453 -- x_purchasing_org_id Purchasing Operating Unit ID
5454 -- x_owning_org_id Owning org ID
5455 -- x_segment1 Blanket Segment1
5456 --
5457 FUNCTION getRate (
5458 x_set_of_books_id NUMBER,
5459 x_from_currency VARCHAR2,
5460 x_conversion_date DATE,
5461 x_conversion_type VARCHAR2 DEFAULT NULL,
5462 x_purchasing_org_id NUMBER,
5463 x_owning_org_id NUMBER,
5464 x_segment1 VARCHAR2) RETURN NUMBER IS
5465 rate NUMBER;
5466 xErrLoc PLS_INTEGER := 100;
5467 l_purchasing_ou_name VARCHAR2(240) := NULL;
5468 l_owning_ou_name VARCHAR2(240) := NULL;
5469 l_to_currency VARCHAR2(240) := NULL;
5470 -- Bug#3352834
5471 l_user_conv_type GL_DAILY_CONVERSION_TYPES.USER_CONVERSION_TYPE%TYPE;
5472 BEGIN
5473
5474 xErrLoc := 200;
5475
5476 SELECT name
5477 INTO l_owning_ou_name
5478 FROM hr_all_organization_units
5479 WHERE organization_id = x_owning_org_id;
5480
5481 IF x_conversion_type = 'User' THEN
5482
5483 -- Format the error message
5484 ICX_POR_EXT_UTL.pushError('Invalid rate type. The default rate type for ' ||
5485 l_owning_ou_name || ' Operating Unit is set to "User Specified Rate Type" ' ||
5486 'on the Purchasing Options form. Please specify a valid default rate type and ' ||
5487 're-run the Extraction Process.');
5488 xErrLoc := 220;
5489 RAISE ICX_POR_EXT_UTL.gException;
5490 END IF;
5491
5492 xErrLoc := 300;
5493 rate := GL_CURRENCY_API.get_rate(x_set_of_books_id, x_from_currency,
5494 x_conversion_date, x_conversion_type);
5495
5496 xErrLoc := 400;
5497 return( rate );
5498
5499 EXCEPTION
5500 when GL_CURRENCY_API.NO_RATE then
5501 -- Get to_currency from GL_SETS_OF_BOOKS, i.e. the functional currency
5502 SELECT currency_code
5503 INTO l_to_currency
5504 FROM GL_SETS_OF_BOOKS
5505 WHERE set_of_books_id = x_set_of_books_id;
5506
5507 -- Bug#3352834
5508 SELECT USER_CONVERSION_TYPE
5509 INTO l_user_conv_type
5510 FROM GL_DAILY_CONVERSION_TYPES
5511 WHERE CONVERSION_TYPE = x_conversion_type;
5512
5513
5514 -- Format the error message
5515 ICX_POR_EXT_UTL.pushError('Error while processing the Global Blanket ' ||
5516 'Agreement [Segment1: ' || x_segment1 || ' owned by the Operating ' ||
5517 'Unit: ' || l_owning_ou_name || ']');
5518
5519 ICX_POR_EXT_UTL.pushError('The default rate type for the ' ||
5520 'Organization ' || l_owning_ou_name || ' is ' || l_user_conv_type ||
5521 ', and the Daily Rate is not defined between ' || x_from_currency ||
5522 ' and ' || l_to_currency || ' for ' || l_user_conv_type || '. Please ' ||
5523 'specify the daily rate value and re-run the Extraction Process.');
5524
5525 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.getRate-' || xErrLoc);
5526 raise ICX_POR_EXT_UTL.gException;
5527
5528 when others then
5529 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.getRate-' || xErrLoc);
5530 raise ICX_POR_EXT_UTL.gException;
5531 END getRate;
5532
5533 -- Open item prices cursor
5534 --Bug#3277977
5535 --Added pSqlString variable, which will pass the sql string to the calling
5536 --procedure, to be passed to extractPriceRows, so that the cursor can be
5537 --opened in extractPriceRows with the sql String
5538 --PROCEDURE openPriceCursor(pType IN VARCHAR2,
5539 -- pCursor IN OUT NOCOPY tCursorType)
5540 PROCEDURE openPriceCursor(pType IN VARCHAR2,
5541 pSqlString IN OUT NOCOPY VARCHAR2)
5542 IS
5543 xErrLoc PLS_INTEGER := 100;
5544 xSelectStr VARCHAR2(4000) := NULL;
5545 xViewStr VARCHAR2(4000) := NULL;
5546 xViewStr2 VARCHAR2(4000) := NULL;
5547 xFromStr VARCHAR2(4000) := NULL;
5548 xWhereStr VARCHAR2(4000) := NULL;
5549 xString VARCHAR2(4000) := NULL;
5550 -- Bug#3352834
5551 xTmpReqId PLS_INTEGER := NULL;
5552 xOneValidUomCode MTL_UNITS_OF_MEASURE_TL.UNIT_OF_MEASURE%TYPE;
5553
5554 BEGIN
5555 xErrLoc := 100;
5556
5557 -- Bug#3352834
5558 IF (pType = 'TEMPLATE') THEN
5559 xTmpReqId := ICX_POR_EXT_ITEM.TEMPLATE_TEMP_REQUEST_ID;
5560 ELSIF (pType = 'CONTRACT') THEN
5561 xTmpReqId := ICX_POR_EXT_ITEM.CONTRACT_TEMP_REQUEST_ID;
5562 ELSIF (pType = 'GLOBAL_AGREEMENT') THEN
5563 xTmpReqId := ICX_POR_EXT_ITEM.GA_TEMP_REQUEST_ID;
5564 ELSIF (pType = 'ASL') THEN
5565 xTmpReqId := ICX_POR_EXT_ITEM.ASL_TEMP_REQUEST_ID;
5566 ELSIF (pType = 'ITEM') THEN
5567 xTmpReqId := ICX_POR_EXT_ITEM.ITEM_TEMP_REQUEST_ID;
5568 END IF;
5569
5570
5571 xErrLoc := 125;
5572 /* Bug#3693294 : srmani
5573 * Picking up a valid UOM here. Used later in the template cursor,
5574 * for bypassing the Outer join issues for the FPLT Items. */
5575
5576 SELECT unit_of_measure
5577 INTO xOneValidUomCode
5578 FROM mtl_units_of_measure_tl
5579 WHERE rownum = 1;
5580
5581 xErrLoc := 150;
5582
5583 IF pType <> 'GLOBAL_AGREEMENT' THEN
5584 xSelectStr :=
5585 'SELECT /*+ LEADING(doc) */ ' ||
5586 'doc.*, ' ||
5587 'ic1.rt_category_id primary_category_id, ' ||
5588 'ic1.category_name primary_category_name, ';
5589 IF pType = 'TEMPLATE' THEN
5590 xSelectStr := xSelectStr ||
5591 'ic2.rt_category_id template_category_id, ';
5592 ELSE
5593 xSelectStr := xSelectStr ||
5594 'TO_NUMBER(NULL) template_category_id, ';
5595 END IF;
5596 xSelectStr := xSelectStr ||
5597 'p.rt_item_id price_rt_item_id, ' ||
5598 'NVL(i.internal_item_id, '||NULL_NUMBER||
5599 ') price_internal_item_id, ' ||
5600 'NVL(i.supplier_id, '||NULL_NUMBER||') price_supplier_id, ' ||
5601 'NVL(i.supplier_part_num, TO_CHAR('||NULL_NUMBER||
5602 ')) price_supplier_part_num, ' ||
5603 'p.contract_line_id price_contract_line_id, ' ||
5604 'p.mtl_category_id price_mtl_category_id, ' ||
5605 'ic3.rt_category_id match_primary_category_id, ' ||
5606 'TO_NUMBER(NULL) rt_item_id, ' ||
5607 'TO_NUMBER(NULL) local_rt_item_id, '||
5608 '''N'' match_template_flag, ';
5609 -- Here we can set active_flag for ITEM because it is based on
5610 -- inventory_item_id + org_id, not rt_item_id
5611 IF pType = 'ITEM' THEN
5612 xSelectStr := xSelectStr ||
5613 'DECODE(doc.status, ' || ICX_POR_EXT_DIAG.VALID_FOR_EXTRACT ||
5614 ', ICX_POR_EXT_ITEM.getItemActiveFlag(doc.internal_item_id, doc.org_id), ' ||
5615 'NULL) active_flag, ';
5616 ELSE
5617 xSelectStr := xSelectStr ||
5618 'p.active_flag active_flag, ';
5619 END IF;
5620 xSelectStr := xSelectStr ||
5621 'ROWIDTOCHAR(p.rowid) price_rowid ';
5622
5623 xErrLoc := 200;
5624 IF pType = 'TEMPLATE' THEN
5625 xErrLoc := 220;
5626 xViewStr :=
5627 'SELECT DECODE(prl.source_type_code, ''VENDOR'', '||
5628 TEMPLATE_TYPE||', '||
5629 INTERNAL_TEMPLATE_TYPE||') document_type, '||
5630 'greatest(prl.last_update_date, prh.last_update_date) ' ||
5631 'last_update_date, '||
5632 'NVL(prl.org_id, '||NULL_NUMBER||') org_id, '||
5633 'NVL(nvl(ph.vendor_id, prl.suggested_vendor_id), '||
5634 NULL_NUMBER||') supplier_id, '||
5635 'icx_pv.vendor_name supplier, '||
5636 'pvs.vendor_site_code supplier_site_code, '||
5637 'NVL(nvl(pl.vendor_product_num, prl.suggested_vendor_product_code), '||
5638 'TO_CHAR('||NULL_NUMBER||')) supplier_part_num, '||
5639 'NVL(prl.item_id, '||NULL_NUMBER||') internal_item_id, '||
5640 'mi.concatenated_segments internal_item_num, '||
5641 'mi.organization_id inventory_organization_id, '||
5642 'ICX_POR_EXT_ITEM.getItemSourceType(DECODE(prl.source_type_code, ''VENDOR'', '||
5643 '''TEMPLATE'', ''INTERNAL_TEMPLATE''), prl.item_id, ' ||
5644 'mi.purchasing_enabled_flag, mi.outside_operation_flag, ' ||
5645 'mi.list_price_per_unit, l.load_item_master, ' ||
5646 'mi.internal_order_enabled_flag, l.load_internal_item) item_source_type, ' ||
5647 'ICX_POR_EXT_ITEM.getSearchType(DECODE(prl.source_type_code, ''VENDOR'', '||
5648 '''TEMPLATE'', ''INTERNAL_TEMPLATE''), prl.item_id, ' ||
5649 'mi.purchasing_enabled_flag, mi.outside_operation_flag, ' ||
5650 'mi.list_price_per_unit, l.load_item_master, ' ||
5651 'mi.internal_order_enabled_flag, l.load_internal_item) item_search_type, ' ||
5652 'nvl(pl.category_id, prl.category_id) mtl_category_id, '||
5653 'TO_CHAR(nvl(pl.category_id, prl.category_id)) category_key, '||
5654 'prl.item_description description, '||
5655 'TO_CHAR(NULL) picture, '||
5656 'TO_CHAR(NULL) picture_url, '||
5657 'DECODE(prl.source_type_code, ''VENDOR'', '||
5658 '''TEMPLATE'', ''INTERNAL_TEMPLATE'') price_type, '||
5659 'TO_NUMBER('||NULL_NUMBER||') asl_id, '||
5660 'NVL(nvl(ph.vendor_site_id, prl.suggested_vendor_site_id), '||
5661 ''||NULL_NUMBER||') supplier_site_id, '||
5662 'NVL(prl.po_header_id, '||NULL_NUMBER||') contract_id, '||
5663 'NVL(prl.po_line_id, '||NULL_NUMBER||') contract_line_id, '||
5664 'prl.express_name template_id, '||
5665 'prl.sequence_num template_line_id, '||
5666 'DECODE(prl.source_type_code, ''VENDOR'', '||
5667 '''SUPPLIER'', ''INTERNAL'') price_search_type, '||
5668 --FPJ FPSL Extractor Changes
5669 -- If value_basis i.e. order_type_lookup_code is 'FIXED PRICE'
5670 -- Then extractor will store amount in unit_price
5671 'DECODE(prl.source_type_code, ''VENDOR'', '||
5672 'DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', '||
5673 'nvl(pl.amount, prl.amount), '||
5674 'nvl(pl.unit_price, prl.unit_price)), NULL) unit_price, '||
5675 --FPJ FPSL Extractor Changes
5676 'pltb.order_type_lookup_code value_basis, '||
5677 'pltb.purchase_basis purchase_basis, '||
5678 --FPJ FPSL Extractor Changes
5679 --allow_price_override_flag and not_to_exceed_price are not
5680 --supported in req templates, so we will get it directly
5681 --from po lines if the req template is sourced from a po.
5682 'pl.allow_price_override_flag allow_price_override_flag, '||
5683 'pl.not_to_exceed_price not_to_exceed_price, '||
5684 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
5685 'prl.suggested_quantity suggested_quantity, '||
5686 -- FPJ Bug# 3110297 jingyu Add negotiated flag
5687 'nvl(pl.negotiated_by_preparer_flag, prl.negotiated_by_preparer_flag) negotiated_by_preparer_flag, '||
5688 'DECODE(prl.source_type_code, ''VENDOR'', '||
5689 'nvl(ph.currency_code, gsb.currency_code), NULL) currency, '||
5690
5691 /* Bug#3693294 : srmani
5692 * An Outer Join is required with UOMTL Table, as the Fixed Price Line Type Items do not have
5693 * a UOM (is null).
5694 * But as we need to pick up the uom from the Po Lines table (when a template is sourced from a
5695 * blanket line), we can't have this outer join in the uomtl table.
5696 * As a hack to eliminate the outer join, we're equating the FPLT Item with a valid UOM , that is
5697 * retrieved at the start of this procedure for the equi join condition.
5698 * Here in the select we want to put back the UOM as null for the FPLT Item Prices.
5699 */
5700 'DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', NULL, uomtl.uom_code) unit_of_measure, '||
5701 --FPJ FPSL Extractor Changes
5702 'DECODE(prl.source_type_code, ''VENDOR'', '||
5703 'nvl(decode(gc.minimum_accountable_unit, null, '||
5704 'round(DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', '||
5705 'pl.amount, pl.unit_price)*nvl(ph.rate, 1),gc.extended_precision), '||
5706 'round(DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', '||
5707 'pl.amount, pl.unit_price)*nvl(ph.rate, 1)/gc.minimum_accountable_unit)* '||
5708 'gc.minimum_accountable_unit), '||
5709 'DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', '||
5710 'prl.amount, prl.unit_price)), NULL) functional_price, '||
5711 'ph.segment1 contract_num, '||
5712 'pl.line_num contract_line_num, '||
5713 'TO_CHAR(NULL) manufacturer, '||
5714 'TO_CHAR(NULL) manufacturer_part_num, '||
5715 'ph.rate_type, '||
5716 'ph.rate_date, '||
5717 'ph.rate, '||
5718 'icx_pv.segment1 supplier_number, '||
5719 'NVL(ph.vendor_contact_id, prl.suggested_vendor_contact_id) supplier_contact_id, '||
5720 'prl.item_revision, '||
5721 'prl.line_type_id, '||
5722 'prl.suggested_buyer_id buyer_id, '||
5723 'TO_CHAR(NULL) global_agreement_flag, '||
5724 'ICX_POR_EXT_DIAG.getTemplateLineStatus(prl.express_name, '||
5725 'prl.sequence_num, prl.org_id, prh.inactive_date, '||
5726 'prl.po_line_id, '''||ICX_POR_EXT_TEST.gTestMode||''') status ';
5727 xViewStr2 :=
5728 'FROM icx_por_loader_values l, ';
5729 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
5730 xViewStr2 := xViewStr2 ||
5731 'ipo_reqexpress_headers_all prh, '||
5732 'ipo_reqexpress_lines_all prl, '||
5733 'ipo_headers_all ph, '||
5734 'ipo_lines_all pl, '||
5735 'imtl_system_items_kfv mi, '||
5736 'ipo_vendors icx_pv, '||
5737 'ipo_vendor_sites_all pvs, '||
5738 'igl_sets_of_books gsb, '||
5739 'ifinancials_system_params_all fsp, '||
5740 --FPJ FPSL Extractor Changes
5741 'ipo_line_types_b pltb, ';
5742 ELSE
5743 xViewStr2 := xViewStr2 ||
5744 'po_reqexpress_headers_all prh, '||
5745 'po_reqexpress_lines_all prl, '||
5746 'po_headers_all ph, '||
5747 'po_lines_all pl, '||
5748 'mtl_system_items_kfv mi, '||
5749 'po_vendors icx_pv, '||
5750 'po_vendor_sites_all pvs, '||
5751 'gl_sets_of_books gsb, '||
5752 'financials_system_params_all fsp, '||
5753 --FPJ FPSL Extractor Changes
5754 'po_line_types_b pltb, ';
5755 END IF;
5756 xViewStr2 := xViewStr2 ||
5757 'mtl_units_of_measure_tl uomtl, '||
5758 'gl_currencies gc '||
5759 -- Bug#3213218/3163334 : pcreddy - Check for the load flag to be 'Y'.
5760 'WHERE ( (l.load_template_lines = ''Y'' AND ' ||
5761 ' l.template_lines_last_run_date IS NULL) OR ' ||
5762 -- 'WHERE (l.template_lines_last_run_date IS NULL OR '||
5763 'greatest(NVL(mi.last_update_date, l.template_lines_last_run_date-1), ' ||
5764 'prl.last_update_date, prh.last_update_date) > '||
5765 'l.template_lines_last_run_date OR '||
5766 'prh.inactive_date BETWEEN l.template_lines_last_run_date AND '||
5767 'SYSDATE) '||
5768 'AND prl.express_name = prh.express_name '||
5769
5770 /* Bug#3693294 : srmani. Pick up the UOM from the
5771 * - BPA Line (when sourced from a BPA),
5772 * - Template Line (otherwise).
5773 * To do this we'll have to equate the UOM Code in the Po Lines table with UOMTL
5774 * As, there already exists an outer join on Po Lines, we can't have the outer
5775 * join on UOMTL (introduced for FPLT Items. ). To still have this work functionally
5776 * without an outerjoin, we're doing an equi-join on Template Line (with line type
5777 * as fixed price) and UOMTL using a valid UOM (retrieved earlier in the procedure.
5778 */
5779
5780 'AND DECODE(pltb.order_type_lookup_code, ' ||
5781 ' ''FIXED PRICE'', ''' || xOneValidUomCode || ''' , ' ||
5782 ' NVL(pl.unit_meas_lookup_code, prl.unit_meas_lookup_code) ) = ' ||
5783 ' uomtl.unit_of_measure ' ||
5784 'AND uomtl.language = ''' || ICX_POR_EXTRACTOR.gBaseLang || ''' ' ||
5785 --Bug#2998604 'AND uomtl.source_lang = uomtl.language '||
5786 'AND (prl.org_id is null and prh.org_id is null or '||
5787 'prl.org_id = prh.org_id) '||
5788 'AND prl.po_header_id = ph.po_header_id(+) '||
5789 'AND prl.po_line_id = pl.po_line_id(+) '||
5790 'AND (prh.org_id is null and fsp.org_id is null or '||
5791 'prh.org_id = fsp.org_id) '||
5792 'AND gsb.set_of_books_id = fsp.set_of_books_id '||
5793 'AND nvl(ph.currency_code, gsb.currency_code) = gc.currency_code '||
5794 'AND fsp.inventory_organization_id = NVL(mi.organization_id, '||
5795 'fsp.inventory_organization_id) '||
5796 'AND prl.item_id = mi.inventory_item_id (+) '||
5797 'AND prl.suggested_vendor_id = icx_pv.vendor_id (+) '||
5798 'AND prl.suggested_vendor_site_id = pvs.vendor_site_id (+) '||
5799 --FPJ FPSL Extractor Changes
5800 'AND prl.line_type_id = pltb.line_type_id '||
5801 'AND NVL(pltb.purchase_basis, ''NULL'') <> ''TEMP LABOR'' ';
5802 ELSIF pType = 'CONTRACT' THEN
5803 xErrLoc := 240;
5804 xViewStr :=
5805 'SELECT '||CONTRACT_TYPE||' document_type, '||
5806 'greatest(pl.last_update_date, ph.last_update_date) '||
5807 'last_update_date, '||
5808 'NVL(pl.org_id, '||NULL_NUMBER||') org_id, '||
5809 'NVL(ph.vendor_id, '||NULL_NUMBER||') supplier_id, '||
5810 'icx_pv.vendor_name supplier, '||
5811 '';
5812 -- Bug # 3865316
5813 -- Check for multiOrgFlag - gMultiOrgFlag
5814 IF gMultiOrgFlag = 'Y' THEN
5815 xViewStr := xViewStr ||
5816 -- pcreddy : Bug # 3258805
5817 -- For global agr, get the purchasing site from po_ga_org_assignments
5818 'DECODE(NVL(ph.global_agreement_flag, ''N''), ''N'', pvs.vendor_site_code, '||
5819 '''Y'', pvs1.vendor_site_code) supplier_site_code, '||
5820 '';
5821 ELSE
5822 xViewStr := xViewStr ||
5823 'pvs.vendor_site_code supplier_site_code, ';
5824 END IF;
5825 xViewStr := xViewStr ||
5826 'NVL(pl.vendor_product_num, TO_CHAR('||NULL_NUMBER||
5827 ')) supplier_part_num, '||
5828 'NVL(pl.item_id, '||NULL_NUMBER||') internal_item_id, '||
5829 'mi.concatenated_segments internal_item_num, '||
5830 'mi.organization_id inventory_organization_id, '||
5831 'ICX_POR_EXT_ITEM.getItemSourceType(''CONTRACT'', pl.item_id, ' ||
5832 'mi.purchasing_enabled_flag, mi.outside_operation_flag, ' ||
5833 'mi.list_price_per_unit, l.load_item_master, ' ||
5834 'mi.internal_order_enabled_flag, l.load_internal_item) item_source_type, ' ||
5835 '''SUPPLIER'' item_search_type, '||
5836 'pl.category_id mtl_category_id, '||
5837 'TO_CHAR(pl.category_id) category_key, '||
5838 'pl.item_description description, '||
5839 'NVL(pl.attribute13, pl.attribute14) picture, '||
5840 'pl.attribute14 picture_url, '||
5841 'ph.type_lookup_code price_type, '||
5842 'TO_NUMBER('||NULL_NUMBER||') asl_id, '||
5843 '';
5844 -- Bug # 3865316
5845 -- Check for multiOrgFlag - gMultiOrgFlag
5846 IF gMultiOrgFlag = 'Y' THEN
5847 xViewStr := xViewStr ||
5848 -- pcreddy : Bug # 3258805
5849 -- For global agr, get the purchasing site from po_ga_org_assignments
5850 'DECODE(NVL(ph.global_agreement_flag, ''N''), ''N'', '||
5851 'NVL(ph.vendor_site_id, '||NULL_NUMBER||'), '||
5852 '''Y'', NVL(t.vendor_site_id, '||NULL_NUMBER||')) supplier_site_id, '||
5853 '';
5854 ELSE
5855 xViewStr := xViewStr ||
5856 'NVL(ph.vendor_site_id, '||NULL_NUMBER||') supplier_site_id, ';
5857 END IF;
5858 xViewStr := xViewStr ||
5859 'pl.po_header_id contract_id, '||
5860 'pl.po_line_id contract_line_id, '||
5861 'TO_CHAR('||NULL_NUMBER||') template_id, '||
5862 'TO_NUMBER('||NULL_NUMBER||') template_line_id, '||
5863 '''SUPPLIER'' price_search_type, '||
5864 --FPJ FPSL Extractor Changes
5865 -- If value_basis i.e. order_type_lookup_code is 'FIXED PRICE'
5866 -- Then extractor will store amount in unit_price
5867 'DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', '||
5868 'pl.amount, pl.unit_price) unit_price, '||
5869 --FPJ FPSL Extractor Changes
5870 'pltb.order_type_lookup_code value_basis, '||
5871 'pltb.purchase_basis purchase_basis, '||
5872 'pl.allow_price_override_flag allow_price_override_flag, '||
5873 'pl.not_to_exceed_price not_to_exceed_price, '||
5874 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
5875 'TO_NUMBER('||NULL_NUMBER||') suggested_quantity, '||
5876 -- FPJ Bug# 3110297 jingyu Add negotiated flag
5877 'DECODE(ph.type_lookup_code, ''QUOTATION'', ''Y'', pl.negotiated_by_preparer_flag) negotiated_by_preparer_flag, ' ||
5878 'ph.currency_code currency, '||
5879 'uomtl.uom_code unit_of_measure, '||
5880 '';
5881 -- Bug # 3865316
5882 -- Check for multiOrgFlag - gMultiOrgFlag
5883 IF gMultiOrgFlag = 'Y' THEN
5884 xViewStr := xViewStr ||
5885 /* Bug#3541008 : Functional Price Calculation
5886 * Rate Type and Rate
5887 * BPA : Use the Rate from the Blanket
5888 * GBPA : Use the Default Rate specified in the Purchasing Options for that Org.
5889 * Price
5890 * Fixed Price Line Type : Use the Amount Field.
5891 * Other Line Types : Use the Unit Price Field.
5892 */
5893 'DECODE(NVL(ph.global_agreement_flag, ''N''), '||
5894 '''N'', decode(gc.minimum_accountable_unit, null, '||
5895 'round(DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', pl.amount, pl.unit_price) * '||
5896 'nvl(ph.rate, 1),gc.extended_precision), '||
5897 'round(DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', pl.amount, pl.unit_price) * '||
5898 'nvl(ph.rate, 1)/gc.minimum_accountable_unit) * gc.minimum_accountable_unit), '||
5899 '''Y'', ICX_CAT_UTIL_PKG.convert_amount_sql(ph.currency_code, gsb.currency_code, SYSDATE, '||
5900 'icx_psp.default_rate_type, DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', '||
5901 'pl.amount, pl.unit_price))) functional_price, '||
5902 '';
5903 ELSE
5904 xViewStr := xViewStr ||
5905 'decode(gc.minimum_accountable_unit, null, '||
5906 'round(DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', pl.amount, pl.unit_price) * '||
5907 'nvl(ph.rate, 1),gc.extended_precision), '||
5908 'round(DECODE(pltb.order_type_lookup_code, ''FIXED PRICE'', pl.amount, pl.unit_price) * '||
5909 'nvl(ph.rate, 1)/gc.minimum_accountable_unit) * gc.minimum_accountable_unit) functional_price, ';
5910 END IF;
5911 xViewStr := xViewStr ||
5912 'ph.segment1 contract_num, '||
5913 'pl.line_num contract_line_num, '||
5914 'TO_CHAR(NULL) manufacturer, '||
5915 'TO_CHAR(NULL) manufacturer_part_num, '||
5916 '';
5917 -- Bug # 3865316
5918 -- Check for multiOrgFlag - gMultiOrgFlag
5919 IF gMultiOrgFlag = 'Y' THEN
5920 xViewStr := xViewStr ||
5921 -- Bug# 2945205: pcreddy: For GA, Extract rate Info from po_system_parameters
5922 -- 'ph.rate_type, '||
5923 'DECODE(NVL(ph.global_agreement_flag, ''N''), '||
5924 '''Y'', icx_psp.default_rate_type, '||
5925 '''N'', ph.rate_type) rate_type, '||
5926 '';
5927 ELSE
5928 xViewStr := xViewStr ||
5929 'ph.rate_type rate_type, ';
5930 END IF;
5931 xViewStr := xViewStr ||
5932 'ph.rate_date, '||
5933 '';
5934 -- Bug # 3865316
5935 -- Check for multiOrgFlag - gMultiOrgFlag
5936 IF gMultiOrgFlag = 'Y' THEN
5937 xViewStr := xViewStr ||
5938 -- 'ph.rate, '||
5939 'DECODE(NVL(ph.global_agreement_flag, ''N''), '||
5940 '''N'', ph.rate, ' ||
5941 '''Y'', ICX_POR_EXT_ITEM.getRate(fsp.set_of_books_id, '||
5942 'ph.currency_code, '||
5943 'sysdate, '||
5944 'icx_psp.default_rate_type, '||
5945 't.purchasing_org_id, '||
5946 'ph.org_id, '||
5947 'ph.segment1)) rate, '||
5948 '';
5949 ELSE
5950 xViewStr := xViewStr ||
5951 'ph.rate, ';
5952 END IF;
5953 xViewStr := xViewStr ||
5954 'icx_pv.segment1 supplier_number, '||
5955 'ph.vendor_contact_id supplier_contact_id, '||
5956 'pl.item_revision, '||
5957 'pl.line_type_id, '||
5958 'ph.agent_id buyer_id, '||
5959 'ph.global_agreement_flag, '||
5960 'ICX_POR_EXT_DIAG.getContractLineStatus(pl.po_line_id, '''||
5961 ICX_POR_EXT_TEST.gTestMode||''') status ';
5962 xViewStr2 :=
5963 'FROM icx_por_loader_values l, ';
5964 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
5965 xViewStr2 := xViewStr2 ||
5966 'ipo_headers_all ph, '||
5967 'ipo_lines_all pl, '||
5968 'imtl_system_items_kfv mi, '||
5969 'ipo_vendors icx_pv, '||
5970 'ipo_vendor_sites_all pvs, '||
5971 'ifinancials_system_params_all fsp, '||
5972 'igl_sets_of_books gsb, '||
5973 '';
5974 -- Bug # 3865316
5975 -- Check for multiOrgFlag - gMultiOrgFlag
5976 IF gMultiOrgFlag = 'Y' THEN
5977 xViewStr2 := xViewStr2 ||
5978 -- Bug# 2945205: pcreddy
5979 'ipo_system_parameters_all icx_psp, '||
5980 -- pcreddy : Bug # 3258805
5981 -- For global agr, get the purchasing site from po_ga_org_assignments
5982 'ipo_ga_org_assignments t, '||
5983 'ipo_vendor_sites_all pvs1, '||
5984 '';
5985 END IF;
5986 xViewStr2 := xViewStr2 ||
5987 --FPJ FPSL Extractor Changes
5988 'ipo_line_types_b pltb, ';
5989 ELSE
5990 xViewStr2 := xViewStr2 ||
5991 'po_headers_all ph, '||
5992 'po_lines_all pl, '||
5993 'mtl_system_items_kfv mi, '||
5994 'po_vendors icx_pv, '||
5995 'po_vendor_sites_all pvs, '||
5996 'financials_system_params_all fsp, '||
5997 'gl_sets_of_books gsb, '||
5998 '';
5999 -- Bug # 3865316
6000 -- Check for multiOrgFlag - gMultiOrgFlag
6001 IF gMultiOrgFlag = 'Y' THEN
6002 xViewStr2 := xViewStr2 ||
6003 -- Bug# 2945205: pcreddy
6004 'po_system_parameters_all icx_psp, '||
6005 -- pcreddy : Bug # 3258805
6006 -- For global agr, get the purchasing site from po_ga_org_assignments
6007 'po_ga_org_assignments t, '||
6008 'po_vendor_sites_all pvs1, '||
6009 '';
6010 END IF;
6011 xViewStr2 := xViewStr2 ||
6012 --FPJ FPSL Extractor Changes
6013 'po_line_types_b pltb, ';
6014 END IF;
6015 xViewStr2 := xViewStr2 ||
6016 'mtl_units_of_measure_tl uomtl, '||
6017 'gl_currencies gc, '||
6018 --Bug : 4474307
6019 'mtl_categories_kfv mck ' ||
6020 'WHERE (l.contracts_last_run_date IS NULL OR '||
6021 'greatest(NVL(mi.last_update_date, l.contracts_last_run_date-1), '||
6022 'pl.last_update_date, ph.last_update_date ';
6023 -- Bug # 3865316
6024 -- Check for multiOrgFlag - gMultiOrgFlag
6025 IF gMultiOrgFlag = 'Y' THEN
6026 xViewStr2 := xViewStr2 ||
6027 ', icx_psp.last_update_date ';
6028 END IF;
6029 xViewStr2 := xViewStr2 ||
6030 ') > l.contracts_last_run_date OR '||
6031 --Bug#4474307 : This condition will pick contracts after the the corresponding
6032 -- category is re-enabled for the web.
6033 'mck.last_update_date > l.contracts_last_run_date OR ' ||
6034 'ph.end_date BETWEEN l.contracts_last_run_date AND SYSDATE OR '||
6035 -- pcreddy # 3122831
6036 'trunc(ph.start_date) between trunc(l.contracts_last_run_date) and trunc(sysdate) OR '||
6037 'pl.expiration_date BETWEEN l.contracts_last_run_date AND '||
6038 'SYSDATE OR '||
6039 '(ph.type_lookup_code = ''QUOTATION'' AND '||
6040 'EXISTS (SELECT ''updated quotaion line location'' ';
6041 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
6042 xViewStr2 := xViewStr2 ||
6043 'FROM ipo_line_locations_all pll, '||
6044 'ipo_quotation_approvals_all pqa ';
6045 ELSE
6046 xViewStr2 := xViewStr2 ||
6047 'FROM po_line_locations_all pll, '||
6048 'po_quotation_approvals_all pqa ';
6049 END IF;
6050 xViewStr2 := xViewStr2 ||
6051 'WHERE pll.po_line_id = pl.po_line_id '||
6052 'AND pqa.line_location_id = pll.line_location_id '||
6053 'AND GREATEST(pll.last_update_date, pqa.last_update_date) > '||
6054 'l.contracts_last_run_date))) '||
6055 'AND ph.po_header_id = pl.po_header_id '||
6056 --Bug #4474307
6057 'AND mck.category_id = pl.category_id ' ||
6058 --Bug #4474307 - end
6059 '';
6060 -- Bug # 3865316
6061 -- Check for multiOrgFlag - gMultiOrgFlag
6062 IF gMultiOrgFlag = 'Y' THEN
6063 xViewStr2 := xViewStr2 ||
6064 -- pcreddy : Bug # 3258805
6065 -- For global agr, get the purchasing site from po_ga_org_assignments
6066 'AND ph.po_header_id = t.po_header_id (+) '||
6067 'AND ph.org_id = t.organization_id (+) '||
6068 'AND t.vendor_site_id = pvs1.vendor_site_id (+) '||
6069 '';
6070 END IF;
6071 xViewStr2 := xViewStr2 ||
6072 --FPJ FPSL Extractor Changes
6073 --For Fixed Price Service line types i.e
6074 --order_type_lookup_code='FIXED PRICE' pl.unit_meas_lookup_code will be null
6075 'AND pl.unit_meas_lookup_code = uomtl.unit_of_measure(+) '||
6076 'AND uomtl.language(+) = '''||ICX_POR_EXTRACTOR.gBaseLang||''' ' ||
6077 --Bug#2998604 'AND uomtl.source_lang = uomtl.language '||
6078 'AND ph.type_lookup_code in (''BLANKET'', ''QUOTATION'') '||
6079 'AND ph.currency_code = gc.currency_code '||
6080 'AND (ph.org_id is null and fsp.org_id is null or '||
6081 'ph.org_id = fsp.org_id) '||
6082 'AND fsp.inventory_organization_id = NVL(mi.organization_id, '||
6083 'fsp.inventory_organization_id) '||
6084 'AND fsp.set_of_books_id = gsb.set_of_books_id '||
6085 'AND pl.item_id = mi.inventory_item_id (+) '||
6086 'AND ph.vendor_id = icx_pv.vendor_id '||
6087 'AND ph.vendor_site_id = pvs.vendor_site_id (+) '||
6088 '';
6089 -- Bug # 3865316
6090 -- Check for multiOrgFlag - gMultiOrgFlag
6091 IF gMultiOrgFlag = 'Y' THEN
6092 xViewStr2 := xViewStr2 ||
6093 -- Bug# 2945205: pcreddy
6094 'AND ph.org_id = icx_psp.org_id '||
6095 '';
6096 END IF;
6097 xViewStr2 := xViewStr2 ||
6098 --FPJ FPSL Extractor Changes
6099 'AND pl.line_type_id = pltb.line_type_id '||
6100 'AND NVL(pltb.purchase_basis, ''NULL'') <> ''TEMP LABOR'' ';
6101 ELSIF pType = 'ASL' THEN
6102 xErrLoc := 260;
6103 xViewStr :=
6104 'SELECT /*+ LEADING(pasl) */'||ASL_TYPE||' document_type, '||
6105 'pasl.last_update_date, '||
6106 'NVL(fsp.org_id, '||NULL_NUMBER||') org_id, '||
6107 'NVL(pasl.vendor_id, '||NULL_NUMBER||') supplier_id, '||
6108 'icx_pv.vendor_name supplier, '||
6109 'pvs.vendor_site_code supplier_site_code, '||
6110 'NVL(pasl.primary_vendor_item, TO_CHAR('||NULL_NUMBER||
6111 ')) supplier_part_num, '||
6112 'pasl.item_id internal_item_id, '||
6113 'mi.concatenated_segments internal_item_num, '||
6114 'mi.organization_id inventory_organization_id, '||
6115 'ICX_POR_EXT_ITEM.getItemSourceType(''ASL'', pasl.item_id, ' ||
6116 'mi.purchasing_enabled_flag, mi.outside_operation_flag, ' ||
6117 'mi.list_price_per_unit, l.load_item_master, ' ||
6118 'mi.internal_order_enabled_flag, l.load_internal_item) item_source_type, ' ||
6119 '''SUPPLIER'' item_search_type, '||
6120 'NVL(pasl.category_id, mic.category_id) mtl_category_id, '||
6121 'TO_CHAR(NVL(pasl.category_id, mic.category_id)) category_key, '||
6122 'mitl.description description, '||
6123 'TO_CHAR(NULL) picture, '||
6124 'TO_CHAR(NULL) picture_url, '||
6125 '''ASL'' price_type, '||
6126 'pasl.asl_id, '||
6127 'NVL(pasl.vendor_site_id, '||NULL_NUMBER||') supplier_site_id, '||
6128 'TO_NUMBER('||NULL_NUMBER||') contract_id, '||
6129 'TO_NUMBER('||NULL_NUMBER||') contract_line_id, '||
6130 'TO_CHAR('||NULL_NUMBER||') template_id, '||
6131 'TO_NUMBER('||NULL_NUMBER||') template_line_id, '||
6132 '''SUPPLIER'' price_search_type, '||
6133 'mi.list_price_per_unit unit_price, '||
6134 --FPJ FPSL Extractor Changes
6135 'TO_CHAR(NULL) value_basis, '||
6136 'TO_CHAR(NULL) purchase_basis, '||
6137 'TO_CHAR(NULL) allow_price_override_flag, '||
6138 'TO_NUMBER(NULL) not_to_exceed_price, '||
6139 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
6140 'TO_NUMBER('||NULL_NUMBER||') suggested_quantity, '||
6141 -- FPJ Bug# 3110297 jingyu Add negotiated flag
6142 '''N'' negotiated_by_preparer_flag, ' ||
6143 'gsb.currency_code currency, '||
6144 'mi.primary_uom_code unit_of_measure, '||
6145 'mi.list_price_per_unit functional_price, '||
6146 'TO_CHAR(NULL) contract_num, '||
6147 'TO_NUMBER(NULL) contract_line_num, '||
6148 'TO_CHAR(NULL) manufacturer, '||
6149 'TO_CHAR(NULL) manufacturer_part_num, '||
6150 'TO_CHAR(NULL) rate_type, '||
6151 'TO_DATE(NULL) rate_date, '||
6152 'TO_NUMBER(NULL) rate, '||
6153 'TO_CHAR(NULL) supplier_number, '||
6154 'TO_NUMBER(NULL) supplier_contact_id, '||
6155 'TO_CHAR(NULL) item_revision, '||
6156 'TO_NUMBER(NULL) line_type_id, '||
6157 'TO_NUMBER(NULL) buyer_id, '||
6158 'TO_CHAR(NULL) global_agreement_flag, '||
6159 'ICX_POR_EXT_DIAG.getASLStatus(pasl.asl_id, '||
6160 'pasl.disable_flag, pasl.asl_status_id, '||
6161 'mi.list_price_per_unit, '''||ICX_POR_EXT_TEST.gTestMode||
6162 ''') status ';
6163 xViewStr2 :=
6164 'FROM icx_por_loader_values l, ';
6165 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
6166 xViewStr2 := xViewStr2 ||
6167 'ipo_approved_supplier_list pasl, '||
6168 'imtl_system_items_kfv mi, '||
6169 'imtl_system_items_tl mitl, '||
6170 'imtl_item_categories mic, '||
6171 'ipo_vendors icx_pv, '||
6172 'ipo_vendor_sites_all pvs, '||
6173 'igl_sets_of_books gsb, '||
6174 'ifinancials_system_params_all fsp ';
6175 ELSE
6176 xViewStr2 := xViewStr2 ||
6177 'po_approved_supplier_list pasl, '||
6178 'mtl_system_items_kfv mi, '||
6179 'mtl_system_items_tl mitl, '||
6180 'mtl_item_categories mic, '||
6181 'po_vendors icx_pv, '||
6182 'po_vendor_sites_all pvs, '||
6183 'gl_sets_of_books gsb, '||
6184 'financials_system_params_all fsp ';
6185 END IF;
6186 xViewStr2 := xViewStr2 ||
6187 -- Bug#3213218/3163334 : pcreddy - Check for the load flag to be 'Y'.
6188 'WHERE ( (l.load_item_master = ''Y'' AND ' ||
6189 ' l.item_master_last_run_date IS NULL) OR ' ||
6190 -- 'WHERE (l.item_master_last_run_date IS NULL OR '||
6191 'GREATEST(NVL(mi.last_update_date, l.item_master_last_run_date-1), '||
6192 'pasl.last_update_date) > l.item_master_last_run_date) '||
6193 'AND mic.category_set_id = '||gCategorySetId||' '||
6194 'AND fsp.inventory_organization_id = pasl.owning_organization_id '||
6195 'AND mic.inventory_item_id = pasl.item_id '||
6196 'AND mic.organization_id = pasl.owning_organization_id '||
6197 'AND pasl.item_id = mi.inventory_item_id '||
6198 'AND pasl.owning_organization_id = mi.organization_id '||
6199 'AND fsp.set_of_books_id = gsb.set_of_books_id '||
6200 'AND mi.inventory_item_id = mitl.inventory_item_id '||
6201 'AND mi.organization_id = mitl.organization_id '||
6202 'AND mitl.language = '''||ICX_POR_EXTRACTOR.gBaseLang||''' '||
6203 'AND pasl.vendor_id = icx_pv.vendor_id '||
6204 'AND pasl.vendor_site_id = pvs.vendor_site_id (+) ';
6205 ELSIF pType = 'ITEM' THEN
6206 xErrLoc := 280;
6207 -- bug #4404948 - Need to add the hint in the ITEM query of openPriceCursor()
6208 xViewStr :=
6209 --'SELECT type.document_type, '||
6210 'SELECT /*+ cardinality(type 2) first_rows use_nl(type l fsp) */ type.document_type, '||
6211 'mi.last_update_date, '||
6212 'NVL(fsp.org_id, '||NULL_NUMBER||') org_id, '||
6213 'TO_NUMBER('||NULL_NUMBER||') supplier_id, '||
6214 'TO_CHAR(NULL) supplier, '||
6215 'TO_CHAR(NULL) supplier_site_code, '||
6216 'TO_CHAR('||NULL_NUMBER||') supplier_part_num, '||
6217 'mi.inventory_item_id internal_item_id, '||
6218 'mi.concatenated_segments internal_item_num, '||
6219 'mi.organization_id inventory_organization_id, '||
6220 'ICX_POR_EXT_ITEM.getItemSourceType(type.price_type, mi.inventory_item_id, ' ||
6221 'mi.purchasing_enabled_flag, mi.outside_operation_flag, ' ||
6222 'mi.list_price_per_unit, l.load_item_master, ' ||
6223 'mi.internal_order_enabled_flag, l.load_internal_item) item_source_type, ' ||
6224 'ICX_POR_EXT_ITEM.getSearchType(type.price_type, mi.inventory_item_id, ' ||
6225 'mi.purchasing_enabled_flag, mi.outside_operation_flag, ' ||
6226 'mi.list_price_per_unit, l.load_item_master, ' ||
6227 'mi.internal_order_enabled_flag, l.load_internal_item) item_search_type, ' ||
6228 'mic.category_id mtl_category_id, '||
6229 'TO_CHAR(mic.category_id) category_key, '||
6230 'TO_CHAR(NULL) description, '||
6231 'TO_CHAR(NULL) picture, '||
6232 'TO_CHAR(NULL) picture_url, '||
6233 'type.price_type, '||
6234 'TO_NUMBER('||NULL_NUMBER||') asl_id, '||
6235 'TO_NUMBER('||NULL_NUMBER||') supplier_site_id, '||
6236 'TO_NUMBER('||NULL_NUMBER||') contract_id, '||
6237 'TO_NUMBER('||NULL_NUMBER||') contract_line_id, '||
6238 'TO_CHAR('||NULL_NUMBER||') template_id, '||
6239 'TO_NUMBER('||NULL_NUMBER||') template_line_id, '||
6240 'type.price_search_type, '||
6241 'DECODE(type.document_type, '||PURCHASING_ITEM_TYPE||', '||
6242 'mi.list_price_per_unit, NULL) unit_price, '||
6243 --FPJ FPSL Extractor Changes
6244 'TO_CHAR(NULL) value_basis, '||
6245 'TO_CHAR(NULL) purchase_basis, '||
6246 'TO_CHAR(NULL) allow_price_override_flag, '||
6247 'TO_NUMBER(NULL) not_to_exceed_price, '||
6248 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
6249 'TO_NUMBER('||NULL_NUMBER||') suggested_quantity, '||
6250 -- FPJ Bug# 3110297 jingyu Add negotiated flag
6251 '''N'' negotiated_by_preparer_flag, ' ||
6252 'DECODE(type.document_type, '||PURCHASING_ITEM_TYPE||', '||
6253 'gsb.currency_code, NULL) currency, '||
6254 'DECODE(type.document_type, '||PURCHASING_ITEM_TYPE||', '||
6255 'mi.primary_uom_code, '||
6256 'NVL(muom.uom_code, mi.primary_uom_code)) unit_of_measure, '||
6257 'DECODE(type.document_type, '||PURCHASING_ITEM_TYPE||', '||
6258 'mi.list_price_per_unit, NULL) functional_price, '||
6259 'TO_CHAR(NULL) contract_num, '||
6260 'TO_NUMBER(NULL) contract_line_num, '||
6261 'TO_CHAR(NULL) manufacturer, '||
6262 'TO_CHAR(NULL) manufacturer_part_num, '||
6263 'TO_CHAR(NULL) rate_type, '||
6264 'TO_DATE(NULL) rate_date, '||
6265 'TO_NUMBER(NULL) rate, '||
6266 'TO_CHAR(NULL) supplier_number, '||
6267 'TO_NUMBER(NULL) supplier_contact_id, '||
6268 'TO_CHAR(NULL) item_revision, '||
6269 'TO_NUMBER(NULL) line_type_id, '||
6270 'TO_NUMBER(NULL) buyer_id, '||
6271 'TO_CHAR(NULL) global_agreement_flag, '||
6272 'DECODE(type.document_type, '||PURCHASING_ITEM_TYPE||', '||
6273 'ICX_POR_EXT_DIAG.getPurchasingItemStatus(mi.purchasing_enabled_flag, '||
6274 'mi.outside_operation_flag, '||
6275 'mi.list_price_per_unit, '''||ICX_POR_EXT_TEST.gTestMode||'''), '||
6276 'ICX_POR_EXT_DIAG.getInternalItemStatus(mi.internal_order_enabled_flag, '''||
6277 ICX_POR_EXT_TEST.gTestMode||''')) status ';
6278 xViewStr2 :=
6279 'FROM icx_por_loader_values l, ';
6280 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
6281 xViewStr2 := xViewStr2 ||
6282 'imtl_system_items_kfv mi, '||
6283 'imtl_categories_kfv mc, '||
6284 'imtl_item_categories mic, '||
6285 'igl_sets_of_books gsb, '||
6286 'ifinancials_system_params_all fsp, ';
6287 ELSE
6288 xViewStr2 := xViewStr2 ||
6289 'mtl_system_items_kfv mi, '||
6290 'mtl_categories_kfv mc, '||
6291 'mtl_item_categories mic, '||
6292 'gl_sets_of_books gsb, '||
6293 'financials_system_params_all fsp, ';
6294 END IF;
6295 xViewStr2 := xViewStr2 ||
6296 'mtl_units_of_measure_tl muom, '||
6297 '(SELECT '||PURCHASING_ITEM_TYPE||' document_type, '||
6298 '''PURCHASING_ITEM'' price_type, '||
6299 '''SUPPLIER'' price_search_type '||
6300 'FROM dual '||
6301 'UNION ALL '||
6302 'SELECT '||INTERNAL_ITEM_TYPE||' document_type, '||
6303 '''INTERNAL_ITEM'' price_type, '||
6304 '''INTERNAL'' price_search_type '||
6305 'FROM dual) type '||
6306 -- Bug#3213218/3163334 : pcreddy - Check for the load flag to be 'Y'.
6307 'WHERE ( (l.load_item_master = ''Y'' AND ' ||
6308 ' l.item_master_last_run_date IS NULL) OR ' ||
6309 ' (l.load_internal_item = ''Y'' AND ' ||
6310 ' l.internal_item_last_run_date IS NULL) OR ' ||
6311 -- 'WHERE (l.item_master_last_run_date IS NULL OR '||
6312 -- 'l.internal_item_last_run_date IS NULL OR '||
6313 -- Bug # 3529303
6314 'mi.last_update_date > LEAST(nvl(l.item_master_last_run_date, '||
6315 'sysdate), nvl(l.internal_item_last_run_date, sysdate)) OR '||
6316 'EXISTS (SELECT ''updated description'' ';
6317 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
6318 xViewStr2 := xViewStr2 ||
6319 'FROM imtl_system_items_tl mitl ';
6320 ELSE
6321 xViewStr2 := xViewStr2 ||
6322 'FROM mtl_system_items_tl mitl ';
6323 END IF;
6324 xViewStr2 := xViewStr2 ||
6325 'WHERE mi.inventory_item_id = mitl.inventory_item_id '||
6326 'AND mi.organization_id = mitl.organization_id '||
6327 'AND mitl.last_update_date > GREATEST(l.item_master_last_run_date, '||
6328 'l.internal_item_last_run_date)) OR '||
6329 'mic.last_update_date > GREATEST(l.item_master_last_run_date, '||
6330 'l.internal_item_last_run_date) OR '||
6331 'mc.last_update_date > GREATEST(l.item_master_last_run_date, '||
6332 'l.internal_item_last_run_date)) '||
6333 'AND mi.inventory_item_id = mic.inventory_item_id '||
6334 'AND mic.organization_id = mi.organization_id '||
6335 'AND mic.category_id = mc.category_id '||
6336 'AND mic.category_set_id = '||gCategorySetId||' '||
6337 'AND mc.web_status = ''Y'' '||
6338 'AND NOT (mi.replenish_to_order_flag = ''Y'' AND '||
6339 'mi.base_item_id IS NOT NULL AND '||
6340 'mi.auto_created_config_flag = ''Y'') '||
6341 'AND mi.unit_of_issue = muom.unit_of_measure(+) '||
6342 'AND muom.language(+) = '''||ICX_POR_EXTRACTOR.gBaseLang||''' '||
6343 'AND mi.organization_id = fsp.inventory_organization_id '||
6344 'AND fsp.set_of_books_id = gsb.set_of_books_id ';
6345 END IF;
6346
6347 xErrLoc := 300;
6348 xFromStr :=
6349 'icx_cat_categories_tl ic1, ' ||
6350 'icx_por_category_data_sources ds1, ';
6351 IF pType = 'TEMPLATE' THEN
6352 xFromStr := xFromStr ||
6353 'icx_cat_categories_tl ic2, '||
6354 'icx_por_category_data_sources ds2, ';
6355 END IF;
6356 xFromStr := xFromStr ||
6357 'icx_cat_item_prices p, '||
6358 'icx_cat_categories_tl ic3, '||
6359 'icx_por_category_data_sources ds3, '||
6360 'icx_cat_items_b i ';
6361
6362 xErrLoc := 400;
6363 xWhereStr :=
6364 'WHERE ic1.key = ds1.category_key '||
6365 'AND ds1.external_source_key = doc.category_key '||
6366 'AND ds1.external_source = ''Oracle'' ' ||
6367 'AND ic1.type = '||ICX_POR_EXT_CLASS.CATEGORY_TYPE||' '||
6368 'AND ic1.language = '''||ICX_POR_EXTRACTOR.gBaseLang||''' ';
6369 IF pType = 'TEMPLATE' THEN
6370 xWhereStr := xWhereStr ||
6371 'AND doc.template_id||''_tmpl'' = ds2.external_source_key (+) '||
6372 'AND ds2.external_source (+) = ''Oracle'' ' ||
6373 'AND ds2.category_key = ic2.key (+) '||
6374 'AND ic2.type (+) = '||ICX_POR_EXT_CLASS.TEMPLATE_HEADER_TYPE||' '||
6375 'AND ic2.language (+) = '''||ICX_POR_EXTRACTOR.gBaseLang||''' '||
6376 'AND doc.template_id = p.template_id (+) '||
6377 'AND doc.template_line_id = p.template_line_id (+) ';
6378 ELSIF pType = 'CONTRACT' THEN
6379 xWhereStr := xWhereStr ||
6380 'AND doc.contract_id = p.contract_id (+) '||
6381 'AND doc.contract_line_id = p.contract_line_id (+) ';
6382 ELSIF pType = 'ASL' THEN
6383 xWhereStr := xWhereStr ||
6384 'AND doc.asl_id = p.asl_id (+) ';
6385 ELSIF pType = 'ITEM' THEN
6386 xWhereStr := xWhereStr ||
6387 'AND doc.template_id = p.template_id (+) '||
6388 'AND doc.template_line_id = p.template_line_id (+) '||
6389 'AND doc.contract_id = p.contract_id (+) '||
6390 'AND doc.contract_line_id = p.contract_line_id (+) '||
6391 'AND doc.asl_id = p.asl_id (+) '||
6392 'AND doc.internal_item_id = p.inventory_item_id (+) ';
6393 END IF;
6394 xWhereStr := xWhereStr ||
6395 'AND doc.price_type = p.price_type (+) '||
6396 'AND doc.org_id = p.org_id (+) '||
6397 'AND i.rt_item_id (+) = p.rt_item_id '||
6398 'AND to_char(p.mtl_category_id) = ds3.external_source_key (+) '||
6399 'AND ds3.external_source (+) = ''Oracle'' ' ||
6400 'AND ds3.category_key = ic3.key (+) '||
6401 'AND ic3.type (+) = '||ICX_POR_EXT_CLASS.CATEGORY_TYPE||' '||
6402 'AND ic3.language (+) = '''||ICX_POR_EXTRACTOR.gBaseLang||''' '||
6403 'AND (p.rowid IS NOT NULL OR '||
6404 'ICX_POR_EXT_DIAG.isValidExtPrice(doc.document_type, doc.status, '''||
6405 ICX_POR_EXTRACTOR.gLoaderValue.load_contracts||''', '''||
6406 ICX_POR_EXTRACTOR.gLoaderValue.load_template_lines||''', '''||
6407 ICX_POR_EXTRACTOR.gLoaderValue.load_item_master||''', '''||
6408 ICX_POR_EXTRACTOR.gLoaderValue.load_internal_item||''') = 1)';
6409
6410 -- Bug#3352834
6411 xErrLoc := 500;
6412 xWhereStr := xWhereStr ||
6413 ' AND nvl(p.request_id, ' || ICX_POR_EXT_ITEM.NEW_PRICE_TEMP_REQUEST_ID ||
6414 ') <> ' || xTmpReqId;
6415
6416 xErrLoc := 510;
6417 --Bug#3277977
6418 pSqlString := xSelectStr||
6419 'FROM ('||xViewStr||xViewStr2||') doc, '||
6420 xFromStr||xWhereStr;
6421
6422 xErrLoc := 520;
6423 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.INFO_LEVEL THEN
6424 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.INFO_LEVEL,
6425 'Query for item extraction: '|| pSqlString);
6426 END IF;
6427
6428 ELSIF pType = 'GLOBAL_AGREEMENT' THEN
6429 xErrLoc := 600;
6430
6431 xSelectStr :=
6432 'SELECT /*+ LEADING(doc) */ '||
6433 GLOBAL_AGREEMENT_TYPE||' document_type, '||
6434 'doc.last_update_date, '||
6435 'doc.org_id, '||
6436 'doc.supplier_id, '||
6437 'doc.supplier, '||
6438 'doc.supplier_site_code, '||
6439 'doc.supplier_part_num, '||
6440 'doc.internal_item_id, '||
6441 'doc.internal_item_num, '||
6442 'doc.inventory_organization_id, '||
6443 'TO_CHAR(NULL) item_source_type, '||
6444 'TO_CHAR(NULL) item_search_type, '||
6445 'doc.mtl_category_id, '||
6446 'TO_CHAR(NULL) category_key, '||
6447 'TO_CHAR(NULL) description, '||
6448 'TO_CHAR(NULL) picture, '||
6449 'TO_CHAR(NULL) picture_url, '||
6450 '''GLOBAL_AGREEMENT'' price_type, '||
6451 'TO_NUMBER(-2) asl_id, '||
6452 'doc.supplier_site_id, '||
6453 'doc.contract_id, '||
6454 'doc.contract_line_id, '||
6455 'TO_CHAR(-2) template_id, '||
6456 'TO_NUMBER(-2) template_line_id, '||
6457 '''SUPPLIER'' price_search_type, '||
6458 'doc.unit_price, '||
6459 'doc.value_basis, '||
6460 'doc.purchase_basis, '||
6461 'doc.allow_price_override_flag, '||
6462 'doc.not_to_exceed_price, '||
6463 'TO_NUMBER(-2) suggested_quantity, '||
6464 'doc.negotiated_by_preparer_flag, '||
6465 'doc.currency, '||
6466 'doc.unit_of_measure, '||
6467 'doc.functional_price, '||
6468 'doc.contract_num, '||
6469 'doc.contract_line_num, '||
6470 'TO_CHAR(NULL) manufacturer, '||
6471 'TO_CHAR(NULL) manufacturer_part_num, '||
6472 'doc.rate_type, '||
6473 'doc.rate_date, '||
6474 'doc.rate, '||
6475 'TO_CHAR(NULL) supplier_number, '||
6476 'TO_NUMBER(NULL) supplier_contact_id, '||
6477 'TO_CHAR(NULL) item_revision, '||
6478 'doc.line_type_id, '||
6479 'TO_NUMBER(NULL) buyer_id, '||
6480 '''N'' global_agreement_flag, '||
6481 'doc.status, '||
6482 'TO_NUMBER(NULL) primary_category_id, '||
6483 'TO_CHAR(NULL) primary_category_name, '||
6484 'TO_NUMBER(NULL) template_category_id, '||
6485 'doc.price_rt_item_id, '||
6486 'TO_NUMBER(NULL) price_internal_item_id, '||
6487 'TO_NUMBER(NULL) price_supplier_id, '||
6488 'TO_CHAR(NULL) price_supplier_part_num, '||
6489 'TO_NUMBER(NULL) price_contract_line_id, '||
6490 'TO_NUMBER(NULL) price_mtl_category_id, '||
6491 'TO_NUMBER(NULL) match_primary_category_id, '||
6492 'TO_NUMBER(NULL) rt_item_id, '||
6493 'TO_NUMBER(NULL) local_rt_item_id, '||
6494 '''N'' match_template_flag, '||
6495 'p.active_flag active_flag, '||
6496 'ROWIDTOCHAR(p.rowid) price_rowid ';
6497
6498 xViewStr :=
6499 'SELECT /*+ LEADING(t) */ '||
6500 't.po_header_id as PoHeaderId, '||
6501 't.organization_id as OrganizationId, '||
6502 'ip.contract_line_id as ContractLineId, '||
6503 't.last_update_date, '||
6504 'NVL(t.organization_id, '||NULL_NUMBER||') org_id, '||
6505 'NVL(i.supplier_id, '||NULL_NUMBER||') supplier_id, '||
6506 'NVL(i.supplier, TO_CHAR('||NULL_NUMBER||')) supplier, '||
6507 'pvs.vendor_site_code supplier_site_code, '||
6508 'NVL(i.supplier_part_num, TO_CHAR('||NULL_NUMBER||
6509 ')) supplier_part_num, '||
6510 'NVL(i.internal_item_id, '||NULL_NUMBER||') internal_item_id, '||
6511 'i.internal_item_num, '||
6512 'mi.organization_id inventory_organization_id, '||
6513 'ip.mtl_category_id, '||
6514 't.vendor_site_id supplier_site_id, '||
6515 't.po_header_id contract_id, '||
6516 'ip.contract_line_id, '||
6517 'ip.unit_price, '||
6518 --FPJ FPSL Extractor Changes
6519 'ip.value_basis, '||
6520 'ip.purchase_basis, '||
6521 'ip.allow_price_override_flag, '||
6522 'ip.not_to_exceed_price, '||
6523 -- FPJ Bug# 3110297 jingyu Add negotiated flag
6524 'ip.negotiated_by_preparer_flag negotiated_by_preparer_flag, '||
6525 'ip.currency, '||
6526 'ip.unit_of_measure, '||
6527 'ICX_CAT_UTIL_PKG.convert_amount_sql(ip.currency, '||
6528 'gsb.currency_code, SYSDATE, icx_psp.default_rate_type, '||
6529 'ip.unit_price) functional_price, '||
6530 'ip.contract_num, '||
6531 'ip.contract_line_num, '||
6532 /* Retrieve and use the Default Rate Type form the Purchasing Options of the
6533 * Enabled Org for calculation of Rate and Functional Price.
6534 */
6535 'icx_psp.default_rate_type rate_type, '||
6536 'sysdate rate_date, '||
6537 'ICX_POR_EXT_ITEM.getRate(fsp.set_of_books_id, '||
6538 'ip.currency, '||
6539 'sysdate, '||
6540 'icx_psp.default_rate_type, ' ||
6541 't.purchasing_org_id, '||
6542 'ip.org_id, '||
6543 'ip.contract_num ) rate, '||
6544 -- bug 2912717: populate line_type, rate info. for GA
6545 'ip.line_type_id line_type_id, '||
6546 'ICX_POR_EXT_DIAG.getGlobalAgreementStatus(t.enabled_flag, '||
6547 'pvs.purchasing_site_flag, '||
6548 'pvs.inactive_date, '||
6549 'mi.purchasing_enabled_flag, '||
6550 'mi.outside_operation_flag, '||
6551 'mi.primary_uom_code, '||
6552 'mi2.purchasing_enabled_flag, '||
6553 'mi2.outside_operation_flag, '||
6554 'ip.unit_of_measure, '||
6555 'mi2.primary_uom_code, '''||
6556 ICX_POR_EXT_TEST.gTestMode||''') status, '||
6557 'ip.rt_item_id price_rt_item_id ';
6558
6559 xErrLoc := 620;
6560 xViewStr2 :=
6561 'FROM icx_por_loader_values l, ';
6562 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
6563 xViewStr2 := xViewStr2 ||
6564 'ipo_ga_org_assignments t, '||
6565 'ipo_vendor_sites_all pvs, '||
6566 'imtl_system_items_kfv mi, '||
6567 'imtl_system_items_kfv mi2, '|| -- Centralized Proc Impacts Enhancement
6568 'igl_sets_of_books gsb, '||
6569 'ifinancials_system_params_all fsp, '||
6570 'ifinancials_system_params_all fsp2, '|| -- Centralized Proc Impacts Enhancement
6571 'ipo_system_parameters_all icx_psp, ';
6572 ELSE
6573 xViewStr2 := xViewStr2 ||
6574 'po_ga_org_assignments t, '||
6575 'po_vendor_sites_all pvs, '||
6576 'mtl_system_items_kfv mi, '||
6577 'mtl_system_items_kfv mi2, '|| -- Centralized Proc Impacts Enhancement
6578 'gl_sets_of_books gsb, '||
6579 'financials_system_params_all fsp, '||
6580 'financials_system_params_all fsp2, '|| -- Centralized Proc Impacts Enhancement
6581 'po_system_parameters_all icx_psp, ';
6582 END IF;
6583 xViewStr2 := xViewStr2 ||
6584 'icx_cat_item_prices ip, '||
6585 'icx_cat_items_b i ';
6586
6587 xErrLoc := 640;
6588 -- Considering global agreement reapproval, use ip.creation_date
6589 xViewStr2 := xViewStr2 ||
6590 'WHERE (l.contracts_last_run_date IS NULL OR '||
6591 'GREATEST(NVL(mi.last_update_date, l.contracts_last_run_date-1), '||
6592 'ip.creation_date, t.last_update_date) > l.contracts_last_run_date) '||
6593 'AND t.vendor_site_id = pvs.vendor_site_id (+) '||
6594 'AND icx_psp.org_id = t.organization_id '||
6595 'AND ip.contract_id = t.po_header_id '||
6596 'AND ip.price_type = ''BLANKET'' '||
6597 'AND t.organization_id <> ip.org_id '||
6598 'AND t.purchasing_org_id = fsp2.org_id '|| -- Centralized Proc Impacts Enhancement
6599 'AND i.rt_item_id = ip.rt_item_id '||
6600 'AND t.organization_id = fsp.org_id '||
6601 'AND fsp.set_of_books_id = gsb.set_of_books_id '||
6602 'AND ip.inventory_item_id = mi.inventory_item_id (+) '||
6603 'AND ip.inventory_item_id = mi2.inventory_item_id (+) '|| -- Centralized Proc Impacts
6604 'AND fsp.inventory_organization_id = NVL(mi.organization_id, '||
6605 'fsp.inventory_organization_id) '||
6606 'AND fsp2.inventory_organization_id = NVL(mi2.organization_id, '|| -- Centralized Proc Impacts
6607 'fsp2.inventory_organization_id) ';
6608
6609 xFromStr :=
6610 'icx_cat_item_prices p ';
6611
6612 xWhereStr :=
6613 'WHERE doc.PoHeaderId = p.contract_id (+) '||
6614 'AND doc.OrganizationId = p.org_id (+) '||
6615 'AND doc.ContractLineId = p.contract_line_id (+) '||
6616 'AND p.price_type (+) = ''GLOBAL_AGREEMENT'' '||
6617 'AND (p.rowid IS NOT NULL OR '||
6618 'ICX_POR_EXT_DIAG.isValidExtPrice('||GLOBAL_AGREEMENT_TYPE||', '||
6619 'doc.status, '''||
6620 ICX_POR_EXTRACTOR.gLoaderValue.load_contracts||''', '''||
6621 ICX_POR_EXTRACTOR.gLoaderValue.load_template_lines||''', '''||
6622 ICX_POR_EXTRACTOR.gLoaderValue.load_item_master||''', '''||
6623 ICX_POR_EXTRACTOR.gLoaderValue.load_internal_item||''') = 1)';
6624
6625
6626 xErrLoc := 650;
6627 -- If a global agreement is updated, we need to reset the active flag
6628 -- for local items. For instance, if a global agreement has supplier_part_number
6629 -- changed, we need to reset the active flag of items with same new/old item
6630 -- uniqueness criteria in all subscribed orgs.
6631 -- Let's say: A global agreement with itemA/supplierB/spnC is defined in org1 and
6632 -- enabled in org2, and in org2, there are two ASLs: asl1 with itemA/supplierB/spnC,
6633 -- asl2 with itemA/supplierB/spnD. Based on precedent rule, asl1 has active_flag 'N'
6634 -- and asl2 has active_flag = 'Y'. Now the global agreement is updated to spnD,
6635 -- then we have to reset active_flag for asl1 and asl2 such that asl1 has
6636 -- active_flag 'Y' and asl2 has active_flag = 'N'
6637 -- NOTE: we use local_rt_item_id to store local rt_item_id
6638 -- The reason we need this second query is the previous query won't pick up this change
6639 xString :=
6640 'SELECT /*+ LEADING(g) */ '||GLOBAL_AGREEMENT_TYPE||' document_type, '||
6641 'p.last_update_date, '||
6642 'NVL(p.org_id, '||NULL_NUMBER||') org_id, '||
6643 'NVL(i.supplier_id, '||NULL_NUMBER||') supplier_id, '||
6644 'NVL(i.supplier, TO_CHAR('||NULL_NUMBER||')) supplier, '||
6645 'TO_CHAR(NULL) supplier_site_code, '||
6646 'NVL(i.supplier_part_num, TO_CHAR('||NULL_NUMBER||
6647 ')) supplier_part_num, '||
6648 'NVL(i.internal_item_id, '||NULL_NUMBER||') internal_item_id, '||
6649 'i.internal_item_num, '||
6650 'TO_NUMBER(NULL) inventory_organization_id, '||
6651 'TO_CHAR(NULL) item_source_type, '||
6652 'TO_CHAR(NULL) item_search_type, '||
6653 'TO_NUMBER(NULL) mtl_category_id, '||
6654 'TO_CHAR(NULL) category_key, '||
6655 'TO_CHAR(NULL) description, '||
6656 'TO_CHAR(NULL) picture, '||
6657 'TO_CHAR(NULL) picture_url, '||
6658 '''SET_ACTIVE_FLAG'' price_type, '||
6659 'TO_NUMBER(NULL) asl_id, '||
6660 'TO_NUMBER(NULL) supplier_site_id, '||
6661 'TO_NUMBER(NULL) contract_id, '||
6662 'p.contract_line_id, '||
6663 'TO_CHAR(NULL) template_id, '||
6664 'TO_NUMBER(NULL) template_line_id, '||
6665 'TO_CHAR(NULL) price_search_type, '||
6666 'TO_NUMBER(NULL) unit_price, '||
6667 --FPJ FPSL Extractor Changes
6668 'TO_CHAR(NULL) value_basis, '||
6669 'TO_CHAR(NULL) purchase_basis, '||
6670 'TO_CHAR(NULL) allow_price_override_flag, '||
6671 'TO_NUMBER(NULL) not_to_exceed_price, '||
6672 -- FPJ Bug# 3007068 sosingha: Extractor Changes For Kit Support Project
6673 'TO_NUMBER(NULL) suggested_quantity, '||
6674 -- FPJ Bug# 3110297 jingyu Add negotiated flag
6675 'TO_CHAR(NULL) negotiated_by_preparer_flag, '||
6676 'TO_CHAR(NULL) currency, '||
6677 'TO_CHAR(NULL) unit_of_measure, '||
6678 'TO_NUMBER(NULL) functional_price, '||
6679 'TO_CHAR(NULL) contract_num, '||
6680 'TO_NUMBER(NULL) contract_line_num, '||
6681 'TO_CHAR(NULL) manufacturer, '||
6682 'TO_CHAR(NULL) manufacturer_part_num, '||
6683 'TO_CHAR(NULL) rate_type, '||
6684 'TO_DATE(NULL) rate_date, '||
6685 'TO_NUMBER(NULL) rate, '||
6686 'TO_CHAR(NULL) supplier_number, '||
6687 'TO_NUMBER(NULL) supplier_contact_id, '||
6688 'TO_CHAR(NULL) item_revision, '||
6689 'TO_NUMBER(NULL) line_type_id, '||
6690 'TO_NUMBER(NULL) buyer_id, '||
6691 'TO_CHAR(NULL) global_agreement_flag, '||
6692 ICX_POR_EXT_DIAG.VALID_FOR_EXTRACT||' status, '||
6693 'TO_NUMBER(NULL) primary_category_id, '||
6694 'TO_CHAR(NULL) primary_category_name, '||
6695 'TO_NUMBER(NULL) template_category_id, '||
6696 'TO_NUMBER(NULL) price_rt_item_id, '||
6697 'TO_NUMBER(NULL) price_internal_item_id, '||
6698 'TO_NUMBER(NULL) price_supplier_id, '||
6699 'TO_CHAR(NULL) price_supplier_part_num, '||
6700 'TO_NUMBER(NULL) price_contract_line_id, '||
6701 'TO_NUMBER(NULL) price_mtl_category_id, '||
6702 'TO_NUMBER(NULL) match_primary_category_id, '||
6703 'TO_NUMBER(NULL) rt_item_id, '||
6704 'p.local_rt_item_id, '||
6705 'TO_CHAR(NULL) match_template_flag, '||
6706 'TO_CHAR(NULL) active_flag, '||
6707 'ROWIDTOCHAR(p.rowid) price_rowid '||
6708 'FROM icx_cat_item_prices p, '||
6709 'icx_cat_extract_ga_gt g, '||
6710 'icx_cat_items_b i '||
6711 'WHERE p.contract_id = g.contract_id '||
6712 'AND p.contract_line_id = g.contract_line_id '||
6713 'AND p.price_type = ''GLOBAL_AGREEMENT'' '||
6714 'AND i.rt_item_id = p.rt_item_id ';
6715
6716 -- Bug#3352834
6717 xErrLoc := 700;
6718 xWhereStr := xWhereStr ||
6719 ' AND nvl(p.request_id, ' || ICX_POR_EXT_ITEM.NEW_PRICE_TEMP_REQUEST_ID ||
6720 ') <> ' || xTmpReqId;
6721 xString := xString ||
6722 ' AND nvl(p.request_id, ' || ICX_POR_EXT_ITEM.NEW_PRICE_TEMP_REQUEST_ID ||
6723 ') <> ' || xTmpReqId;
6724
6725 xErrLoc := 725;
6726 --Bug#3277977
6727 pSqlString :=
6728 xSelectStr ||
6729 'FROM ( '|| xViewStr || xViewStr2 || ') doc, '||
6730 xFromStr || xWhereStr ||
6731 ' UNION ALL ' || xString;
6732
6733 xErrLoc := 750;
6734 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.INFO_LEVEL THEN
6735 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.INFO_LEVEL,
6736 'Query for global agreement extraction: ' || pSqlString);
6737 END IF;
6738
6739 END IF;
6740
6741 xErrLoc := 800;
6742
6743 EXCEPTION
6744 when ICX_POR_EXT_UTL.gException then
6745 -- rollback;
6746 ICX_POR_EXT_UTL.extRollback;
6747
6748 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.openPriceCursor-'||
6749 xErrLoc);
6750 raise ICX_POR_EXT_UTL.gException;
6751 when others then
6752 -- rollback;
6753 ICX_POR_EXT_UTL.extRollback;
6754 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.openPriceCursor-'||
6755 xErrLoc||' '||SQLERRM);
6756 raise ICX_POR_EXT_UTL.gException;
6757 END openPriceCursor;
6758
6759 -- Extract vendor name changes
6760 PROCEDURE extractVendorNames IS
6761 xErrLoc PLS_INTEGER := 100;
6762 xContinue BOOLEAN := TRUE;
6763 xCommitSize PLS_INTEGER;
6764 xRowCount PLS_INTEGER := 0;
6765 xRtItemIds DBMS_SQL.NUMBER_TABLE;
6766 cUpdatedVendorNames tCursorType;
6767 xString VARCHAR2(2000);
6768 xVendorId DBMS_SQL.NUMBER_TABLE;
6769 xVendorName DBMS_SQL.VARCHAR2_TABLE;
6770 xNewVendorNames DBMS_SQL.VARCHAR2_TABLE;
6771 xIndex PLS_INTEGER;
6772 -- For Vendor Site Update.
6773 cUpdatedVendorSites tCursorType;
6774 xVendorSiteIds DBMS_SQL.NUMBER_TABLE;
6775 xVendorSiteNames DBMS_SQL.VARCHAR2_TABLE;
6776 BEGIN
6777 xErrLoc := 100;
6778 xIndex := 1;
6779
6780 xErrLoc := 110;
6781 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
6782 'Handling vendors with name changed.');
6783
6784 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
6785 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
6786 'Enter extractVendorNames()');
6787 END IF;
6788
6789 xCommitSize := ICX_POR_EXT_UTL.gCommitSize/
6790 (ICX_POR_EXTRACTOR.gInstalledLanguageCount+1);
6791
6792 xErrLoc := 120;
6793 xString :=
6794 'SELECT /*+ LEADING(v) */ v.vendor_id, '||
6795 'v.vendor_name ';
6796 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
6797 xString := xString ||
6798 'FROM ipo_vendors v, ';
6799 ELSE
6800 xString := xString ||
6801 'FROM po_vendors v, ';
6802 END IF;
6803 xString := xString ||
6804 'icx_por_loader_values l ' ||
6805 'WHERE (l.vendor_last_run_date IS NULL OR ' ||
6806 'v.last_update_date > l.vendor_last_run_date) ' ||
6807 'AND NOT EXISTS (SELECT ''updated vendor name'' ' ||
6808 'FROM icx_cat_items_b i ' ||
6809 'WHERE i.supplier_id = v.vendor_id ' ||
6810 'AND i.supplier = v.vendor_name)';
6811
6812 xErrLoc := 140;
6813 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.INFO_LEVEL THEN
6814 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.INFO_LEVEL,
6815 'Query for updated vendor names: ' || xString);
6816 END IF;
6817 xErrLoc := 150;
6818 OPEN cUpdatedVendorNames FOR xString;
6819
6820 /* Changing the fetch for cUpdatedVendorNames to bulk fetch into plsql tables
6821 and moving the fetch outside of the loop for the following reasons:
6822 1. Dont expect a huge number of vendor_names that needs changes in catalog items table
6823 Even if there are huge number of vendor_names that will be returned by the cursor cUpdatedVendorNames
6824 doing a bulk fetch will only increase the size of plsql tables
6825 2. We can take the advantage of doing bulk fetch for cUpdatedVendorNames
6826 3. While updating icx_cat_items_tlp we can utilize forall instead of processing one vendor at a time
6827 anyway we will be processing only 2500 rows at a time, since we have the rownum constraint.
6828 */
6829 xErrLoc := 160;
6830 IF (ICX_POR_EXT_UTL.getDatabaseVersion < 9.0) THEN
6831 xErrLoc := 165;
6832 LOOP
6833 FETCH cUpdatedVendorNames INTO xVendorId(xIndex), xVendorName(xIndex);
6834 EXIT WHEN cUpdatedVendorNames%NOTFOUND;
6835 xIndex := xIndex+1;
6836 END LOOP;
6837 ELSE
6838 xErrLoc := 170;
6839 FETCH cUpdatedVendorNames BULK COLLECT
6840 INTO xVendorId, xVendorName;
6841 END IF;
6842
6843 xErrLoc := 180;
6844 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
6845 xErrLoc := 190;
6846 IF ( xVendorId.COUNT > 0 ) THEN
6847 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
6848 'List of Vendor Id and Names from extractVendorNames cursor...');
6849 END IF;
6850 xErrLoc := 195;
6851 FOR i in 1..xVendorId.COUNT LOOP
6852 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
6853 'vendor_id: '|| ICX_POR_EXT_UTL.getTableElement(xVendorId, i) ||
6854 ', vendor_name: '|| ICX_POR_EXT_UTL.getTableElement(xVendorName, i) );
6855 END LOOP;
6856 END IF;
6857
6858 xErrLoc := 196;
6859 xContinue := TRUE;
6860
6861 xErrLoc := 197;
6862 WHILE xContinue LOOP
6863
6864 xErrLoc := 200;
6865 xRtItemIds.DELETE;
6866 xNewVendorNames.DELETE;
6867
6868 xErrLoc := 240;
6869 FORALL i in 1..xVendorId.COUNT
6870 UPDATE icx_cat_items_b
6871 SET supplier = xVendorName(i),
6872 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
6873 last_update_date = SYSDATE,
6874 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
6875 request_id = ICX_POR_EXTRACTOR.gRequestId,
6876 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
6877 program_id = ICX_POR_EXTRACTOR.gProgramId,
6878 program_update_date = SYSDATE
6879 WHERE supplier_id = xVendorId(i)
6880 AND supplier <> xVendorName(i)
6881 AND rownum <= xCommitSize
6882 RETURNING RT_ITEM_ID, SUPPLIER BULK COLLECT INTO xRtItemIds, xNewVendorNames;
6883
6884 xErrLoc := 260;
6885 IF (SQL%ROWCOUNT < xCommitSize) THEN
6886 xContinue := FALSE;
6887 END IF;
6888
6889 xErrLoc := 270;
6890 xRowCount := xRowCount + 1;
6891
6892 xErrLoc := 280;
6893 -- Since the vendor name changes need to be built into
6894 -- interMedia index, have to set the column jobNum
6895 FORALL i IN 1..xRtItemIds.COUNT
6896 UPDATE icx_cat_items_tlp
6897 SET supplier = xNewVendorNames(i),
6898 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
6899 last_update_date = SYSDATE,
6900 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
6901 request_id = ICX_POR_EXTRACTOR.gRequestId,
6902 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
6903 program_id = ICX_POR_EXTRACTOR.gProgramId,
6904 program_update_date = SYSDATE
6905 WHERE rt_item_id = xRtItemIds(i);
6906
6907 xErrLoc := 300;
6908 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
6909 'Number of processed items in batch: '|| xRowCount ||
6910 ', for vendor name change: ' || SQL%ROWCOUNT);
6911 FND_CONCURRENT.AF_COMMIT;
6912 END LOOP;
6913
6914 xErrLoc := 400;
6915 IF (cUpdatedVendorNames%ISOPEN) THEN
6916 xErrLoc := 410;
6917 CLOSE cUpdatedVendorNames;
6918 END IF;
6919
6920 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
6921 'Total Number of batches processed for vendor name change : ' || xRowCount);
6922
6923 xErrLoc := 500;
6924
6925 -- Handling Vendor Sites' Name Updates.
6926 xIndex := 1;
6927 xRowCount := 0;
6928
6929 xErrLoc := 510;
6930 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
6931 'Handling vendor sites with name changed.');
6932
6933 xErrLoc := 520;
6934 xString :=
6935 'SELECT /*+ LEADING(vs) */ ' ||
6936 ' vs.vendor_site_id, ' ||
6937 ' vs.vendor_site_code ';
6938 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
6939 xString := xString ||
6940 'FROM ipo_vendor_sites_all vs, ';
6941 ELSE
6942 xString := xString ||
6943 'FROM po_vendor_sites_all vs, ';
6944 END IF;
6945 xString := xString ||
6946 ' icx_por_loader_values l ' ||
6947 'WHERE (l.vendor_last_run_date IS NULL OR ' ||
6948 ' vs.last_update_date > l.vendor_last_run_date) ' ||
6949 ' AND EXISTS ( SELECT ''Updated VendorSite In Catalog'' ' ||
6950 ' FROM icx_cat_item_prices ip ' ||
6951 ' WHERE ip.supplier_site_id = vs.vendor_site_id )';
6952
6953
6954 xErrLoc := 530;
6955 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
6956 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
6957 'Query for updated vendor site names: ' || xString);
6958 END IF;
6959
6960 xErrLoc := 540;
6961 OPEN cUpdatedVendorSites FOR xString;
6962 xErrLoc := 550;
6963 IF (ICX_POR_EXT_UTL.getDatabaseVersion < 9.0) THEN
6964 xErrLoc := 560;
6965 LOOP
6966 FETCH cUpdatedVendorSites INTO xVendorSiteIds(xIndex), xVendorSiteNames(xIndex);
6967 EXIT WHEN cUpdatedVendorSites%NOTFOUND;
6968 xIndex := xIndex+1;
6969 END LOOP;
6970 ELSE
6971 xErrLoc := 570;
6972 FETCH cUpdatedVendorSites BULK COLLECT
6973 INTO xVendorSiteIds, xVendorSiteNames;
6974 END IF;
6975
6976 xErrLoc := 580;
6977 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DEBUG_LEVEL THEN
6978 xErrLoc := 590;
6979 IF ( xVendorSiteIds.COUNT > 0 ) THEN
6980 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
6981 'List of Vendor Site Id and Names from extractVendorSiteNames cursor...');
6982 END IF;
6983 xErrLoc := 600;
6984 FOR i in 1..xVendorSiteIds.COUNT LOOP
6985 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DEBUG_LEVEL,
6986 'vendor_site_id: '|| ICX_POR_EXT_UTL.getTableElement(xVendorSiteIds, i) ||
6987 ', vendor_site_name: '|| ICX_POR_EXT_UTL.getTableElement(xVendorSiteNames, i) );
6988 END LOOP;
6989 END IF;
6990
6991 xErrLoc := 610;
6992 xContinue := TRUE;
6993
6994 xErrLoc := 620;
6995 WHILE xContinue LOOP
6996
6997 xErrLoc := 630;
6998 FORALL i in 1..xVendorSiteIds.COUNT
6999 UPDATE icx_cat_item_prices
7000 SET supplier_site_code = xVendorSiteNames(i),
7001 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
7002 last_update_date = SYSDATE,
7003 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
7004 request_id = ICX_POR_EXTRACTOR.gRequestId,
7005 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
7006 program_id = ICX_POR_EXTRACTOR.gProgramId,
7007 program_update_date = SYSDATE
7008 WHERE supplier_site_id = xVendorSiteIds(i)
7009 AND supplier_site_code <> xVendorSiteNames(i)
7010 AND rownum <= xCommitSize;
7011
7012 xErrLoc := 640;
7013 IF (SQL%ROWCOUNT < xCommitSize) THEN
7014 xContinue := FALSE;
7015 END IF;
7016
7017 xErrLoc := 650;
7018 xRowCount := xRowCount + 1;
7019
7020 xErrLoc := 660;
7021 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7022 'Number of processed items in batch: '|| xRowCount ||
7023 ', for vendor site name change: ' || SQL%ROWCOUNT);
7024 FND_CONCURRENT.AF_COMMIT;
7025 END LOOP;
7026
7027 xErrLoc := 670;
7028 IF (cUpdatedVendorSites%ISOPEN) THEN
7029 xErrLoc := 680;
7030 CLOSE cUpdatedVendorSites;
7031 END IF;
7032 xErrLoc := 690;
7033 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7034 'Total Number of batches processed for vendor sites name change : ' || xRowCount);
7035
7036
7037 EXCEPTION
7038 when ICX_POR_EXT_UTL.gException then
7039 ICX_POR_EXT_UTL.extRollback;
7040
7041 IF (cUpdatedVendorNames%ISOPEN) THEN
7042 CLOSE cUpdatedVendorNames;
7043 END IF;
7044 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.extractVendorNames-'||
7045 xErrLoc);
7046 raise ICX_POR_EXT_UTL.gException;
7047 when others then
7048 ICX_POR_EXT_UTL.extRollback;
7049
7050 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.extractVendorNames-'||
7051 xErrLoc||' '||SQLERRM);
7052
7053 raise ICX_POR_EXT_UTL.gException;
7054 END extractVendorNames;
7055
7056 -- Truncate global temporary table
7057 PROCEDURE truncateTempTable(pType IN VARCHAR2) IS
7058 xErrLoc PLS_INTEGER := 100;
7059 xIcxSchema VARCHAR2(20);
7060 BEGIN
7061 xErrLoc := 100;
7062 xIcxSchema := ICX_POR_EXT_UTL.getIcxSchema;
7063 xErrLoc := 120;
7064 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.INFO_LEVEL,
7065 'Truncate global temporary table');
7066 xErrLoc := 160;
7067 EXECUTE IMMEDIATE
7068 'TRUNCATE TABLE '||xIcxSchema||'.icx_cat_extract_gt';
7069 xErrLoc := 200;
7070 IF pType = 'ALL' THEN
7071 EXECUTE IMMEDIATE
7072 'TRUNCATE TABLE '||xIcxSchema||'.icx_cat_extract_ga_gt';
7073 END IF;
7074 xErrLoc := 300;
7075 EXCEPTION
7076 when others then
7077 ICX_POR_EXT_UTL.extRollback;
7078 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.truncateTempTable-'||
7079 xErrLoc||' '||SQLERRM);
7080 raise ICX_POR_EXT_UTL.gException;
7081 END truncateTempTable;
7082
7083 --Cleanup Items without prices
7084 PROCEDURE cleanupItems IS
7085 xErrLoc PLS_INTEGER := 100;
7086 xActionMode VARCHAR2(80);
7087 xRowCount PLS_INTEGER := 0;
7088
7089 CURSOR cItemNoPrices IS
7090 SELECT i.rt_item_id
7091 FROM icx_cat_extract_gt i
7092 WHERE i.type = 'CLEANUP_ITEM'
7093 AND NOT EXISTS (SELECT 'price rows'
7094 FROM icx_cat_item_prices p
7095 WHERE p.rt_item_id = i.rt_item_id);
7096 BEGIN
7097 xErrLoc := 100;
7098 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7099 'Cleanup items without price.');
7100
7101 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
7102 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
7103 'Enter cleanupItems()');
7104 END IF;
7105
7106 xErrLoc := 150;
7107 xActionMode := 'DELETE_ITEM_NOPRICE';
7108 clearTables(xActionMode);
7109
7110 OPEN cItemNoPrices;
7111
7112 xErrLoc := 180;
7113 LOOP
7114 clearTables(xActionMode);
7115 xErrLoc := 200;
7116 FETCH cItemNoPrices
7117 BULK COLLECT INTO gDIRtItemIds
7118 LIMIT ICX_POR_EXT_UTL.gCommitSize;
7119 EXIT WHEN gDIRtItemIds.COUNT = 0;
7120 xRowCount := xRowCount + gDIRtItemIds.COUNT;
7121
7122 xErrLoc := 220;
7123 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
7124 FOR i in 1..gDIRtItemIds.COUNT LOOP
7125 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
7126 snapShot(i, xActionMode));
7127 END LOOP;
7128 END IF;
7129
7130 xErrLoc := 240;
7131 ICX_POR_DELETE_CATALOG.setCommitSize(ICX_POR_EXT_UTL.gCommitSize);
7132
7133 xErrLoc := 300;
7134 ICX_POR_DELETE_CATALOG.deleteCommonTables(gDIRtItemIds,
7135 ICX_POR_DELETE_CATALOG.ITEM_TABLE_LAST);
7136
7137 xErrLoc := 340;
7138 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7139 'Processed records: ' || xRowCount);
7140 ICX_POR_EXT_UTL.extAFCommit;
7141 END LOOP;
7142
7143 xErrLoc := 400;
7144 CLOSE cItemNoPrices;
7145
7146 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7147 'Total deleted items without price : ' || xRowCount);
7148
7149 xErrLoc := 500;
7150 EXCEPTION
7151 when ICX_POR_EXT_UTL.gException then
7152 ICX_POR_EXT_UTL.extRollback;
7153
7154 IF (cItemNoPrices%ISOPEN) THEN
7155 CLOSE cItemNoPrices;
7156 END IF;
7157 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.cleanupItems-'||
7158 xErrLoc);
7159 raise ICX_POR_EXT_UTL.gException;
7160 when others then
7161 ICX_POR_EXT_UTL.extRollback;
7162 IF (cItemNoPrices%ISOPEN) THEN
7163 CLOSE cItemNoPrices;
7164 END IF;
7165 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.cleanupItems-'||
7166 xErrLoc||' '||SQLERRM);
7167
7168 raise ICX_POR_EXT_UTL.gException;
7169 END cleanupItems;
7170
7171 PROCEDURE setActiveFlags IS
7172 xErrLoc PLS_INTEGER := 100;
7173 xActionMode VARCHAR2(80);
7174 xIndex PLS_INTEGER;
7175 xRowCount PLS_INTEGER := 0;
7176
7177 --Bug#3542291
7178 --Handle exception
7179 --ORA-01555: snapshot too old: rollback segment number with name "" too small
7180 snap_shot_too_old EXCEPTION;
7181 PRAGMA EXCEPTION_INIT(snap_shot_too_old, -1555);
7182
7183 CURSOR cActiveFlagPrices IS
7184 SELECT p.price_type,
7185 p.rt_item_id,
7186 p.rowid price_rowid,
7187 ICX_POR_EXT_ITEM.getActiveFlag(p.price_type, p.rowid) active_flag
7188 FROM icx_cat_item_prices p,
7189 icx_cat_extract_gt i
7190 WHERE i.type = 'ACTIVE_FLAG'
7191 AND p.rt_item_id = i.rt_item_id
7192 AND p.price_type <> 'GLOBAL_AGREEMENT'
7193 AND nvl(p.request_id, ICX_POR_EXT_ITEM.AF_NEW_PRICE_TEMP_REQUEST_ID) <>
7194 ICX_POR_EXT_ITEM.AF_CURRENT_REQUEST_ID; -- Bug # 3542291
7195 BEGIN
7196 xErrLoc := 100;
7197 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7198 'Set active flags.');
7199
7200 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
7201 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
7202 'Enter setActiveFlags()');
7203 END IF;
7204
7205 xErrLoc := 150;
7206 xActionMode := 'SET_ACTIVE_FLAG';
7207 clearTables(xActionMode);
7208
7209 OPEN cActiveFlagPrices;
7210
7211 xErrLoc := 180;
7212 LOOP
7213 clearTables(xActionMode);
7214 xErrLoc := 190;
7215 BEGIN
7216 xErrLoc := 200;
7217 FETCH cActiveFlagPrices
7218 BULK COLLECT INTO gSAPriceTypes, gSARtItemIds, gSARowIds,
7219 gSAActiveFlags
7220 LIMIT ICX_POR_EXT_UTL.gCommitSize;
7221 EXIT WHEN gSARtItemIds.COUNT = 0;
7222 xRowCount := xRowCount + gSARtItemIds.COUNT;
7223
7224 xErrLoc := 220;
7225 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
7226 FOR i in 1..gSARtItemIds.COUNT LOOP
7227 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
7228 snapShot(i, xActionMode));
7229 END LOOP;
7230 END IF;
7231
7232 xErrLoc := 240;
7233 FORALL i IN 1..gSARowIds.COUNT
7234 UPDATE icx_cat_item_prices
7235 SET active_flag = gSAActiveFlags(i),
7236 last_updated_by = ICX_POR_EXTRACTOR.gUserId,
7237 last_update_date = SYSDATE,
7238 last_update_login = ICX_POR_EXTRACTOR.gLoginId,
7239 -- Bug # 3542291
7240 request_id = ICX_POR_EXT_ITEM.AF_CURRENT_REQUEST_ID,
7241 program_application_id = ICX_POR_EXTRACTOR.gProgramApplicationId,
7242 program_id = ICX_POR_EXTRACTOR.gProgramId,
7243 program_update_date = SYSDATE
7244 WHERE rowid = gSARowIds(i);
7245
7246 ICX_POR_EXT_UTL.extAFCommit;
7247
7248 EXCEPTION
7249 when snap_shot_too_old then
7250 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7251 'ORA-01555: snapshot too old: caught at '||
7252 'ICX_POR_EXT_ITEM.setActiveFlags-'||xErrLoc ||
7253 ', Total processed rows to set active flag: ' || xRowCount ||
7254 ', SQLERRM:' ||SQLERRM ||
7255 '; so close the cursor and reopen the cursor-');
7256 xErrLoc := 440;
7257 ICX_POR_EXT_UTL.extAFCommit;
7258 IF (cActiveFlagPrices%ISOPEN) THEN
7259 xErrLoc := 450;
7260 CLOSE cActiveFlagPrices;
7261 xErrLoc := 460;
7262 OPEN cActiveFlagPrices;
7263 END IF;
7264 END;
7265 END LOOP;
7266
7267 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7268 'Total processed rows to set active flag: ' || xRowCount);
7269
7270
7271 xErrLoc := 300;
7272
7273 setActivePriceItemAttributes();
7274
7275 xErrLoc := 500;
7276 EXCEPTION
7277 when ICX_POR_EXT_UTL.gException then
7278 ICX_POR_EXT_UTL.extRollback;
7279
7280 IF (cActiveFlagPrices%ISOPEN) THEN
7281 CLOSE cActiveFlagPrices;
7282 END IF;
7283 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.setActiveFlags-'||
7284 xErrLoc);
7285 raise ICX_POR_EXT_UTL.gException;
7286 when others then
7287 ICX_POR_EXT_UTL.extRollback;
7288 IF (cActiveFlagPrices%ISOPEN) THEN
7289 CLOSE cActiveFlagPrices;
7290 END IF;
7291 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.setActiveFlags-'||
7292 xErrLoc||' '||SQLERRM);
7293
7294 raise ICX_POR_EXT_UTL.gException;
7295 END setActiveFlags;
7296
7297 -- Process item price rows
7298 PROCEDURE processItemData (pType IN VARCHAR2) IS
7299 xErrLoc PLS_INTEGER := 100;
7300 cPriceRows tCursorType;
7301 --Bug#3277977
7302 --Added xSqlString to hold sql string passed from openPriceCursors
7303 xSqlString VARCHAR2(25000) := NULL;
7304 BEGIN
7305 xErrLoc := 100;
7306 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7307 'Start to process ' || pType);
7308 --Bug#3277977
7309 --Added xSqlString to hold sql string passed from openPriceCursors
7310 --openPriceCursor(pType, cPriceRows);
7311 openPriceCursor(pType, xSqlString);
7312
7313 -- Bug#3352834
7314 xErrLoc := 120;
7315 IF (pType = 'TEMPLATE') THEN
7316 ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID :=
7317 ICX_POR_EXT_ITEM.TEMPLATE_TEMP_REQUEST_ID;
7318 -- Bug # 3542291
7319 ICX_POR_EXT_ITEM.AF_CURRENT_REQUEST_ID :=
7320 ICX_POR_EXT_ITEM.AF_TEMPLATE_TEMP_REQUEST_ID;
7321 ELSIF (pType = 'CONTRACT') THEN
7322 ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID :=
7323 ICX_POR_EXT_ITEM.CONTRACT_TEMP_REQUEST_ID;
7324 ICX_POR_EXT_ITEM.AF_CURRENT_REQUEST_ID :=
7325 ICX_POR_EXT_ITEM.AF_CONTRACT_TEMP_REQUEST_ID;
7326 ELSIF (pType = 'GLOBAL_AGREEMENT') THEN
7327 ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID :=
7328 ICX_POR_EXT_ITEM.GA_TEMP_REQUEST_ID;
7329 ICX_POR_EXT_ITEM.AF_CURRENT_REQUEST_ID :=
7330 ICX_POR_EXT_ITEM.AF_GA_TEMP_REQUEST_ID;
7331 ELSIF (pType = 'ASL') THEN
7332 ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID :=
7333 ICX_POR_EXT_ITEM.ASL_TEMP_REQUEST_ID;
7334 ICX_POR_EXT_ITEM.AF_CURRENT_REQUEST_ID :=
7335 ICX_POR_EXT_ITEM.AF_ASL_TEMP_REQUEST_ID;
7336 ELSIF (pType = 'ITEM') THEN
7337 ICX_POR_EXT_ITEM.CURRENT_REQUEST_ID :=
7338 ICX_POR_EXT_ITEM.ITEM_TEMP_REQUEST_ID;
7339 ICX_POR_EXT_ITEM.AF_CURRENT_REQUEST_ID :=
7340 ICX_POR_EXT_ITEM.AF_ITEM_TEMP_REQUEST_ID;
7341 END IF;
7342
7343
7344 xErrLoc := 130;
7345 --Bug#3277977
7346 --Pass xSqlString to extractPriceRows instead of cPriceRows cursor
7347 --extractPriceRows(cPriceRows);
7348 extractPriceRows(xSqlString);
7349
7350 xErrLoc := 140;
7351 cleanupItems;
7352 xErrLoc := 160;
7353 setActiveFlags;
7354 xErrLoc := 200;
7355 truncateTempTable('NOGA');
7356 xErrLoc := 300;
7357 gTotalCount := gTotalCount + gPriceRowCount;
7358 EXCEPTION
7359 when others then
7360 ICX_POR_EXT_UTL.extRollback;
7361 IF (cPriceRows%ISOPEN) THEN
7362 CLOSE cPriceRows;
7363 END IF;
7364 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.processItemData-'||
7365 xErrLoc||' '||SQLERRM);
7366 raise ICX_POR_EXT_UTL.gException;
7367 END processItemData;
7368
7369 --Cleanup Invalid Prices
7370 PROCEDURE cleanupPrices IS
7371 xErrLoc PLS_INTEGER := 100;
7372 xActionMode VARCHAR2(80);
7373 xRowCount PLS_INTEGER := 0;
7374 cInvalidPrices tCursorType;
7375 xString VARCHAR2(2000);
7376 BEGIN
7377 xErrLoc := 100;
7378 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7379 'Cleanup invalid prices.');
7380
7381 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
7382 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
7383 'Enter cleanupPrices()');
7384 END IF;
7385
7386 xErrLoc := 150;
7387 xActionMode := 'DELETE_ITEM_PRICE';
7388 clearTables(xActionMode);
7389
7390 xString :=
7391 'SELECT p.rowid, '||
7392 'p.rt_item_id, '||
7393 'ic.rt_category_id template_category_id, '||
7394 'p.inventory_item_id, '||
7395 'p.org_id, '||
7396 'p.local_rt_item_id '||
7397 'FROM icx_cat_item_prices p, '||
7398 'icx_cat_categories_tl ic '||
7399 'WHERE p.price_type IN (''TEMPLATE'', ''INTERNAL_TEMPLATE'', ' ||
7400 ' ''BLANKET'', ''QUOTATION'', ''GLOBAL_AGREEMENT'', ''ASL'', ' ||
7401 ' ''PURCHASING_ITEM'', ''INTERNAL_ITEM'') ' ||
7402 'AND ICX_POR_EXT_DIAG.getPriceStatus(p.price_type, p.rowid, '''||
7403 ICX_POR_EXT_TEST.gTestMode||''') <> '||
7404 ICX_POR_EXT_DIAG.VALID_FOR_EXTRACT||' '||
7405 'AND p.template_id||''_tmpl'' = ic.key (+) '||
7406 'AND ic.type (+) = '||ICX_POR_EXT_CLASS.TEMPLATE_HEADER_TYPE||' '||
7407 'AND ic.language (+) = '''||ICX_POR_EXTRACTOR.gBaseLang||''' ';
7408 IF ICX_POR_EXT_TEST.gTestMode = 'Y' THEN
7409 xString := xString ||
7410 'AND p.last_updated_by = '||ICX_POR_EXT_TEST.TEST_USER_ID||' ';
7411 END IF;
7412
7413 xErrLoc := 160;
7414 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.INFO_LEVEL THEN
7415 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.INFO_LEVEL,
7416 'Query for invalid prices: ' || xString);
7417 END IF;
7418 OPEN cInvalidPrices FOR xString;
7419
7420 xErrLoc := 180;
7421 LOOP
7422 clearTables(xActionMode);
7423 xErrLoc := 200;
7424 IF (ICX_POR_EXT_UTL.getDatabaseVersion < 9.0) THEN
7425 xErrLoc := 210;
7426 EXIT WHEN cInvalidPrices%NOTFOUND;
7427 FOR i IN 1..ICX_POR_EXT_UTL.gCommitSize LOOP
7428 FETCH cInvalidPrices INTO
7429 gDPRowIds(i), gDPRtItemIds(i),
7430 gDPTemplateCategoryIds(i),
7431 gDPInventoryItemIds(i), gDPOrgIds(i),
7432 gDPLocalRtItemIds(i);
7433 EXIT WHEN cInvalidPrices%NOTFOUND;
7434 END LOOP;
7435 ELSE
7436 xErrLoc := 215;
7437 FETCH cInvalidPrices
7438 BULK COLLECT INTO gDPRowIds, gDPRtItemIds,
7439 gDPTemplateCategoryIds,
7440 gDPInventoryItemIds, gDPOrgIds,
7441 gDPLocalRtItemIds
7442 LIMIT ICX_POR_EXT_UTL.gCommitSize;
7443 EXIT WHEN gDPRowIds.COUNT = 0;
7444 END IF;
7445 xRowCount := xRowCount + gDPRowIds.COUNT;
7446
7447 xErrLoc := 220;
7448 IF (ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL) THEN
7449 FOR i in 1..gDPRowIds.COUNT LOOP
7450 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
7451 snapShot(i, xActionMode));
7452 END LOOP;
7453 END IF;
7454
7455 xErrLoc := 240;
7456 FORALL i IN 1..gDPRowIds.COUNT
7457 DELETE icx_cat_item_prices
7458 WHERE rowid = gDPRowIds(i);
7459
7460 xErrLoc := 260;
7461 FORALL i IN 1..gDPTemplateCategoryIds.COUNT
7462 DELETE icx_cat_category_items
7463 WHERE rt_category_id = gDPTemplateCategoryIds(i)
7464 AND rt_item_id = gDPRtItemIds(i);
7465
7466 xErrLoc := 280;
7467 -- Insert temporary table to cleanup items
7468 FORALL i IN 1..gDPRtItemIds.COUNT
7469 INSERT INTO icx_cat_extract_gt
7470 (rt_item_id, type)
7471 VALUES (gDPRtItemIds(i), 'CLEANUP_ITEM');
7472
7473 -- Insert temporary table to set active flags
7474 FORALL i IN 1..gDPRtItemIds.COUNT
7475 INSERT INTO icx_cat_extract_gt
7476 (rt_item_id, type)
7477 VALUES (gDPRtItemIds(i), 'ACTIVE_FLAG');
7478
7479 FORALL i IN 1..gDPInventoryItemIds.COUNT
7480 INSERT INTO icx_cat_extract_gt
7481 (rt_item_id, type)
7482 SELECT rt_item_id, 'ACTIVE_FLAG'
7483 FROM icx_cat_items_b
7484 WHERE internal_item_id = gDPInventoryItemIds(i)
7485 AND org_id = NVL(gDPOrgIds(i), org_id)
7486 AND supplier IS NULL;
7487
7488 -- Ignore null local rt_item_id values
7489 -- Local rt_item_id not-null only for local org assignments of a global org
7490 FORALL i IN 1..gDPLocalRtItemIds.COUNT
7491 INSERT INTO icx_cat_extract_gt
7492 (rt_item_id, type)
7493 SELECT gDPLocalRtItemIds(i), 'ACTIVE_FLAG'
7494 FROM dual
7495 WHERE gDPLocalRtItemIds(i) IS NOT NULL;
7496
7497 clearTables(xActionMode);
7498
7499 xErrLoc := 300;
7500 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7501 'Processed records: ' || xRowCount);
7502 ICX_POR_EXT_UTL.extAFCommit;
7503 END LOOP;
7504
7505 xErrLoc := 400;
7506 CLOSE cInvalidPrices;
7507
7508 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7509 'Total deleted invalid price rows : ' || xRowCount);
7510
7511 xErrLoc := 420;
7512 cleanupItems;
7513 xErrLoc := 440;
7514 -- Bug # 3542291
7515 ICX_POR_EXT_ITEM.AF_CURRENT_REQUEST_ID :=
7516 ICX_POR_EXT_ITEM.AF_CLEANUP_TEMP_REQUEST_ID;
7517 setActiveFlags;
7518 xErrLoc := 460;
7519 truncateTempTable('NOGA');
7520 xErrLoc := 500;
7521 EXCEPTION
7522 when ICX_POR_EXT_UTL.gException then
7523 ICX_POR_EXT_UTL.extRollback;
7524
7525 IF (cInvalidPrices%ISOPEN) THEN
7526 CLOSE cInvalidPrices;
7527 END IF;
7528 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.cleanupPrices-'||
7529 xErrLoc);
7530 raise ICX_POR_EXT_UTL.gException;
7531 when others then
7532 ICX_POR_EXT_UTL.extRollback;
7533 IF (cInvalidPrices%ISOPEN) THEN
7534 CLOSE cInvalidPrices;
7535 END IF;
7536 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.cleanupPrices-'||
7537 xErrLoc||' '||SQLERRM);
7538
7539 raise ICX_POR_EXT_UTL.gException;
7540 END cleanupPrices;
7541
7542 -- Extract item data
7543 PROCEDURE extractItemData IS
7544 xErrLoc PLS_INTEGER := 100;
7545 BEGIN
7546 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7547 'Extract item data');
7548
7549 IF ICX_POR_EXT_UTL.gDebugLevel >= ICX_POR_EXT_UTL.DETIL_LEVEL THEN
7550 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.DETIL_LEVEL,
7551 'Enter extractItemData()');
7552 END IF;
7553
7554 xErrLoc := 100;
7555 -- get category set info
7556 select category_set_id,
7557 validate_flag,
7558 structure_id
7559 into gCategorySetId,
7560 gValidateFlag,
7561 gStructureId
7562 from mtl_default_sets_view
7563 where functional_area_id = 2;
7564
7565 xErrLoc := 110;
7566 -- Bug # 3865316
7567 -- get multi org flag
7568 select nvl(multi_org_flag, 'N')
7569 into gMultiOrgFlag
7570 from fnd_product_groups;
7571
7572 xErrLoc := 120;
7573 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7574 'Multi Org Flag: ' || gMultiOrgFlag);
7575
7576 xErrLoc := 150;
7577 FND_PROFILE.GET('POR_EXTRACT_A13_AND_A14',gExtractImageDet);
7578 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7579 'Profile option POR_EXTRACT_A13_AND_A14: ' || gExtractImageDet);
7580
7581 xErrLoc := 200;
7582 extractVendorNames;
7583 xErrLoc := 220;
7584 ICX_POR_EXTRACTOR.setLastRunDates('VENDOR_NAME');
7585 xErrLoc := 260;
7586 -- use global temporary table to hold all items need to reset active_flag...
7587 truncateTempTable('NOGA');
7588 xErrLoc := 280;
7589 initCaches;
7590 xErrLoc := 300;
7591 processItemData('TEMPLATE');
7592 xErrLoc := 320;
7593 IF gSetTemplateLastRunDate THEN
7594 ICX_POR_EXTRACTOR.setLastRunDates('TEMPLATE');
7595 END IF;
7596 xErrLoc := 340;
7597 processItemData('CONTRACT');
7598 xErrLoc := 360;
7599 processItemData('GLOBAL_AGREEMENT');
7600 xErrLoc := 380;
7601 ICX_POR_EXTRACTOR.setLastRunDates('CONTRACT');
7602 xErrLoc := 400;
7603 processItemData('ASL');
7604 xErrLoc := 420;
7605 processItemData('ITEM');
7606 xErrLoc := 440;
7607 ICX_POR_EXTRACTOR.setLastRunDates('ITEM');
7608 xErrLoc := 460;
7609 ICX_POR_EXT_UTL.debug(ICX_POR_EXT_UTL.MUST_LEVEL,
7610 'All updated price rows processing done: ' || gTotalCount);
7611 xErrLoc := 480;
7612 IF ICX_POR_EXTRACTOR.gLoaderValue.cleanup_flag = 'Y' THEN
7613 cleanupPrices;
7614 END IF;
7615
7616 updatePriceRequestIds;
7617
7618 xErrLoc := 500;
7619 truncateTempTable('ALL');
7620 EXCEPTION
7621 when others then
7622 ICX_POR_EXT_UTL.extRollback;
7623 updatePriceRequestIds;
7624 truncateTempTable('ALL');
7625 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.extractItemData-'||
7626 xErrLoc||' '||SQLERRM);
7627 raise ICX_POR_EXT_UTL.gException;
7628 END extractItemData;
7629
7630 -- Bug#3352834
7631 -- Update Request Ids.
7632 PROCEDURE updatePriceRequestIds IS
7633 xErrLoc PLS_INTEGER := 100;
7634 BEGIN
7635 xErrLoc := 100;
7636
7637 UPDATE ICX_CAT_ITEM_PRICES
7638 SET REQUEST_ID = ICX_POR_EXTRACTOR.gRequestId
7639 WHERE REQUEST_ID IN (
7640 TEMPLATE_TEMP_REQUEST_ID,
7641 CONTRACT_TEMP_REQUEST_ID,
7642 GA_TEMP_REQUEST_ID,
7643 ASL_TEMP_REQUEST_ID,
7644 ITEM_TEMP_REQUEST_ID,
7645 -- Bug # 3542291
7646 AF_TEMPLATE_TEMP_REQUEST_ID,
7647 AF_CONTRACT_TEMP_REQUEST_ID,
7648 AF_GA_TEMP_REQUEST_ID,
7649 AF_ASL_TEMP_REQUEST_ID,
7650 AF_ITEM_TEMP_REQUEST_ID,
7651 AF_CLEANUP_TEMP_REQUEST_ID);
7652
7653 COMMIT;
7654
7655 EXCEPTION
7656 when others then
7657 ICX_POR_EXT_UTL.extRollback;
7658
7659 ICX_POR_EXT_UTL.pushError('ICX_POR_EXT_ITEM.updatePriceRequestIds -'||
7660 xErrLoc||' '||SQLERRM);
7661
7662 raise ICX_POR_EXT_UTL.gException;
7663 END updatePriceRequestIds;
7664
7665 END ICX_POR_EXT_ITEM;