DBA Data[Home] [Help]

PACKAGE BODY: APPS.ICX_CAT_POPULATE_ITEM_PVT

Source


1 PACKAGE BODY ICX_CAT_POPULATE_ITEM_PVT AS
2 /* $Header: ICXVPPIB.pls 120.25 2011/05/06 09:41:51 mmaramga ship $*/
3 
4 -- Constants
5 G_PKG_NAME                      CONSTANT VARCHAR2(30) :='ICX_CAT_POPULATE_ITEM_PVT';
6 gTotalRowCount                  PLS_INTEGER := 0;
7 TYPE g_csr_type                 IS REF CURSOR;
8 
9 ----------------------------------------------------
10         -- Global PL/SQL Tables --
11 ----------------------------------------------------
12 -- INSERT icx_cat_items_ctx_hdrs_tlp
13 gIHInventoryItemIdTbl           DBMS_SQL.NUMBER_TABLE;
14 gIHPoLineIdTbl                  DBMS_SQL.NUMBER_TABLE;
15 gIHReqTemplateNameTbl           DBMS_SQL.VARCHAR2_TABLE;
16 gIHReqTemplateLineNumTbl        DBMS_SQL.NUMBER_TABLE;
17 gIHOrgIdTbl                     DBMS_SQL.NUMBER_TABLE;
18 gIHLanguageTbl                  DBMS_SQL.VARCHAR2_TABLE;
19 gIHSourceTypeTbl                DBMS_SQL.VARCHAR2_TABLE;
20 gIHItemTypeTbl                  DBMS_SQL.VARCHAR2_TABLE;
21 gIHPurchasingOrgIdTbl           DBMS_SQL.NUMBER_TABLE;
22 gIHOwningOrgIdTbl               DBMS_SQL.NUMBER_TABLE;
23 gIHIpCategoryIdTbl              DBMS_SQL.NUMBER_TABLE;
24 gIHIpCategoryNameTbl            DBMS_SQL.VARCHAR2_TABLE;
25 gIHPoCategoryIdTbl              DBMS_SQL.NUMBER_TABLE;
26 gIHSupplierIdTbl                DBMS_SQL.NUMBER_TABLE;
27 gIHSupplierPartNumTbl           DBMS_SQL.VARCHAR2_TABLE;
28 gIHSupplierPartAuxidTbl         DBMS_SQL.VARCHAR2_TABLE;
29 gIHSupplierSiteIdTbl            DBMS_SQL.NUMBER_TABLE;
30 gIHReqTemplatePoLineIdTbl       DBMS_SQL.NUMBER_TABLE;
31 gIHItemRevisionTbl              DBMS_SQL.VARCHAR2_TABLE;
32 gIHPoHeaderIdTbl                DBMS_SQL.NUMBER_TABLE;
33 gIHDocumentNumberTbl            DBMS_SQL.VARCHAR2_TABLE;
34 gIHLineNumTbl                   DBMS_SQL.NUMBER_TABLE;
35 gIHAllowPriceOverrideFlagTbl	DBMS_SQL.VARCHAR2_TABLE;
36 gIHNotToExceedPriceTbl          DBMS_SQL.NUMBER_TABLE;
37 gIHLineTypeIdTbl                DBMS_SQL.NUMBER_TABLE;
38 gIHUnitMeasLookupCodeTbl        DBMS_SQL.VARCHAR2_TABLE;
39 gIHSuggestedQuantityTbl         DBMS_SQL.NUMBER_TABLE;
40 gIHUnitPriceTbl                 DBMS_SQL.NUMBER_TABLE;
41 gIHAmountTbl                    DBMS_SQL.NUMBER_TABLE;
42 gIHCurrencyCodeTbl              DBMS_SQL.VARCHAR2_TABLE;
43 gIHRateTypeTbl                  DBMS_SQL.VARCHAR2_TABLE;
44 gIHRateDateTbl                  DBMS_SQL.DATE_TABLE;
45 gIHRateTbl                      DBMS_SQL.NUMBER_TABLE;
46 gIHBuyerIdTbl                   DBMS_SQL.NUMBER_TABLE;
47 gIHSupplierContactIdTbl         DBMS_SQL.NUMBER_TABLE;
48 gIHRfqRequiredFlagTbl           DBMS_SQL.VARCHAR2_TABLE;
49 gIHNegotiatedByPreparerFlagTbl  DBMS_SQL.VARCHAR2_TABLE;
50 gIHDescriptionTbl               DBMS_SQL.VARCHAR2_TABLE;
51 --Bug6599217
52 gIHLongDescriptionTbl           ICX_CAT_POPULATE_MI_PVT.VARCHAR4_TABLE;
53 gIHOrganizationIdTbl            DBMS_SQL.NUMBER_TABLE;
54 gIHMasterOrganizationIdTbl      DBMS_SQL.NUMBER_TABLE;
55 gIHOrderTypeLookupCodeTbl       DBMS_SQL.VARCHAR2_TABLE;
56 gIHSupplierTbl                  DBMS_SQL.VARCHAR2_TABLE;
57 gIHGlobalAgreementFlagTbl       DBMS_SQL.VARCHAR2_TABLE;
58 gIHMergedSourceTypeTbl          DBMS_SQL.VARCHAR2_TABLE;
59 
60 -- INSERT icx_cat_items_ctx_dtls_tlp
61 gIDInventoryItemIdTbl           DBMS_SQL.NUMBER_TABLE;
62 gIDPoLineIdTbl                  DBMS_SQL.NUMBER_TABLE;
63 gIDReqTemplateNameTbl           DBMS_SQL.VARCHAR2_TABLE;
64 gIDReqTemplateLineNumTbl        DBMS_SQL.NUMBER_TABLE;
65 gIDOrgIdTbl                     DBMS_SQL.NUMBER_TABLE;
66 gIDLanguageTbl                  DBMS_SQL.VARCHAR2_TABLE;
67 gIDPurchasingOrgIdTbl           DBMS_SQL.NUMBER_TABLE;
68 gIDOwningOrgIdTbl               DBMS_SQL.NUMBER_TABLE;
69 
70 -- UPDATE icx_cat_items_ctx_hdrs_tlp
71 gUHInventoryItemIdTbl           DBMS_SQL.NUMBER_TABLE;
72 gUHPoLineIdTbl                  DBMS_SQL.NUMBER_TABLE;
73 gUHReqTemplateNameTbl           DBMS_SQL.VARCHAR2_TABLE;
74 gUHReqTemplateLineNumTbl        DBMS_SQL.NUMBER_TABLE;
75 gUHOrgIdTbl                     DBMS_SQL.NUMBER_TABLE;
76 gUHLanguageTbl                  DBMS_SQL.VARCHAR2_TABLE;
77 gUHSourceTypeTbl                DBMS_SQL.VARCHAR2_TABLE;
78 gUHItemTypeTbl                  DBMS_SQL.VARCHAR2_TABLE;
79 gUHPurchasingOrgIdTbl           DBMS_SQL.NUMBER_TABLE;
80 gUHIpCategoryIdTbl              DBMS_SQL.NUMBER_TABLE;
81 gUHIpCategoryNameTbl            DBMS_SQL.VARCHAR2_TABLE;
82 gUHPoCategoryIdTbl              DBMS_SQL.NUMBER_TABLE;
83 gUHSupplierIdTbl                DBMS_SQL.NUMBER_TABLE;
84 gUHSupplierPartNumTbl           DBMS_SQL.VARCHAR2_TABLE;
85 gUHSupplierPartAuxidTbl         DBMS_SQL.VARCHAR2_TABLE;
86 gUHSupplierSiteIdTbl            DBMS_SQL.NUMBER_TABLE;
87 gUHReqTemplatePoLineIdTbl       DBMS_SQL.NUMBER_TABLE;
88 gUHItemRevisionTbl              DBMS_SQL.VARCHAR2_TABLE;
89 gUHPoHeaderIdTbl                DBMS_SQL.NUMBER_TABLE;
90 gUHDocumentNumberTbl            DBMS_SQL.VARCHAR2_TABLE;
91 gUHLineNumTbl                   DBMS_SQL.NUMBER_TABLE;
92 gUHAllowPriceOverrideFlagTbl	DBMS_SQL.VARCHAR2_TABLE;
93 gUHNotToExceedPriceTbl          DBMS_SQL.NUMBER_TABLE;
94 gUHLineTypeIdTbl                DBMS_SQL.NUMBER_TABLE;
95 gUHUnitMeasLookupCodeTbl        DBMS_SQL.VARCHAR2_TABLE;
96 gUHSuggestedQuantityTbl         DBMS_SQL.NUMBER_TABLE;
97 gUHUnitPriceTbl                 DBMS_SQL.NUMBER_TABLE;
98 gUHAmountTbl                    DBMS_SQL.NUMBER_TABLE;
99 gUHCurrencyCodeTbl              DBMS_SQL.VARCHAR2_TABLE;
100 gUHRateTypeTbl                  DBMS_SQL.VARCHAR2_TABLE;
101 gUHRateDateTbl                  DBMS_SQL.DATE_TABLE;
102 gUHRateTbl                      DBMS_SQL.NUMBER_TABLE;
103 gUHBuyerIdTbl                   DBMS_SQL.NUMBER_TABLE;
104 gUHSupplierContactIdTbl         DBMS_SQL.NUMBER_TABLE;
105 gUHRfqRequiredFlagTbl           DBMS_SQL.VARCHAR2_TABLE;
106 gUHNegotiatedByPreparerFlagTbl  DBMS_SQL.VARCHAR2_TABLE;
107 gUHDescriptionTbl               DBMS_SQL.VARCHAR2_TABLE;
108 --Bug6599217
109 gUHLongDescriptionTbl           ICX_CAT_POPULATE_MI_PVT.VARCHAR4_TABLE;
110 gUHOrganizationIdTbl            DBMS_SQL.NUMBER_TABLE;
111 gUHMasterOrganizationIdTbl      DBMS_SQL.NUMBER_TABLE;
112 
113 gUHOrderTypeLookupCodeTbl       DBMS_SQL.VARCHAR2_TABLE;
114 gUHSupplierTbl                  DBMS_SQL.VARCHAR2_TABLE;
115 gUHGlobalAgreementFlagTbl       DBMS_SQL.VARCHAR2_TABLE;
116 gUHMergedSourceTypeTbl          DBMS_SQL.VARCHAR2_TABLE;
117 
118 -- DELETE icx_cat_items_ctx_hdrs_tlp
119 gDHInventoryItemIdTbl           DBMS_SQL.NUMBER_TABLE;
120 gDHPoLineIdTbl                  DBMS_SQL.NUMBER_TABLE;
121 gDHReqTemplateNameTbl           DBMS_SQL.VARCHAR2_TABLE;
122 gDHReqTemplateLineNumTbl        DBMS_SQL.NUMBER_TABLE;
123 gDHOrgIdTbl                     DBMS_SQL.NUMBER_TABLE;
124 gDHLanguageTbl                  DBMS_SQL.VARCHAR2_TABLE;
125 
126 -- DELETE icx_cat_items_ctx_dtls_tlp
127 gDDInventoryItemIdTbl           DBMS_SQL.NUMBER_TABLE;
128 gDDPoLineIdTbl                  DBMS_SQL.NUMBER_TABLE;
129 gDDReqTemplateNameTbl           DBMS_SQL.VARCHAR2_TABLE;
130 gDDReqTemplateLineNumTbl        DBMS_SQL.NUMBER_TABLE;
131 gDDOrgIdTbl                     DBMS_SQL.NUMBER_TABLE;
132 gDDLanguageTbl                  DBMS_SQL.VARCHAR2_TABLE;
133 
134 -- DELETE rows with sequence 1 (Mandatory Row) in icx_cat_items_ctx_dtl_tlp
135 gDMDInventoryItemIdTbl          DBMS_SQL.NUMBER_TABLE;
136 gDMDPoLineIdTbl                 DBMS_SQL.NUMBER_TABLE;
137 gDMDReqTemplateNameTbl          DBMS_SQL.VARCHAR2_TABLE;
138 gDMDReqTemplateLineNumTbl       DBMS_SQL.NUMBER_TABLE;
139 gDMDOrgIdTbl                    DBMS_SQL.NUMBER_TABLE;
140 gDMDOwningOrgIdTbl              DBMS_SQL.NUMBER_TABLE;
141 gDMDLanguageTbl                 DBMS_SQL.VARCHAR2_TABLE;
142 
143 -- DELETE rows with sequence 2 (Supplier) in icx_cat_items_ctx_dtl_tlp
144 gDSDInventoryItemIdTbl         DBMS_SQL.NUMBER_TABLE;
145 gDSDPoLineIdTbl                DBMS_SQL.NUMBER_TABLE;
146 gDSDReqTemplateNameTbl         DBMS_SQL.VARCHAR2_TABLE;
147 gDSDReqTemplateLineNumTbl      DBMS_SQL.NUMBER_TABLE;
148 gDSDOrgIdTbl                   DBMS_SQL.NUMBER_TABLE;
149 gDSDOwningOrgIdTbl             DBMS_SQL.NUMBER_TABLE;
150 gDSDLanguageTbl                DBMS_SQL.VARCHAR2_TABLE;
151 
152 -- DELETE rows with sequence 5 (ItemRevision) in icx_cat_items_ctx_dtl_tlp
153 gDIRDInventoryItemIdTbl         DBMS_SQL.NUMBER_TABLE;
154 gDIRDPoLineIdTbl                DBMS_SQL.NUMBER_TABLE;
155 gDIRDReqTemplateNameTbl         DBMS_SQL.VARCHAR2_TABLE;
156 gDIRDReqTemplateLineNumTbl      DBMS_SQL.NUMBER_TABLE;
157 gDIRDOrgIdTbl                   DBMS_SQL.NUMBER_TABLE;
158 gDIRDOwningOrgIdTbl             DBMS_SQL.NUMBER_TABLE;
159 gDIRDLanguageTbl                DBMS_SQL.VARCHAR2_TABLE;
160 
161 -- DELETE rows with sequence 6 (ShoppingCategory) in icx_cat_items_ctx_dtl_tlp
162 gDSCDInventoryItemIdTbl         DBMS_SQL.NUMBER_TABLE;
163 gDSCDPoLineIdTbl                DBMS_SQL.NUMBER_TABLE;
164 gDSCDReqTemplateNameTbl         DBMS_SQL.VARCHAR2_TABLE;
165 gDSCDReqTemplateLineNumTbl      DBMS_SQL.NUMBER_TABLE;
166 gDSCDOrgIdTbl                   DBMS_SQL.NUMBER_TABLE;
167 gDSCDOwningOrgIdTbl             DBMS_SQL.NUMBER_TABLE;
168 gDSCDLanguageTbl                DBMS_SQL.VARCHAR2_TABLE;
169 
170 -- DELETE rows with sequence 15001 (PurchasingOrgId) in icx_cat_items_ctx_dtl_tlp
171 gDPODInventoryItemIdTbl         DBMS_SQL.NUMBER_TABLE;
172 gDPODPoLineIdTbl                DBMS_SQL.NUMBER_TABLE;
173 gDPODReqTemplateNameTbl         DBMS_SQL.VARCHAR2_TABLE;
174 gDPODReqTemplateLineNumTbl      DBMS_SQL.NUMBER_TABLE;
175 gDPODOrgIdTbl                   DBMS_SQL.NUMBER_TABLE;
176 gDPODOwningOrgIdTbl             DBMS_SQL.NUMBER_TABLE;
177 gDPODPurchasingOrgIdTbl         DBMS_SQL.NUMBER_TABLE;
178 gDPODLanguageTbl                DBMS_SQL.VARCHAR2_TABLE;
179 
180 -- DELETE rows with sequence > 100 and < 10000 in icx_cat_items_ctx_dtl_tlp
181 -- (Regular Base and Local Attributes)
182 gDBLDInventoryItemIdTbl         DBMS_SQL.NUMBER_TABLE;
183 gDBLDPoLineIdTbl                DBMS_SQL.NUMBER_TABLE;
184 gDBLDReqTemplateNameTbl         DBMS_SQL.VARCHAR2_TABLE;
185 gDBLDReqTemplateLineNumTbl      DBMS_SQL.NUMBER_TABLE;
186 gDBLDOrgIdTbl                   DBMS_SQL.NUMBER_TABLE;
187 gDBLDOwningOrgIdTbl             DBMS_SQL.NUMBER_TABLE;
188 gDBLDLanguageTbl                DBMS_SQL.VARCHAR2_TABLE;
189 
190 PROCEDURE clearTables
191 (       p_action_mode   IN      VARCHAR2
192 )
193 IS
194   l_err_loc PLS_INTEGER;
195 BEGIN
196   l_err_loc := 100;
197   IF (p_action_mode IN ('ALL', 'INSERT_CTX_HDRS', 'INSERT_ATTR_VALUES', 'INSERT_ATTR_VALUES_TLP')) THEN
198     l_err_loc := 200;
199     -- INSERT icx_cat_items_ctx_hdrs_tlp
200     gIHInventoryItemIdTbl.DELETE;
201     gIHPoLineIdTbl.DELETE;
202     gIHReqTemplateNameTbl.DELETE;
203     gIHReqTemplateLineNumTbl.DELETE;
204     gIHOrgIdTbl.DELETE;
205     gIHLanguageTbl.DELETE;
206     gIHSourceTypeTbl.DELETE;
207     gIHItemTypeTbl.DELETE;
208     gIHPurchasingOrgIdTbl.DELETE;
209     gIHOwningOrgIdTbl.DELETE;
210     gIHIpCategoryIdTbl.DELETE;
211     gIHIpCategoryNameTbl.DELETE;
212     gIHPoCategoryIdTbl.DELETE;
213     gIHSupplierIdTbl.DELETE;
214     gIHSupplierPartNumTbl.DELETE;
215     gIHSupplierPartAuxidTbl.DELETE;
216     gIHSupplierSiteIdTbl.DELETE;
217     gIHReqTemplatePoLineIdTbl.DELETE;
218     gIHItemRevisionTbl.DELETE;
219     gIHPoHeaderIdTbl.DELETE;
220     gIHDocumentNumberTbl.DELETE;
221     gIHLineNumTbl.DELETE;
222     gIHAllowPriceOverrideFlagTbl.DELETE;
223     gIHNotToExceedPriceTbl.DELETE;
224     gIHLineTypeIdTbl.DELETE;
225     gIHUnitMeasLookupCodeTbl.DELETE;
226     gIHSuggestedQuantityTbl.DELETE;
227     gIHUnitPriceTbl.DELETE;
228     gIHAmountTbl.DELETE;
229     gIHCurrencyCodeTbl.DELETE;
230     gIHRateTypeTbl.DELETE;
231     gIHRateDateTbl.DELETE;
232     gIHRateTbl.DELETE;
233     gIHBuyerIdTbl.DELETE;
234     gIHSupplierContactIdTbl.DELETE;
235     gIHRfqRequiredFlagTbl.DELETE;
236     gIHNegotiatedByPreparerFlagTbl.DELETE;
237     gIHDescriptionTbl.DELETE;
238     gIHLongDescriptionTbl.DELETE;
239     gIHOrganizationIdTbl.DELETE;
240     gIHMasterOrganizationIdTbl.DELETE;
241     gIHOrderTypeLookupCodeTbl.DELETE;
242     gIHSupplierTbl.DELETE;
243     gIHGlobalAgreementFlagTbl.DELETE;
244     gIHMergedSourceTypeTbl.DELETE;
245   END IF;
246 
247   l_err_loc := 300;
248 
249   IF (p_action_mode IN ('ALL', 'INSERT_CTX_DTLS')) THEN
250     l_err_loc := 400;
251     -- INSERT icx_cat_items_ctx_dtl_tlp
252     gIDInventoryItemIdTbl.DELETE;
253     gIDPoLineIdTbl.DELETE;
254     gIDReqTemplateNameTbl.DELETE;
255     gIDReqTemplateLineNumTbl.DELETE;
256     gIDOrgIdTbl.DELETE;
257     gIDLanguageTbl.DELETE;
258     gIDPurchasingOrgIdTbl.DELETE;
259     gIDOwningOrgIdTbl.DELETE;
260   END IF;
261 
262   l_err_loc := 500;
263 
264   IF (p_action_mode IN ('ALL', 'UPDATE_CTX_HDRS', 'INSERT_TO_UPDATE_ATTR_VALUES', 'INSERT_TO_UPDATE_ATTR_VALUES_TLP')) THEN
265     l_err_loc := 600;
266     -- UPDATE icx_cat_items_ctx_hdrs_tlp
267     gUHInventoryItemIdTbl.DELETE;
268     gUHPoLineIdTbl.DELETE;
269     gUHReqTemplateNameTbl.DELETE;
270     gUHReqTemplateLineNumTbl.DELETE;
271     gUHOrgIdTbl.DELETE;
272     gUHLanguageTbl.DELETE;
273     gUHSourceTypeTbl.DELETE;
274     gUHItemTypeTbl.DELETE;
275     gUHPurchasingOrgIdTbl.DELETE;
276     gUHIpCategoryIdTbl.DELETE;
277     gUHIpCategoryNameTbl.DELETE;
278     gUHPoCategoryIdTbl.DELETE;
279     gUHSupplierIdTbl.DELETE;
280     gUHSupplierPartNumTbl.DELETE;
281     gUHSupplierPartAuxidTbl.DELETE;
282     gUHSupplierSiteIdTbl.DELETE;
283     gUHReqTemplatePoLineIdTbl.DELETE;
284     gUHItemRevisionTbl.DELETE;
285     gUHPoHeaderIdTbl.DELETE;
286     gUHDocumentNumberTbl.DELETE;
287     gUHLineNumTbl.DELETE;
288     gUHAllowPriceOverrideFlagTbl.DELETE;
289     gUHNotToExceedPriceTbl.DELETE;
290     gUHLineTypeIdTbl.DELETE;
291     gUHUnitMeasLookupCodeTbl.DELETE;
292     gUHSuggestedQuantityTbl.DELETE;
293     gUHUnitPriceTbl.DELETE;
294     gUHAmountTbl.DELETE;
295     gUHCurrencyCodeTbl.DELETE;
296     gUHRateTypeTbl.DELETE;
297     gUHRateDateTbl.DELETE;
298     gUHRateTbl.DELETE;
299     gUHBuyerIdTbl.DELETE;
300     gUHSupplierContactIdTbl.DELETE;
301     gUHRfqRequiredFlagTbl.DELETE;
302     gUHNegotiatedByPreparerFlagTbl.DELETE;
303     gUHDescriptionTbl.DELETE;
304     gUHLongDescriptionTbl.DELETE;
305     gUHOrganizationIdTbl.DELETE;
306     gUHMasterOrganizationIdTbl.DELETE;
307     gUHOrderTypeLookupCodeTbl.DELETE;
308     gUHSupplierTbl.DELETE;
309     gUHGlobalAgreementFlagTbl.DELETE;
310     gUHMergedSourceTypeTbl.DELETE;
311   END IF;
312 
313   l_err_loc := 700;
314 
315   IF (p_action_mode IN ('ALL', 'DELETE_CTX_HDRS', 'DELETE_ATTR_VALUES', 'DELETE_ATTR_VALUES_TLP')) THEN
316     l_err_loc := 800;
317     -- DELETE icx_cat_items_ctx_hdrs_tlp
318     gDHInventoryItemIdTbl.DELETE;
319     gDHPoLineIdTbl.DELETE;
320     gDHReqTemplateNameTbl.DELETE;
321     gDHReqTemplateLineNumTbl.DELETE;
322     gDHOrgIdTbl.DELETE;
323     gDHLanguageTbl.DELETE;
324   END IF;
325 
326   l_err_loc := 900;
327 
328   IF (p_action_mode IN ('ALL', 'DELETE_CTX_DTLS')) THEN
329     l_err_loc := 1000;
330     -- DELETE icx_cat_items_ctx_dtl_tlp
331     gDDInventoryItemIdTbl.DELETE;
332     gDDPoLineIdTbl.DELETE;
333     gDDReqTemplateNameTbl.DELETE;
334     gDDReqTemplateLineNumTbl.DELETE;
335     gDDOrgIdTbl.DELETE;
336     gDDLanguageTbl.DELETE;
337   END IF;
338 
339   l_err_loc := 1100;
340 
341   IF (p_action_mode IN ('ALL', 'DELETE_SPECIFIC_CTX_DTLS')) THEN
342     l_err_loc := 1200;
343     -- DELETE rows with sequence > 100 and < 10000 icx_cat_items_ctx_dtl_tlp
344     gDBLDInventoryItemIdTbl.DELETE;
345     gDBLDPoLineIdTbl.DELETE;
346     gDBLDReqTemplateNameTbl.DELETE;
347     gDBLDReqTemplateLineNumTbl.DELETE;
348     gDBLDOrgIdTbl.DELETE;
349     gDBLDOwningOrgIdTbl.DELETE;
350     gDBLDLanguageTbl.DELETE;
351   END IF;
352 
353   l_err_loc := 1300;
354 
355   IF (p_action_mode IN ('ALL', 'DELETE_MANDATORY_ROW_CTX_DTLS')) THEN
356     l_err_loc := 1400;
357     -- DELETE rows with sequence = 1 in icx_cat_items_ctx_dtl_tlp
358     gDMDInventoryItemIdTbl.DELETE;
359     gDMDPoLineIdTbl.DELETE;
360     gDMDReqTemplateNameTbl.DELETE;
361     gDMDReqTemplateLineNumTbl.DELETE;
362     gDMDOrgIdTbl.DELETE;
363     gDMDOwningOrgIdTbl.DELETE;
364     gDMDLanguageTbl.DELETE;
365   END IF;
366 
367   l_err_loc := 1500;
368 
369   IF (p_action_mode IN ('ALL', 'DELETE_SUPPLIER_ROW_CTX_DTLS')) THEN
370     l_err_loc := 1600;
371     -- DELETE rows with sequence = 2 in icx_cat_items_ctx_dtl_tlp
372     gDSDInventoryItemIdTbl.DELETE;
373     gDSDPoLineIdTbl.DELETE;
374     gDSDReqTemplateNameTbl.DELETE;
375     gDSDReqTemplateLineNumTbl.DELETE;
376     gDSDOrgIdTbl.DELETE;
377     gDSDOwningOrgIdTbl.DELETE;
378     gDSDLanguageTbl.DELETE;
379   END IF;
380 
381   l_err_loc := 1700;
382 
383   IF (p_action_mode IN ('ALL', 'DELETE_ITEMREV_ROW_CTX_DTLS')) THEN
384     l_err_loc := 1800;
385     -- DELETE rows with sequence = 5 in icx_cat_items_ctx_dtl_tlp
386     gDIRDInventoryItemIdTbl.DELETE;
387     gDIRDPoLineIdTbl.DELETE;
388     gDIRDReqTemplateNameTbl.DELETE;
389     gDIRDReqTemplateLineNumTbl.DELETE;
390     gDIRDOrgIdTbl.DELETE;
391     gDIRDOwningOrgIdTbl.DELETE;
392     gDIRDLanguageTbl.DELETE;
393   END IF;
394 
395   l_err_loc := 1900;
396 
397   IF (p_action_mode IN ('ALL', 'DELETE_SHOPCATG_ROW_CTX_DTLS')) THEN
398     l_err_loc := 2000;
399     -- DELETE rows with sequence = 6 in icx_cat_items_ctx_dtl_tlp
400     gDSCDInventoryItemIdTbl.DELETE;
401     gDSCDPoLineIdTbl.DELETE;
402     gDSCDReqTemplateNameTbl.DELETE;
403     gDSCDReqTemplateLineNumTbl.DELETE;
404     gDSCDOrgIdTbl.DELETE;
405     gDSCDOwningOrgIdTbl.DELETE;
406     gDSCDLanguageTbl.DELETE;
407   END IF;
408 
409   l_err_loc := 2100;
410 
411   IF (p_action_mode IN ('ALL', 'DELETE_PURCHORG_ROW_CTX_DTLS')) THEN
412     l_err_loc := 2200;
413     -- DELETE rows with sequence =15001 in icx_cat_items_ctx_dtl_tlp
414     gDPODInventoryItemIdTbl.DELETE;
415     gDPODPoLineIdTbl.DELETE;
416     gDPODReqTemplateNameTbl.DELETE;
417     gDPODReqTemplateLineNumTbl.DELETE;
418     gDPODOrgIdTbl.DELETE;
419     gDPODOwningOrgIdTbl.DELETE;
420     gDPODPurchasingOrgIdTbl.DELETE;
421     gDPODLanguageTbl.DELETE;
422   END IF;
423 
424   l_err_loc := 2300;
425 
426 END clearTables;
427 
428 /*
429 FUNCTION logPLSQLTableRow
430 (       p_index         IN      NUMBER  ,
431         p_action_mode   IN      VARCHAR2
432 )
433 RETURN VARCHAR2 IS
434   l_string VARCHAR2(4000);
435 BEGIN
436   l_string := 'logPLSQLTableRow('||p_action_mode||')['||p_index||']--';
437   IF (p_action_mode = 'INSERT_CTX_HDRS') THEN
438     --INSERT icx_cat_items_ctx_hdrs_tlp
439     l_string := l_string || ' gIHInventoryItemIdTbl: ' ||
440       ICX_CAT_UTIL_PVT.getTableElement(gIHInventoryItemIdTbl, p_index) || ', ';
441     l_string := l_string || ' gIHPoLineIdTbl: ' ||
442       ICX_CAT_UTIL_PVT.getTableElement(gIHPoLineIdTbl, p_index) || ', ';
443     l_string := l_string || ' gIHReqTemplateNameTbl: ' ||
444       ICX_CAT_UTIL_PVT.getTableElement(gIHReqTemplateNameTbl, p_index) || ', ';
445     l_string := l_string || ' gIHReqTemplateLineNumTbl: ' ||
446       ICX_CAT_UTIL_PVT.getTableElement(gIHReqTemplateLineNumTbl, p_index) || ', ';
447     l_string := l_string || ' gIHOrgIdTbl: ' ||
448       ICX_CAT_UTIL_PVT.getTableElement(gIHOrgIdTbl, p_index) || ', ';
449     l_string := l_string || ' gIHLanguageTbl: ' ||
450       ICX_CAT_UTIL_PVT.getTableElement(gIHLanguageTbl, p_index) || ', ';
451     l_string := l_string || ' gIHSourceTypeTbl: ' ||
452       ICX_CAT_UTIL_PVT.getTableElement(gIHSourceTypeTbl, p_index) || ', ';
453     l_string := l_string || ' gIHItemTypeTbl: ' ||
454       ICX_CAT_UTIL_PVT.getTableElement(gIHItemTypeTbl, p_index) || ', ';
455     l_string := l_string || ' gIHPurchasingOrgIdTbl: ' ||
456       ICX_CAT_UTIL_PVT.getTableElement(gIHPurchasingOrgIdTbl, p_index) || ', ';
457     l_string := l_string || ' gIHOwningOrgIdTbl: ' ||
458       ICX_CAT_UTIL_PVT.getTableElement(gIHOwningOrgIdTbl, p_index) || ', ';
459     l_string := l_string || ' gIHIpCategoryIdTbl: ' ||
460       ICX_CAT_UTIL_PVT.getTableElement(gIHIpCategoryIdTbl, p_index) || ', ';
461     l_string := l_string || ' gIHIpCategoryNameTbl: ' ||
462       ICX_CAT_UTIL_PVT.getTableElement(gIHIpCategoryNameTbl, p_index) || ', ';
463     l_string := l_string || ' gIHPoCategoryIdTbl: ' ||
464       ICX_CAT_UTIL_PVT.getTableElement(gIHPoCategoryIdTbl, p_index) || ', ';
465     l_string := l_string || ' gIHSupplierIdTbl: ' ||
466       ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierIdTbl, p_index) || ', ';
467     l_string := l_string || ' gIHSupplierPartNumTbl: ' ||
468       ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierPartNumTbl, p_index) || ', ';
469     l_string := l_string || ' gIHSupplierPartAuxidTbl: ' ||
470       ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierPartAuxidTbl, p_index) || ', ';
471     l_string := l_string || ' gIHSupplierSiteIdTbl: ' ||
472       ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierSiteIdTbl, p_index) || ', ';
473     l_string := l_string || ' gIHReqTemplatePoLineIdTbl: ' ||
474       ICX_CAT_UTIL_PVT.getTableElement(gIHReqTemplatePoLineIdTbl, p_index) || ', ';
475     l_string := l_string || ' gIHItemRevisionTbl: ' ||
476       ICX_CAT_UTIL_PVT.getTableElement(gIHItemRevisionTbl, p_index) || ', ';
477     l_string := l_string || ' gIHPoHeaderIdTbl: ' ||
478       ICX_CAT_UTIL_PVT.getTableElement(gIHPoHeaderIdTbl, p_index) || ', ';
479     l_string := l_string || ' gIHDocumentNumberTbl: ' ||
480       ICX_CAT_UTIL_PVT.getTableElement(gIHDocumentNumberTbl, p_index) || ', ';
481     l_string := l_string || ' gIHLineNumTbl: ' ||
482       ICX_CAT_UTIL_PVT.getTableElement(gIHLineNumTbl, p_index) || ', ';
483     l_string := l_string || ' gIHAllowPriceOverrideFlagTbl: ' ||
484       ICX_CAT_UTIL_PVT.getTableElement(gIHAllowPriceOverrideFlagTbl, p_index) || ', ';
485     l_string := l_string || ' gIHNotToExceedPriceTbl: ' ||
486       ICX_CAT_UTIL_PVT.getTableElement(gIHNotToExceedPriceTbl, p_index) || ', ';
487     l_string := l_string || ' gIHLineTypeIdTbl: ' ||
488       ICX_CAT_UTIL_PVT.getTableElement(gIHLineTypeIdTbl, p_index) || ', ';
489     l_string := l_string || ' gIHUnitMeasLookupCodeTbl: ' ||
490       ICX_CAT_UTIL_PVT.getTableElement(gIHUnitMeasLookupCodeTbl, p_index) || ', ';
491     l_string := l_string || ' gIHSuggestedQuantityTbl: ' ||
492       ICX_CAT_UTIL_PVT.getTableElement(gIHSuggestedQuantityTbl, p_index) || ', ';
493     l_string := l_string || ' gIHUnitPriceTbl: ' ||
494       ICX_CAT_UTIL_PVT.getTableElement(gIHUnitPriceTbl, p_index) || ', ';
495     l_string := l_string || ' gIHAmountTbl: ' ||
496       ICX_CAT_UTIL_PVT.getTableElement(gIHAmountTbl, p_index) || ', ';
497     l_string := l_string || ' gIHCurrencyCodeTbl: ' ||
498       ICX_CAT_UTIL_PVT.getTableElement(gIHCurrencyCodeTbl, p_index) || ', ';
499     l_string := l_string || ' gIHRateTypeTbl: ' ||
500       ICX_CAT_UTIL_PVT.getTableElement(gIHRateTypeTbl, p_index) || ', ';
501     l_string := l_string || ' gIHRateDateTbl: ' ||
502       ICX_CAT_UTIL_PVT.getTableElement(gIHRateDateTbl, p_index) || ', ';
503     l_string := l_string || ' gIHRateTbl: ' ||
504       ICX_CAT_UTIL_PVT.getTableElement(gIHRateTbl, p_index) || ', ';
505     l_string := l_string || ' gIHBuyerIdTbl: ' ||
506       ICX_CAT_UTIL_PVT.getTableElement(gIHBuyerIdTbl, p_index) || ', ';
507     l_string := l_string || ' gIHSupplierContactIdTbl: ' ||
508       ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierContactIdTbl, p_index) || ', ';
509     l_string := l_string || ' gIHRfqRequiredFlagTbl: ' ||
510       ICX_CAT_UTIL_PVT.getTableElement(gIHRfqRequiredFlagTbl, p_index) || ', ';
511     l_string := l_string || ' gIHNegotiatedByPreparerFlagTbl: ' ||
512       ICX_CAT_UTIL_PVT.getTableElement(gIHNegotiatedByPreparerFlagTbl, p_index) || ', ';
513     l_string := l_string || ' gIHDescriptionTbl: ' ||
514       ICX_CAT_UTIL_PVT.getTableElement(gIHDescriptionTbl, p_index) || ', ';
515     l_string := l_string || ' gIHOrderTypeLookupCodeTbl: ' ||
516       ICX_CAT_UTIL_PVT.getTableElement(gIHOrderTypeLookupCodeTbl, p_index) || ', ';
517     l_string := l_string || ' gIHSupplierTbl: ' ||
518       ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierTbl, p_index) || ', ';
519     l_string := l_string || ' gIHGlobalAgreementFlagTbl: ' ||
520       ICX_CAT_UTIL_PVT.getTableElement(gIHGlobalAgreementFlagTbl, p_index) || ', ';
521     l_string := l_string || ' gIHMergedSourceTypeTbl: ' ||
522       ICX_CAT_UTIL_PVT.getTableElement(gIHMergedSourceTypeTbl, p_index) || ', ';
523   END IF;
524 
525   IF (p_action_mode = 'INSERT_CTX_DTLS') THEN
526     --INSERT icx_cat_items_ctx_dtl_tlp
527     l_string := l_string || ' gIDInventoryItemIdTbl: ' ||
528       ICX_CAT_UTIL_PVT.getTableElement(gIDInventoryItemIdTbl, p_index) || ', ';
529     l_string := l_string || ' gIDPoLineIdTbl: ' ||
530       ICX_CAT_UTIL_PVT.getTableElement(gIDPoLineIdTbl, p_index) || ', ';
531     l_string := l_string || ' gIDReqTemplateNameTbl: ' ||
532       ICX_CAT_UTIL_PVT.getTableElement(gIDReqTemplateNameTbl, p_index) || ', ';
533     l_string := l_string || ' gIDReqTemplateLineNumTbl: ' ||
534       ICX_CAT_UTIL_PVT.getTableElement(gIDReqTemplateLineNumTbl, p_index) || ', ';
535     l_string := l_string || ' gIDOrgIdTbl: ' ||
536       ICX_CAT_UTIL_PVT.getTableElement(gIDOrgIdTbl, p_index) || ', ';
537     l_string := l_string || ' gIDLanguageTbl: ' ||
538       ICX_CAT_UTIL_PVT.getTableElement(gIDLanguageTbl, p_index) || ', ';
539     l_string := l_string || ' gIDPurchasingOrgIdTbl: ' ||
540       ICX_CAT_UTIL_PVT.getTableElement(gIDPurchasingOrgIdTbl, p_index) || ', ';
541     l_string := l_string || ' gIDOwningOrgIdTbl: ' ||
542       ICX_CAT_UTIL_PVT.getTableElement(gIDOwningOrgIdTbl, p_index) || ', ';
543   END IF;
544 
545   IF (p_action_mode = 'UPDATE_CTX_HDRS') THEN
546     --UPDATE icx_cat_items_ctx_hdrs_tlp
547     l_string := l_string || ' gUHInventoryItemIdTbl: ' ||
548       ICX_CAT_UTIL_PVT.getTableElement(gUHInventoryItemIdTbl, p_index) || ', ';
549     l_string := l_string || ' gUHPoLineIdTbl: ' ||
550       ICX_CAT_UTIL_PVT.getTableElement(gUHPoLineIdTbl, p_index) || ', ';
551     l_string := l_string || ' gUHReqTemplateNameTbl: ' ||
552       ICX_CAT_UTIL_PVT.getTableElement(gUHReqTemplateNameTbl, p_index) || ', ';
553     l_string := l_string || ' gUHReqTemplateLineNumTbl: ' ||
554       ICX_CAT_UTIL_PVT.getTableElement(gUHReqTemplateLineNumTbl, p_index) || ', ';
555     l_string := l_string || ' gUHOrgIdTbl: ' ||
556       ICX_CAT_UTIL_PVT.getTableElement(gUHOrgIdTbl, p_index) || ', ';
557     l_string := l_string || ' gUHLanguageTbl: ' ||
558       ICX_CAT_UTIL_PVT.getTableElement(gUHLanguageTbl, p_index) || ', ';
559     l_string := l_string || ' gUHSourceTypeTbl: ' ||
560       ICX_CAT_UTIL_PVT.getTableElement(gUHSourceTypeTbl, p_index) || ', ';
561     l_string := l_string || ' gUHItemTypeTbl: ' ||
562       ICX_CAT_UTIL_PVT.getTableElement(gUHItemTypeTbl, p_index) || ', ';
563     l_string := l_string || ' gUHPurchasingOrgIdTbl: ' ||
564       ICX_CAT_UTIL_PVT.getTableElement(gUHPurchasingOrgIdTbl, p_index) || ', ';
565     l_string := l_string || ' gUHIpCategoryIdTbl: ' ||
566       ICX_CAT_UTIL_PVT.getTableElement(gUHIpCategoryIdTbl, p_index) || ', ';
567     l_string := l_string || ' gUHIpCategoryNameTbl: ' ||
568       ICX_CAT_UTIL_PVT.getTableElement(gUHIpCategoryNameTbl, p_index) || ', ';
569     l_string := l_string || ' gUHPoCategoryIdTbl: ' ||
570       ICX_CAT_UTIL_PVT.getTableElement(gUHPoCategoryIdTbl, p_index) || ', ';
571     l_string := l_string || ' gUHSupplierIdTbl: ' ||
572       ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierIdTbl, p_index) || ', ';
573     l_string := l_string || ' gUHSupplierPartNumTbl: ' ||
574       ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierPartNumTbl, p_index) || ', ';
575     l_string := l_string || ' gUHSupplierPartAuxidTbl: ' ||
576       ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierPartAuxidTbl, p_index) || ', ';
577     l_string := l_string || ' gUHSupplierSiteIdTbl: ' ||
578       ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierSiteIdTbl, p_index) || ', ';
579     l_string := l_string || ' gUHReqTemplatePoLineIdTbl: ' ||
580       ICX_CAT_UTIL_PVT.getTableElement(gUHReqTemplatePoLineIdTbl, p_index) || ', ';
581     l_string := l_string || ' gUHItemRevisionTbl: ' ||
582       ICX_CAT_UTIL_PVT.getTableElement(gUHItemRevisionTbl, p_index) || ', ';
583     l_string := l_string || ' gUHPoHeaderIdTbl: ' ||
584       ICX_CAT_UTIL_PVT.getTableElement(gUHPoHeaderIdTbl, p_index) || ', ';
585     l_string := l_string || ' gUHDocumentNumberTbl: ' ||
586       ICX_CAT_UTIL_PVT.getTableElement(gUHDocumentNumberTbl, p_index) || ', ';
587     l_string := l_string || ' gUHLineNumTbl: ' ||
588       ICX_CAT_UTIL_PVT.getTableElement(gUHLineNumTbl, p_index) || ', ';
589     l_string := l_string || ' gUHAllowPriceOverrideFlagTbl: ' ||
590       ICX_CAT_UTIL_PVT.getTableElement(gUHAllowPriceOverrideFlagTbl, p_index) || ', ';
591     l_string := l_string || ' gUHNotToExceedPriceTbl: ' ||
592       ICX_CAT_UTIL_PVT.getTableElement(gUHNotToExceedPriceTbl, p_index) || ', ';
593     l_string := l_string || ' gUHLineTypeIdTbl: ' ||
594       ICX_CAT_UTIL_PVT.getTableElement(gUHLineTypeIdTbl, p_index) || ', ';
595     l_string := l_string || ' gUHUnitMeasLookupCodeTbl: ' ||
596       ICX_CAT_UTIL_PVT.getTableElement(gUHUnitMeasLookupCodeTbl, p_index) || ', ';
597     l_string := l_string || ' gUHSuggestedQuantityTbl: ' ||
598       ICX_CAT_UTIL_PVT.getTableElement(gUHSuggestedQuantityTbl, p_index) || ', ';
599     l_string := l_string || ' gUHUnitPriceTbl: ' ||
600       ICX_CAT_UTIL_PVT.getTableElement(gUHUnitPriceTbl, p_index) || ', ';
601     l_string := l_string || ' gUHAmountTbl: ' ||
602       ICX_CAT_UTIL_PVT.getTableElement(gUHAmountTbl, p_index) || ', ';
603     l_string := l_string || ' gUHCurrencyCodeTbl: ' ||
604       ICX_CAT_UTIL_PVT.getTableElement(gUHCurrencyCodeTbl, p_index) || ', ';
605     l_string := l_string || ' gUHRateTypeTbl: ' ||
606       ICX_CAT_UTIL_PVT.getTableElement(gUHRateTypeTbl, p_index) || ', ';
607     l_string := l_string || ' gUHRateDateTbl: ' ||
608       ICX_CAT_UTIL_PVT.getTableElement(gUHRateDateTbl, p_index) || ', ';
609     l_string := l_string || ' gUHRateTbl: ' ||
610       ICX_CAT_UTIL_PVT.getTableElement(gUHRateTbl, p_index) || ', ';
611     l_string := l_string || ' gUHBuyerIdTbl: ' ||
612       ICX_CAT_UTIL_PVT.getTableElement(gUHBuyerIdTbl, p_index) || ', ';
613     l_string := l_string || ' gUHSupplierContactIdTbl: ' ||
614       ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierContactIdTbl, p_index) || ', ';
615     l_string := l_string || ' gUHRfqRequiredFlagTbl: ' ||
616       ICX_CAT_UTIL_PVT.getTableElement(gUHRfqRequiredFlagTbl, p_index) || ', ';
617     l_string := l_string || ' gUHNegotiatedByPreparerFlagTbl: ' ||
618       ICX_CAT_UTIL_PVT.getTableElement(gUHNegotiatedByPreparerFlagTbl, p_index) || ', ';
619     l_string := l_string || ' gUHDescriptionTbl: ' ||
620       ICX_CAT_UTIL_PVT.getTableElement(gUHDescriptionTbl, p_index) || ', ';
621     l_string := l_string || ' gUHOrderTypeLookupCodeTbl: ' ||
622       ICX_CAT_UTIL_PVT.getTableElement(gUHOrderTypeLookupCodeTbl, p_index) || ', ';
623     l_string := l_string || ' gUHSupplierTbl: ' ||
624       ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierTbl, p_index) || ', ';
625     l_string := l_string || ' gUHGlobalAgreementFlagTbl: ' ||
626       ICX_CAT_UTIL_PVT.getTableElement(gUHGlobalAgreementFlagTbl, p_index) || ', ';
627     l_string := l_string || ' gUHMergedSourceTypeTbl: ' ||
628       ICX_CAT_UTIL_PVT.getTableElement(gUHMergedSourceTypeTbl, p_index) || ', ';
629   END IF;
630 
631   IF (p_action_mode = 'DELETE_CTX_HDRS') THEN
632     --DELETE icx_cat_items_ctx_hdrs_tlp
633     l_string := l_string || ' gDHInventoryItemIdTbl: ' ||
634       ICX_CAT_UTIL_PVT.getTableElement(gDHInventoryItemIdTbl, p_index) || ', ';
635     l_string := l_string || ' gDHPoLineIdTbl: ' ||
636       ICX_CAT_UTIL_PVT.getTableElement(gDHPoLineIdTbl, p_index) || ', ';
637     l_string := l_string || ' gDHReqTemplateNameTbl: ' ||
638       ICX_CAT_UTIL_PVT.getTableElement(gDHReqTemplateNameTbl, p_index) || ', ';
639     l_string := l_string || ' gDHReqTemplateLineNumTbl: ' ||
640       ICX_CAT_UTIL_PVT.getTableElement(gDHReqTemplateLineNumTbl, p_index) || ', ';
641     l_string := l_string || ' gDHOrgIdTbl: ' ||
642       ICX_CAT_UTIL_PVT.getTableElement(gDHOrgIdTbl, p_index) || ', ';
643     l_string := l_string || ' gDHLanguageTbl: ' ||
644       ICX_CAT_UTIL_PVT.getTableElement(gDHLanguageTbl, p_index) || ', ';
645   END IF;
646 
647   IF (p_action_mode = 'DELETE_CTX_DTLS') THEN
648     --DELETE icx_cat_items_ctx_dtl_tlp
649     l_string := l_string || ' gDDInventoryItemIdTbl: ' ||
650       ICX_CAT_UTIL_PVT.getTableElement(gDDInventoryItemIdTbl, p_index) || ', ';
651     l_string := l_string || ' gDDPoLineIdTbl: ' ||
652       ICX_CAT_UTIL_PVT.getTableElement(gDDPoLineIdTbl, p_index) || ', ';
653     l_string := l_string || ' gDDReqTemplateNameTbl: ' ||
654       ICX_CAT_UTIL_PVT.getTableElement(gDDReqTemplateNameTbl, p_index) || ', ';
655     l_string := l_string || ' gDDReqTemplateLineNumTbl: ' ||
656       ICX_CAT_UTIL_PVT.getTableElement(gDDReqTemplateLineNumTbl, p_index) || ', ';
657     l_string := l_string || ' gDDOrgIdTbl: ' ||
658       ICX_CAT_UTIL_PVT.getTableElement(gDDOrgIdTbl, p_index) || ', ';
659     l_string := l_string || ' gDDLanguageTbl: ' ||
660       ICX_CAT_UTIL_PVT.getTableElement(gDDLanguageTbl, p_index) || ', ';
661   END IF;
662 
663   IF (p_action_mode = 'DELETE_MANDATORY_ROW_CTX_DTLS') THEN
664     --DELETE rows with sequence = 1 in icx_cat_items_ctx_dtl_tlp
665     l_string := l_string || ' gDMDInventoryItemIdTbl: ' ||
666       ICX_CAT_UTIL_PVT.getTableElement(gDMDInventoryItemIdTbl, p_index) || ', ';
667     l_string := l_string || ' gDMDPoLineIdTbl: ' ||
668       ICX_CAT_UTIL_PVT.getTableElement(gDMDPoLineIdTbl, p_index) || ', ';
669     l_string := l_string || ' gDMDReqTemplateNameTbl: ' ||
670       ICX_CAT_UTIL_PVT.getTableElement(gDMDReqTemplateNameTbl, p_index) || ', ';
671     l_string := l_string || ' gDMDReqTemplateLineNumTbl: ' ||
672       ICX_CAT_UTIL_PVT.getTableElement(gDMDReqTemplateLineNumTbl, p_index) || ', ';
673     l_string := l_string || ' gDMDOrgIdTbl: ' ||
674       ICX_CAT_UTIL_PVT.getTableElement(gDMDOrgIdTbl, p_index) || ', ';
675     l_string := l_string || ' gDMDLanguageTbl: ' ||
676       ICX_CAT_UTIL_PVT.getTableElement(gDMDLanguageTbl, p_index) || ', ';
677   END IF;
678 
679   IF (p_action_mode = 'DELETE_SUPPLIER_ROW_CTX_DTLS') THEN
680     --DELETE rows with sequence = 2 in icx_cat_items_ctx_dtl_tlp
681     l_string := l_string || ' gDSDInventoryItemIdTbl: ' ||
682       ICX_CAT_UTIL_PVT.getTableElement(gDSDInventoryItemIdTbl, p_index) || ', ';
683     l_string := l_string || ' gDSDPoLineIdTbl: ' ||
684       ICX_CAT_UTIL_PVT.getTableElement(gDSDPoLineIdTbl, p_index) || ', ';
685     l_string := l_string || ' gDSDReqTemplateNameTbl: ' ||
686       ICX_CAT_UTIL_PVT.getTableElement(gDSDReqTemplateNameTbl, p_index) || ', ';
687     l_string := l_string || ' gDSDReqTemplateLineNumTbl: ' ||
688       ICX_CAT_UTIL_PVT.getTableElement(gDSDReqTemplateLineNumTbl, p_index) || ', ';
689     l_string := l_string || ' gDSDOrgIdTbl: ' ||
690       ICX_CAT_UTIL_PVT.getTableElement(gDSDOrgIdTbl, p_index) || ', ';
691     l_string := l_string || ' gDSDLanguageTbl: ' ||
692       ICX_CAT_UTIL_PVT.getTableElement(gDSDLanguageTbl, p_index) || ', ';
693   END IF;
694 
695   IF (p_action_mode = 'DELETE_ITEMREV_ROW_CTX_DTLS') THEN
696     --DELETE rows with sequence = 5 in icx_cat_items_ctx_dtl_tlp
697     l_string := l_string || ' gDIRDInventoryItemIdTbl: ' ||
698       ICX_CAT_UTIL_PVT.getTableElement(gDIRDInventoryItemIdTbl, p_index) || ', ';
699     l_string := l_string || ' gDIRDPoLineIdTbl: ' ||
700       ICX_CAT_UTIL_PVT.getTableElement(gDIRDPoLineIdTbl, p_index) || ', ';
701     l_string := l_string || ' gDIRDReqTemplateNameTbl: ' ||
702       ICX_CAT_UTIL_PVT.getTableElement(gDIRDReqTemplateNameTbl, p_index) || ', ';
703     l_string := l_string || ' gDIRDReqTemplateLineNumTbl: ' ||
704       ICX_CAT_UTIL_PVT.getTableElement(gDIRDReqTemplateLineNumTbl, p_index) || ', ';
705     l_string := l_string || ' gDIRDOrgIdTbl: ' ||
706       ICX_CAT_UTIL_PVT.getTableElement(gDIRDOrgIdTbl, p_index) || ', ';
707     l_string := l_string || ' gDIRDLanguageTbl: ' ||
708       ICX_CAT_UTIL_PVT.getTableElement(gDIRDLanguageTbl, p_index) || ', ';
709   END IF;
710 
711   IF (p_action_mode = 'DELETE_SHOPCATG_ROW_CTX_DTLS') THEN
712     --DELETE rows with sequence = 6 in icx_cat_items_ctx_dtl_tlp
713     l_string := l_string || ' gDSCDInventoryItemIdTbl: ' ||
714       ICX_CAT_UTIL_PVT.getTableElement(gDSCDInventoryItemIdTbl, p_index) || ', ';
715     l_string := l_string || ' gDSCDPoLineIdTbl: ' ||
716       ICX_CAT_UTIL_PVT.getTableElement(gDSCDPoLineIdTbl, p_index) || ', ';
717     l_string := l_string || ' gDSCDReqTemplateNameTbl: ' ||
718       ICX_CAT_UTIL_PVT.getTableElement(gDSCDReqTemplateNameTbl, p_index) || ', ';
719     l_string := l_string || ' gDSCDReqTemplateLineNumTbl: ' ||
720       ICX_CAT_UTIL_PVT.getTableElement(gDSCDReqTemplateLineNumTbl, p_index) || ', ';
721     l_string := l_string || ' gDSCDOrgIdTbl: ' ||
722       ICX_CAT_UTIL_PVT.getTableElement(gDSCDOrgIdTbl, p_index) || ', ';
723     l_string := l_string || ' gDSCDLanguageTbl: ' ||
724       ICX_CAT_UTIL_PVT.getTableElement(gDSCDLanguageTbl, p_index) || ', ';
725   END IF;
726 
727   IF (p_action_mode = 'DELETE_PURCHORG_ROW_CTX_DTLS') THEN
728     --DELETE rows with sequence =15001 in icx_cat_items_ctx_dtl_tlp
729     l_string := l_string || ' gDPODInventoryItemIdTbl: ' ||
730       ICX_CAT_UTIL_PVT.getTableElement(gDPODInventoryItemIdTbl, p_index) || ', ';
731     l_string := l_string || ' gDPODPoLineIdTbl: ' ||
732       ICX_CAT_UTIL_PVT.getTableElement(gDPODPoLineIdTbl, p_index) || ', ';
733     l_string := l_string || ' gDPODReqTemplateNameTbl: ' ||
734       ICX_CAT_UTIL_PVT.getTableElement(gDPODReqTemplateNameTbl, p_index) || ', ';
735     l_string := l_string || ' gDPODReqTemplateLineNumTbl: ' ||
736       ICX_CAT_UTIL_PVT.getTableElement(gDPODReqTemplateLineNumTbl, p_index) || ', ';
737     l_string := l_string || ' gDPODOrgIdTbl: ' ||
738       ICX_CAT_UTIL_PVT.getTableElement(gDPODOrgIdTbl, p_index) || ', ';
739     l_string := l_string || ' gDPODPurchasingOrgIdTbl: ' ||
740       ICX_CAT_UTIL_PVT.getTableElement(gDPODPurchasingOrgIdTbl, p_index) || ', ';
741     l_string := l_string || ' gDPODLanguageTbl: ' ||
742       ICX_CAT_UTIL_PVT.getTableElement(gDPODLanguageTbl, p_index) || ', ';
743   END IF;
744 
745   RETURN l_string;
746 
747 END logPLSQLTableRow;
748 */
749 
750 PROCEDURE logPLSQLTableRow
751 (       p_api_name      IN      VARCHAR2        ,
752         p_log_level     IN      NUMBER          ,
753         p_index         IN      NUMBER          ,
754         p_action_mode   IN      VARCHAR2
755 )
756 IS
757   l_log_string  VARCHAR2(4000);
758   l_err_loc     PLS_INTEGER;
759   l_module_name VARCHAR2(80);
760 BEGIN
761   l_err_loc := 100;
762   IF (p_log_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
763     l_err_loc := 200;
764     l_module_name := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, p_api_name);
765 
766     l_err_loc := 220;
767     l_log_string := 'logPLSQLTableRow('||p_action_mode||')['||p_index||']--';
768     FND_LOG.string(p_log_level, l_module_name, l_log_string);
769 
770     l_err_loc := 240;
771     IF (p_action_mode = 'INSERT_CTX_HDRS') THEN
772       l_err_loc := 300;
773       -- INSERT icx_cat_items_ctx_hdrs_tlp
774       l_log_string := ' gIHInventoryItemIdTbl['||p_index||']: ' ||
775         ICX_CAT_UTIL_PVT.getTableElement(gIHInventoryItemIdTbl, p_index) || '; ';
776       FND_LOG.string(p_log_level, l_module_name, l_log_string);
777 
778       l_log_string := ' gIHPoLineIdTbl['||p_index||']: ' ||
779         ICX_CAT_UTIL_PVT.getTableElement(gIHPoLineIdTbl, p_index) || '; ';
780       FND_LOG.string(p_log_level, l_module_name, l_log_string);
781 
782       l_log_string := ' gIHReqTemplateNameTbl['||p_index||']: ' ||
783         ICX_CAT_UTIL_PVT.getTableElement(gIHReqTemplateNameTbl, p_index) || '; ';
784       FND_LOG.string(p_log_level, l_module_name, l_log_string);
785 
786       l_log_string := ' gIHReqTemplateLineNumTbl['||p_index||']: ' ||
787         ICX_CAT_UTIL_PVT.getTableElement(gIHReqTemplateLineNumTbl, p_index) || '; ';
788       FND_LOG.string(p_log_level, l_module_name, l_log_string);
789 
790       l_log_string := ' gIHOrgIdTbl['||p_index||']: ' ||
791         ICX_CAT_UTIL_PVT.getTableElement(gIHOrgIdTbl, p_index) || '; ';
792       FND_LOG.string(p_log_level, l_module_name, l_log_string);
793 
794       l_log_string := ' gIHLanguageTbl['||p_index||']: ' ||
795         ICX_CAT_UTIL_PVT.getTableElement(gIHLanguageTbl, p_index) || '; ';
796       FND_LOG.string(p_log_level, l_module_name, l_log_string);
797 
798       l_log_string := ' gIHSourceTypeTbl['||p_index||']: ' ||
799         ICX_CAT_UTIL_PVT.getTableElement(gIHSourceTypeTbl, p_index) || '; ';
800       FND_LOG.string(p_log_level, l_module_name, l_log_string);
801 
802       l_log_string := ' gIHItemTypeTbl['||p_index||']: ' ||
803         ICX_CAT_UTIL_PVT.getTableElement(gIHItemTypeTbl, p_index) || '; ';
804       FND_LOG.string(p_log_level, l_module_name, l_log_string);
805 
806       l_log_string := ' gIHPurchasingOrgIdTbl['||p_index||']: ' ||
807         ICX_CAT_UTIL_PVT.getTableElement(gIHPurchasingOrgIdTbl, p_index) || '; ';
808       FND_LOG.string(p_log_level, l_module_name, l_log_string);
809 
810       l_log_string := ' gIHOwningOrgIdTbl['||p_index||']: ' ||
811         ICX_CAT_UTIL_PVT.getTableElement(gIHOwningOrgIdTbl, p_index) || '; ';
812       FND_LOG.string(p_log_level, l_module_name, l_log_string);
813 
814       l_log_string := ' gIHIpCategoryIdTbl['||p_index||']: ' ||
815         ICX_CAT_UTIL_PVT.getTableElement(gIHIpCategoryIdTbl, p_index) || '; ';
816       FND_LOG.string(p_log_level, l_module_name, l_log_string);
817 
818       l_log_string := ' gIHIpCategoryNameTbl['||p_index||']: ' ||
819         ICX_CAT_UTIL_PVT.getTableElement(gIHIpCategoryNameTbl, p_index) || '; ';
820       FND_LOG.string(p_log_level, l_module_name, l_log_string);
821 
822       l_log_string := ' gIHPoCategoryIdTbl['||p_index||']: ' ||
823         ICX_CAT_UTIL_PVT.getTableElement(gIHPoCategoryIdTbl, p_index) || '; ';
824       FND_LOG.string(p_log_level, l_module_name, l_log_string);
825 
826       l_log_string := ' gIHSupplierIdTbl['||p_index||']: ' ||
827         ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierIdTbl, p_index) || '; ';
828       FND_LOG.string(p_log_level, l_module_name, l_log_string);
829 
830       l_log_string := ' gIHSupplierPartNumTbl['||p_index||']: ' ||
831         ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierPartNumTbl, p_index) || '; ';
832       FND_LOG.string(p_log_level, l_module_name, l_log_string);
833 
834       l_log_string := ' gIHSupplierPartAuxidTbl['||p_index||']: ' ||
835         ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierPartAuxidTbl, p_index) || '; ';
836       FND_LOG.string(p_log_level, l_module_name, l_log_string);
837 
838       l_log_string := ' gIHSupplierSiteIdTbl['||p_index||']: ' ||
839         ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierSiteIdTbl, p_index) || '; ';
840       FND_LOG.string(p_log_level, l_module_name, l_log_string);
841 
842       l_log_string := ' gIHReqTemplatePoLineIdTbl['||p_index||']: ' ||
843         ICX_CAT_UTIL_PVT.getTableElement(gIHReqTemplatePoLineIdTbl, p_index) || '; ';
844       FND_LOG.string(p_log_level, l_module_name, l_log_string);
845 
846       l_log_string := ' gIHItemRevisionTbl['||p_index||']: ' ||
847         ICX_CAT_UTIL_PVT.getTableElement(gIHItemRevisionTbl, p_index) || '; ';
848       FND_LOG.string(p_log_level, l_module_name, l_log_string);
849 
850       l_log_string := ' gIHPoHeaderIdTbl['||p_index||']: ' ||
851         ICX_CAT_UTIL_PVT.getTableElement(gIHPoHeaderIdTbl, p_index) || '; ';
852       FND_LOG.string(p_log_level, l_module_name, l_log_string);
853 
854       l_log_string := ' gIHDocumentNumberTbl['||p_index||']: ' ||
855         ICX_CAT_UTIL_PVT.getTableElement(gIHDocumentNumberTbl, p_index) || '; ';
856       FND_LOG.string(p_log_level, l_module_name, l_log_string);
857 
858       l_log_string := ' gIHLineNumTbl['||p_index||']: ' ||
859         ICX_CAT_UTIL_PVT.getTableElement(gIHLineNumTbl, p_index) || '; ';
860       FND_LOG.string(p_log_level, l_module_name, l_log_string);
861 
862       l_log_string := ' gIHAllowPriceOverrideFlagTbl['||p_index||']: ' ||
863         ICX_CAT_UTIL_PVT.getTableElement(gIHAllowPriceOverrideFlagTbl, p_index) || '; ';
864       FND_LOG.string(p_log_level, l_module_name, l_log_string);
865 
866       l_log_string := ' gIHNotToExceedPriceTbl['||p_index||']: ' ||
867         ICX_CAT_UTIL_PVT.getTableElement(gIHNotToExceedPriceTbl, p_index) || '; ';
868       FND_LOG.string(p_log_level, l_module_name, l_log_string);
869 
870       l_log_string := ' gIHLineTypeIdTbl['||p_index||']: ' ||
871         ICX_CAT_UTIL_PVT.getTableElement(gIHLineTypeIdTbl, p_index) || '; ';
872       FND_LOG.string(p_log_level, l_module_name, l_log_string);
873 
874       l_log_string := ' gIHUnitMeasLookupCodeTbl['||p_index||']: ' ||
875         ICX_CAT_UTIL_PVT.getTableElement(gIHUnitMeasLookupCodeTbl, p_index) || '; ';
876       FND_LOG.string(p_log_level, l_module_name, l_log_string);
877 
878       l_log_string := ' gIHSuggestedQuantityTbl['||p_index||']: ' ||
879         ICX_CAT_UTIL_PVT.getTableElement(gIHSuggestedQuantityTbl, p_index) || '; ';
880       FND_LOG.string(p_log_level, l_module_name, l_log_string);
881 
882       l_log_string := ' gIHUnitPriceTbl['||p_index||']: ' ||
883         ICX_CAT_UTIL_PVT.getTableElement(gIHUnitPriceTbl, p_index) || '; ';
884       FND_LOG.string(p_log_level, l_module_name, l_log_string);
885 
886       l_log_string := ' gIHAmountTbl['||p_index||']: ' ||
887         ICX_CAT_UTIL_PVT.getTableElement(gIHAmountTbl, p_index) || '; ';
888       FND_LOG.string(p_log_level, l_module_name, l_log_string);
889 
890       l_log_string := ' gIHCurrencyCodeTbl['||p_index||']: ' ||
891         ICX_CAT_UTIL_PVT.getTableElement(gIHCurrencyCodeTbl, p_index) || '; ';
892       FND_LOG.string(p_log_level, l_module_name, l_log_string);
893 
894       l_log_string := ' gIHRateTypeTbl['||p_index||']: ' ||
895         ICX_CAT_UTIL_PVT.getTableElement(gIHRateTypeTbl, p_index) || '; ';
896       FND_LOG.string(p_log_level, l_module_name, l_log_string);
897 
898       l_log_string := ' gIHRateDateTbl['||p_index||']: ' ||
899         ICX_CAT_UTIL_PVT.getTableElement(gIHRateDateTbl, p_index) || '; ';
900       FND_LOG.string(p_log_level, l_module_name, l_log_string);
901 
902       l_log_string := ' gIHRateTbl['||p_index||']: ' ||
903         ICX_CAT_UTIL_PVT.getTableElement(gIHRateTbl, p_index) || '; ';
904       FND_LOG.string(p_log_level, l_module_name, l_log_string);
905 
906       l_log_string := ' gIHBuyerIdTbl['||p_index||']: ' ||
907         ICX_CAT_UTIL_PVT.getTableElement(gIHBuyerIdTbl, p_index) || '; ';
908       FND_LOG.string(p_log_level, l_module_name, l_log_string);
909 
910       l_log_string := ' gIHSupplierContactIdTbl['||p_index||']: ' ||
911         ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierContactIdTbl, p_index) || '; ';
912       FND_LOG.string(p_log_level, l_module_name, l_log_string);
913 
914       l_log_string := ' gIHRfqRequiredFlagTbl['||p_index||']: ' ||
915         ICX_CAT_UTIL_PVT.getTableElement(gIHRfqRequiredFlagTbl, p_index) || '; ';
916       FND_LOG.string(p_log_level, l_module_name, l_log_string);
917 
918       l_log_string := ' gIHNegotiatedByPreparerFlagTbl['||p_index||']: ' ||
919         ICX_CAT_UTIL_PVT.getTableElement(gIHNegotiatedByPreparerFlagTbl, p_index) || '; ';
920       FND_LOG.string(p_log_level, l_module_name, l_log_string);
921 
922       l_log_string := ' gIHDescriptionTbl['||p_index||']: ' ||
923         ICX_CAT_UTIL_PVT.getTableElement(gIHDescriptionTbl, p_index) || '; ';
924       FND_LOG.string(p_log_level, l_module_name, l_log_string);
925 
926       l_log_string := ' gIHOrderTypeLookupCodeTbl['||p_index||']: ' ||
927         ICX_CAT_UTIL_PVT.getTableElement(gIHOrderTypeLookupCodeTbl, p_index) || '; ';
928       FND_LOG.string(p_log_level, l_module_name, l_log_string);
929 
930       l_log_string := ' gIHSupplierTbl['||p_index||']: ' ||
931         ICX_CAT_UTIL_PVT.getTableElement(gIHSupplierTbl, p_index) || '; ';
932       FND_LOG.string(p_log_level, l_module_name, l_log_string);
933 
934       l_log_string := ' gIHGlobalAgreementFlagTbl['||p_index||']: ' ||
935         ICX_CAT_UTIL_PVT.getTableElement(gIHGlobalAgreementFlagTbl, p_index) || '; ';
936       FND_LOG.string(p_log_level, l_module_name, l_log_string);
937 
938       l_log_string := ' gIHMergedSourceTypeTbl['||p_index||']: ' ||
939         ICX_CAT_UTIL_PVT.getTableElement(gIHMergedSourceTypeTbl, p_index) || '; ';
940       FND_LOG.string(p_log_level, l_module_name, l_log_string);
941 
942     END IF;
943 
944     l_err_loc := 400;
945 
946     IF (p_action_mode = 'INSERT_CTX_DTLS') THEN
947       l_err_loc := 500;
948       -- INSERT icx_cat_items_ctx_dtl_tlp
949       l_log_string := ' gIDInventoryItemIdTbl['||p_index||']: ' ||
950         ICX_CAT_UTIL_PVT.getTableElement(gIDInventoryItemIdTbl, p_index) || '; ';
951       FND_LOG.string(p_log_level, l_module_name, l_log_string);
952 
953       l_log_string := ' gIDPoLineIdTbl['||p_index||']: ' ||
954         ICX_CAT_UTIL_PVT.getTableElement(gIDPoLineIdTbl, p_index) || '; ';
955       FND_LOG.string(p_log_level, l_module_name, l_log_string);
956 
957       l_log_string := ' gIDReqTemplateNameTbl['||p_index||']: ' ||
958         ICX_CAT_UTIL_PVT.getTableElement(gIDReqTemplateNameTbl, p_index) || '; ';
959       FND_LOG.string(p_log_level, l_module_name, l_log_string);
960 
961       l_log_string := ' gIDReqTemplateLineNumTbl['||p_index||']: ' ||
962         ICX_CAT_UTIL_PVT.getTableElement(gIDReqTemplateLineNumTbl, p_index) || '; ';
963       FND_LOG.string(p_log_level, l_module_name, l_log_string);
964 
965       l_log_string := ' gIDOrgIdTbl['||p_index||']: ' ||
966         ICX_CAT_UTIL_PVT.getTableElement(gIDOrgIdTbl, p_index) || '; ';
967       FND_LOG.string(p_log_level, l_module_name, l_log_string);
968 
969       l_log_string := ' gIDLanguageTbl['||p_index||']: ' ||
970         ICX_CAT_UTIL_PVT.getTableElement(gIDLanguageTbl, p_index) || '; ';
971       FND_LOG.string(p_log_level, l_module_name, l_log_string);
972 
973       l_log_string := ' gIDPurchasingOrgIdTbl['||p_index||']: ' ||
974         ICX_CAT_UTIL_PVT.getTableElement(gIDPurchasingOrgIdTbl, p_index) || '; ';
975       FND_LOG.string(p_log_level, l_module_name, l_log_string);
976 
977       l_log_string := ' gIDOwningOrgIdTbl['||p_index||']: ' ||
978         ICX_CAT_UTIL_PVT.getTableElement(gIDOwningOrgIdTbl, p_index) || '; ';
979       FND_LOG.string(p_log_level, l_module_name, l_log_string);
980 
981     END IF;
982 
983     l_err_loc := 600;
984 
985     IF (p_action_mode = 'UPDATE_CTX_HDRS') THEN
986       l_err_loc := 700;
987       -- UPDATE icx_cat_items_ctx_hdrs_tlp
988       l_log_string := ' gUHInventoryItemIdTbl['||p_index||']: ' ||
989         ICX_CAT_UTIL_PVT.getTableElement(gUHInventoryItemIdTbl, p_index) || '; ';
990       FND_LOG.string(p_log_level, l_module_name, l_log_string);
991 
992       l_log_string := ' gUHPoLineIdTbl['||p_index||']: ' ||
993         ICX_CAT_UTIL_PVT.getTableElement(gUHPoLineIdTbl, p_index) || '; ';
994       FND_LOG.string(p_log_level, l_module_name, l_log_string);
995 
996       l_log_string := ' gUHReqTemplateNameTbl['||p_index||']: ' ||
997         ICX_CAT_UTIL_PVT.getTableElement(gUHReqTemplateNameTbl, p_index) || '; ';
998       FND_LOG.string(p_log_level, l_module_name, l_log_string);
999 
1000       l_log_string := ' gUHReqTemplateLineNumTbl['||p_index||']: ' ||
1001         ICX_CAT_UTIL_PVT.getTableElement(gUHReqTemplateLineNumTbl, p_index) || '; ';
1002       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1003 
1004       l_log_string := ' gUHOrgIdTbl['||p_index||']: ' ||
1005         ICX_CAT_UTIL_PVT.getTableElement(gUHOrgIdTbl, p_index) || '; ';
1006       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1007 
1008       l_log_string := ' gUHLanguageTbl['||p_index||']: ' ||
1009         ICX_CAT_UTIL_PVT.getTableElement(gUHLanguageTbl, p_index) || '; ';
1010       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1011 
1012       l_log_string := ' gUHSourceTypeTbl['||p_index||']: ' ||
1013         ICX_CAT_UTIL_PVT.getTableElement(gUHSourceTypeTbl, p_index) || '; ';
1014       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1015 
1016       l_log_string := ' gUHItemTypeTbl['||p_index||']: ' ||
1017         ICX_CAT_UTIL_PVT.getTableElement(gUHItemTypeTbl, p_index) || '; ';
1018       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1019 
1020       l_log_string := ' gUHPurchasingOrgIdTbl['||p_index||']: ' ||
1021         ICX_CAT_UTIL_PVT.getTableElement(gUHPurchasingOrgIdTbl, p_index) || '; ';
1022       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1023 
1024       l_log_string := ' gUHIpCategoryIdTbl['||p_index||']: ' ||
1025         ICX_CAT_UTIL_PVT.getTableElement(gUHIpCategoryIdTbl, p_index) || '; ';
1026       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1027 
1028       l_log_string := ' gUHIpCategoryNameTbl['||p_index||']: ' ||
1029         ICX_CAT_UTIL_PVT.getTableElement(gUHIpCategoryNameTbl, p_index) || '; ';
1030       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1031 
1032       l_log_string := ' gUHPoCategoryIdTbl['||p_index||']: ' ||
1033         ICX_CAT_UTIL_PVT.getTableElement(gUHPoCategoryIdTbl, p_index) || '; ';
1034       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1035 
1036       l_log_string := ' gUHSupplierIdTbl['||p_index||']: ' ||
1037         ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierIdTbl, p_index) || '; ';
1038       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1039 
1040       l_log_string := ' gUHSupplierPartNumTbl['||p_index||']: ' ||
1041         ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierPartNumTbl, p_index) || '; ';
1042       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1043 
1044       l_log_string := ' gUHSupplierPartAuxidTbl['||p_index||']: ' ||
1045         ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierPartAuxidTbl, p_index) || '; ';
1046       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1047 
1048       l_log_string := ' gUHSupplierSiteIdTbl['||p_index||']: ' ||
1049         ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierSiteIdTbl, p_index) || '; ';
1050       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1051 
1052       l_log_string := ' gUHReqTemplatePoLineIdTbl['||p_index||']: ' ||
1053         ICX_CAT_UTIL_PVT.getTableElement(gUHReqTemplatePoLineIdTbl, p_index) || '; ';
1054       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1055 
1056       l_log_string := ' gUHItemRevisionTbl['||p_index||']: ' ||
1057         ICX_CAT_UTIL_PVT.getTableElement(gUHItemRevisionTbl, p_index) || '; ';
1058       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1059 
1060       l_log_string := ' gUHPoHeaderIdTbl['||p_index||']: ' ||
1061         ICX_CAT_UTIL_PVT.getTableElement(gUHPoHeaderIdTbl, p_index) || '; ';
1062       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1063 
1064       l_log_string := ' gUHDocumentNumberTbl['||p_index||']: ' ||
1065         ICX_CAT_UTIL_PVT.getTableElement(gUHDocumentNumberTbl, p_index) || '; ';
1066       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1067 
1068       l_log_string := ' gUHLineNumTbl['||p_index||']: ' ||
1069         ICX_CAT_UTIL_PVT.getTableElement(gUHLineNumTbl, p_index) || '; ';
1070       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1071 
1072       l_log_string := ' gUHAllowPriceOverrideFlagTbl['||p_index||']: ' ||
1073         ICX_CAT_UTIL_PVT.getTableElement(gUHAllowPriceOverrideFlagTbl, p_index) || '; ';
1074       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1075 
1076       l_log_string := ' gUHNotToExceedPriceTbl['||p_index||']: ' ||
1077         ICX_CAT_UTIL_PVT.getTableElement(gUHNotToExceedPriceTbl, p_index) || '; ';
1078       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1079 
1080       l_log_string := ' gUHLineTypeIdTbl['||p_index||']: ' ||
1081         ICX_CAT_UTIL_PVT.getTableElement(gUHLineTypeIdTbl, p_index) || '; ';
1082       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1083 
1084       l_log_string := ' gUHUnitMeasLookupCodeTbl['||p_index||']: ' ||
1085         ICX_CAT_UTIL_PVT.getTableElement(gUHUnitMeasLookupCodeTbl, p_index) || '; ';
1086       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1087 
1088       l_log_string := ' gUHSuggestedQuantityTbl['||p_index||']: ' ||
1089         ICX_CAT_UTIL_PVT.getTableElement(gUHSuggestedQuantityTbl, p_index) || '; ';
1090       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1091 
1092       l_log_string := ' gUHUnitPriceTbl['||p_index||']: ' ||
1093         ICX_CAT_UTIL_PVT.getTableElement(gUHUnitPriceTbl, p_index) || '; ';
1094       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1095 
1096       l_log_string := ' gUHAmountTbl['||p_index||']: ' ||
1097         ICX_CAT_UTIL_PVT.getTableElement(gUHAmountTbl, p_index) || '; ';
1098       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1099 
1100       l_log_string := ' gUHCurrencyCodeTbl['||p_index||']: ' ||
1101         ICX_CAT_UTIL_PVT.getTableElement(gUHCurrencyCodeTbl, p_index) || '; ';
1102       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1103 
1104       l_log_string := ' gUHRateTypeTbl['||p_index||']: ' ||
1105         ICX_CAT_UTIL_PVT.getTableElement(gUHRateTypeTbl, p_index) || '; ';
1106       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1107 
1108       l_log_string := ' gUHRateDateTbl['||p_index||']: ' ||
1109         ICX_CAT_UTIL_PVT.getTableElement(gUHRateDateTbl, p_index) || '; ';
1110       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1111 
1112       l_log_string := ' gUHRateTbl['||p_index||']: ' ||
1113         ICX_CAT_UTIL_PVT.getTableElement(gUHRateTbl, p_index) || '; ';
1114       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1115 
1116       l_log_string := ' gUHBuyerIdTbl['||p_index||']: ' ||
1117         ICX_CAT_UTIL_PVT.getTableElement(gUHBuyerIdTbl, p_index) || '; ';
1118       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1119 
1120       l_log_string := ' gUHSupplierContactIdTbl['||p_index||']: ' ||
1121         ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierContactIdTbl, p_index) || '; ';
1122       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1123 
1124       l_log_string := ' gUHRfqRequiredFlagTbl['||p_index||']: ' ||
1125         ICX_CAT_UTIL_PVT.getTableElement(gUHRfqRequiredFlagTbl, p_index) || '; ';
1126       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1127 
1128       l_log_string := ' gUHNegotiatedByPreparerFlagTbl['||p_index||']: ' ||
1129         ICX_CAT_UTIL_PVT.getTableElement(gUHNegotiatedByPreparerFlagTbl, p_index) || '; ';
1130       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1131 
1132       l_log_string := ' gUHDescriptionTbl['||p_index||']: ' ||
1133         ICX_CAT_UTIL_PVT.getTableElement(gUHDescriptionTbl, p_index) || '; ';
1134       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1135 
1136       l_log_string := ' gUHOrderTypeLookupCodeTbl['||p_index||']: ' ||
1137         ICX_CAT_UTIL_PVT.getTableElement(gUHOrderTypeLookupCodeTbl, p_index) || '; ';
1138       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1139 
1140       l_log_string := ' gUHSupplierTbl['||p_index||']: ' ||
1141         ICX_CAT_UTIL_PVT.getTableElement(gUHSupplierTbl, p_index) || '; ';
1142       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1143 
1144       l_log_string := ' gUHGlobalAgreementFlagTbl['||p_index||']: ' ||
1145         ICX_CAT_UTIL_PVT.getTableElement(gUHGlobalAgreementFlagTbl, p_index) || '; ';
1146       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1147 
1148       l_log_string := ' gUHMergedSourceTypeTbl['||p_index||']: ' ||
1149         ICX_CAT_UTIL_PVT.getTableElement(gUHMergedSourceTypeTbl, p_index) || '; ';
1150       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1151 
1152     END IF;
1153 
1154     l_err_loc := 800;
1155 
1156     IF (p_action_mode = 'DELETE_CTX_HDRS') THEN
1157       l_err_loc := 900;
1158       -- DELETE icx_cat_items_ctx_hdrs_tlp
1159       l_log_string := ' gDHInventoryItemIdTbl['||p_index||']: ' ||
1160         ICX_CAT_UTIL_PVT.getTableElement(gDHInventoryItemIdTbl, p_index) || '; ';
1161       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1162 
1163       l_log_string := ' gDHPoLineIdTbl['||p_index||']: ' ||
1164         ICX_CAT_UTIL_PVT.getTableElement(gDHPoLineIdTbl, p_index) || '; ';
1165       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1166 
1167       l_log_string := ' gDHReqTemplateNameTbl['||p_index||']: ' ||
1168         ICX_CAT_UTIL_PVT.getTableElement(gDHReqTemplateNameTbl, p_index) || '; ';
1169       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1170 
1171       l_log_string := ' gDHReqTemplateLineNumTbl['||p_index||']: ' ||
1172         ICX_CAT_UTIL_PVT.getTableElement(gDHReqTemplateLineNumTbl, p_index) || '; ';
1173       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1174 
1175       l_log_string := ' gDHOrgIdTbl['||p_index||']: ' ||
1176         ICX_CAT_UTIL_PVT.getTableElement(gDHOrgIdTbl, p_index) || '; ';
1177       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1178 
1179       l_log_string := ' gDHLanguageTbl['||p_index||']: ' ||
1180         ICX_CAT_UTIL_PVT.getTableElement(gDHLanguageTbl, p_index) || '; ';
1181       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1182 
1183     END IF;
1184 
1185     l_err_loc := 1000;
1186 
1187     IF (p_action_mode = 'DELETE_CTX_DTLS') THEN
1188       l_err_loc := 1100;
1189       -- DELETE icx_cat_items_ctx_dtl_tlp
1190       l_log_string := ' gDDInventoryItemIdTbl['||p_index||']: ' ||
1191         ICX_CAT_UTIL_PVT.getTableElement(gDDInventoryItemIdTbl, p_index) || '; ';
1192       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1193 
1194       l_log_string := ' gDDPoLineIdTbl['||p_index||']: ' ||
1195         ICX_CAT_UTIL_PVT.getTableElement(gDDPoLineIdTbl, p_index) || '; ';
1196       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1197 
1198       l_log_string := ' gDDReqTemplateNameTbl['||p_index||']: ' ||
1199         ICX_CAT_UTIL_PVT.getTableElement(gDDReqTemplateNameTbl, p_index) || '; ';
1200       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1201 
1202       l_log_string := ' gDDReqTemplateLineNumTbl['||p_index||']: ' ||
1203         ICX_CAT_UTIL_PVT.getTableElement(gDDReqTemplateLineNumTbl, p_index) || '; ';
1204       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1205 
1206       l_log_string := ' gDDOrgIdTbl['||p_index||']: ' ||
1207         ICX_CAT_UTIL_PVT.getTableElement(gDDOrgIdTbl, p_index) || '; ';
1208       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1209 
1210       l_log_string := ' gDDLanguageTbl['||p_index||']: ' ||
1211         ICX_CAT_UTIL_PVT.getTableElement(gDDLanguageTbl, p_index) || '; ';
1212       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1213 
1214     END IF;
1215 
1216     l_err_loc := 1200;
1217 
1218     IF (p_action_mode = 'DELETE_MANDATORY_ROW_CTX_DTLS') THEN
1219       l_err_loc := 1300;
1220       -- DELETE rows with sequence = 1 in icx_cat_items_ctx_dtl_tlp
1221       l_log_string := ' gDMDInventoryItemIdTbl['||p_index||']: ' ||
1222         ICX_CAT_UTIL_PVT.getTableElement(gDMDInventoryItemIdTbl, p_index) || '; ';
1223       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1224 
1225       l_log_string := ' gDMDPoLineIdTbl['||p_index||']: ' ||
1226         ICX_CAT_UTIL_PVT.getTableElement(gDMDPoLineIdTbl, p_index) || '; ';
1227       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1228 
1229       l_log_string := ' gDMDReqTemplateNameTbl['||p_index||']: ' ||
1230         ICX_CAT_UTIL_PVT.getTableElement(gDMDReqTemplateNameTbl, p_index) || '; ';
1231       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1232 
1233       l_log_string := ' gDMDReqTemplateLineNumTbl['||p_index||']: ' ||
1234         ICX_CAT_UTIL_PVT.getTableElement(gDMDReqTemplateLineNumTbl, p_index) || '; ';
1235       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1236 
1237       l_log_string := ' gDMDOrgIdTbl['||p_index||']: ' ||
1238         ICX_CAT_UTIL_PVT.getTableElement(gDMDOrgIdTbl, p_index) || '; ';
1239       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1240 
1241       l_log_string := ' gDMDLanguageTbl['||p_index||']: ' ||
1242         ICX_CAT_UTIL_PVT.getTableElement(gDMDLanguageTbl, p_index) || '; ';
1243       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1244 
1245     END IF;
1246 
1247     l_err_loc := 1400;
1248 
1249     IF (p_action_mode = 'DELETE_SUPPLIER_ROW_CTX_DTLS') THEN
1250       l_err_loc := 1500;
1251       -- DELETE rows with sequence = 2 in icx_cat_items_ctx_dtl_tlp
1252       l_log_string := ' gDSDInventoryItemIdTbl['||p_index||']: ' ||
1253         ICX_CAT_UTIL_PVT.getTableElement(gDSDInventoryItemIdTbl, p_index) || '; ';
1254       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1255 
1256       l_log_string := ' gDSDPoLineIdTbl['||p_index||']: ' ||
1257         ICX_CAT_UTIL_PVT.getTableElement(gDSDPoLineIdTbl, p_index) || '; ';
1258       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1259 
1260       l_log_string := ' gDSDReqTemplateNameTbl['||p_index||']: ' ||
1261         ICX_CAT_UTIL_PVT.getTableElement(gDSDReqTemplateNameTbl, p_index) || '; ';
1262       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1263 
1264       l_log_string := ' gDSDReqTemplateLineNumTbl['||p_index||']: ' ||
1265         ICX_CAT_UTIL_PVT.getTableElement(gDSDReqTemplateLineNumTbl, p_index) || '; ';
1266       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1267 
1268       l_log_string := ' gDSDOrgIdTbl['||p_index||']: ' ||
1269         ICX_CAT_UTIL_PVT.getTableElement(gDSDOrgIdTbl, p_index) || '; ';
1270       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1271 
1272       l_log_string := ' gDSDLanguageTbl['||p_index||']: ' ||
1273         ICX_CAT_UTIL_PVT.getTableElement(gDSDLanguageTbl, p_index) || '; ';
1274       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1275 
1276     END IF;
1277 
1278     l_err_loc := 1600;
1279 
1280     IF (p_action_mode = 'DELETE_ITEMREV_ROW_CTX_DTLS') THEN
1281       l_err_loc := 1700;
1282       -- DELETE rows with sequence = 5 in icx_cat_items_ctx_dtl_tlp
1283       l_log_string := ' gDIRDInventoryItemIdTbl['||p_index||']: ' ||
1284         ICX_CAT_UTIL_PVT.getTableElement(gDIRDInventoryItemIdTbl, p_index) || '; ';
1285       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1286 
1287       l_log_string := ' gDIRDPoLineIdTbl['||p_index||']: ' ||
1288         ICX_CAT_UTIL_PVT.getTableElement(gDIRDPoLineIdTbl, p_index) || '; ';
1289       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1290 
1291       l_log_string := ' gDIRDReqTemplateNameTbl['||p_index||']: ' ||
1292         ICX_CAT_UTIL_PVT.getTableElement(gDIRDReqTemplateNameTbl, p_index) || '; ';
1293       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1294 
1295       l_log_string := ' gDIRDReqTemplateLineNumTbl['||p_index||']: ' ||
1296         ICX_CAT_UTIL_PVT.getTableElement(gDIRDReqTemplateLineNumTbl, p_index) || '; ';
1297       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1298 
1299       l_log_string := ' gDIRDOrgIdTbl['||p_index||']: ' ||
1300         ICX_CAT_UTIL_PVT.getTableElement(gDIRDOrgIdTbl, p_index) || '; ';
1301       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1302 
1303       l_log_string := ' gDIRDLanguageTbl['||p_index||']: ' ||
1304         ICX_CAT_UTIL_PVT.getTableElement(gDIRDLanguageTbl, p_index) || '; ';
1305       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1306 
1307     END IF;
1308 
1309     l_err_loc := 1800;
1310 
1311     IF (p_action_mode = 'DELETE_SHOPCATG_ROW_CTX_DTLS') THEN
1312       l_err_loc := 1900;
1313       -- DELETE rows with sequence = 6 in icx_cat_items_ctx_dtl_tlp
1314       l_log_string := ' gDSCDInventoryItemIdTbl['||p_index||']: ' ||
1315         ICX_CAT_UTIL_PVT.getTableElement(gDSCDInventoryItemIdTbl, p_index) || '; ';
1316       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1317 
1318       l_log_string := ' gDSCDPoLineIdTbl['||p_index||']: ' ||
1319         ICX_CAT_UTIL_PVT.getTableElement(gDSCDPoLineIdTbl, p_index) || '; ';
1320       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1321 
1322       l_log_string := ' gDSCDReqTemplateNameTbl['||p_index||']: ' ||
1323         ICX_CAT_UTIL_PVT.getTableElement(gDSCDReqTemplateNameTbl, p_index) || '; ';
1324       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1325 
1326       l_log_string := ' gDSCDReqTemplateLineNumTbl['||p_index||']: ' ||
1327         ICX_CAT_UTIL_PVT.getTableElement(gDSCDReqTemplateLineNumTbl, p_index) || '; ';
1328       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1329 
1330       l_log_string := ' gDSCDOrgIdTbl['||p_index||']: ' ||
1331         ICX_CAT_UTIL_PVT.getTableElement(gDSCDOrgIdTbl, p_index) || '; ';
1332       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1333 
1334       l_log_string := ' gDSCDLanguageTbl['||p_index||']: ' ||
1335         ICX_CAT_UTIL_PVT.getTableElement(gDSCDLanguageTbl, p_index) || '; ';
1336       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1337 
1338     END IF;
1339 
1340     l_err_loc := 2000;
1341 
1342     IF (p_action_mode = 'DELETE_PURCHORG_ROW_CTX_DTLS') THEN
1343       l_err_loc := 2100;
1344       -- DELETE rows with sequence =15001 in icx_cat_items_ctx_dtl_tlp
1345       l_log_string := ' gDPODInventoryItemIdTbl['||p_index||']: ' ||
1346         ICX_CAT_UTIL_PVT.getTableElement(gDPODInventoryItemIdTbl, p_index) || '; ';
1347       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1348 
1349       l_log_string := ' gDPODPoLineIdTbl['||p_index||']: ' ||
1350         ICX_CAT_UTIL_PVT.getTableElement(gDPODPoLineIdTbl, p_index) || '; ';
1351       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1352 
1353       l_log_string := ' gDPODReqTemplateNameTbl['||p_index||']: ' ||
1354         ICX_CAT_UTIL_PVT.getTableElement(gDPODReqTemplateNameTbl, p_index) || '; ';
1355       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1356 
1357       l_log_string := ' gDPODReqTemplateLineNumTbl['||p_index||']: ' ||
1358         ICX_CAT_UTIL_PVT.getTableElement(gDPODReqTemplateLineNumTbl, p_index) || '; ';
1359       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1360 
1361       l_log_string := ' gDPODOrgIdTbl['||p_index||']: ' ||
1362         ICX_CAT_UTIL_PVT.getTableElement(gDPODOrgIdTbl, p_index) || '; ';
1363       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1364 
1365       l_log_string := ' gDPODPurchasingOrgIdTbl['||p_index||']: ' ||
1366         ICX_CAT_UTIL_PVT.getTableElement(gDPODPurchasingOrgIdTbl, p_index) || '; ';
1367       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1368 
1369       l_log_string := ' gDPODLanguageTbl['||p_index||']: ' ||
1370         ICX_CAT_UTIL_PVT.getTableElement(gDPODLanguageTbl, p_index) || '; ';
1371       FND_LOG.string(p_log_level, l_module_name, l_log_string);
1372 
1373     END IF;
1374   END IF;
1375 
1376   l_err_loc := 2200;
1377 END logPLSQLTableRow;
1378 
1379 PROCEDURE deleteItemCtxHdrsTLP
1380 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1381 )
1382 IS
1383   l_api_name    CONSTANT VARCHAR2(30)   := 'deleteItemCtxHdrsTLP';
1384   l_err_loc     PLS_INTEGER;
1385   l_index       PLS_INTEGER;
1386 BEGIN
1387   l_err_loc := 100;
1388   gTotalRowCount := gTotalRowCount + 1;
1389   l_index := gDHInventoryItemIdTbl.COUNT + 1;
1390 
1391   l_err_loc := 200;
1392   gDHInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.ctx_inventory_item_id;
1393   gDHPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1394   gDHReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1395   gDHReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1396   gDHOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1397   gDHLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1398 
1399   l_err_loc := 300;
1400 EXCEPTION
1401   WHEN OTHERS THEN
1402     ICX_CAT_UTIL_PVT.logUnexpectedException(
1403       G_PKG_NAME, l_api_name,
1404       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1405     RAISE;
1406 END deleteItemCtxHdrsTLP;
1407 
1408 PROCEDURE deleteItemCtxDtlsTLP
1409 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1410 )
1411 IS
1412   l_api_name    CONSTANT VARCHAR2(30)   := 'deleteItemCtxDtlsTLP';
1413   l_err_loc     PLS_INTEGER;
1414   l_index       PLS_INTEGER;
1415 BEGIN
1416   l_err_loc := 100;
1417   gTotalRowCount := gTotalRowCount + 1;
1418   l_index := gDDInventoryItemIdTbl.COUNT + 1;
1419 
1420   l_err_loc := 200;
1421   gDDInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.ctx_inventory_item_id;
1422   gDDPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1423   gDDReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1424   gDDReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1425   gDDOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1426   gDDLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1427 
1428   l_err_loc := 300;
1429 EXCEPTION
1430   WHEN OTHERS THEN
1431     ICX_CAT_UTIL_PVT.logUnexpectedException(
1432       G_PKG_NAME, l_api_name,
1433       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1434     RAISE;
1435 END deleteItemCtxDtlsTLP;
1436 
1437 -- Re-populate the row with sequence = 1 i.e. Mandatory row in icx_cat_items_ctx_dtls_tlp
1438 -- This row contains concatenated string of language, source_type, supid, ipcatid, pocatid and supsiteid
1439 PROCEDURE delMandatoryRowFromCtxDtlsTLP
1440 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1441 )
1442 IS
1443   l_api_name    CONSTANT VARCHAR2(30)   := 'delMandatoryRowFromCtxDtlsTLP';
1444   l_err_loc     PLS_INTEGER;
1445   l_index       PLS_INTEGER;
1446 BEGIN
1447   l_err_loc := 100;
1448   gTotalRowCount := gTotalRowCount + 1;
1449   l_index := gDMDInventoryItemIdTbl.COUNT + 1;
1450 
1451   l_err_loc := 200;
1452   gDMDInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1453   gDMDPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1454   gDMDReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1455   gDMDReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1456   gDMDOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1457   gDMDOwningOrgIdTbl(l_index) := p_current_ctx_item_rec.owning_org_id;
1458   gDMDLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1459 
1460   l_err_loc := 300;
1461 EXCEPTION
1462   WHEN OTHERS THEN
1463     ICX_CAT_UTIL_PVT.logUnexpectedException(
1464       G_PKG_NAME, l_api_name,
1465       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1466     RAISE;
1467 END delMandatoryRowFromCtxDtlsTLP;
1468 
1469 -- Re-populate the row with sequence = 2 i.e. Supplier row in icx_cat_items_ctx_dtls_tlp
1470 PROCEDURE delSupplierRowFromCtxDtlsTLP
1471 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1472 )
1473 IS
1474   l_api_name    CONSTANT VARCHAR2(30)   := 'delSupplierRowFromCtxDtlsTLP';
1475   l_err_loc     PLS_INTEGER;
1476   l_index       PLS_INTEGER;
1477 BEGIN
1478   l_err_loc := 100;
1479   gTotalRowCount := gTotalRowCount + 1;
1480   l_index := gDSDInventoryItemIdTbl.COUNT + 1;
1481 
1482   l_err_loc := 200;
1483   gDSDInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1484   gDSDPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1485   gDSDReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1486   gDSDReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1487   gDSDOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1488   gDSDOwningOrgIdTbl(l_index) := p_current_ctx_item_rec.owning_org_id;
1489   gDSDLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1490 
1491   l_err_loc := 300;
1492 EXCEPTION
1493   WHEN OTHERS THEN
1494     ICX_CAT_UTIL_PVT.logUnexpectedException(
1495       G_PKG_NAME, l_api_name,
1496       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1497     RAISE;
1498 END delSupplierRowFromCtxDtlsTLP;
1499 
1500 -- Re-populate the row with sequence = 5 i.e. Item Revision row in icx_cat_items_ctx_dtls_tlp
1501 PROCEDURE delItemRevRowFromCtxDtlsTLP
1502 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1503 )
1504 IS
1505   l_api_name    CONSTANT VARCHAR2(30)   := 'delItemRevRowFromCtxDtlsTLP';
1506   l_err_loc     PLS_INTEGER;
1507   l_index       PLS_INTEGER;
1508 BEGIN
1509   l_err_loc := 100;
1510   gTotalRowCount := gTotalRowCount + 1;
1511   l_index := gDIRDInventoryItemIdTbl.COUNT + 1;
1512 
1513   l_err_loc := 200;
1514   gDIRDInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1515   gDIRDPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1516   gDIRDReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1517   gDIRDReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1518   gDIRDOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1519   gDIRDOwningOrgIdTbl(l_index) := p_current_ctx_item_rec.owning_org_id;
1520   gDIRDLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1521 
1522   l_err_loc := 300;
1523 EXCEPTION
1524   WHEN OTHERS THEN
1525     ICX_CAT_UTIL_PVT.logUnexpectedException(
1526       G_PKG_NAME, l_api_name,
1527       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1528     RAISE;
1529 END delItemRevRowFromCtxDtlsTLP;
1530 
1531 -- Re-populate the row with sequence = 6 i.e. shopping_category row in icx_cat_items_ctx_dtls_tlp
1532 PROCEDURE delShopCatgRowFromCtxDtlsTLP
1533 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1534 )
1535 IS
1536   l_api_name    CONSTANT VARCHAR2(30)   := 'delShopCatgRowFromCtxDtlsTLP';
1537   l_err_loc     PLS_INTEGER;
1538   l_index       PLS_INTEGER;
1539 BEGIN
1540   l_err_loc := 100;
1541   gTotalRowCount := gTotalRowCount + 1;
1542   l_index := gDSCDInventoryItemIdTbl.COUNT + 1;
1543 
1544   l_err_loc := 200;
1545   gDSCDInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1546   gDSCDPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1547   gDSCDReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1548   gDSCDReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1549   gDSCDOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1550   gDSCDOwningOrgIdTbl(l_index) := p_current_ctx_item_rec.owning_org_id;
1551   gDSCDLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1552 
1553   l_err_loc := 300;
1554 EXCEPTION
1555   WHEN OTHERS THEN
1556     ICX_CAT_UTIL_PVT.logUnexpectedException(
1557       G_PKG_NAME, l_api_name,
1558       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1559     RAISE;
1560 END delShopCatgRowFromCtxDtlsTLP;
1561 
1562 -- Re-populate the row with sequence = 15001 i.e. purchorgid in icx_cat_items_ctx_dtls_tlp
1563 PROCEDURE delPurchOrgRowFromCtxDtlsTLP
1564 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1565 )
1566 IS
1567   l_api_name    CONSTANT VARCHAR2(30)   := 'delPurchOrgRowFromCtxDtlsTLP';
1568   l_err_loc     PLS_INTEGER;
1569   l_index       PLS_INTEGER;
1570 BEGIN
1571   l_err_loc := 100;
1572   gTotalRowCount := gTotalRowCount + 1;
1573   l_index := gDPODInventoryItemIdTbl.COUNT + 1;
1574 
1575   l_err_loc := 200;
1576   gDPODInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1577   gDPODPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1578   gDPODReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1579   gDPODReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1580   gDPODOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1581   gDPODOwningOrgIdTbl(l_index) := p_current_ctx_item_rec.owning_org_id;
1582   gDPODLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1583   gDPODPurchasingOrgIdTbl(l_index) := p_current_ctx_item_rec.purchasing_org_id;
1584 
1585   l_err_loc := 300;
1586 EXCEPTION
1587   WHEN OTHERS THEN
1588     ICX_CAT_UTIL_PVT.logUnexpectedException(
1589       G_PKG_NAME, l_api_name,
1590       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1591     RAISE;
1592 END delPurchOrgRowFromCtxDtlsTLP;
1593 
1594 PROCEDURE delBaseLocalAttrItemCtxDtlsTLP
1595 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1596 )
1597 IS
1598   l_api_name    CONSTANT VARCHAR2(30)   := 'delBaseLocalAttrItemCtxDtlsTLP';
1599   l_err_loc     PLS_INTEGER;
1600   l_index       PLS_INTEGER;
1601 BEGIN
1602   l_err_loc := 100;
1603   gTotalRowCount := gTotalRowCount + 1;
1604   l_index := gDBLDInventoryItemIdTbl.COUNT + 1;
1605 
1606   l_err_loc := 200;
1607   gDBLDInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1608   gDBLDPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1609   gDBLDReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1610   gDBLDReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1611   gDBLDOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1612   gDBLDOwningOrgIdTbl(l_index) := p_current_ctx_item_rec.owning_org_id;
1613   gDBLDLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1614 
1615   l_err_loc := 300;
1616 EXCEPTION
1617   WHEN OTHERS THEN
1618     ICX_CAT_UTIL_PVT.logUnexpectedException(
1619       G_PKG_NAME, l_api_name,
1620       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1621     RAISE;
1622 END delBaseLocalAttrItemCtxDtlsTLP;
1623 
1624 PROCEDURE insertItemCtxHdrsTLP
1625 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1626 )
1627 IS
1628   l_api_name    CONSTANT VARCHAR2(30)   := 'insertItemCtxHdrsTLP';
1629   l_err_loc     PLS_INTEGER;
1630   l_index       PLS_INTEGER;
1631 BEGIN
1632   l_err_loc := 100;
1633   gTotalRowCount := gTotalRowCount + 1;
1634   l_index := gIHInventoryItemIdTbl.COUNT + 1;
1635 
1636   l_err_loc := 200;
1637   gIHInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1638   gIHPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1639   gIHReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1640   gIHReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1641   gIHOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1642   gIHLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1643   gIHSourceTypeTbl(l_index) := p_current_ctx_item_rec.source_type;
1644   gIHItemTypeTbl(l_index) := p_current_ctx_item_rec.item_type;
1645   gIHPurchasingOrgIdTbl(l_index) := p_current_ctx_item_rec.purchasing_org_id;
1646   gIHOwningOrgIdTbl(l_index) := p_current_ctx_item_rec.owning_org_id;
1647   gIHIpCategoryIdTbl(l_index) := p_current_ctx_item_rec.ip_category_id;
1648   gIHIpCategoryNameTbl(l_index) := p_current_ctx_item_rec.ip_category_name;
1649   gIHPoCategoryIdTbl(l_index) := p_current_ctx_item_rec.po_category_id;
1650   gIHSupplierIdTbl(l_index) := p_current_ctx_item_rec.supplier_id;
1651   gIHSupplierPartNumTbl(l_index) := p_current_ctx_item_rec.supplier_part_num;
1652   gIHSupplierPartAuxidTbl(l_index) := p_current_ctx_item_rec.supplier_part_auxid;
1653   gIHSupplierSiteIdTbl(l_index) := p_current_ctx_item_rec.supplier_site_id;
1654   gIHReqTemplatePoLineIdTbl(l_index) := p_current_ctx_item_rec.req_template_po_line_id;
1655   gIHItemRevisionTbl(l_index) := p_current_ctx_item_rec.item_revision;
1656   gIHPoHeaderIdTbl(l_index) := p_current_ctx_item_rec.po_header_id;
1657   gIHDocumentNumberTbl(l_index) := p_current_ctx_item_rec.document_number;
1658   gIHLineNumTbl(l_index) := p_current_ctx_item_rec.line_num;
1659   gIHAllowPriceOverrideFlagTbl(l_index) := p_current_ctx_item_rec.allow_price_override_flag;
1660   gIHNotToExceedPriceTbl(l_index) := p_current_ctx_item_rec.not_to_exceed_price;
1661   gIHLineTypeIdTbl(l_index) := p_current_ctx_item_rec.line_type_id;
1662   gIHUnitMeasLookupCodeTbl(l_index) := p_current_ctx_item_rec.unit_meas_lookup_code;
1663   gIHSuggestedQuantityTbl(l_index) := p_current_ctx_item_rec.suggested_quantity;
1664   gIHUnitPriceTbl(l_index) := p_current_ctx_item_rec.unit_price;
1665   gIHAmountTbl(l_index) := p_current_ctx_item_rec.amount;
1666   gIHCurrencyCodeTbl(l_index) := p_current_ctx_item_rec.currency_code;
1667   gIHRateTypeTbl(l_index) := p_current_ctx_item_rec.rate_type;
1668   gIHRateDateTbl(l_index) := p_current_ctx_item_rec.rate_date;
1669   gIHRateTbl(l_index) := p_current_ctx_item_rec.rate;
1670   gIHBuyerIdTbl(l_index) := p_current_ctx_item_rec.buyer_id;
1671   gIHSupplierContactIdTbl(l_index) := p_current_ctx_item_rec.supplier_contact_id;
1672   gIHRfqRequiredFlagTbl(l_index) := p_current_ctx_item_rec.rfq_required_flag;
1673   gIHNegotiatedByPreparerFlagTbl(l_index) := p_current_ctx_item_rec.negotiated_by_preparer_flag;
1674   gIHDescriptionTbl(l_index) := p_current_ctx_item_rec.description;
1675   gIHLongDescriptionTbl(l_index) := p_current_ctx_item_rec.long_description;
1676   gIHOrganizationIdTbl(l_index) := p_current_ctx_item_rec.organization_id;
1677   gIHMasterOrganizationIdTbl(l_index) := p_current_ctx_item_rec.master_organization_id;
1678   gIHOrderTypeLookupCodeTbl(l_index) := p_current_ctx_item_rec.order_type_lookup_code;
1679   gIHSupplierTbl(l_index) := p_current_ctx_item_rec.supplier;
1680   gIHGlobalAgreementFlagTbl(l_index) := p_current_ctx_item_rec.global_agreement_flag;
1681   gIHMergedSourceTypeTbl(l_index) := p_current_ctx_item_rec.merged_source_type;
1682   l_err_loc := 300;
1683 EXCEPTION
1684   WHEN OTHERS THEN
1685     ICX_CAT_UTIL_PVT.logUnexpectedException(
1686       G_PKG_NAME, l_api_name,
1687       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1688     RAISE;
1689 END insertItemCtxHdrsTLP;
1690 
1691 PROCEDURE insertItemCtxDtlsTLP
1692 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1693 )
1694 IS
1695   l_api_name    CONSTANT VARCHAR2(30)   := 'insertItemCtxDtlsTLP';
1696   l_err_loc     PLS_INTEGER;
1697   l_index       PLS_INTEGER;
1698 BEGIN
1699   l_err_loc := 100;
1700   gTotalRowCount := gTotalRowCount + 1;
1701   l_index := gIDInventoryItemIdTbl.COUNT + 1;
1702 
1703   l_err_loc := 200;
1704   gIDInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1705   gIDPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1706   gIDReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1707   gIDReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1708   gIDOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1709   gIDLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1710   gIDPurchasingOrgIdTbl(l_index) := p_current_ctx_item_rec.purchasing_org_id;
1711   gIDOwningOrgIdTbl(l_index) := p_current_ctx_item_rec.owning_org_id;
1712 
1713   -- Removed the call to delPurchOrgRowFromCtxDtlsTLP,
1714   -- because it adds one delete script for upgrade case which is not necessary
1715   -- so add one more insert script for gIDInventoryItemIdTbl to insert the
1716   -- purchasing_org_id row i.e. row with sequence = 15001 in icx_cat_items_ctx_dtls_tlp
1717   -- delPurchOrgRowFromCtxDtlsTLP(p_current_ctx_item_rec);
1718 
1719   l_err_loc := 300;
1720 EXCEPTION
1721   WHEN OTHERS THEN
1722     ICX_CAT_UTIL_PVT.logUnexpectedException(
1723       G_PKG_NAME, l_api_name,
1724       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1725     RAISE;
1726 END insertItemCtxDtlsTLP;
1727 
1728 PROCEDURE updateItemCtxHdrsTLP
1729 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type
1730 )
1731 IS
1732   l_api_name    CONSTANT VARCHAR2(30)   := 'updateItemCtxHdrsTLP';
1733   l_err_loc     PLS_INTEGER;
1734   l_index       PLS_INTEGER;
1735 BEGIN
1736   l_err_loc := 100;
1737   gTotalRowCount := gTotalRowCount + 1;
1738   l_index := gUHInventoryItemIdTbl.COUNT + 1;
1739 
1740   l_err_loc := 200;
1741   gUHInventoryItemIdTbl(l_index) := p_current_ctx_item_rec.inventory_item_id;
1742   gUHPoLineIdTbl(l_index) := p_current_ctx_item_rec.po_line_id;
1743   gUHReqTemplateNameTbl(l_index) := p_current_ctx_item_rec.req_template_name;
1744   gUHReqTemplateLineNumTbl(l_index) := p_current_ctx_item_rec.req_template_line_num;
1745   gUHOrgIdTbl(l_index) := p_current_ctx_item_rec.org_id;
1746   gUHLanguageTbl(l_index) := p_current_ctx_item_rec.language;
1747   gUHSourceTypeTbl(l_index) := p_current_ctx_item_rec.source_type;
1748   gUHItemTypeTbl(l_index) := p_current_ctx_item_rec.item_type;
1749   gUHPurchasingOrgIdTbl(l_index) := p_current_ctx_item_rec.purchasing_org_id;
1750   gUHIpCategoryIdTbl(l_index) := p_current_ctx_item_rec.ip_category_id;
1751   gUHIpCategoryNameTbl(l_index) := p_current_ctx_item_rec.ip_category_name;
1752   gUHPoCategoryIdTbl(l_index) := p_current_ctx_item_rec.po_category_id;
1753   gUHSupplierIdTbl(l_index) := p_current_ctx_item_rec.supplier_id;
1754   gUHSupplierPartNumTbl(l_index) := p_current_ctx_item_rec.supplier_part_num;
1755   gUHSupplierPartAuxidTbl(l_index) := p_current_ctx_item_rec.supplier_part_auxid;
1756   gUHSupplierSiteIdTbl(l_index) := p_current_ctx_item_rec.supplier_site_id;
1757   gUHReqTemplatePoLineIdTbl(l_index) := p_current_ctx_item_rec.req_template_po_line_id;
1758   gUHItemRevisionTbl(l_index) := p_current_ctx_item_rec.item_revision;
1759   gUHPoHeaderIdTbl(l_index) := p_current_ctx_item_rec.po_header_id;
1760   gUHDocumentNumberTbl(l_index) := p_current_ctx_item_rec.document_number;
1761   gUHLineNumTbl(l_index) := p_current_ctx_item_rec.line_num;
1762   gUHAllowPriceOverrideFlagTbl(l_index) := p_current_ctx_item_rec.allow_price_override_flag;
1763   gUHNotToExceedPriceTbl(l_index) := p_current_ctx_item_rec.not_to_exceed_price;
1764   gUHLineTypeIdTbl(l_index) := p_current_ctx_item_rec.line_type_id;
1765   gUHUnitMeasLookupCodeTbl(l_index) := p_current_ctx_item_rec.unit_meas_lookup_code;
1766   gUHSuggestedQuantityTbl(l_index) := p_current_ctx_item_rec.suggested_quantity;
1767   gUHUnitPriceTbl(l_index) := p_current_ctx_item_rec.unit_price;
1768   gUHAmountTbl(l_index) := p_current_ctx_item_rec.amount;
1769   gUHCurrencyCodeTbl(l_index) := p_current_ctx_item_rec.currency_code;
1770   gUHRateTypeTbl(l_index) := p_current_ctx_item_rec.rate_type;
1771   gUHRateDateTbl(l_index) := p_current_ctx_item_rec.rate_date;
1772   gUHRateTbl(l_index) := p_current_ctx_item_rec.rate;
1773   gUHBuyerIdTbl(l_index) := p_current_ctx_item_rec.buyer_id;
1774   gUHSupplierContactIdTbl(l_index) := p_current_ctx_item_rec.supplier_contact_id;
1775   gUHRfqRequiredFlagTbl(l_index) := p_current_ctx_item_rec.rfq_required_flag;
1776   gUHNegotiatedByPreparerFlagTbl(l_index) := p_current_ctx_item_rec.negotiated_by_preparer_flag;
1777   gUHDescriptionTbl(l_index) := p_current_ctx_item_rec.description;
1778   gUHLongDescriptionTbl(l_index) := p_current_ctx_item_rec.long_description;
1779   gUHOrganizationIdTbl(l_index) := p_current_ctx_item_rec.organization_id;
1780   gUHMasterOrganizationIdTbl(l_index) := p_current_ctx_item_rec.master_organization_id;
1781   gUHOrderTypeLookupCodeTbl(l_index) := p_current_ctx_item_rec.order_type_lookup_code;
1782   gUHSupplierTbl(l_index) := p_current_ctx_item_rec.supplier;
1783   gUHGlobalAgreementFlagTbl(l_index) := p_current_ctx_item_rec.global_agreement_flag;
1784   gUHMergedSourceTypeTbl(l_index) := p_current_ctx_item_rec.merged_source_type;
1785   l_err_loc := 300;
1786 EXCEPTION
1787   WHEN OTHERS THEN
1788     ICX_CAT_UTIL_PVT.logUnexpectedException(
1789       G_PKG_NAME, l_api_name,
1790       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1791     RAISE;
1792 END updateItemCtxHdrsTLP;
1793 
1794 PROCEDURE processCurrentCtxItemRow
1795 (       p_current_ctx_item_rec  IN      g_ctx_item_rec_type             ,
1796         p_current_cursor        IN      VARCHAR2      ,
1797         p_mode                  IN      VARCHAR2
1798 )
1799 IS
1800   l_api_name                    CONSTANT VARCHAR2(30)   := 'processCurrentCtxItemRow';
1801   l_err_loc                     PLS_INTEGER;
1802   l_repopulate_mandatory_row    BOOLEAN := FALSE;
1803   l_update_item_ctx_hdr_row     BOOLEAN := FALSE;
1804 BEGIN
1805   l_err_loc := 100;
1806   IF (p_current_ctx_item_rec.ctx_rowid IS NULL) THEN
1807     -- Row does not exist in item ctx tables
1808     IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1809       FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1810           ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1811           'New row');
1812     END IF;
1813     l_err_loc := 200;
1814     insertItemCtxHdrsTLP(p_current_ctx_item_rec);
1815     l_err_loc := 300;
1816     insertItemCtxDtlsTLP(p_current_ctx_item_rec);
1817   ELSE
1818     -- Row is present in the icx_cat_item_ctx_hdrs_tlp
1819     -- Possible scenarios:
1820     -- 1. Need to update the row in both ctx_hdrs and ctx_dtls tlp tables
1821     -- 2. Need to update the row only in ctx_dtls tables (i.e rebuild the populate string)
1822     -- 3. Need to delete the row based upon status
1823     l_err_loc := 400;
1824     IF (p_current_ctx_item_rec.status = 0) THEN
1825       l_err_loc := 500;
1826       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1827         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1828             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1829             'Update row. p_current_cursor:' || p_current_cursor ||
1830             ', p_mode:' || p_mode);
1831       END IF;
1832 
1833       l_err_loc := 550;
1834       IF (p_current_ctx_item_rec.ctx_inventory_item_id <> p_current_ctx_item_rec.inventory_item_id)
1835       THEN
1836         -- inventory item id has changed which means in a po line or req template line,
1837         -- the description based item has been changed to an inventory item.
1838         -- For this case, just delete and recreate the item.
1839         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1840           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
1841               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1842               'Inventory item changed: for po_line_id:' || p_current_ctx_item_rec.po_line_id ||
1843               ', templt_name:' || p_current_ctx_item_rec.req_template_name ||
1844               ', template_line_num:' || p_current_ctx_item_rec.req_template_line_num ||
1845               ', inventory_item_id:' || p_current_ctx_item_rec.inventory_item_id ||
1846               ', org_id:' || p_current_ctx_item_rec.org_id ||
1847               ', language:' || p_current_ctx_item_rec.language);
1848         END IF;
1849         l_err_loc := 600;
1850         deleteItemCtxHdrsTLP(p_current_ctx_item_rec);
1851         l_err_loc := 700;
1852         deleteItemCtxDtlsTLP(p_current_ctx_item_rec);
1853         l_err_loc := 800;
1854         insertItemCtxHdrsTLP(p_current_ctx_item_rec);
1855         l_err_loc := 900;
1856         insertItemCtxDtlsTLP(p_current_ctx_item_rec);
1857       ELSE
1858         l_err_loc := 1000;
1859         -- Check for changes in any of the special ctx dtls rows for rebuild of that particular row only,
1860         IF (p_current_ctx_item_rec.ctx_purchasing_org_id <> p_current_ctx_item_rec.purchasing_org_id OR
1861             p_current_ctx_item_rec.ctx_ip_category_id <> p_current_ctx_item_rec.ip_category_id OR
1862             p_current_ctx_item_rec.ctx_po_category_id <> p_current_ctx_item_rec.po_category_id OR
1863             p_current_ctx_item_rec.ctx_item_type <> p_current_ctx_item_rec.item_type OR
1864             p_current_ctx_item_rec.ctx_supplier_id <> p_current_ctx_item_rec.supplier_id OR
1865             p_current_ctx_item_rec.ctx_supplier_site_id <> p_current_ctx_item_rec.supplier_site_id OR
1866             p_current_ctx_item_rec.ctx_supplier_part_num <> p_current_ctx_item_rec.supplier_part_num OR
1867             p_current_ctx_item_rec.ctx_supplier_part_auxid <> p_current_ctx_item_rec.supplier_part_auxid )
1868         THEN
1869           l_err_loc := 1100;
1870           l_update_item_ctx_hdr_row := TRUE;
1871 
1872           -- re-create the intermedia ctxString in icx_cat_ctx_dtls_tlp
1873           -- In icx_cat_items_ctx_dtls_tlp, need to
1874           -- 1. remove some of the special rows depending on the changes and
1875           -- 2. remove the base and local attributes rows i.e. sequence > 100 and < 10000
1876 
1877           IF (p_current_ctx_item_rec.ctx_po_category_id <> p_current_ctx_item_rec.po_category_id  OR
1878               p_current_ctx_item_rec.ctx_item_type <> p_current_ctx_item_rec.item_type OR
1879               p_current_ctx_item_rec.ctx_supplier_site_id <> p_current_ctx_item_rec.supplier_site_id OR
1880               p_current_ctx_item_rec.ctx_supplier_part_num <> p_current_ctx_item_rec.supplier_part_num OR
1881               p_current_ctx_item_rec.ctx_supplier_part_auxid <> p_current_ctx_item_rec.supplier_part_auxid)
1882           THEN
1883             l_err_loc := 1200;
1884             -- Re-populate the row with sequence = 1 i.e. mandatory row
1885             IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1886               FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1887                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1888                   'Row 1 needs to be re-populated:');
1889             END IF;
1890             l_repopulate_mandatory_row := TRUE;
1891           END IF;
1892 
1893           l_err_loc := 1300;
1894           IF (p_current_ctx_item_rec.ctx_supplier_id <> p_current_ctx_item_rec.supplier_id)
1895           THEN
1896             l_err_loc := 1400;
1897             -- Re-populate the row with sequence = 1 and 2 i.e. mandatory row and supplier row
1898             IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1899               FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1900                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1901                   'Supplier Row needs to be re-populated:');
1902             END IF;
1903             l_repopulate_mandatory_row := TRUE;
1904             delSupplierRowFromCtxDtlsTLP(p_current_ctx_item_rec);
1905           END IF;
1906 
1907           l_err_loc := 1500;
1908 
1909           -- The row with sequence = 3 i.e.
1910           -- Internal Item Number has already been taken care in the IF Loop.
1911 
1912           -- Row with sequence = 4 holds the source
1913           -- which cannnot be changed once created, so donot need to remove the row
1914           -- Source for BPA/GBPA/Quotation: Agreement/Quotation <segment1>.
1915           -- segment1 in po_headers cannot be changed
1916           -- Source for req templates: express_name.
1917           -- express_name in po_reqexpress_headers_all cannot be changed once created.
1918           IF (p_current_ctx_item_rec.ctx_ip_category_id <> p_current_ctx_item_rec.ip_category_id) THEN
1919             l_err_loc := 1600;
1920             -- Re-populate the row with sequence = 1 and 6 i.e. mandatory row and shopping_category row
1921             IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1922               FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1923                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1924                   'Shop category Row needs to be re-populated:');
1925             END IF;
1926             l_repopulate_mandatory_row := TRUE;
1927             delShopCatgRowFromCtxDtlsTLP(p_current_ctx_item_rec);
1928           END IF;
1929 
1930           l_err_loc := 1700;
1931 
1932           IF (p_current_ctx_item_rec.ctx_purchasing_org_id <> p_current_ctx_item_rec.purchasing_org_id) THEN
1933             l_err_loc := 1800;
1934             IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1935               FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1936                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1937                   'purchasing org_id Row needs to be re-populated:');
1938             END IF;
1939             -- Re-populate the row with sequence = 15001 i.e. purchorgid
1940             delPurchOrgRowFromCtxDtlsTLP(p_current_ctx_item_rec);
1941           END IF;
1942 
1943           l_err_loc := 1900;
1944 
1945           IF (l_repopulate_mandatory_row) THEN
1946             l_err_loc := 2000;
1947             delMandatoryRowFromCtxDtlsTLP(p_current_ctx_item_rec);
1948           END IF;
1949         END IF; -- End of IF check for changes in the special attributes
1950 
1951         l_err_loc := 2100;
1952 
1953         -- re-populate for the following conditions:
1954         -- Upgrade, always repopulate for all except master items
1955         -- Online, always repopulate for req template
1956         -- Online, repopulate for Blankets and global blankets only if item_revision has changed
1957         IF ( (p_mode = 'UPGRADE' AND
1958               p_current_ctx_item_rec.source_type <> 'MASTER_ITEM')
1959              OR
1960              (p_mode = 'ONLINE' AND
1961               (p_current_ctx_item_rec.source_type IN ('TEMPLATE', 'INTERNAL_TEMPLATE'))
1962               OR
1963               (p_current_ctx_item_rec.source_type IN ('GLOBAL_BLANKET', 'BLANKET') AND
1964                p_current_ctx_item_rec.item_revision <> p_current_ctx_item_rec.ctx_item_revision))
1965            )
1966         THEN
1967           l_err_loc := 2200;
1968           l_update_item_ctx_hdr_row := TRUE;
1969           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1970             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1971                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1972                 'item revision Row needs to be re-populated:' ||
1973                 ', source_type:' || p_current_ctx_item_rec.source_type ||
1974                 ', p_mode:' || p_mode ||
1975                 ', item_revision:' ||  p_current_ctx_item_rec.item_revision ||
1976                 ', ctx_item_revision:' || p_current_ctx_item_rec.ctx_item_revision);
1977           END IF;
1978           -- Re-populate the row with sequence = 5 i.e. Item Revision
1979           delItemRevRowFromCtxDtlsTLP(p_current_ctx_item_rec);
1980         END IF;
1981 
1982         l_err_loc := 2300;
1983 
1984         -- For master items the description will be in the ctx index as part of sequence between 101 and 4999.
1985         -- i.e. in sequence 101
1986         -- There will not be any category attribute row between 5001 and 9999
1987         -- ICX_CAT_UTIL_PVT.g_ItemCatgChange_const will be set to true only from master items
1988         -- category change API i.e. in ICX_CAT_POPULATE_MI_PVT.populateItemCatgChange
1989         -- For category change of a master item we dont want to re-populate the base and local attributes of
1990         -- master item.  So here we check for ICX_CAT_UTIL_PVT.g_ItemCatgChange_const
1991         -- (Note: Master items will not have any local attributes populated)
1992         -- Local and Base attributes does not need to repopulated (for blankets and global blankets)
1993         -- when coming from populateOrgAssignments
1994         IF (NOT ICX_CAT_UTIL_PVT.g_ItemCatgChange_const
1995             AND NOT (p_mode = 'ONLINE' AND
1996                      p_current_ctx_item_rec.source_type IN ('GLOBAL_BLANKET', 'BLANKET') AND
1997                      p_current_cursor = 'ORG_ASSIGNMENT_CSR'))
1998         THEN
1999           l_err_loc := 2400;
2000           l_update_item_ctx_hdr_row := TRUE;
2001           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2002             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2003                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2004                 'base and local Row needs to be re-populated:' ||
2005                 ', source_type:' || p_current_ctx_item_rec.source_type ||
2006                 ', p_mode:' || p_mode ||
2007                 ', p_current_cursor:' || p_current_cursor);
2008           END IF;
2009           delBaseLocalAttrItemCtxDtlsTLP(p_current_ctx_item_rec);
2010         END IF;
2011 
2012         l_err_loc := 2500;
2013 
2014         IF (l_update_item_ctx_hdr_row) THEN
2015           l_err_loc := 2600;
2016           -- Update scenario
2017           -- The row needs to be updated in icx_cat_items_ctx_hdrs
2018           -- We have to update the ctx_desc to null in hdrs table, for rebuild indexes.
2019           updateItemCtxHdrsTLP(p_current_ctx_item_rec);
2020         ELSE
2021           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2022             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2023                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2024                 ', l_update_item_ctx_hdr_row is false; so will not call updateItemCtxHdrsTLP');
2025           END IF;
2026         END IF;
2027 
2028         l_err_loc := 2700;
2029       END IF;
2030     ELSE -- status is not 0
2031       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2032         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2033             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2034             'Delete row');
2035       END IF;
2036       -- i.e. the row is invalid and needs to be deleted
2037       l_err_loc := 2800;
2038       deleteItemCtxHdrsTLP(p_current_ctx_item_rec);
2039       deleteItemCtxDtlsTLP(p_current_ctx_item_rec);
2040     END IF;
2041   END IF;
2042   l_err_loc := 2900;
2043 EXCEPTION
2044   WHEN OTHERS THEN
2045     ICX_CAT_UTIL_PVT.logUnexpectedException(
2046       G_PKG_NAME, l_api_name,
2047       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2048     RAISE;
2049 END processCurrentCtxItemRow;
2050 
2051 /*
2052 -- p_current_cursor
2053         VALUES: ICX_CAT_UTIL_PVT.g_BPACsr_const := 'BPA';
2054                 ICX_CAT_UTIL_PVT.g_QuoteCsr_const := 'Quote';
2055                 ICX_CAT_UTIL_PVT.g_GBPACsr_const := 'GBPA';
2056                 ICX_CAT_UTIL_PVT.g_ReqTemplateCsr_const := 'ReqTemplate';
2057                 ICX_CAT_UTIL_PVT.g_MasterItemCsr_const := 'MASTER_ITEM';
2058 -- 1. Used to process the DML to icx_cat_items_ctx_dtls_tlp differently for GBPAs
2059 -- 2. Used to call the appropriate buildCtxSqls, list of ctx sqls are different depending upon the source
2060 -- req_templates and master items dont need to run the sql for contract_num
2061 -- master items need to only run sql with sequence 1 and org info.
2062 */
2063 PROCEDURE populateItemCtxTables
2064 (       p_mode                  IN      VARCHAR2                        ,
2065         p_current_cursor        IN      VARCHAR2
2066 )
2067 IS
2068   l_api_name                    CONSTANT VARCHAR2(30)   := 'populateItemCtxTables';
2069   l_err_loc                     PLS_INTEGER;
2070   l_action_mode                 VARCHAR2(80);
2071   l_special_ctx_sql_tbl         ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_tbl_type;
2072   l_regular_ctx_sql_tbl         ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_tbl_type;
2073   l_ctx_sqlstring_rec           ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_rec_type;
2074   l_csr_handle                  NUMBER;
2075   l_status                      PLS_INTEGER;
2076   l_start_sequence              NUMBER;
2077   l_end_sequence                NUMBER;
2078   l_sequence                    NUMBER;
2079   l_ctx_sql_string              VARCHAR2(4000);
2080 
2081   --BUG 6599217: start1
2082   l_ip_category_id           NUMBER ;
2083   l_inventory_item_id       NUMBER;
2084   l_org_id                      NUMBER;
2085   l_description                 VARCHAR2(4000);
2086   l_long_description            po_attribute_values_tlp.long_description%TYPE;
2087   l_organization_id             NUMBER;
2088   l_master_organization_id      NUMBER;
2089   l_language                    icx_cat_items_ctx_hdrs_tlp.language%TYPE;
2090    --BUG 6599217: end 1
2091 BEGIN
2092   l_err_loc := 100;
2093   IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2094     FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2095         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2096         'Enter populateItemCtxTables(' || p_mode || ', ' || p_current_cursor ||
2097         ')gTotalRowCount: ' || gTotalRowCount);
2098   END IF;
2099 
2100   l_err_loc := 150;
2101   IF (p_mode = 'OUTLOOP' OR gTotalRowCount >= ICX_CAT_UTIL_PVT.g_batch_size) THEN
2102     l_err_loc := 200;
2103     gTotalRowCount := 0;
2104 
2105     IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2106       FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2107           ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2108           '; Num. of rows to be inserted into hdrs:' || gIHInventoryItemIdTbl.COUNT ||
2109           '; Num. of rows to be inserted into dtls:' || gIDInventoryItemIdTbl.COUNT ||
2110           ', Total num. of rows to be updated:' || gUHInventoryItemIdTbl.COUNT ||
2111           ', Mandatory rows to be re-populated for:' || gDMDInventoryItemIdTbl.COUNT ||
2112           ', Supplier rows to be re-populated for:' || gDSDInventoryItemIdTbl.COUNT ||
2113           ', Item Revision rows to be re-populated for:' || gDIRDInventoryItemIdTbl.COUNT ||
2114           ', Shopping Category rows to be re-populated for:' || gDSCDInventoryItemIdTbl.COUNT ||
2115           ', Base and Local attribute rows to be re-populated for:' || gDBLDInventoryItemIdTbl.COUNT ||
2116           ', Num. of rows to be deleted:' || gDHInventoryItemIdTbl.COUNT);
2117     END IF;
2118 
2119     l_err_loc := 250;
2120     l_action_mode := 'INSERT_CTX_HDRS';
2121     FORALL i in 1..gIHInventoryItemIdTbl.COUNT
2122       INSERT INTO icx_cat_items_ctx_hdrs_tlp
2123       (inventory_item_id, po_line_id,
2124        req_template_name, req_template_line_num,
2125        org_id, language,
2126        source_type, item_type, purchasing_org_id, owning_org_id,
2127        ip_category_id, ip_category_name, po_category_id,
2128        supplier_id, supplier_part_num,
2129        supplier_part_auxid, supplier_site_id,
2130        req_template_po_line_id, item_revision, po_header_id,
2131        document_number, line_num, allow_price_override_flag,
2132        not_to_exceed_price, line_type_id, unit_meas_lookup_code,
2133        suggested_quantity, unit_price, amount, currency_code, rate_type,
2134        rate_date, rate, buyer_id, supplier_contact_id,
2135        rfq_required_flag, negotiated_by_preparer_flag,
2136        description, order_type_lookup_code,
2137        supplier, global_agreement_flag, merged_source_type,
2138        last_update_login, last_updated_by, last_update_date,
2139        created_by, creation_date, internal_request_id, request_id,
2140        program_application_id, program_id, program_login_id)
2141       VALUES(gIHInventoryItemIdTbl(i), gIHPoLineIdTbl(i),
2142        gIHReqTemplateNameTbl(i), gIHReqTemplateLineNumTbl(i),
2143        gIHOrgIdTbl(i), gIHLanguageTbl(i),
2144        gIHSourceTypeTbl(i), gIHItemTypeTbl(i), gIHPurchasingOrgIdTbl(i), gIHOwningOrgIdTbl(i),
2145        gIHIpCategoryIdTbl(i), gIHIpCategoryNameTbl(i), gIHPoCategoryIdTbl(i),
2146        gIHSupplierIdTbl(i), gIHSupplierPartNumTbl(i),
2147        gIHSupplierPartAuxidTbl(i), gIHSupplierSiteIdTbl(i), gIHReqTemplatePoLineIdTbl(i),
2148        gIHItemRevisionTbl(i), gIHPoHeaderIdTbl(i), gIHDocumentNumberTbl(i),
2149        gIHLineNumTbl(i), gIHAllowPriceOverrideFlagTbl(i), gIHNotToExceedPriceTbl(i),
2150        gIHLineTypeIdTbl(i), gIHUnitMeasLookupCodeTbl(i), gIHSuggestedQuantityTbl(i),
2151        gIHUnitPriceTbl(i), gIHAmountTbl(i), gIHCurrencyCodeTbl(i),  gIHRateTypeTbl(i),
2152        gIHRateDateTbl(i), gIHRateTbl(i), gIHBuyerIdTbl(i), gIHSupplierContactIdTbl(i),
2153        gIHRfqRequiredFlagTbl(i), gIHNegotiatedByPreparerFlagTbl(i), gIHDescriptionTbl(i),
2154        gIHOrderTypeLookupCodeTbl(i), gIHSupplierTbl(i),
2155        gIHGlobalAgreementFlagTbl(i), gIHMergedSourceTypeTbl(i),
2156        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
2157        sysdate, ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
2158        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
2159        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
2160        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
2161        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
2162        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
2163 
2164     IF (gIHInventoryItemIdTbl.COUNT > 0) THEN
2165       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2166         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2167             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2168             'Num. of rows inserted into ctx_hdrs:' ||SQL%ROWCOUNT);
2169       END IF;
2170     END IF;
2171 
2172     l_err_loc := 310;
2173 
2174 --BUG 6599217.start 2
2175     if ( p_current_cursor = ICX_CAT_UTIL_PVT.g_MasterItemCsr_const) then
2176 
2177     l_action_mode := 'INSERT_PO_ATTR_VALUES';
2178 
2179     IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2180         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2181             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2182             ' loop count : ' ||gIHInventoryItemIdTbl.Count);
2183     END IF;
2184 
2185     FOR i IN 1..gIHInventoryItemIdTbl.Count LOOP
2186       -- call the po package to populate the po tables so that the
2187       -- merge st in this procedure will insert rows in icx tables
2188 
2189           l_ip_category_id      := gIHIpCategoryIdTbl(i);
2190           l_inventory_item_id   := gIHInventoryItemIdTbl(i);
2191           l_org_id              := gIHOrgIdTbl(i);
2192           l_description         := gIHDescriptionTbl(i);
2193           l_long_description    := gIHLongDescriptionTbl(i);
2194           l_organization_id     := gIHOrganizationIdTbl(i);
2195           l_master_organization_id := gIHMasterOrganizationIdTbl(i);
2196 
2197        IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2198         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2199             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2200             'Value of variable are  l_ip_category_id= ' ||l_ip_category_id|| 'l_inventory_item_id=' ||l_inventory_item_id||
2201             'l_org_id='||l_org_id||'l_description='||l_description);
2202        END IF;
2203 
2204        po_attribute_values_pvt.create_default_attributes_MI
2205         (
2206           p_ip_category_id      =>   l_ip_category_id,
2207           p_inventory_item_id   =>  l_inventory_item_id,
2208           p_org_id              =>  l_org_id,
2209           p_description         =>   l_description,
2210           p_organization_id     =>   l_organization_id,
2211           p_master_organization_id => l_master_organization_id
2212         );
2213     END LOOP;
2214 
2215     END IF;
2216       l_err_loc := 315;
2217 
2218     --BUG 6599217.end 2
2219 
2220 
2221     l_action_mode := 'INSERT_ATTR_VALUES';
2222     FORALL i in 1..gIHInventoryItemIdTbl.COUNT
2223       MERGE INTO icx_cat_attribute_values icav
2224       USING (SELECT *
2225              FROM po_attribute_values
2226              WHERE inventory_item_id = gIHInventoryItemIdTbl(i)
2227              AND   po_line_id = gIHPoLineIdTbl(i)
2228              AND   req_template_name = gIHReqTemplateNameTbl(i)
2229              AND   req_template_line_num = gIHReqTemplateLineNumTbl(i)
2230              AND   org_id = gIHOrgIdTbl(i)) temp
2231       ON (icav.inventory_item_id = temp.inventory_item_id AND
2232           icav.po_line_id = temp.po_line_id AND
2233           icav.req_template_name = temp.req_template_name AND
2234           icav.req_template_line_num = temp.req_template_line_num AND
2235           icav.org_id = temp.org_id)
2236       WHEN NOT MATCHED THEN INSERT VALUES (
2237           temp.attribute_values_id, temp.po_line_id, temp.req_template_name,
2238           temp.req_template_line_num, temp.ip_category_id, temp.inventory_item_id,
2239           temp.org_id, temp.manufacturer_part_num, temp.picture, temp.thumbnail_image,
2240           temp.supplier_url, temp.manufacturer_url, temp.attachment_url, temp.unspsc,
2241           temp.availability, temp.lead_time,
2242           temp.text_base_attribute1, temp.text_base_attribute2, temp.text_base_attribute3,
2243           temp.text_base_attribute4, temp.text_base_attribute5, temp.text_base_attribute6,
2244           temp.text_base_attribute7, temp.text_base_attribute8, temp.text_base_attribute9,
2245           temp.text_base_attribute10, temp.text_base_attribute11, temp.text_base_attribute12,
2246           temp.text_base_attribute13, temp.text_base_attribute14, temp.text_base_attribute15,
2247           temp.text_base_attribute16, temp.text_base_attribute17, temp.text_base_attribute18,
2248           temp.text_base_attribute19, temp.text_base_attribute20, temp.text_base_attribute21,
2249           temp.text_base_attribute22, temp.text_base_attribute23, temp.text_base_attribute24,
2250           temp.text_base_attribute25, temp.text_base_attribute26, temp.text_base_attribute27,
2251           temp.text_base_attribute28, temp.text_base_attribute29, temp.text_base_attribute30,
2252           temp.text_base_attribute31, temp.text_base_attribute32, temp.text_base_attribute33,
2253           temp.text_base_attribute34, temp.text_base_attribute35, temp.text_base_attribute36,
2254           temp.text_base_attribute37, temp.text_base_attribute38, temp.text_base_attribute39,
2255           temp.text_base_attribute40, temp.text_base_attribute41, temp.text_base_attribute42,
2256           temp.text_base_attribute43, temp.text_base_attribute44, temp.text_base_attribute45,
2257           temp.text_base_attribute46, temp.text_base_attribute47, temp.text_base_attribute48,
2258           temp.text_base_attribute49, temp.text_base_attribute50, temp.text_base_attribute51,
2259           temp.text_base_attribute52, temp.text_base_attribute53, temp.text_base_attribute54,
2260           temp.text_base_attribute55, temp.text_base_attribute56, temp.text_base_attribute57,
2261           temp.text_base_attribute58, temp.text_base_attribute59, temp.text_base_attribute60,
2262           temp.text_base_attribute61, temp.text_base_attribute62, temp.text_base_attribute63,
2263           temp.text_base_attribute64, temp.text_base_attribute65, temp.text_base_attribute66,
2264           temp.text_base_attribute67, temp.text_base_attribute68, temp.text_base_attribute69,
2265           temp.text_base_attribute70, temp.text_base_attribute71, temp.text_base_attribute72,
2266           temp.text_base_attribute73, temp.text_base_attribute74, temp.text_base_attribute75,
2267           temp.text_base_attribute76, temp.text_base_attribute77, temp.text_base_attribute78,
2268           temp.text_base_attribute79, temp.text_base_attribute80, temp.text_base_attribute81,
2269           temp.text_base_attribute82, temp.text_base_attribute83, temp.text_base_attribute84,
2270           temp.text_base_attribute85, temp.text_base_attribute86, temp.text_base_attribute87,
2271           temp.text_base_attribute88, temp.text_base_attribute89, temp.text_base_attribute90,
2272           temp.text_base_attribute91, temp.text_base_attribute92, temp.text_base_attribute93,
2273           temp.text_base_attribute94, temp.text_base_attribute95, temp.text_base_attribute96,
2274           temp.text_base_attribute97, temp.text_base_attribute98, temp.text_base_attribute99,
2275           temp.text_base_attribute100,
2276           temp.num_base_attribute1, temp.num_base_attribute2, temp.num_base_attribute3,
2277           temp.num_base_attribute4, temp.num_base_attribute5, temp.num_base_attribute6,
2278           temp.num_base_attribute7, temp.num_base_attribute8, temp.num_base_attribute9,
2279           temp.num_base_attribute10, temp.num_base_attribute11, temp.num_base_attribute12,
2280           temp.num_base_attribute13, temp.num_base_attribute14, temp.num_base_attribute15,
2281           temp.num_base_attribute16, temp.num_base_attribute17, temp.num_base_attribute18,
2282           temp.num_base_attribute19, temp.num_base_attribute20, temp.num_base_attribute21,
2283           temp.num_base_attribute22, temp.num_base_attribute23, temp.num_base_attribute24,
2284           temp.num_base_attribute25, temp.num_base_attribute26, temp.num_base_attribute27,
2285           temp.num_base_attribute28, temp.num_base_attribute29, temp.num_base_attribute30,
2286           temp.num_base_attribute31, temp.num_base_attribute32, temp.num_base_attribute33,
2287           temp.num_base_attribute34, temp.num_base_attribute35, temp.num_base_attribute36,
2288           temp.num_base_attribute37, temp.num_base_attribute38, temp.num_base_attribute39,
2289           temp.num_base_attribute40, temp.num_base_attribute41, temp.num_base_attribute42,
2290           temp.num_base_attribute43, temp.num_base_attribute44, temp.num_base_attribute45,
2291           temp.num_base_attribute46, temp.num_base_attribute47, temp.num_base_attribute48,
2292           temp.num_base_attribute49, temp.num_base_attribute50, temp.num_base_attribute51,
2293           temp.num_base_attribute52, temp.num_base_attribute53, temp.num_base_attribute54,
2294           temp.num_base_attribute55, temp.num_base_attribute56, temp.num_base_attribute57,
2295           temp.num_base_attribute58, temp.num_base_attribute59, temp.num_base_attribute60,
2296           temp.num_base_attribute61, temp.num_base_attribute62, temp.num_base_attribute63,
2297           temp.num_base_attribute64, temp.num_base_attribute65, temp.num_base_attribute66,
2298           temp.num_base_attribute67, temp.num_base_attribute68, temp.num_base_attribute69,
2299           temp.num_base_attribute70, temp.num_base_attribute71, temp.num_base_attribute72,
2300           temp.num_base_attribute73, temp.num_base_attribute74, temp.num_base_attribute75,
2301           temp.num_base_attribute76, temp.num_base_attribute77, temp.num_base_attribute78,
2302           temp.num_base_attribute79, temp.num_base_attribute80, temp.num_base_attribute81,
2303           temp.num_base_attribute82, temp.num_base_attribute83, temp.num_base_attribute84,
2304           temp.num_base_attribute85, temp.num_base_attribute86, temp.num_base_attribute87,
2305           temp.num_base_attribute88, temp.num_base_attribute89, temp.num_base_attribute90,
2306           temp.num_base_attribute91, temp.num_base_attribute92, temp.num_base_attribute93,
2307           temp.num_base_attribute94, temp.num_base_attribute95, temp.num_base_attribute96,
2308           temp.num_base_attribute97, temp.num_base_attribute98, temp.num_base_attribute99,
2309           temp.num_base_attribute100,
2310           temp.text_cat_attribute1, temp.text_cat_attribute2, temp.text_cat_attribute3,
2311           temp.text_cat_attribute4, temp.text_cat_attribute5, temp.text_cat_attribute6,
2312           temp.text_cat_attribute7, temp.text_cat_attribute8, temp.text_cat_attribute9,
2313           temp.text_cat_attribute10, temp.text_cat_attribute11, temp.text_cat_attribute12,
2314           temp.text_cat_attribute13, temp.text_cat_attribute14, temp.text_cat_attribute15,
2315           temp.text_cat_attribute16, temp.text_cat_attribute17, temp.text_cat_attribute18,
2316           temp.text_cat_attribute19, temp.text_cat_attribute20, temp.text_cat_attribute21,
2317           temp.text_cat_attribute22, temp.text_cat_attribute23, temp.text_cat_attribute24,
2318           temp.text_cat_attribute25, temp.text_cat_attribute26, temp.text_cat_attribute27,
2319           temp.text_cat_attribute28, temp.text_cat_attribute29, temp.text_cat_attribute30,
2320           temp.text_cat_attribute31, temp.text_cat_attribute32, temp.text_cat_attribute33,
2321           temp.text_cat_attribute34, temp.text_cat_attribute35, temp.text_cat_attribute36,
2322           temp.text_cat_attribute37, temp.text_cat_attribute38, temp.text_cat_attribute39,
2323           temp.text_cat_attribute40, temp.text_cat_attribute41, temp.text_cat_attribute42,
2324           temp.text_cat_attribute43, temp.text_cat_attribute44, temp.text_cat_attribute45,
2325           temp.text_cat_attribute46, temp.text_cat_attribute47, temp.text_cat_attribute48,
2326           temp.text_cat_attribute49, temp.text_cat_attribute50,
2327           temp.num_cat_attribute1, temp.num_cat_attribute2, temp.num_cat_attribute3,
2328           temp.num_cat_attribute4, temp.num_cat_attribute5, temp.num_cat_attribute6,
2329           temp.num_cat_attribute7, temp.num_cat_attribute8, temp.num_cat_attribute9,
2330           temp.num_cat_attribute10, temp.num_cat_attribute11, temp.num_cat_attribute12,
2331           temp.num_cat_attribute13, temp.num_cat_attribute14, temp.num_cat_attribute15,
2332           temp.num_cat_attribute16, temp.num_cat_attribute17, temp.num_cat_attribute18,
2333           temp.num_cat_attribute19, temp.num_cat_attribute20, temp.num_cat_attribute21,
2334           temp.num_cat_attribute22, temp.num_cat_attribute23, temp.num_cat_attribute24,
2335           temp.num_cat_attribute25, temp.num_cat_attribute26, temp.num_cat_attribute27,
2336           temp.num_cat_attribute28, temp.num_cat_attribute29, temp.num_cat_attribute30,
2337           temp.num_cat_attribute31, temp.num_cat_attribute32, temp.num_cat_attribute33,
2338           temp.num_cat_attribute34, temp.num_cat_attribute35, temp.num_cat_attribute36,
2339           temp.num_cat_attribute37, temp.num_cat_attribute38, temp.num_cat_attribute39,
2340           temp.num_cat_attribute40, temp.num_cat_attribute41, temp.num_cat_attribute42,
2341           temp.num_cat_attribute43, temp.num_cat_attribute44, temp.num_cat_attribute45,
2342           temp.num_cat_attribute46, temp.num_cat_attribute47, temp.num_cat_attribute48,
2343           temp.num_cat_attribute49, temp.num_cat_attribute50,
2344           temp.last_update_login, temp.last_updated_by, temp.last_update_date, temp.created_by,
2345           temp.creation_date, temp.request_id, temp.program_application_id, temp.program_id,
2346           temp.program_update_date, temp.last_updated_program, temp.rebuild_search_index_flag);
2347 
2348     IF (gIHInventoryItemIdTbl.COUNT > 0) THEN
2349       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2350         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2351             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2352             'Num. of rows inserted into icx_cat_attribute_values:' ||SQL%ROWCOUNT);
2353       END IF;
2354     END IF;
2355 
2356     l_err_loc := 330;
2357 
2358     -- BUG 6599217.start 3 new procedure to insert into PO_ATTRIBUTE_VALUES_TLP
2359     if ( p_current_cursor = ICX_CAT_UTIL_PVT.g_MasterItemCsr_const) then
2360     l_action_mode := 'INSERT_PO_ATTR_VALUES_TLP';
2361 
2362     IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2363         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2364             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2365             ' loop count : ' ||gIHInventoryItemIdTbl.Count);
2366     END IF;
2367 
2368     FOR i IN 1..gIHInventoryItemIdTbl.Count LOOP
2369       -- call the po package to populate the po tables so that the
2370       -- merge st in this procedure will insert rows in icx tables
2371 
2372         l_inventory_item_id   := gIHInventoryItemIdTbl(i);
2373         l_org_id              := gIHOrgIdTbl(i);
2374         l_language            := gIHLanguageTbl(i);
2375         l_description         := gIHDescriptionTbl(i);
2376         l_ip_category_id      := gIHIpCategoryIdTbl(i);
2377         l_long_description    := gIHLongDescriptionTbl(i);
2378         l_organization_id     := gIHOrganizationIdTbl(i);
2379         l_master_organization_id := gIHMasterOrganizationIdTbl(i);
2380 
2381        IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2382         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2383             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2384             'Value of variable are  l_inventory_item_id=' ||l_inventory_item_id||
2385             'l_org_id='||l_org_id||'l_language='||l_language||' l_ip_category_id=' ||l_ip_category_id);
2386        END IF;
2387 
2388        po_attribute_values_pvt.create_attributes_tlp_MI
2389         (
2390           p_inventory_item_id   =>  l_inventory_item_id,
2391           p_ip_category_id       =>  l_ip_category_id ,
2392           p_org_id              =>  l_org_id,
2393           p_language         =>     l_language,
2394           p_description      =>     l_description,
2395           p_long_description => l_long_description,
2396           p_organization_id => l_organization_id,
2397           p_master_organization_id => l_master_organization_id
2398         );
2399     END LOOP;
2400 
2401     End if;
2402     --BUG 6599217.end 2
2403 
2404 
2405     l_err_loc := 335;
2406 
2407 
2408     l_action_mode := 'INSERT_ATTR_VALUES_TLP';
2409     FORALL i in 1..gIHInventoryItemIdTbl.COUNT
2410       MERGE INTO icx_cat_attribute_values_tlp icavt
2411       USING (SELECT *
2412              FROM po_attribute_values_tlp
2413              WHERE inventory_item_id = gIHInventoryItemIdTbl(i)
2414              AND   po_line_id = gIHPoLineIdTbl(i)
2415              AND   req_template_name = gIHReqTemplateNameTbl(i)
2416              AND   req_template_line_num = gIHReqTemplateLineNumTbl(i)
2417              AND   org_id = gIHOrgIdTbl(i)
2418              AND   language = gIHLanguageTbl(i)) temp
2419       ON (icavt.inventory_item_id = temp.inventory_item_id AND
2420           icavt.po_line_id = temp.po_line_id AND
2421           icavt.req_template_name = temp.req_template_name AND
2422           icavt.req_template_line_num = temp.req_template_line_num AND
2423           icavt.org_id = temp.org_id AND
2424           icavt.language = temp.language)
2425       WHEN NOT MATCHED THEN INSERT VALUES (
2426           temp.attribute_values_tlp_id, temp.po_line_id, temp.req_template_name,
2427           temp.req_template_line_num, temp.ip_category_id, temp.inventory_item_id,
2428           temp.org_id, temp.language, temp.description, temp.manufacturer,
2429           temp.comments, temp.alias, temp.long_description,
2430           temp.tl_text_base_attribute1, temp.tl_text_base_attribute2, temp.tl_text_base_attribute3,
2431           temp.tl_text_base_attribute4, temp.tl_text_base_attribute5, temp.tl_text_base_attribute6,
2432           temp.tl_text_base_attribute7, temp.tl_text_base_attribute8, temp.tl_text_base_attribute9,
2433           temp.tl_text_base_attribute10, temp.tl_text_base_attribute11, temp.tl_text_base_attribute12,
2434           temp.tl_text_base_attribute13, temp.tl_text_base_attribute14, temp.tl_text_base_attribute15,
2435           temp.tl_text_base_attribute16, temp.tl_text_base_attribute17, temp.tl_text_base_attribute18,
2436           temp.tl_text_base_attribute19, temp.tl_text_base_attribute20, temp.tl_text_base_attribute21,
2437           temp.tl_text_base_attribute22, temp.tl_text_base_attribute23, temp.tl_text_base_attribute24,
2438           temp.tl_text_base_attribute25, temp.tl_text_base_attribute26, temp.tl_text_base_attribute27,
2439           temp.tl_text_base_attribute28, temp.tl_text_base_attribute29, temp.tl_text_base_attribute30,
2440           temp.tl_text_base_attribute31, temp.tl_text_base_attribute32, temp.tl_text_base_attribute33,
2441           temp.tl_text_base_attribute34, temp.tl_text_base_attribute35, temp.tl_text_base_attribute36,
2442           temp.tl_text_base_attribute37, temp.tl_text_base_attribute38, temp.tl_text_base_attribute39,
2443           temp.tl_text_base_attribute40, temp.tl_text_base_attribute41, temp.tl_text_base_attribute42,
2444           temp.tl_text_base_attribute43, temp.tl_text_base_attribute44, temp.tl_text_base_attribute45,
2445           temp.tl_text_base_attribute46, temp.tl_text_base_attribute47, temp.tl_text_base_attribute48,
2446           temp.tl_text_base_attribute49, temp.tl_text_base_attribute50, temp.tl_text_base_attribute51,
2447           temp.tl_text_base_attribute52, temp.tl_text_base_attribute53, temp.tl_text_base_attribute54,
2448           temp.tl_text_base_attribute55, temp.tl_text_base_attribute56, temp.tl_text_base_attribute57,
2449           temp.tl_text_base_attribute58, temp.tl_text_base_attribute59, temp.tl_text_base_attribute60,
2450           temp.tl_text_base_attribute61, temp.tl_text_base_attribute62, temp.tl_text_base_attribute63,
2451           temp.tl_text_base_attribute64, temp.tl_text_base_attribute65, temp.tl_text_base_attribute66,
2452           temp.tl_text_base_attribute67, temp.tl_text_base_attribute68, temp.tl_text_base_attribute69,
2453           temp.tl_text_base_attribute70, temp.tl_text_base_attribute71, temp.tl_text_base_attribute72,
2454           temp.tl_text_base_attribute73, temp.tl_text_base_attribute74, temp.tl_text_base_attribute75,
2455           temp.tl_text_base_attribute76, temp.tl_text_base_attribute77, temp.tl_text_base_attribute78,
2456           temp.tl_text_base_attribute79, temp.tl_text_base_attribute80, temp.tl_text_base_attribute81,
2457           temp.tl_text_base_attribute82, temp.tl_text_base_attribute83, temp.tl_text_base_attribute84,
2458           temp.tl_text_base_attribute85, temp.tl_text_base_attribute86, temp.tl_text_base_attribute87,
2459           temp.tl_text_base_attribute88, temp.tl_text_base_attribute89, temp.tl_text_base_attribute90,
2460           temp.tl_text_base_attribute91, temp.tl_text_base_attribute92, temp.tl_text_base_attribute93,
2461           temp.tl_text_base_attribute94, temp.tl_text_base_attribute95, temp.tl_text_base_attribute96,
2462           temp.tl_text_base_attribute97, temp.tl_text_base_attribute98, temp.tl_text_base_attribute99,
2463           temp.tl_text_base_attribute100,
2464           temp.tl_text_cat_attribute1, temp.tl_text_cat_attribute2, temp.tl_text_cat_attribute3,
2465           temp.tl_text_cat_attribute4, temp.tl_text_cat_attribute5, temp.tl_text_cat_attribute6,
2466           temp.tl_text_cat_attribute7, temp.tl_text_cat_attribute8, temp.tl_text_cat_attribute9,
2467           temp.tl_text_cat_attribute10, temp.tl_text_cat_attribute11, temp.tl_text_cat_attribute12,
2468           temp.tl_text_cat_attribute13, temp.tl_text_cat_attribute14, temp.tl_text_cat_attribute15,
2469           temp.tl_text_cat_attribute16, temp.tl_text_cat_attribute17, temp.tl_text_cat_attribute18,
2470           temp.tl_text_cat_attribute19, temp.tl_text_cat_attribute20, temp.tl_text_cat_attribute21,
2471           temp.tl_text_cat_attribute22, temp.tl_text_cat_attribute23, temp.tl_text_cat_attribute24,
2472           temp.tl_text_cat_attribute25, temp.tl_text_cat_attribute26, temp.tl_text_cat_attribute27,
2473           temp.tl_text_cat_attribute28, temp.tl_text_cat_attribute29, temp.tl_text_cat_attribute30,
2474           temp.tl_text_cat_attribute31, temp.tl_text_cat_attribute32, temp.tl_text_cat_attribute33,
2475           temp.tl_text_cat_attribute34, temp.tl_text_cat_attribute35, temp.tl_text_cat_attribute36,
2476           temp.tl_text_cat_attribute37, temp.tl_text_cat_attribute38, temp.tl_text_cat_attribute39,
2477           temp.tl_text_cat_attribute40, temp.tl_text_cat_attribute41, temp.tl_text_cat_attribute42,
2478           temp.tl_text_cat_attribute43, temp.tl_text_cat_attribute44, temp.tl_text_cat_attribute45,
2479           temp.tl_text_cat_attribute46, temp.tl_text_cat_attribute47, temp.tl_text_cat_attribute48,
2480           temp.tl_text_cat_attribute49, temp.tl_text_cat_attribute50,
2481           temp.last_update_login, temp.last_updated_by, temp.last_update_date, temp.created_by,
2482           temp.creation_date, temp.request_id, temp.program_application_id, temp.program_id,
2483           temp.program_update_date, temp.last_updated_program, temp.rebuild_search_index_flag);
2484 
2485     IF (gIHInventoryItemIdTbl.COUNT > 0) THEN
2486       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2487         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2488             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2489             'Num. of rows inserted into icx_cat_attribute_values_tlp:' ||SQL%ROWCOUNT);
2490       END IF;
2491     END IF;
2492 
2493     l_err_loc := 340;
2494     clearTables(l_action_mode);
2495 
2496     l_err_loc := 350;
2497     l_action_mode := 'UPDATE_CTX_HDRS';
2498     FORALL i in 1..gUHInventoryItemIdTbl.COUNT
2499       UPDATE icx_cat_items_ctx_hdrs_tlp
2500       SET ctx_desc = null,
2501           purchasing_org_id = gUHPurchasingOrgIdTbl(i),
2502           ip_category_id = gUHIpCategoryIdTbl(i),
2503           ip_category_name = gUHIpCategoryNameTbl(i),
2504           po_category_id = gUHPoCategoryIdTbl(i),
2505           supplier_id = gUHSupplierIdTbl(i),
2506           supplier_part_num = gUHSupplierPartNumTbl(i),
2507           supplier_part_auxid = gUHSupplierPartAuxidTbl(i),
2508           supplier_site_id = gUHSupplierSiteIdTbl(i),
2509           req_template_po_line_id = gUHReqTemplatePoLineIdTbl(i),
2510           item_revision = gUHItemRevisionTbl(i),
2511           po_header_id = gUHPoHeaderIdTbl(i),
2512           document_number = gUHDocumentNumberTbl(i),
2513           line_num = gUHLineNumTbl(i),
2514           allow_price_override_flag = gUHAllowPriceOverrideFlagTbl(i),
2515           not_to_exceed_price = gUHNotToExceedPriceTbl(i),
2516           line_type_id = gUHLineTypeIdTbl(i),
2517           unit_meas_lookup_code = gUHUnitMeasLookupCodeTbl(i),
2518           suggested_quantity = gUHSuggestedQuantityTbl(i),
2519           unit_price = gUHUnitPriceTbl(i),
2520           amount = gUHAmountTbl(i),
2521           currency_code = gUHCurrencyCodeTbl(i),
2522           rate_type = gUHRateTypeTbl(i),
2523           rate_date = gUHRateDateTbl(i),
2524           rate = gUHRateTbl(i),
2525           buyer_id = gUHBuyerIdTbl(i),
2526           supplier_contact_id = gUHSupplierContactIdTbl(i),
2527           rfq_required_flag = gUHRfqRequiredFlagTbl(i),
2528           negotiated_by_preparer_flag = gUHNegotiatedByPreparerFlagTbl(i),
2529           description = gUHDescriptionTbl(i),
2530           order_type_lookup_code = gUHOrderTypeLookupCodeTbl(i),
2531           supplier = gUHSupplierTbl(i),
2532           global_agreement_flag = gUHGlobalAgreementFlagTbl(i),
2533           merged_source_type = gUHMergedSourceTypeTbl(i),
2534           item_type = gUHItemTypeTbl(i),
2535           last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
2536           last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
2537           last_update_date = sysdate,
2538           internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
2539           request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
2540           program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
2541           program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
2542           program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
2543       WHERE inventory_item_id = gUHInventoryItemIdTbl(i)
2544       AND   po_line_id = gUHPoLineIdTbl(i)
2545       AND   req_template_name = gUHReqTemplateNameTbl(i)
2546       AND   req_template_line_num = gUHReqTemplateLineNumTbl(i)
2547       AND   org_id = gUHOrgIdTbl(i)
2548       AND   language = gUHLanguageTbl(i)
2549       AND   source_type = gUHSourceTypeTbl(i);
2550 
2551     IF (gUHInventoryItemIdTbl.COUNT > 0) THEN
2552       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2553         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2554             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2555             'Num. of rows updated in ctx_hdrs:' ||SQL%ROWCOUNT);
2556       END IF;
2557     END IF;
2558 
2559     l_err_loc := 405;
2560     l_action_mode := 'DELETE_TO_UPDATE_ATTR_VALUES';
2561 
2562      --BUG 6599217 Start3 : Here the po_attribute tables have stale data so update
2563      --the po_attribute tables with new values.
2564     if (p_current_cursor = ICX_CAT_UTIL_PVT.g_MasterItemCsr_const) then
2565 
2566      IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2567         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2568             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2569             'updating po attribute tables count=:' ||gUHInventoryItemIdTbl.Count);
2570      END IF;
2571 
2572 
2573     FOR i in 1..gUHInventoryItemIdTbl.Count Loop
2574 
2575         po_attribute_values_pvt.update_attributes_MI
2576         (
2577           p_org_id                => gUHOrgIdTbl(i),
2578           p_ip_category_id        => gUHIpCategoryIdTbl(i),
2579           p_inventory_item_id     => gUHInventoryItemIdTbl(i),
2580           p_language              => gUHLanguageTbl(i),
2581           p_item_description      => gUHDescriptionTbl(i),
2582           p_long_description      => gUHLongDescriptionTbl(i),
2583           p_organization_id       => gUHOrganizationIdTbl(i),
2584           p_master_organization_id => gUHMasterOrganizationIdTbl(i)
2585         );
2586      END LOOP;
2587     end if;
2588      --BUG 6599217 End 3
2589 
2590     FORALL i in 1..gUHInventoryItemIdTbl.COUNT
2591       DELETE FROM icx_cat_attribute_values
2592       WHERE inventory_item_id = gUHInventoryItemIdTbl(i)
2593       AND   po_line_id = gUHPoLineIdTbl(i)
2594       AND   req_template_name = gUHReqTemplateNameTbl(i)
2595       AND   req_template_line_num = gUHReqTemplateLineNumTbl(i)
2596       AND   org_id = gUHOrgIdTbl(i);
2597 
2598     IF (gUHInventoryItemIdTbl.COUNT > 0) THEN
2599       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2600         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2601             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2602             'Num. of rows deleted for update from icx_cat_attribute_values:' ||SQL%ROWCOUNT);
2603       END IF;
2604     END IF;
2605 
2606     l_err_loc := 415;
2607     l_action_mode := 'INSERT_TO_UPDATE_ATTR_VALUES';
2608     FORALL i in 1..gUHInventoryItemIdTbl.COUNT
2609       MERGE INTO icx_cat_attribute_values icav
2610       USING (SELECT *
2611              FROM po_attribute_values
2612              WHERE inventory_item_id = gUHInventoryItemIdTbl(i)
2613              AND   po_line_id = gUHPoLineIdTbl(i)
2614              AND   req_template_name = gUHReqTemplateNameTbl(i)
2615              AND   req_template_line_num = gUHReqTemplateLineNumTbl(i)
2616              AND   org_id = gUHOrgIdTbl(i)) temp
2617       ON (icav.inventory_item_id = temp.inventory_item_id AND
2618           icav.po_line_id = temp.po_line_id AND
2619           icav.req_template_name = temp.req_template_name AND
2620           icav.req_template_line_num = temp.req_template_line_num AND
2621           icav.org_id = temp.org_id)
2622       WHEN NOT MATCHED THEN INSERT VALUES (
2623           temp.attribute_values_id, temp.po_line_id, temp.req_template_name,
2624           temp.req_template_line_num, temp.ip_category_id, temp.inventory_item_id,
2625           temp.org_id, temp.manufacturer_part_num, temp.picture, temp.thumbnail_image,
2626           temp.supplier_url, temp.manufacturer_url, temp.attachment_url, temp.unspsc,
2627           temp.availability, temp.lead_time,
2628           temp.text_base_attribute1, temp.text_base_attribute2, temp.text_base_attribute3,
2629           temp.text_base_attribute4, temp.text_base_attribute5, temp.text_base_attribute6,
2630           temp.text_base_attribute7, temp.text_base_attribute8, temp.text_base_attribute9,
2631           temp.text_base_attribute10, temp.text_base_attribute11, temp.text_base_attribute12,
2632           temp.text_base_attribute13, temp.text_base_attribute14, temp.text_base_attribute15,
2633           temp.text_base_attribute16, temp.text_base_attribute17, temp.text_base_attribute18,
2634           temp.text_base_attribute19, temp.text_base_attribute20, temp.text_base_attribute21,
2635           temp.text_base_attribute22, temp.text_base_attribute23, temp.text_base_attribute24,
2636           temp.text_base_attribute25, temp.text_base_attribute26, temp.text_base_attribute27,
2637           temp.text_base_attribute28, temp.text_base_attribute29, temp.text_base_attribute30,
2638           temp.text_base_attribute31, temp.text_base_attribute32, temp.text_base_attribute33,
2639           temp.text_base_attribute34, temp.text_base_attribute35, temp.text_base_attribute36,
2640           temp.text_base_attribute37, temp.text_base_attribute38, temp.text_base_attribute39,
2641           temp.text_base_attribute40, temp.text_base_attribute41, temp.text_base_attribute42,
2642           temp.text_base_attribute43, temp.text_base_attribute44, temp.text_base_attribute45,
2643           temp.text_base_attribute46, temp.text_base_attribute47, temp.text_base_attribute48,
2644           temp.text_base_attribute49, temp.text_base_attribute50, temp.text_base_attribute51,
2645           temp.text_base_attribute52, temp.text_base_attribute53, temp.text_base_attribute54,
2646           temp.text_base_attribute55, temp.text_base_attribute56, temp.text_base_attribute57,
2647           temp.text_base_attribute58, temp.text_base_attribute59, temp.text_base_attribute60,
2648           temp.text_base_attribute61, temp.text_base_attribute62, temp.text_base_attribute63,
2649           temp.text_base_attribute64, temp.text_base_attribute65, temp.text_base_attribute66,
2650           temp.text_base_attribute67, temp.text_base_attribute68, temp.text_base_attribute69,
2651           temp.text_base_attribute70, temp.text_base_attribute71, temp.text_base_attribute72,
2652           temp.text_base_attribute73, temp.text_base_attribute74, temp.text_base_attribute75,
2653           temp.text_base_attribute76, temp.text_base_attribute77, temp.text_base_attribute78,
2654           temp.text_base_attribute79, temp.text_base_attribute80, temp.text_base_attribute81,
2655           temp.text_base_attribute82, temp.text_base_attribute83, temp.text_base_attribute84,
2656           temp.text_base_attribute85, temp.text_base_attribute86, temp.text_base_attribute87,
2657           temp.text_base_attribute88, temp.text_base_attribute89, temp.text_base_attribute90,
2658           temp.text_base_attribute91, temp.text_base_attribute92, temp.text_base_attribute93,
2659           temp.text_base_attribute94, temp.text_base_attribute95, temp.text_base_attribute96,
2660           temp.text_base_attribute97, temp.text_base_attribute98, temp.text_base_attribute99,
2661           temp.text_base_attribute100,
2662           temp.num_base_attribute1, temp.num_base_attribute2, temp.num_base_attribute3,
2663           temp.num_base_attribute4, temp.num_base_attribute5, temp.num_base_attribute6,
2664           temp.num_base_attribute7, temp.num_base_attribute8, temp.num_base_attribute9,
2665           temp.num_base_attribute10, temp.num_base_attribute11, temp.num_base_attribute12,
2666           temp.num_base_attribute13, temp.num_base_attribute14, temp.num_base_attribute15,
2667           temp.num_base_attribute16, temp.num_base_attribute17, temp.num_base_attribute18,
2668           temp.num_base_attribute19, temp.num_base_attribute20, temp.num_base_attribute21,
2669           temp.num_base_attribute22, temp.num_base_attribute23, temp.num_base_attribute24,
2670           temp.num_base_attribute25, temp.num_base_attribute26, temp.num_base_attribute27,
2671           temp.num_base_attribute28, temp.num_base_attribute29, temp.num_base_attribute30,
2672           temp.num_base_attribute31, temp.num_base_attribute32, temp.num_base_attribute33,
2673           temp.num_base_attribute34, temp.num_base_attribute35, temp.num_base_attribute36,
2674           temp.num_base_attribute37, temp.num_base_attribute38, temp.num_base_attribute39,
2675           temp.num_base_attribute40, temp.num_base_attribute41, temp.num_base_attribute42,
2676           temp.num_base_attribute43, temp.num_base_attribute44, temp.num_base_attribute45,
2677           temp.num_base_attribute46, temp.num_base_attribute47, temp.num_base_attribute48,
2678           temp.num_base_attribute49, temp.num_base_attribute50, temp.num_base_attribute51,
2679           temp.num_base_attribute52, temp.num_base_attribute53, temp.num_base_attribute54,
2680           temp.num_base_attribute55, temp.num_base_attribute56, temp.num_base_attribute57,
2681           temp.num_base_attribute58, temp.num_base_attribute59, temp.num_base_attribute60,
2682           temp.num_base_attribute61, temp.num_base_attribute62, temp.num_base_attribute63,
2683           temp.num_base_attribute64, temp.num_base_attribute65, temp.num_base_attribute66,
2684           temp.num_base_attribute67, temp.num_base_attribute68, temp.num_base_attribute69,
2685           temp.num_base_attribute70, temp.num_base_attribute71, temp.num_base_attribute72,
2686           temp.num_base_attribute73, temp.num_base_attribute74, temp.num_base_attribute75,
2687           temp.num_base_attribute76, temp.num_base_attribute77, temp.num_base_attribute78,
2688           temp.num_base_attribute79, temp.num_base_attribute80, temp.num_base_attribute81,
2689           temp.num_base_attribute82, temp.num_base_attribute83, temp.num_base_attribute84,
2690           temp.num_base_attribute85, temp.num_base_attribute86, temp.num_base_attribute87,
2691           temp.num_base_attribute88, temp.num_base_attribute89, temp.num_base_attribute90,
2692           temp.num_base_attribute91, temp.num_base_attribute92, temp.num_base_attribute93,
2693           temp.num_base_attribute94, temp.num_base_attribute95, temp.num_base_attribute96,
2694           temp.num_base_attribute97, temp.num_base_attribute98, temp.num_base_attribute99,
2695           temp.num_base_attribute100,
2696           temp.text_cat_attribute1, temp.text_cat_attribute2, temp.text_cat_attribute3,
2697           temp.text_cat_attribute4, temp.text_cat_attribute5, temp.text_cat_attribute6,
2698           temp.text_cat_attribute7, temp.text_cat_attribute8, temp.text_cat_attribute9,
2699           temp.text_cat_attribute10, temp.text_cat_attribute11, temp.text_cat_attribute12,
2700           temp.text_cat_attribute13, temp.text_cat_attribute14, temp.text_cat_attribute15,
2701           temp.text_cat_attribute16, temp.text_cat_attribute17, temp.text_cat_attribute18,
2702           temp.text_cat_attribute19, temp.text_cat_attribute20, temp.text_cat_attribute21,
2703           temp.text_cat_attribute22, temp.text_cat_attribute23, temp.text_cat_attribute24,
2704           temp.text_cat_attribute25, temp.text_cat_attribute26, temp.text_cat_attribute27,
2705           temp.text_cat_attribute28, temp.text_cat_attribute29, temp.text_cat_attribute30,
2706           temp.text_cat_attribute31, temp.text_cat_attribute32, temp.text_cat_attribute33,
2707           temp.text_cat_attribute34, temp.text_cat_attribute35, temp.text_cat_attribute36,
2708           temp.text_cat_attribute37, temp.text_cat_attribute38, temp.text_cat_attribute39,
2709           temp.text_cat_attribute40, temp.text_cat_attribute41, temp.text_cat_attribute42,
2710           temp.text_cat_attribute43, temp.text_cat_attribute44, temp.text_cat_attribute45,
2711           temp.text_cat_attribute46, temp.text_cat_attribute47, temp.text_cat_attribute48,
2712           temp.text_cat_attribute49, temp.text_cat_attribute50,
2713           temp.num_cat_attribute1, temp.num_cat_attribute2, temp.num_cat_attribute3,
2714           temp.num_cat_attribute4, temp.num_cat_attribute5, temp.num_cat_attribute6,
2715           temp.num_cat_attribute7, temp.num_cat_attribute8, temp.num_cat_attribute9,
2716           temp.num_cat_attribute10, temp.num_cat_attribute11, temp.num_cat_attribute12,
2717           temp.num_cat_attribute13, temp.num_cat_attribute14, temp.num_cat_attribute15,
2718           temp.num_cat_attribute16, temp.num_cat_attribute17, temp.num_cat_attribute18,
2719           temp.num_cat_attribute19, temp.num_cat_attribute20, temp.num_cat_attribute21,
2720           temp.num_cat_attribute22, temp.num_cat_attribute23, temp.num_cat_attribute24,
2721           temp.num_cat_attribute25, temp.num_cat_attribute26, temp.num_cat_attribute27,
2722           temp.num_cat_attribute28, temp.num_cat_attribute29, temp.num_cat_attribute30,
2723           temp.num_cat_attribute31, temp.num_cat_attribute32, temp.num_cat_attribute33,
2724           temp.num_cat_attribute34, temp.num_cat_attribute35, temp.num_cat_attribute36,
2725           temp.num_cat_attribute37, temp.num_cat_attribute38, temp.num_cat_attribute39,
2726           temp.num_cat_attribute40, temp.num_cat_attribute41, temp.num_cat_attribute42,
2727           temp.num_cat_attribute43, temp.num_cat_attribute44, temp.num_cat_attribute45,
2728           temp.num_cat_attribute46, temp.num_cat_attribute47, temp.num_cat_attribute48,
2729           temp.num_cat_attribute49, temp.num_cat_attribute50,
2730           temp.last_update_login, temp.last_updated_by, temp.last_update_date, temp.created_by,
2731           temp.creation_date, temp.request_id, temp.program_application_id, temp.program_id,
2732           temp.program_update_date, temp.last_updated_program, temp.rebuild_search_index_flag);
2733 
2734     IF (gUHInventoryItemIdTbl.COUNT > 0) THEN
2735       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2736         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2737             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2738             'Num. of rows updated into icx_cat_attribute_values:' ||SQL%ROWCOUNT);
2739       END IF;
2740     END IF;
2741 
2742     l_err_loc := 425;
2743     l_action_mode := 'DELETE_TO_UPDATE_ATTR_VALUES_TLP';
2744     FORALL i in 1..gUHInventoryItemIdTbl.COUNT
2745       DELETE FROM icx_cat_attribute_values_tlp
2746       WHERE inventory_item_id = gUHInventoryItemIdTbl(i)
2747       AND   po_line_id = gUHPoLineIdTbl(i)
2748       AND   req_template_name = gUHReqTemplateNameTbl(i)
2749       AND   req_template_line_num = gUHReqTemplateLineNumTbl(i)
2750       AND   org_id = gUHOrgIdTbl(i)
2751       AND   language = gUHLanguageTbl(i);
2752 
2753     IF (gUHInventoryItemIdTbl.COUNT > 0) THEN
2754       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2755         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2756             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2757             'Num. of rows deleted for update from icx_cat_attribute_values_tlp:' ||SQL%ROWCOUNT);
2758       END IF;
2759     END IF;
2760 
2761     l_err_loc := 435;
2762     l_action_mode := 'INSERT_TO_UPDATE_ATTR_VALUES_TLP';
2763     FORALL i in 1..gUHInventoryItemIdTbl.COUNT
2764       MERGE INTO icx_cat_attribute_values_tlp icavt
2765       USING (SELECT *
2766              FROM po_attribute_values_tlp
2767              WHERE inventory_item_id = gUHInventoryItemIdTbl(i)
2768              AND   po_line_id = gUHPoLineIdTbl(i)
2769              AND   req_template_name = gUHReqTemplateNameTbl(i)
2770              AND   req_template_line_num = gUHReqTemplateLineNumTbl(i)
2771              AND   org_id = gUHOrgIdTbl(i)
2772              AND   language = gUHLanguageTbl(i)) temp
2773       ON (icavt.inventory_item_id = temp.inventory_item_id AND
2774           icavt.po_line_id = temp.po_line_id AND
2775           icavt.req_template_name = temp.req_template_name AND
2776           icavt.req_template_line_num = temp.req_template_line_num AND
2777           icavt.org_id = temp.org_id AND
2778           icavt.language = temp.language)
2779       WHEN NOT MATCHED THEN INSERT VALUES (
2780           temp.attribute_values_tlp_id, temp.po_line_id, temp.req_template_name,
2781           temp.req_template_line_num, temp.ip_category_id, temp.inventory_item_id,
2782           temp.org_id, temp.language, temp.description, temp.manufacturer,
2783           temp.comments, temp.alias, temp.long_description,
2784           temp.tl_text_base_attribute1, temp.tl_text_base_attribute2, temp.tl_text_base_attribute3,
2785           temp.tl_text_base_attribute4, temp.tl_text_base_attribute5, temp.tl_text_base_attribute6,
2786           temp.tl_text_base_attribute7, temp.tl_text_base_attribute8, temp.tl_text_base_attribute9,
2787           temp.tl_text_base_attribute10, temp.tl_text_base_attribute11, temp.tl_text_base_attribute12,
2788           temp.tl_text_base_attribute13, temp.tl_text_base_attribute14, temp.tl_text_base_attribute15,
2789           temp.tl_text_base_attribute16, temp.tl_text_base_attribute17, temp.tl_text_base_attribute18,
2790           temp.tl_text_base_attribute19, temp.tl_text_base_attribute20, temp.tl_text_base_attribute21,
2791           temp.tl_text_base_attribute22, temp.tl_text_base_attribute23, temp.tl_text_base_attribute24,
2792           temp.tl_text_base_attribute25, temp.tl_text_base_attribute26, temp.tl_text_base_attribute27,
2793           temp.tl_text_base_attribute28, temp.tl_text_base_attribute29, temp.tl_text_base_attribute30,
2794           temp.tl_text_base_attribute31, temp.tl_text_base_attribute32, temp.tl_text_base_attribute33,
2795           temp.tl_text_base_attribute34, temp.tl_text_base_attribute35, temp.tl_text_base_attribute36,
2796           temp.tl_text_base_attribute37, temp.tl_text_base_attribute38, temp.tl_text_base_attribute39,
2797           temp.tl_text_base_attribute40, temp.tl_text_base_attribute41, temp.tl_text_base_attribute42,
2798           temp.tl_text_base_attribute43, temp.tl_text_base_attribute44, temp.tl_text_base_attribute45,
2799           temp.tl_text_base_attribute46, temp.tl_text_base_attribute47, temp.tl_text_base_attribute48,
2800           temp.tl_text_base_attribute49, temp.tl_text_base_attribute50, temp.tl_text_base_attribute51,
2801           temp.tl_text_base_attribute52, temp.tl_text_base_attribute53, temp.tl_text_base_attribute54,
2802           temp.tl_text_base_attribute55, temp.tl_text_base_attribute56, temp.tl_text_base_attribute57,
2803           temp.tl_text_base_attribute58, temp.tl_text_base_attribute59, temp.tl_text_base_attribute60,
2804           temp.tl_text_base_attribute61, temp.tl_text_base_attribute62, temp.tl_text_base_attribute63,
2805           temp.tl_text_base_attribute64, temp.tl_text_base_attribute65, temp.tl_text_base_attribute66,
2806           temp.tl_text_base_attribute67, temp.tl_text_base_attribute68, temp.tl_text_base_attribute69,
2807           temp.tl_text_base_attribute70, temp.tl_text_base_attribute71, temp.tl_text_base_attribute72,
2808           temp.tl_text_base_attribute73, temp.tl_text_base_attribute74, temp.tl_text_base_attribute75,
2809           temp.tl_text_base_attribute76, temp.tl_text_base_attribute77, temp.tl_text_base_attribute78,
2810           temp.tl_text_base_attribute79, temp.tl_text_base_attribute80, temp.tl_text_base_attribute81,
2811           temp.tl_text_base_attribute82, temp.tl_text_base_attribute83, temp.tl_text_base_attribute84,
2812           temp.tl_text_base_attribute85, temp.tl_text_base_attribute86, temp.tl_text_base_attribute87,
2813           temp.tl_text_base_attribute88, temp.tl_text_base_attribute89, temp.tl_text_base_attribute90,
2814           temp.tl_text_base_attribute91, temp.tl_text_base_attribute92, temp.tl_text_base_attribute93,
2815           temp.tl_text_base_attribute94, temp.tl_text_base_attribute95, temp.tl_text_base_attribute96,
2816           temp.tl_text_base_attribute97, temp.tl_text_base_attribute98, temp.tl_text_base_attribute99,
2817           temp.tl_text_base_attribute100,
2818           temp.tl_text_cat_attribute1, temp.tl_text_cat_attribute2, temp.tl_text_cat_attribute3,
2819           temp.tl_text_cat_attribute4, temp.tl_text_cat_attribute5, temp.tl_text_cat_attribute6,
2820           temp.tl_text_cat_attribute7, temp.tl_text_cat_attribute8, temp.tl_text_cat_attribute9,
2821           temp.tl_text_cat_attribute10, temp.tl_text_cat_attribute11, temp.tl_text_cat_attribute12,
2822           temp.tl_text_cat_attribute13, temp.tl_text_cat_attribute14, temp.tl_text_cat_attribute15,
2823           temp.tl_text_cat_attribute16, temp.tl_text_cat_attribute17, temp.tl_text_cat_attribute18,
2824           temp.tl_text_cat_attribute19, temp.tl_text_cat_attribute20, temp.tl_text_cat_attribute21,
2825           temp.tl_text_cat_attribute22, temp.tl_text_cat_attribute23, temp.tl_text_cat_attribute24,
2826           temp.tl_text_cat_attribute25, temp.tl_text_cat_attribute26, temp.tl_text_cat_attribute27,
2827           temp.tl_text_cat_attribute28, temp.tl_text_cat_attribute29, temp.tl_text_cat_attribute30,
2828           temp.tl_text_cat_attribute31, temp.tl_text_cat_attribute32, temp.tl_text_cat_attribute33,
2829           temp.tl_text_cat_attribute34, temp.tl_text_cat_attribute35, temp.tl_text_cat_attribute36,
2830           temp.tl_text_cat_attribute37, temp.tl_text_cat_attribute38, temp.tl_text_cat_attribute39,
2831           temp.tl_text_cat_attribute40, temp.tl_text_cat_attribute41, temp.tl_text_cat_attribute42,
2832           temp.tl_text_cat_attribute43, temp.tl_text_cat_attribute44, temp.tl_text_cat_attribute45,
2833           temp.tl_text_cat_attribute46, temp.tl_text_cat_attribute47, temp.tl_text_cat_attribute48,
2834           temp.tl_text_cat_attribute49, temp.tl_text_cat_attribute50,
2835           temp.last_update_login, temp.last_updated_by, temp.last_update_date, temp.created_by,
2836           temp.creation_date, temp.request_id, temp.program_application_id, temp.program_id,
2837           temp.program_update_date, temp.last_updated_program, temp.rebuild_search_index_flag);
2838 
2839     IF (gUHInventoryItemIdTbl.COUNT > 0) THEN
2840       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2841         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2842             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2843             'Num. of rows updated into icx_cat_attribute_values_tlp:' ||SQL%ROWCOUNT);
2844       END IF;
2845     END IF;
2846 
2847     l_err_loc := 440;
2848     clearTables(l_action_mode);
2849 
2850     l_err_loc := 450;
2851     l_action_mode := 'DELETE_CTX_DTLS';
2852     FORALL i in 1..gDDInventoryItemIdTbl.COUNT
2853       DELETE FROM icx_cat_items_ctx_dtls_tlp
2854       WHERE inventory_item_id = gDDInventoryItemIdTbl(i)
2855       AND   po_line_id = gDDPoLineIdTbl(i)
2856       AND   req_template_name = gDDReqTemplateNameTbl(i)
2857       AND   req_template_line_num = gDDReqTemplateLineNumTbl(i)
2858       AND   org_id = gDDOrgIdTbl(i)
2859       AND   language = gDDLanguageTbl(i);
2860 
2861     IF (gDDInventoryItemIdTbl.COUNT > 0) THEN
2862       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2863         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2864             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2865             'Num. of rows deleted from ctx_dtls:' ||SQL%ROWCOUNT);
2866       END IF;
2867     END IF;
2868 
2869     l_err_loc := 500;
2870     clearTables(l_action_mode);
2871 
2872     l_err_loc := 550;
2873     l_action_mode := 'DELETE_CTX_HDRS';
2874     FORALL i in 1..gDHInventoryItemIdTbl.COUNT
2875       DELETE FROM icx_cat_items_ctx_hdrs_tlp
2876       WHERE inventory_item_id = gDHInventoryItemIdTbl(i)
2877       AND   po_line_id = gDHPoLineIdTbl(i)
2878       AND   req_template_name = gDHReqTemplateNameTbl(i)
2879       AND   req_template_line_num = gDHReqTemplateLineNumTbl(i)
2880       AND   org_id = gDHOrgIdTbl(i)
2881       AND   language = gDHLanguageTbl(i);
2882 
2883     IF (gDHInventoryItemIdTbl.COUNT > 0) THEN
2884       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2885         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2886             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2887             'Num. of rows deleted from ctx_hdrs:' ||SQL%ROWCOUNT);
2888       END IF;
2889     END IF;
2890 
2891     l_err_loc := 610;
2892     l_action_mode := 'DELETE_ATTR_VALUES';
2893     FORALL i in 1..gDHInventoryItemIdTbl.COUNT
2894       DELETE FROM icx_cat_attribute_values
2895       WHERE inventory_item_id = gDHInventoryItemIdTbl(i)
2896       AND   po_line_id = gDHPoLineIdTbl(i)
2897       AND   req_template_name = gDHReqTemplateNameTbl(i)
2898       AND   req_template_line_num = gDHReqTemplateLineNumTbl(i)
2899       AND   org_id = gDHOrgIdTbl(i);
2900 
2901     IF (gDHInventoryItemIdTbl.COUNT > 0) THEN
2902       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2903         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2904             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2905             'Num. of rows deleted from icx_Cat_attribute_values:' ||SQL%ROWCOUNT);
2906       END IF;
2907     END IF;
2908 
2909     l_err_loc := 630;
2910     l_action_mode := 'DELETE_ATTR_VALUES_TLP';
2911     FORALL i in 1..gDHInventoryItemIdTbl.COUNT
2912       DELETE FROM icx_cat_attribute_values_tlp
2913       WHERE inventory_item_id = gDHInventoryItemIdTbl(i)
2914       AND   po_line_id = gDHPoLineIdTbl(i)
2915       AND   req_template_name = gDHReqTemplateNameTbl(i)
2916       AND   req_template_line_num = gDHReqTemplateLineNumTbl(i)
2917       AND   org_id = gDHOrgIdTbl(i)
2918       AND   language = gDHLanguageTbl(i);
2919 
2920     IF (gDHInventoryItemIdTbl.COUNT > 0) THEN
2921       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2922         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2923             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2924             'Num. of rows deleted from icx_Cat_attribute_values_tlp:' ||SQL%ROWCOUNT);
2925       END IF;
2926     END IF;
2927 
2928     l_err_loc := 640;
2929     clearTables(l_action_mode);
2930 
2931     -- For gIDInventoryItemIdTbl:    populate all rows between 1 and 15001
2932     -- Need to populate base, local and org attributes i.e. rows with sequence between 1 and 15001
2933     -- 1a. Rows with sequence between 1 and 100 (i.e. base special attributes) will be populated here.
2934     -- 1b. Rows with sequence between 101 and 5000 (i.e. base regular attributes) will be populated here.
2935     -- 2. Rows with sequence between 10000 and 15001 (i.e. org attributes)
2936     --    will be populated below
2937     -- 3. Rows with sequence between 5001 and 9999 (i.e. catg/local attributes)
2938     --    will be populated in the final call to ICX_CAT_POPULATE_CTXSTRING_PVT.populateCtxCatgAtt
2939     -- For gDBLDInventoryItemIdTbl:  re-populate only rows between 101 and 5000
2940     -- Need to re-populate only non-seeded base attributes and local attributes i.e. rows with sequence between 101 and 5000
2941     -- 1. Rows with sequence between 101 and 5000 (i.e. base regular attributes) will be populated here.
2942     -- 2. Rows with sequence between 5001 and 9999 (i.e. catg/local attributes)
2943     --    will be populated in the final call to ICX_CAT_POPULATE_CTXSTRING_PVT.populateCtxCatgAtt
2944     --    CategoryAttributes will be deleted for gDBLDInventoryItemIdTbl here, but will be
2945     --    inserted back using ICX_CAT_POPULATE_CTXSTRING_PVT.populateCtxCatgAtt
2946     -- For gDMDInventoryItemIdTbl: re-populate only the row with sequence = 1           <=> Mandatory row
2947     -- For gDSDInventoryItemIdTbl: re-populate only the row with sequence = 2           <=> Supplier row
2948     -- For gDIRDInventoryItemIdTbl: re-populate only the row with sequence = 5          <=> Item Revision row
2949     -- For gDSCDInventoryItemIdTbl: re-populate only the row with sequence = 6          <=> Shopping Category row
2950     -- For gDPODInventoryItemIdTbl: re-populate only the row with sequence = 15001      <=> purchasing_org_id row
2951 
2952     l_err_loc := 650;
2953     IF (gIDInventoryItemIdTbl.COUNT > 0 OR
2954         gDBLDInventoryItemIdTbl.COUNT > 0 OR
2955         gDMDInventoryItemIdTbl.COUNT > 0 OR
2956         gDSDInventoryItemIdTbl.COUNT > 0 OR
2957         gDIRDInventoryItemIdTbl.COUNT > 0 OR
2958         gDSCDInventoryItemIdTbl.COUNT > 0 OR
2959         gDPODInventoryItemIdTbl.COUNT > 0 )
2960     THEN
2961       l_err_loc := 700;
2962       l_special_ctx_sql_tbl.DELETE;
2963       l_regular_ctx_sql_tbl.DELETE;
2964 
2965       IF (p_current_cursor IN (ICX_CAT_UTIL_PVT.g_BPACsr_const,
2966                                ICX_CAT_UTIL_PVT.g_QuoteCsr_const,
2967                                ICX_CAT_UTIL_PVT.g_GBPACsr_const))
2968       THEN
2969         l_err_loc := 750;
2970         ICX_CAT_POPULATE_PODOCS_PVT.buildCtxSqlForPODocs(l_special_ctx_sql_tbl, l_regular_ctx_sql_tbl);
2971 
2972       ELSIF (p_current_cursor = ICX_CAT_UTIL_PVT.g_ReqTemplateCsr_const) THEN
2973         l_err_loc := 800;
2974         ICX_CAT_POPULATE_REQTMPL_PVT.buildCtxSqlForRTs(l_special_ctx_sql_tbl, l_regular_ctx_sql_tbl);
2975 
2976       ELSIF (p_current_cursor = ICX_CAT_UTIL_PVT.g_MasterItemCsr_const) THEN
2977         l_err_loc := 900;
2978         ICX_CAT_POPULATE_MI_PVT.buildCtxSqlForMIs(l_special_ctx_sql_tbl, l_regular_ctx_sql_tbl);
2979       END IF;
2980     END IF;
2981 
2982     l_err_loc := 1050;
2983     l_action_mode := 'DELETE_MANDATORY_ROW_CTX_DTLS';
2984     -- DELETE rows with sequence = 1 in icx_cat_items_ctx_dtl_tlp
2985     -- l_sequence := 1;
2986     FORALL i in 1..gDMDInventoryItemIdTbl.COUNT
2987       DELETE FROM icx_cat_items_ctx_dtls_tlp
2988       WHERE inventory_item_id = gDMDInventoryItemIdTbl(i)
2989       AND   po_line_id = gDMDPoLineIdTbl(i)
2990       AND   req_template_name = gDMDReqTemplateNameTbl(i)
2991       AND   req_template_line_num = gDMDReqTemplateLineNumTbl(i)
2992       AND   org_id = gDMDOrgIdTbl(i)
2993       AND   language = gDMDLanguageTbl(i)
2994       AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqMandatoryBaseRow;
2995 
2996     IF (gDMDInventoryItemIdTbl.COUNT > 0) THEN
2997       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2998         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2999             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3000             'Num. of rows deleted from ctx_dtls for mandatory row changes:' ||SQL%ROWCOUNT);
3001       END IF;
3002     END IF;
3003 
3004     l_err_loc := 1100;
3005     l_action_mode := 'DELETE_SUPPLIER_ROW_CTX_DTLS';
3006     -- DELETE rows with sequence = 2 in icx_cat_items_ctx_dtl_tlp
3007     -- l_sequence := 2;
3008     FORALL i in 1..gDSDInventoryItemIdTbl.COUNT
3009       DELETE FROM icx_cat_items_ctx_dtls_tlp
3010       WHERE inventory_item_id = gDSDInventoryItemIdTbl(i)
3011       AND   po_line_id = gDSDPoLineIdTbl(i)
3012       AND   req_template_name = gDSDReqTemplateNameTbl(i)
3013       AND   req_template_line_num = gDSDReqTemplateLineNumTbl(i)
3014       AND   org_id = gDSDOrgIdTbl(i)
3015       AND   language = gDSDLanguageTbl(i)
3016       AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForSupplierRow;
3017 
3018     IF (gDSDInventoryItemIdTbl.COUNT > 0) THEN
3019       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3020         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3021             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3022             'Num. of rows deleted from ctx_dtls for supplier row changes:' ||SQL%ROWCOUNT);
3023       END IF;
3024     END IF;
3025 
3026     l_err_loc := 1150;
3027     l_action_mode := 'DELETE_ITEMREV_ROW_CTX_DTLS';
3028     -- DELETE rows with sequence = 5 in icx_cat_items_ctx_dtl_tlp
3029     -- l_sequence := 5;
3030     FORALL i in 1..gDIRDInventoryItemIdTbl.COUNT
3031       DELETE FROM icx_cat_items_ctx_dtls_tlp
3032       WHERE inventory_item_id = gDIRDInventoryItemIdTbl(i)
3033       AND   po_line_id = gDIRDPoLineIdTbl(i)
3034       AND   req_template_name = gDIRDReqTemplateNameTbl(i)
3035       AND   req_template_line_num = gDIRDReqTemplateLineNumTbl(i)
3036       AND   org_id = gDIRDOrgIdTbl(i)
3037       AND   language = gDIRDLanguageTbl(i)
3038       AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForItemRevisionRow;
3039 
3040     IF (gDIRDInventoryItemIdTbl.COUNT > 0) THEN
3041       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3042         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3043             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3044             'Num. of rows deleted from ctx_dtls for item revision row changes:' ||SQL%ROWCOUNT);
3045       END IF;
3046     END IF;
3047 
3048     l_err_loc := 1200;
3049     l_action_mode := 'DELETE_SHOPCATG_ROW_CTX_DTLS';
3050     -- DELETE rows with sequence = 6 in icx_cat_items_ctx_dtl_tlp
3051     -- l_sequence := 6;
3052     FORALL i in 1..gDSCDInventoryItemIdTbl.COUNT
3053       DELETE FROM icx_cat_items_ctx_dtls_tlp
3054       WHERE inventory_item_id = gDSCDInventoryItemIdTbl(i)
3055       AND   po_line_id = gDSCDPoLineIdTbl(i)
3056       AND   req_template_name = gDSCDReqTemplateNameTbl(i)
3057       AND   req_template_line_num = gDSCDReqTemplateLineNumTbl(i)
3058       AND   org_id = gDSCDOrgIdTbl(i)
3059       AND   language = gDSCDLanguageTbl(i)
3060       AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForShoppingCategoryRow;
3061 
3062     IF (gDSCDInventoryItemIdTbl.COUNT > 0) THEN
3063       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3064         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3065             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3066             'Num. of rows deleted from ctx_dtls for shop category row changes:' ||SQL%ROWCOUNT);
3067       END IF;
3068     END IF;
3069 
3070     l_err_loc := 1250;
3071     l_action_mode := 'DELETE_PURCHORG_ROW_CTX_DTLS';
3072     -- DELETE rows with sequence = 15001 in icx_cat_items_ctx_dtl_tlp
3073     -- l_sequence := 15001;
3074     FORALL i in 1..gDPODInventoryItemIdTbl.COUNT
3075       DELETE FROM icx_cat_items_ctx_dtls_tlp
3076       WHERE inventory_item_id = gDPODInventoryItemIdTbl(i)
3077       AND   po_line_id = gDPODPoLineIdTbl(i)
3078       AND   req_template_name = gDPODReqTemplateNameTbl(i)
3079       AND   req_template_line_num = gDPODReqTemplateLineNumTbl(i)
3080       AND   org_id = gDPODOrgIdTbl(i)
3081       AND   language = gDPODLanguageTbl(i)
3082       AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForPurchasingOrgIdRow;
3083 
3084     IF (gDPODInventoryItemIdTbl.COUNT > 0) THEN
3085       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3086         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3087             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3088             'Num. of rows deleted from ctx_dtls for purch org row changes:' ||SQL%ROWCOUNT);
3089       END IF;
3090     END IF;
3091 -- Bug 7691407 - Added logic to delete and insert the dtls ctx tables for
3092 -- internal item number
3093     l_err_loc := 1300;
3094     l_action_mode := 'DELETE_SPECIFIC_CTX_DTLS';
3095     -- DELETE rows with sequence > 100 and < 10000 icx_cat_items_ctx_dtl_tlp
3096     l_start_sequence := 101;
3097     l_end_sequence := 9999;
3098     FORALL i in 1..gDBLDInventoryItemIdTbl.COUNT
3099       DELETE FROM icx_cat_items_ctx_dtls_tlp
3100       WHERE inventory_item_id = gDBLDInventoryItemIdTbl(i)
3101       AND   po_line_id = gDBLDPoLineIdTbl(i)
3102       AND   req_template_name = gDBLDReqTemplateNameTbl(i)
3103       AND   req_template_line_num = gDBLDReqTemplateLineNumTbl(i)
3104       AND   org_id = gDBLDOrgIdTbl(i)
3105       AND   language = gDBLDLanguageTbl(i)
3106       AND   ((sequence BETWEEN l_start_sequence AND l_end_sequence) OR SEQUENCE = 3);
3107 
3108     IF (gDBLDInventoryItemIdTbl.COUNT > 0) THEN
3109       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3110         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3111             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3112             'Num. of rows deleted from ctx_dtls for base and local row changes:' ||SQL%ROWCOUNT);
3113       END IF;
3114     END IF;
3115 
3116     l_err_loc := 1350;
3117     l_action_mode := 'INSERT_CTX_DTLS';
3118     -- populate the org rows in ctx details
3119     --  sequence        ctx_desc
3120     --  10000           <orgid>
3121     --  10001           to_char(gIDOrgIdTbl(i))
3122     --  15000           </orgid>
3123     --  15001           <purchorgid> || to_char(gIDPurchasingOrgIdTbl(i)) || </purchorgid>
3124     --  15001           <purchorgid> || to_char(gDPODPurchasingOrgIdTbl(i)) || </purchorgid>
3125     FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3126       INSERT INTO icx_cat_items_ctx_dtls_tlp
3127       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3128        org_id, language, sequence, ctx_desc,
3129        last_update_login, last_updated_by, last_update_date,
3130        created_by, creation_date, internal_request_id, request_id,
3131        program_application_id, program_id, program_login_id)
3132       VALUES(gIDInventoryItemIdTbl(i), gIDPoLineIdTbl(i), gIDReqTemplateNameTbl(i), gIDReqTemplateLineNumTbl(i),
3133        gIDOrgIdTbl(i), gIDLanguageTbl(i), 10000, '<orgid>',
3134        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3135        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3136        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3137        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3138        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3139        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3140        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3141        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3142 
3143     l_err_loc := 1400;
3144     FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3145       INSERT INTO icx_cat_items_ctx_dtls_tlp
3146       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3147        org_id, language, sequence, ctx_desc,
3148        last_update_login, last_updated_by, last_update_date,
3149        created_by, creation_date, internal_request_id, request_id,
3150        program_application_id, program_id, program_login_id)
3151       VALUES(gIDInventoryItemIdTbl(i), gIDPoLineIdTbl(i), gIDReqTemplateNameTbl(i), gIDReqTemplateLineNumTbl(i),
3152        gIDOrgIdTbl(i), gIDLanguageTbl(i), 10001, to_char(gIDOrgIdTbl(i)),
3153        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3154        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3155        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3156        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3157        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3158        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3159        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3160        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3161 
3162     l_err_loc := 1450;
3163     FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3164       INSERT INTO icx_cat_items_ctx_dtls_tlp
3165       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3166        org_id, language, sequence, ctx_desc,
3167        last_update_login, last_updated_by, last_update_date,
3168        created_by, creation_date, internal_request_id, request_id,
3169        program_application_id, program_id, program_login_id)
3170       VALUES(gIDInventoryItemIdTbl(i), gIDPoLineIdTbl(i), gIDReqTemplateNameTbl(i), gIDReqTemplateLineNumTbl(i),
3171        gIDOrgIdTbl(i), gIDLanguageTbl(i), 15000, '</orgid>',
3172        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3173        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3174        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3175        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3176        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3177        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3178        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3179        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3180 
3181     IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3182       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3183         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3184             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3185             'Num. of rows inserted into ctx_dtls for org row:' ||SQL%ROWCOUNT);
3186       END IF;
3187     END IF;
3188 
3189     l_err_loc := 1460;
3190     -- Purchasing_org_id row needs to be populated for new rows i.e. gIDInventoryItemIdTbl and gDPODInventoryItemIdTbl
3191     FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3192       INSERT INTO icx_cat_items_ctx_dtls_tlp
3193       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3194        org_id, language, sequence, ctx_desc,
3195        last_update_login, last_updated_by, last_update_date,
3196        created_by, creation_date, internal_request_id, request_id,
3197        program_application_id, program_id, program_login_id)
3198       VALUES(gIDInventoryItemIdTbl(i), gIDPoLineIdTbl(i), gIDReqTemplateNameTbl(i), gIDReqTemplateLineNumTbl(i),
3199        gIDOrgIdTbl(i), gIDLanguageTbl(i), 15001, '<purchorgid>' || to_char(gIDPurchasingOrgIdTbl(i)) || '</purchorgid>',
3200        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3201        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3202        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3203        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3204        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3205        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3206        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3207        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3208 
3209     IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3210       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3211         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3212             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3213             'Num. of rows inserted into ctx_dtls for purch_org row:' ||SQL%ROWCOUNT);
3214       END IF;
3215     END IF;
3216 
3217     l_err_loc := 1500;
3218     l_action_mode := 'DELETE_PURCHORG_ROW_CTX_DTLS';
3219     -- Purchasing_org_id row needs to be populated for new rows i.e. gIDInventoryItemIdTbl and gDPODInventoryItemIdTbl
3220     FORALL i in 1..gDPODInventoryItemIdTbl.COUNT
3221       INSERT INTO icx_cat_items_ctx_dtls_tlp
3222       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3223        org_id, language, sequence, ctx_desc,
3224        last_update_login, last_updated_by, last_update_date,
3225        created_by, creation_date, internal_request_id, request_id,
3226        program_application_id, program_id, program_login_id)
3227       VALUES(gDPODInventoryItemIdTbl(i), gDPODPoLineIdTbl(i), gDPODReqTemplateNameTbl(i), gDPODReqTemplateLineNumTbl(i),
3228        gDPODOrgIdTbl(i), gDPODLanguageTbl(i), 15001, '<purchorgid>' || to_char(gDPODPurchasingOrgIdTbl(i)) || '</purchorgid>',
3229        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3230        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3231        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3232        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3233        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3234        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3235        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3236        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3237 
3238     IF (gDPODInventoryItemIdTbl.COUNT > 0) THEN
3239       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3240         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3241             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3242             'Num. of rows inserted into ctx_dtls for purch_org row:' ||SQL%ROWCOUNT);
3243       END IF;
3244     END IF;
3245 
3246     l_err_loc := 1550;
3247     -- Inserting rows for special attribute rows i.e. sequence between 1 and 100
3248     IF (gIDInventoryItemIdTbl.COUNT > 0 OR
3249         gDMDInventoryItemIdTbl.COUNT > 0 OR
3250         gDSDInventoryItemIdTbl.COUNT > 0 OR
3251         gDIRDInventoryItemIdTbl.COUNT > 0 OR
3252         gDSCDInventoryItemIdTbl.COUNT > 0 OR
3253         gDBLDInventoryItemIdTbl.Count > 0) THEN
3254       FOR i IN 1..l_special_ctx_sql_tbl.COUNT LOOP
3255         l_err_loc := 1600;
3256         l_ctx_sqlstring_rec := l_special_ctx_sql_tbl(i);
3257         l_ctx_sql_string := l_ctx_sqlstring_rec.ctx_sql_string;
3258         l_sequence := l_ctx_sqlstring_rec.bind_sequence;
3259         IF (p_current_cursor = ICX_CAT_UTIL_PVT.g_GBPACsr_const AND i > 1) THEN
3260           -- For GBPAs enabled org we only need to populate the row with sequence 1
3261           -- diffferntly than the owning org.  The other rows i.e. between sequence 2 to 9999
3262           -- will be exact copies of owning org
3263           EXIT;
3264         END IF;
3265         l_err_loc := 1650;
3266         l_csr_handle:=DBMS_SQL.OPEN_CURSOR;
3267         l_err_loc := 1700;
3268         DBMS_SQL.PARSE(l_csr_handle, l_ctx_sql_string, DBMS_SQL.NATIVE);
3269         IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3270           l_err_loc := 1750;
3271           l_action_mode := 'INSERT_CTX_DTLS';
3272           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3273           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gIDInventoryItemIdTbl);
3274           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gIDPoLineIdTbl);
3275           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gIDReqTemplateNameTbl);
3276           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gIDReqTemplateLineNumTbl);
3277           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gIDOrgIdTbl);
3278           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gIDLanguageTbl);
3279           l_err_loc := 1800;
3280           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3281           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3282             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3283                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3284                 'special Ctx SQLS details..' ||
3285                 '; Num. of rows in dtls plsql table:' || gIDInventoryItemIdTbl.COUNT ||
3286                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3287           END IF;
3288         END IF;
3289 
3290         IF (l_sequence = 1 AND gDMDInventoryItemIdTbl.COUNT > 0) THEN
3291           l_err_loc := 1850;
3292           l_action_mode := 'DELETE_MANDATORY_ROW_CTX_DTLS';
3293           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3294           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDMDInventoryItemIdTbl);
3295           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDMDPoLineIdTbl);
3296           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDMDReqTemplateNameTbl);
3297           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDMDReqTemplateLineNumTbl);
3298           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDMDOrgIdTbl);
3299           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDMDLanguageTbl);
3300           l_err_loc := 1900;
3301           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3302           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3303             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3304                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3305                 'special Ctx SQLS, Mandatory Row details..' ||
3306                 '; Num. of rows in dtls plsql table:' || gDMDInventoryItemIdTbl.COUNT ||
3307                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3308           END IF;
3309         END IF;
3310 
3311         IF (l_sequence = 2 AND gDSDInventoryItemIdTbl.COUNT > 0) THEN
3312           l_err_loc := 1950;
3313           l_action_mode := 'DELETE_SUPPLIER_ROW_CTX_DTLS';
3314           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3315           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDSDInventoryItemIdTbl);
3316           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDSDPoLineIdTbl);
3317           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDSDReqTemplateNameTbl);
3318           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDSDReqTemplateLineNumTbl);
3319           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDSDOrgIdTbl);
3320           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDSDLanguageTbl);
3321           l_err_loc := 2000;
3322           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3323           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3324             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3325                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3326                 'special Ctx SQLS, Supplier Row details..' ||
3327                 '; Num. of rows in dtls plsql table:' || gDSDInventoryItemIdTbl.COUNT ||
3328                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3329           END IF;
3330         END IF;
3331 -- Bug 7691407 - Added logic to delete and insert the dtls ctx tables for
3332 -- internal item number
3333         IF (l_sequence = 3 AND gDBLDInventoryItemIdTbl.COUNT > 0) THEN
3334           l_err_loc := 2010;
3335           l_action_mode := 'DELETE_SPECIFIC_CTX_DTLS';
3336           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3337           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDBLDInventoryItemIdTbl);
3338           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDBLDPoLineIdTbl);
3339           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDBLDReqTemplateNameTbl);
3340           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDBLDReqTemplateLineNumTbl);
3341           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDBLDOrgIdTbl);
3342           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDBLDLanguageTbl);
3343           l_err_loc := 2020;
3344           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3345           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3346             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3347                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3348                 'special Ctx SQLS, Item Number details..' ||
3349                 '; Num. of rows in dtls plsql table:' || gDBLDInventoryItemIdTbl.COUNT ||
3350                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3351           END IF;
3352         END IF;
3353 
3354         IF (l_sequence = 5 AND gDIRDInventoryItemIdTbl.COUNT > 0) THEN
3355           l_err_loc := 2050;
3356           l_action_mode := 'DELETE_ITEMREV_ROW_CTX_DTLS';
3357           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3358           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDIRDInventoryItemIdTbl);
3359           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDIRDPoLineIdTbl);
3360           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDIRDReqTemplateNameTbl);
3361           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDIRDReqTemplateLineNumTbl);
3362           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDIRDOrgIdTbl);
3363           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDIRDLanguageTbl);
3364           l_err_loc := 2100;
3365           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3366           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3367             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3368                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3369                 'special Ctx SQLS, ItemRev Row details..' ||
3370                 '; Num. of rows in dtls plsql table:' || gDIRDInventoryItemIdTbl.COUNT ||
3371                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3372           END IF;
3373         END IF;
3374 
3375         IF (l_sequence = 6 AND gDSCDInventoryItemIdTbl.COUNT > 0) THEN
3376           l_err_loc := 2150;
3377           l_action_mode := 'DELETE_SHOPCATG_ROW_CTX_DTLS';
3378           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3379           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDSCDInventoryItemIdTbl);
3380           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDSCDPoLineIdTbl);
3381           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDSCDReqTemplateNameTbl);
3382           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDSCDReqTemplateLineNumTbl);
3383           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDSCDOrgIdTbl);
3384           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDSCDLanguageTbl);
3385           l_err_loc := 2200;
3386           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3387           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3388             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3389                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3390                 'special Ctx SQLS, ShopCatg Row details..' ||
3391                 '; Num. of rows in dtls plsql table:' || gDSCDInventoryItemIdTbl.COUNT ||
3392                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3393           END IF;
3394         END IF;
3395 
3396         l_err_loc := 2250;
3397         DBMS_SQL.CLOSE_CURSOR(l_csr_handle);
3398         l_err_loc := 10000 + i;
3399       END LOOP;
3400     END IF;
3401 
3402     l_err_loc :=2300;
3403     -- Inserting rows for base attribute rows i.e. sequence between 101 and 5000
3404     IF (p_current_cursor = ICX_CAT_UTIL_PVT.g_GBPACsr_const) THEN
3405       l_err_loc := 2400;
3406       l_action_mode := 'INSERT_CTX_DTLS';
3407       l_start_sequence := 2;
3408       l_end_sequence := 5000;
3409       -- rows with sequence between 5001 and 9999 (local attributes) will be done after the
3410       -- final call to ICX_CAT_POPULATE_CTXSTRING_PVT.populateCtxCatgAtt in
3411       FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3412         INSERT INTO icx_cat_items_ctx_dtls_tlp
3413          (inventory_item_id, po_line_id, req_template_name,
3414           req_template_line_num, org_id, language,
3415           last_update_login, last_updated_by, last_update_date,
3416           created_by, creation_date, internal_request_id, request_id,
3417           program_application_id, program_id, program_login_id,
3418           sequence, ctx_desc)
3419         SELECT inventory_item_id, po_line_id, req_template_name,
3420                req_template_line_num, gIDOrgIdTbl(i), language,
3421                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3422                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3423                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3424                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3425                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3426                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3427                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3428                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3429                sequence, ctx_desc
3430         FROM icx_cat_items_ctx_dtls_tlp
3431         WHERE inventory_item_id = gIDInventoryItemIdTbl(i)
3432         AND   po_line_id = gIDPoLineIdTbl(i)
3433         AND   req_template_name = gIDReqTemplateNameTbl(i)
3434         AND   req_template_line_num = gIDReqTemplateLineNumTbl(i)
3435         AND   org_id = gIDOwningOrgIdTbl(i)
3436         AND   language = gIDLanguageTbl(i)
3437         AND   sequence BETWEEN l_start_sequence AND l_end_sequence;
3438 
3439       IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3440         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3441           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3442               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3443               'Num. of rows inserted into ctx_dtls for GBPA with seq between 2 - 5000 row:' ||SQL%ROWCOUNT);
3444         END IF;
3445       END IF;
3446       l_err_loc := 2500;
3447 
3448       l_action_mode := 'DELETE_SPECIFIC_CTX_DTLS';
3449       l_start_sequence := 101;
3450       FORALL i in 1..gDBLDInventoryItemIdTbl.COUNT
3451         INSERT INTO icx_cat_items_ctx_dtls_tlp
3452          (inventory_item_id, po_line_id, req_template_name,
3453           req_template_line_num, org_id, language,
3454           last_update_login, last_updated_by, last_update_date,
3455           created_by, creation_date, internal_request_id, request_id,
3456           program_application_id, program_id, program_login_id,
3457           sequence, ctx_desc)
3458         SELECT inventory_item_id, po_line_id, req_template_name,
3459                req_template_line_num, gDBLDOrgIdTbl(i), language,
3460                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3461                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3462                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3463                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3464                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3465                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3466                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3467                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3468                sequence, ctx_desc
3469         FROM icx_cat_items_ctx_dtls_tlp
3470         WHERE inventory_item_id = gDBLDInventoryItemIdTbl(i)
3471         AND   po_line_id = gDBLDPoLineIdTbl(i)
3472         AND   req_template_name = gDBLDReqTemplateNameTbl(i)
3473         AND   req_template_line_num = gDBLDReqTemplateLineNumTbl(i)
3474         AND   org_id = gDBLDOwningOrgIdTbl(i)
3475         AND   language = gDBLDLanguageTbl(i)
3476         AND   ((sequence BETWEEN l_start_sequence AND l_end_sequence) or
3477 sequence =3);
3478 
3479       l_err_loc := 2600;
3480       IF (gDBLDInventoryItemIdTbl.COUNT > 0) THEN
3481         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3482           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3483               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3484               'Num. of rows inserted into ctx_dtls for 101 - 5000 row:' ||SQL%ROWCOUNT);
3485         END IF;
3486       END IF;
3487 
3488       l_action_mode := 'DELETE_SUPPLIER_ROW_CTX_DTLS';
3489       -- l_sequence := 2;
3490       FORALL i in 1..gDSDInventoryItemIdTbl.COUNT
3491         INSERT INTO icx_cat_items_ctx_dtls_tlp
3492          (inventory_item_id, po_line_id, req_template_name,
3493           req_template_line_num, org_id, language,
3494           last_update_login, last_updated_by, last_update_date,
3495           created_by, creation_date, internal_request_id, request_id,
3496           program_application_id, program_id, program_login_id,
3497           sequence, ctx_desc)
3498         SELECT inventory_item_id, po_line_id, req_template_name,
3499                req_template_line_num, gDSDOrgIdTbl(i), language,
3500                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3501                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3502                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3503                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3504                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3505                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3506                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3507                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3508                sequence, ctx_desc
3509         FROM icx_cat_items_ctx_dtls_tlp
3510         WHERE inventory_item_id = gDSDInventoryItemIdTbl(i)
3511         AND   po_line_id = gDSDPoLineIdTbl(i)
3512         AND   req_template_name = gDSDReqTemplateNameTbl(i)
3513         AND   req_template_line_num = gDSDReqTemplateLineNumTbl(i)
3514         AND   org_id = gDSDOwningOrgIdTbl(i)
3515         AND   language = gDSDLanguageTbl(i)
3516         AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForSupplierRow;
3517 
3518       IF (gDSDInventoryItemIdTbl.COUNT > 0) THEN
3519         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3520           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3521               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3522               'Num. of rows inserted into ctx_dtls for seq 2 row:' ||SQL%ROWCOUNT);
3523         END IF;
3524       END IF;
3525       l_err_loc := 2700;
3526 
3527       l_action_mode := 'DELETE_ITEMREV_ROW_CTX_DTLS';
3528       -- l_sequence := 5;
3529       FORALL i in 1..gDIRDInventoryItemIdTbl.COUNT
3530         INSERT INTO icx_cat_items_ctx_dtls_tlp
3531          (inventory_item_id, po_line_id, req_template_name,
3532           req_template_line_num, org_id, language,
3533           last_update_login, last_updated_by, last_update_date,
3534           created_by, creation_date, internal_request_id, request_id,
3535           program_application_id, program_id, program_login_id,
3536           sequence, ctx_desc)
3537         SELECT inventory_item_id, po_line_id, req_template_name,
3538                req_template_line_num, gDIRDOrgIdTbl(i), language,
3539                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3540                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3541                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3542                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3543                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3544                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3545                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3546                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3547                sequence, ctx_desc
3548         FROM icx_cat_items_ctx_dtls_tlp
3549         WHERE inventory_item_id = gDIRDInventoryItemIdTbl(i)
3550         AND   po_line_id = gDIRDPoLineIdTbl(i)
3551         AND   req_template_name = gDIRDReqTemplateNameTbl(i)
3552         AND   req_template_line_num = gDIRDReqTemplateLineNumTbl(i)
3553         AND   org_id = gDIRDOwningOrgIdTbl(i)
3554         AND   language = gDIRDLanguageTbl(i)
3555         AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForItemRevisionRow;
3556 
3557       l_err_loc := 2800;
3558       IF (gDIRDInventoryItemIdTbl.COUNT > 0) THEN
3559         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3560           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3561               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3562               'Num. of rows inserted into ctx_dtls for seq 5 row:' ||SQL%ROWCOUNT);
3563         END IF;
3564       END IF;
3565 
3566       l_action_mode := 'DELETE_SHOPCATG_ROW_CTX_DTLS';
3567       -- l_sequence := 6;
3568       FORALL i in 1..gDSCDInventoryItemIdTbl.COUNT
3569         INSERT INTO icx_cat_items_ctx_dtls_tlp
3570          (inventory_item_id, po_line_id, req_template_name,
3571           req_template_line_num, org_id, language,
3572           last_update_login, last_updated_by, last_update_date,
3573           created_by, creation_date, internal_request_id, request_id,
3574           program_application_id, program_id, program_login_id,
3575           sequence, ctx_desc)
3576         SELECT inventory_item_id, po_line_id, req_template_name,
3577                req_template_line_num, gDSCDOrgIdTbl(i), language,
3578                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3579                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3580                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3581                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3582                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3583                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3584                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3585                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3586                sequence, ctx_desc
3587         FROM icx_cat_items_ctx_dtls_tlp
3588         WHERE inventory_item_id = gDSCDInventoryItemIdTbl(i)
3589         AND   po_line_id = gDSCDPoLineIdTbl(i)
3590         AND   req_template_name = gDSCDReqTemplateNameTbl(i)
3591         AND   req_template_line_num = gDSCDReqTemplateLineNumTbl(i)
3592         AND   org_id = gDSCDOwningOrgIdTbl(i)
3593         AND   language = gDSCDLanguageTbl(i)
3594         AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForShoppingCategoryRow;
3595 
3596       l_err_loc := 2900;
3597       IF (gDSCDInventoryItemIdTbl.COUNT > 0) THEN
3598         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3599           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3600               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3601               'Num. of rows inserted into ctx_dtls for seq 6 row:' ||SQL%ROWCOUNT);
3602         END IF;
3603       END IF;
3604     ELSE
3605       l_err_loc := 3000;
3606       FOR i IN 1..l_regular_ctx_sql_tbl.COUNT LOOP
3607         l_err_loc := 3100;
3608         l_ctx_sqlstring_rec := l_regular_ctx_sql_tbl(i);
3609         l_err_loc := 3200;
3610         l_csr_handle:=DBMS_SQL.OPEN_CURSOR;
3611         l_err_loc := 3300;
3612         DBMS_SQL.PARSE(l_csr_handle, l_ctx_sqlstring_rec.ctx_sql_string, DBMS_SQL.NATIVE);
3613         IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3614           l_action_mode := 'INSERT_CTX_DTLS';
3615           l_err_loc := 3400;
3616           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_ctx_sqlstring_rec.bind_sequence);
3617           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gIDInventoryItemIdTbl);
3618           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gIDPoLineIdTbl);
3619           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gIDReqTemplateNameTbl);
3620           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gIDReqTemplateLineNumTbl);
3621           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gIDOrgIdTbl);
3622           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gIDLanguageTbl);
3623           l_err_loc := 3500;
3624           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3625           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3626             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3627                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3628                 'regular Ctx SQLS details..' ||
3629                 '; Num. of rows in dtls plsql table:' || gIDInventoryItemIdTbl.COUNT ||
3630                 ', for seq:' || l_ctx_sqlstring_rec.bind_sequence ||
3631                 ', Num. of rows inserted into dtls:' || l_status);
3632           END IF;
3633         END IF;
3634         l_err_loc := 3600;
3635         IF (gDBLDInventoryItemIdTbl.COUNT > 0) THEN
3636           l_action_mode := 'DELETE_SPECIFIC_CTX_DTLS';
3637           l_err_loc := 3700;
3638           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_ctx_sqlstring_rec.bind_sequence);
3639           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDBLDInventoryItemIdTbl);
3640           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDBLDPoLineIdTbl);
3641           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDBLDReqTemplateNameTbl);
3642           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDBLDReqTemplateLineNumTbl);
3643           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDBLDOrgIdTbl);
3644           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDBLDLanguageTbl);
3645           l_err_loc := 3800;
3646           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3647           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3648             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3649                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3650                 'regular Ctx SQLS details..' ||
3651                 '; Num. of rows in dtls plsql table:' || gDBLDInventoryItemIdTbl.COUNT ||
3652                 ', for seq:' || l_ctx_sqlstring_rec.bind_sequence ||
3653                 ', Num. of rows inserted into dtls:' || l_status);
3654           END IF;
3655         END IF;
3656         l_err_loc := 3900;
3657         DBMS_SQL.CLOSE_CURSOR(l_csr_handle);
3658         l_err_loc := 20000 + i;
3659       END LOOP;
3660     END IF;  -- (p_current_cursor = ICX_CAT_UTIL_PVT.g_GBPACsr_const)
3661 
3662     l_err_loc := 4000;
3663     clearTables('ALL');
3664 
3665     l_err_loc := 4100;
3666     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
3667       COMMIT;
3668       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3669         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3670             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3671             'Commit done.');
3672       END IF;
3673     ELSE
3674       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3675         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3676             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3677             'Commit not done.');
3678       END IF;
3679     END IF;
3680     l_err_loc := 4200;
3681 
3682   END IF; -- (p_mode = 'OUTLOOP' OR gTotalRowCount >= ICX_CAT_UTIL_PVT.g_batch_size)
3683   l_err_loc := 4300;
3684 EXCEPTION
3685   WHEN OTHERS THEN
3686     logPLSQLTableRow(l_api_name, FND_LOG.LEVEL_UNEXPECTED, SQL%ROWCOUNT+1, l_action_mode);
3687     ICX_CAT_UTIL_PVT.logUnexpectedException(
3688       G_PKG_NAME, l_api_name,
3689       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
3690     RAISE;
3691 END populateItemCtxTables;
3692 
3693 PROCEDURE populateVendorNameChanges
3694 (       p_vendor_party_id       IN              NUMBER          ,
3695         p_vendor_name           IN              VARCHAR2
3696 )
3697 IS
3698   l_api_name            CONSTANT VARCHAR2(30)   := 'populateVendorNameChanges';
3699   l_err_loc             PLS_INTEGER;
3700   l_searchable          NUMBER;
3701   l_section_tag         NUMBER;
3702   l_continue            BOOLEAN := TRUE;
3703   l_rowid_tbl           DBMS_SQL.UROWID_TABLE;
3704   l_row_count           PLS_INTEGER;
3705 BEGIN
3706   l_err_loc := 100;
3707   ICX_CAT_BUILD_CTX_SQL_PVT.checkIfAttributeIsSrchble
3708                 ('SUPPLIER', l_searchable, l_section_tag);
3709 
3710   l_err_loc := 200;
3711   -- Set the batch_size if supplier needs to be updated
3712   ICX_CAT_UTIL_PVT.setBatchSize;
3713 
3714   l_err_loc := 300;
3715   -- Set the who columns
3716   ICX_CAT_UTIL_PVT.setWhoColumns(null);
3717 
3718   l_err_loc := 400;
3719   IF (l_searchable = 1) THEN
3720 
3721     l_err_loc := 500;
3722     WHILE l_continue LOOP
3723       l_err_loc := 600;
3724       l_rowid_tbl.DELETE;
3725 
3726       l_err_loc := 700;
3727       UPDATE icx_cat_items_ctx_hdrs_tlp
3728       SET ctx_desc = NULL,
3729           supplier = p_vendor_name,
3730           last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3731           last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3732           last_update_date = sysdate,
3733           internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3734           request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3735           program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3736           program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3737           program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
3738       WHERE supplier_id IN (SELECT vendor_id
3739                             FROM po_vendors
3740                             WHERE party_id = p_vendor_party_id)
3741       AND internal_request_id <> ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id
3742       AND ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
3743       RETURNING ROWID BULK COLLECT INTO l_rowid_tbl;
3744 
3745       l_err_loc := 800;
3746       l_row_count := SQL%ROWCOUNT;
3747       IF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
3748         l_err_loc := 900;
3749         l_continue := FALSE;
3750         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3751           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3752                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3753                'Num of rows updated in ctx_hdrs for supplier name change:' || l_row_count);
3754         END IF;
3755       END IF;
3756 
3757       l_err_loc := 1000;
3758       FORALL i IN 1..l_rowid_tbl.COUNT
3759         UPDATE icx_cat_items_ctx_dtls_tlp dtls
3760         SET ctx_desc = '<' || l_section_tag || '>' || replace(replace(p_vendor_name, '<', ' '), '>', ' ') || '</' || l_section_tag || '>',
3761             last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3762             last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3763             last_update_date = sysdate,
3764             internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3765             request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3766             program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3767             program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3768             program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
3769         WHERE sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForSupplierRow
3770         AND EXISTS ( SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
3771                      WHERE hdrs.po_line_id = dtls.po_line_id
3772                      AND hdrs.req_template_name = dtls.req_template_name
3773                      AND hdrs.req_template_line_num = dtls.req_template_line_num
3774                      AND hdrs.inventory_item_id = dtls.inventory_item_id
3775                      AND hdrs.org_id = dtls.org_id
3776                      AND hdrs.language = dtls.language
3777                      AND hdrs.rowid = l_rowid_tbl(i) );
3778 
3779       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3780         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3781              ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3782              'Num of rows updated in ctx_dtls for supplier name change:' ||SQL%ROWCOUNT);
3783       END IF;
3784 
3785       l_err_loc := 1100;
3786       IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
3787         l_err_loc := 1200;
3788         COMMIT;
3789         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3790           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3791               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3792               'Commit done.');
3793         END IF;
3794       ELSE
3795         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3796           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3797               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3798               'Commit not done.');
3799         END IF;
3800       END IF;
3801     END LOOP;
3802 
3803     l_err_loc := 1300;
3804     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
3805       l_err_loc := 1400;
3806       -- Call the rebuild index
3807       ICX_CAT_INTERMEDIA_INDEX_PVT.rebuild_index;
3808       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3809         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3810             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3811             'Rebuild indexes called.');
3812       END IF;
3813     END IF;
3814   ELSE
3815 
3816     l_err_loc := 1400;
3817     WHILE l_continue LOOP
3818       l_err_loc := 1500;
3819       l_rowid_tbl.DELETE;
3820 
3821       l_err_loc := 1600;
3822       UPDATE icx_cat_items_ctx_hdrs_tlp
3823       SET supplier = p_vendor_name,
3824           last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3825           last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3826           last_update_date = sysdate,
3827           internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3828           request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3829           program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3830           program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3831           program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
3832       WHERE supplier_id IN (SELECT vendor_id
3833                             FROM po_vendors
3834                             WHERE party_id = p_vendor_party_id)
3835       AND internal_request_id <> ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id
3836       AND ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size;
3837 
3838       l_err_loc := 1700;
3839       l_row_count := SQL%ROWCOUNT;
3840       IF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
3841         l_err_loc := 1800;
3842         l_continue := FALSE;
3843         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3844           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3845                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3846                'Num of rows updated in ctx_hdrs for supplier name change:' || l_row_count);
3847         END IF;
3848       END IF;
3849 
3850       l_err_loc := 1900;
3851       IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
3852         l_err_loc := 2000;
3853         COMMIT;
3854         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3855           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3856               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3857               'Commit done.');
3858         END IF;
3859       ELSE
3860         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3861           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3862               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3863               'Commit not done.');
3864         END IF;
3865       END IF;
3866     END LOOP;
3867 
3868     l_err_loc := 2100;
3869     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3870       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3871           ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3872           'Only update the supplier name on the header; Supplier is not searchable l_searchable:' || l_searchable );
3873     END IF;
3874   END IF; -- IF (l_searchable = 1) THEN
3875 
3876   l_err_loc := 2200;
3877 EXCEPTION
3878   WHEN OTHERS THEN
3879     ICX_CAT_UTIL_PVT.logUnexpectedException(
3880       G_PKG_NAME, l_api_name,
3881       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
3882     RAISE;
3883 END populateVendorNameChanges;
3884 
3885 /*
3886 Steps:
3887 1. update supplier_id, supplier_site_id and ctx_desc in icx_cat_items_ctx_hdrs_tlp
3888 2. delete and insert into icx_cat_items_ctx_dtls_tlp : sequence 1 for supid and siteid
3889 3. Check if supplier is searchable, if yes then update icx_cat_items_ctx_dtls_tlp : sequence 2 for supplier
3890 4. call rebuild_index.
3891 */
3892 PROCEDURE populateVendorMerge
3893 (       p_from_vendor_id        IN              NUMBER                  ,
3894         p_from_site_id          IN              NUMBER                  ,
3895         p_to_vendor_id          IN              NUMBER                  ,
3896         p_to_site_id            IN              NUMBER
3897 )
3898 IS
3899   l_api_name                    CONSTANT VARCHAR2(30)   := 'populateVendorMerge';
3900   l_err_loc                     PLS_INTEGER;
3901   l_to_vendor_name              po_vendors.vendor_name%TYPE;
3902   l_continue                    BOOLEAN := TRUE;
3903   l_rowid_tbl                   DBMS_SQL.UROWID_TABLE;
3904   l_rows_updated                BOOLEAN := TRUE;
3905   l_metadataTblFormed           BOOLEAN := FALSE;
3906   l_special_metadata_tbl        ICX_CAT_BUILD_CTX_SQL_PVT.g_metadata_tbl_type;
3907   l_regular_nontl_metadata_tbl  ICX_CAT_BUILD_CTX_SQL_PVT.g_metadata_tbl_type;
3908   l_regular_tl_metadata_tbl     ICX_CAT_BUILD_CTX_SQL_PVT.g_metadata_tbl_type;
3909   l_all_ctx_sql_tbl             ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_tbl_type;
3910   l_special_ctx_sql_tbl         ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_tbl_type;
3911   l_regular_ctx_sql_tbl         ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_tbl_type;
3912   l_ctx_sqlstring_rec           ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_rec_type;
3913   l_csr_handle                  NUMBER;
3914   l_status                      PLS_INTEGER;
3915   l_searchable                  VARCHAR2(1) := NULL;
3916   l_metadata_rec                ICX_CAT_BUILD_CTX_SQL_PVT.g_metadata_rec_type;
3917   l_row_count                   PLS_INTEGER;
3918 BEGIN
3919   l_err_loc := 100;
3920   -- Set the batch_size if supplier needs to be updated
3921   ICX_CAT_UTIL_PVT.setBatchSize;
3922 
3923   l_err_loc := 300;
3924   -- Set the who columns
3925   ICX_CAT_UTIL_PVT.setWhoColumns(null);
3926 
3927   l_err_loc := 400;
3928 
3929   SELECT vendor_name
3930   INTO   l_to_vendor_name
3931   FROM   po_vendors
3932   WHERE  vendor_id = p_to_vendor_id;
3933 
3934   l_err_loc := 500;
3935   IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3936     FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3937         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3938         'l_to_vendor_name:' || l_to_vendor_name);
3939   END IF;
3940 
3941   l_err_loc := 600;
3942   -- open the cursor for the dynamic sql to insert the
3943   -- row with sequence 1 in icx_cat_items_ctx_dtls_tlp only once
3944   l_csr_handle := DBMS_SQL.OPEN_CURSOR;
3945 
3946   l_err_loc := 700;
3947   WHILE l_continue LOOP
3948     l_err_loc := 800;
3949     l_rowid_tbl.DELETE;
3950 
3951     l_err_loc := 900;
3952     UPDATE icx_cat_items_ctx_hdrs_tlp
3953     SET ctx_desc = NULL,
3954         supplier_id = p_to_vendor_id,
3955         supplier_site_id = p_to_site_id,
3956         supplier = l_to_vendor_name,
3957         last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3958         last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3959         last_update_date = sysdate,
3960         internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3961         request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3962         program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3963         program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3964         program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
3965     WHERE supplier_id = p_from_vendor_id
3966     AND   supplier_site_id = p_from_site_id
3967     AND   internal_request_id <> ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id
3968     AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
3969     RETURNING ROWID BULK COLLECT INTO l_rowid_tbl;
3970 
3971     l_err_loc := 1000;
3972     l_row_count := SQL%ROWCOUNT;
3973     IF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
3974       l_err_loc := 1100;
3975       l_continue := FALSE;
3976         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3977           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3978                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3979                'Num of rows updated in ctx_hdrs for vendor merge:' || l_row_count);
3980         END IF;
3981     END IF;
3982 
3983     l_err_loc := 1200;
3984 
3985     IF (l_rowid_tbl.COUNT > 0) THEN
3986       l_err_loc := 1300;
3987       -- delete the mandatory row in icx_cat_items_ctx_dtls_tlp i.e. the row with sequence = 1
3988       FORALL i IN 1..l_rowid_tbl.COUNT
3989         DELETE FROM icx_cat_items_ctx_dtls_tlp dtls
3990         WHERE sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqMandatoryBaseRow
3991         AND EXISTS ( SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
3992                      WHERE hdrs.po_line_id = dtls.po_line_id
3993                      AND hdrs.req_template_name = dtls.req_template_name
3994                      AND hdrs.req_template_line_num = dtls.req_template_line_num
3995                      AND hdrs.inventory_item_id = dtls.inventory_item_id
3996                      AND hdrs.org_id = dtls.org_id
3997                      AND hdrs.language = dtls.language
3998                      AND hdrs.rowid = l_rowid_tbl(i) );
3999 
4000       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4001         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4002              ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4003              'Num. of rows deleted from dtls for seq=1:' || SQL%ROWCOUNT);
4004       END IF;
4005 
4006       l_err_loc := 1400;
4007 
4008       IF (NOT l_metadataTblFormed) THEN
4009         l_err_loc := 1500;
4010         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4011           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4012                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4013                'populateVendorMerge: about to call buildMetaDataInfo and buildCtxSql');
4014         END IF;
4015 
4016         ICX_CAT_BUILD_CTX_SQL_PVT.buildMetadataInfo
4017                (0, l_special_metadata_tbl, l_regular_nontl_metadata_tbl, l_regular_tl_metadata_tbl);
4018         l_metadataTblFormed := TRUE;
4019 
4020         l_err_loc := 1600;
4021 
4022         ICX_CAT_BUILD_CTX_SQL_PVT.buildCtxSql
4023              (0, 'ALL', 'ROWID', l_special_metadata_tbl,
4024               l_regular_nontl_metadata_tbl, l_regular_tl_metadata_tbl,
4025               l_all_ctx_sql_tbl, l_special_ctx_sql_tbl, l_regular_ctx_sql_tbl);
4026 
4027         l_err_loc := 1700;
4028         l_ctx_sqlstring_rec := l_special_ctx_sql_tbl(1);
4029 
4030         -- parse the cursor only once
4031         l_err_loc := 1800;
4032         DBMS_SQL.PARSE(l_csr_handle, l_ctx_sqlstring_rec.ctx_sql_string, DBMS_SQL.NATIVE);
4033       END IF;
4034 
4035       l_err_loc := 1900;
4036 
4037       -- insert the mandatory row in icx_cat_items_ctx_dtls_tlp i.e. the row with sequence = 1
4038       DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_ctx_sqlstring_rec.bind_sequence);
4039       DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_rowid', l_rowid_tbl);
4040       l_err_loc := 2000;
4041       l_status := DBMS_SQL.EXECUTE(l_csr_handle);
4042       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4043         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4044              ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4045              'Num. of rows inserted into dtls for seq=1:' || l_status);
4046       END IF;
4047 
4048       l_err_loc := 2100;
4049 
4050       IF (l_searchable IS NULL) THEN
4051         l_err_loc := 2200;
4052         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4053           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4054                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4055                'about to call the getAttributeDetails for supplier');
4056         END IF;
4057 
4058         ICX_CAT_BUILD_CTX_SQL_PVT.getAttributeDetails
4059             (l_special_metadata_tbl, 'SUPPLIER', l_searchable, l_metadata_rec);
4060       END IF;
4061 
4062       l_err_loc := 2300;
4063       IF (l_searchable = 'Y') THEN
4064         l_err_loc := 2400;
4065         FORALL i IN 1..l_rowid_tbl.COUNT
4066           UPDATE icx_cat_items_ctx_dtls_tlp dtls
4067           SET ctx_desc = '<' || l_metadata_rec.section_tag || '>' ||
4068                          replace(replace(l_to_vendor_name, '<', ' '), '>', ' ') ||
4069                          '</' || l_metadata_rec.section_tag || '>',
4070               last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
4071               last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
4072               last_update_date = sysdate,
4073               internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
4074               request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
4075               program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
4076               program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
4077               program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
4078           WHERE sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForSupplierRow
4079           AND EXISTS ( SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
4080                        WHERE hdrs.po_line_id = dtls.po_line_id
4081                        AND hdrs.req_template_name = dtls.req_template_name
4082                        AND hdrs.req_template_line_num = dtls.req_template_line_num
4083                        AND hdrs.inventory_item_id = dtls.inventory_item_id
4084                        AND hdrs.org_id = dtls.org_id
4085                        AND hdrs.language = dtls.language
4086                        AND hdrs.rowid = l_rowid_tbl(i) );
4087       ELSE
4088         l_err_loc := 2500;
4089         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4090           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4091               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4092               'Supplier is not searchable l_searchable:' || l_searchable );
4093         END IF;
4094       END IF;
4095 
4096       l_err_loc := 2600;
4097       IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4098         l_err_loc := 2700;
4099         COMMIT;
4100         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4101           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4102               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4103               'Commit done.');
4104         END IF;
4105       ELSE
4106         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4107           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4108               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4109               'Commit not done.');
4110         END IF;
4111       END IF;
4112     END IF;  -- IF (l_rowid_tbl.COUNT > 0)
4113   END LOOP;  -- WHILE l_continue LOOP
4114 
4115   l_err_loc := 2800;
4116 
4117   -- close the cursor for the dynamic sql to insert the
4118   -- row with sequence 1 in icx_cat_items_ctx_dtls_tlp only once
4119   IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4120     FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4121         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4122         'the dynamic sql is closed');
4123   END IF;
4124   DBMS_SQL.CLOSE_CURSOR(l_csr_handle);
4125 
4126   l_err_loc := 2900;
4127   IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4128     l_err_loc := 3000;
4129     -- Call the rebuild index
4130     ICX_CAT_INTERMEDIA_INDEX_PVT.rebuild_index;
4131 
4132     l_err_loc := 3100;
4133     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4134       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4135           ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4136           'Commit done.');
4137     END IF;
4138   END IF;
4139   l_err_loc := 3200;
4140 EXCEPTION
4141   WHEN OTHERS THEN
4142     ICX_CAT_UTIL_PVT.logUnexpectedException(
4143       G_PKG_NAME, l_api_name,
4144       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4145     RAISE;
4146 END populateVendorMerge;
4147 
4148 PROCEDURE openInvalidCategoryCsr
4149 (       p_invalid_category_csr          IN OUT NOCOPY           g_csr_type
4150 )
4151 IS
4152   l_api_name    CONSTANT VARCHAR2(30)   := 'openInvalidCategoryCsr';
4153   l_err_loc     PLS_INTEGER;
4154 BEGIN
4155   l_err_loc := 100;
4156   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4157     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE,
4158         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4159         'Processing cursor:' || l_api_name ||
4160         ', g_structure_id:' || ICX_CAT_UTIL_PVT.g_structure_id ||
4161         ', g_category_set_id:' || ICX_CAT_UTIL_PVT.g_category_set_id ||
4162         '; g_validate_flag:' || ICX_CAT_UTIL_PVT.g_validate_flag);
4163   END IF;
4164 
4165   -- No need of joining with icx_cat_categories_tl, because
4166   -- 1. the ip category will exist only if the profile
4167   --    POR_AUTO_CREATE_SHOPPING_CAT is set to Y
4168   -- 2. the ip category is optional for items in iprocurement.
4169   -- 3. When the mtl category gets invalid we remove all the master items
4170   --    that belonged to the mtl category.
4171   l_err_loc := 150;
4172   IF (ICX_CAT_UTIL_PVT.g_validate_flag = 'N') THEN
4173     l_err_loc := 200;
4174     OPEN p_invalid_category_csr FOR
4175       SELECT mtlb.category_id
4176       FROM mtl_categories_b mtlb
4177       WHERE mtlb.structure_id = ICX_CAT_UTIL_PVT.g_structure_id
4178       AND (NVL(mtlb.end_date_active, SYSDATE + 1) < SYSDATE
4179            OR NVL(mtlb.disable_date, SYSDATE + 1) < SYSDATE)
4180       AND EXISTS (SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
4181                   WHERE hdrs.po_category_id = mtlb.category_id
4182                   AND hdrs.source_type = 'MASTER_ITEM');
4183   ELSE
4184     l_err_loc := 300;
4185     OPEN p_invalid_category_csr FOR
4186       SELECT mtlb.category_id
4187       FROM mtl_categories_b mtlb,
4188            mtl_category_set_valid_cats mcsvc
4189       WHERE mtlb.structure_id = ICX_CAT_UTIL_PVT.g_structure_id
4190       AND (NVL(mtlb.end_date_active, SYSDATE + 1) < SYSDATE
4191            OR NVL(mtlb.disable_date, SYSDATE + 1) < SYSDATE)
4192       AND mcsvc.category_set_id = ICX_CAT_UTIL_PVT.g_category_set_id
4193       AND mcsvc.category_id = mtlb.category_id
4194       AND EXISTS (SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
4195                   WHERE hdrs.po_category_id = mtlb.category_id
4196                   AND hdrs.source_type = 'MASTER_ITEM');
4197   END IF;
4198   l_err_loc := 400;
4199 EXCEPTION
4200   WHEN OTHERS THEN
4201     ICX_CAT_UTIL_PVT.logUnexpectedException(
4202       G_PKG_NAME, l_api_name,
4203       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4204     RAISE;
4205 END openInvalidCategoryCsr;
4206 
4207 -- Purges items in invalid/expired categories
4208 PROCEDURE purgeInvalidCategoryItems
4209 IS
4210 
4211   ----- Start of declaring columns fetched from the cursor-----
4212   l_po_category_id_tbl          DBMS_SQL.NUMBER_TABLE;
4213   l_po_line_id_tbl              DBMS_SQL.NUMBER_TABLE;
4214   l_req_template_name_tbl       DBMS_SQL.VARCHAR2_TABLE;
4215   l_req_template_line_num_tbl   DBMS_SQL.NUMBER_TABLE;
4216   l_inventory_item_id_tbl       DBMS_SQL.NUMBER_TABLE;
4217   l_org_id_tbl                  DBMS_SQL.NUMBER_TABLE;
4218   l_language_tbl                DBMS_SQL.VARCHAR2_TABLE;
4219   ------ End of declaring columns fetched from the cursor ------
4220 
4221   l_api_name                    CONSTANT VARCHAR2(30)   := 'purgeInvalidCategoryItems';
4222   l_continue                    BOOLEAN := TRUE;
4223   l_invalid_category_csr        g_csr_type;
4224   l_err_string                  VARCHAR2(4000);
4225   l_err_loc                     PLS_INTEGER;
4226   l_start_date                  DATE;
4227   l_end_date                    DATE;
4228   l_log_string		        VARCHAR2(2000);
4229   l_row_count                   PLS_INTEGER;
4230 BEGIN
4231   l_err_loc := 100;
4232   l_start_date := sysdate;
4233 
4234   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4235     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4236     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4237   END IF;
4238 
4239   l_err_loc := 150;
4240   ICX_CAT_UTIL_PVT.getPurchasingCategorySetInfo;
4241 
4242   l_err_loc := 200;
4243   openInvalidCategoryCsr(l_invalid_category_csr);
4244 
4245   l_err_loc := 300;
4246   LOOP
4247     BEGIN
4248 
4249       l_err_loc := 400;
4250       l_po_category_id_tbl.DELETE;
4251 
4252       l_err_loc := 450;
4253       FETCH l_invalid_category_csr
4254       BULK COLLECT INTO l_po_category_id_tbl
4255       LIMIT ICX_CAT_UTIL_PVT.g_batch_size;
4256 
4257       l_err_loc := 500;
4258       EXIT WHEN l_po_category_id_tbl.COUNT = 0;
4259 
4260       FOR i IN 1..l_po_category_id_tbl.COUNT LOOP
4261         l_err_loc := 600;
4262         l_continue := TRUE;
4263         WHILE l_continue LOOP
4264           l_err_loc := 700;
4265           l_po_line_id_tbl.DELETE;
4266           l_req_template_name_tbl.DELETE;
4267           l_req_template_line_num_tbl.DELETE;
4268           l_inventory_item_id_tbl.DELETE;
4269           l_org_id_tbl.DELETE;
4270           l_language_tbl.DELETE;
4271 
4272           l_err_loc := 800;
4273           DELETE FROM icx_cat_items_ctx_hdrs_tlp hdrs
4274           WHERE hdrs.source_type = 'MASTER_ITEM'
4275           AND po_category_id = l_po_category_id_tbl(i)
4276           AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
4277           RETURNING po_line_id, req_template_name, req_template_line_num,
4278               inventory_item_id, org_id, language
4279           BULK COLLECT INTO l_po_line_id_tbl, l_req_template_name_tbl, l_req_template_line_num_tbl,
4280               l_inventory_item_id_tbl, l_org_id_tbl, l_language_tbl;
4281 
4282           l_err_loc := 900;
4283           l_row_count := SQL%ROWCOUNT;
4284           IF (l_row_count = 0) THEN
4285             IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4286               FND_LOG.string(FND_LOG.LEVEL_EVENT,
4287                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4288                   'No rows deleted from ctx_hdrs for invalid category, so exit out of the loop;');
4289             END IF;
4290             EXIT;
4291           ELSIF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
4292             l_continue := FALSE;
4293             IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4294               FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4295                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4296                   'Num. of rows deleted from ctx_hdrs for invalid category:' || l_row_count);
4297             END IF;
4298           END IF;
4299 
4300           l_err_loc := 1000;
4301           FORALL j IN 1..l_po_line_id_tbl.COUNT
4302             DELETE FROM icx_cat_items_ctx_dtls_tlp
4303             WHERE po_line_id = l_po_line_id_tbl(j)
4304             AND req_template_name = l_req_template_name_tbl(j)
4305             AND req_template_line_num = l_req_template_line_num_tbl(j)
4306             AND inventory_item_id = l_inventory_item_id_tbl(j)
4307             AND org_id = l_org_id_tbl(j)
4308             AND language = l_language_tbl(j);
4309 
4310           l_err_loc := 1100;
4311           IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4312             l_err_loc := 1200;
4313             COMMIT;
4314             IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4315               FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4316                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4317                   'Commit done inside the while loop.');
4318             END IF;
4319           ELSE
4320             l_err_loc := 1300;
4321             IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4322               FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4323                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4324                   'Commit not done inside the while loop.');
4325             END IF;
4326           END IF;
4327         END LOOP;
4328       END LOOP;
4329 
4330       l_err_loc := 1400;
4331       -- When the po_category becomes invalid, No need of deleting the ip category
4332       -- and mapping because the po_category can still exist on a document line and
4333       -- bulkload should be able to update the document line.
4334 
4335       l_err_loc := 1500;
4336 
4337       IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4338         l_err_loc := 1600;
4339         COMMIT;
4340         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4341           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4342               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4343               'Commit done inside the fetch loop.');
4344         END IF;
4345       ELSE
4346         l_err_loc := 1700;
4347         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4348           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4349               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4350               'Commit not done inside the fetch loop.');
4351         END IF;
4352       END IF;
4353 
4354       l_err_loc := 1750;
4355       EXIT WHEN l_po_category_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
4356     EXCEPTION
4357       WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
4358         l_err_string := 'ICX_CAT_POPULATE_ITEM_PVT.purgeInvalidCategoryItems' ||l_err_loc;
4359         ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
4360         CLOSE l_invalid_category_csr;
4361         openInvalidCategoryCsr(l_invalid_category_csr);
4362     END;
4363   END LOOP;
4364 
4365   l_err_loc := 1800;
4366   l_end_date := sysdate;
4367   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4368     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4369        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4370   END IF;
4371 EXCEPTION
4372   WHEN OTHERS THEN
4373     ICX_CAT_UTIL_PVT.logUnexpectedException(
4374       G_PKG_NAME, l_api_name,
4375       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4376     RAISE;
4377 END purgeInvalidCategoryItems;
4378 
4379 -- Purges invalid/expired Req Templates
4380 -- Purges the Req templates copied from blankets that are now invalid/expired
4381 PROCEDURE purgeInvalidReqTmpltLines
4382 IS
4383 
4384   ----- Start of declaring columns returned from the delete -----
4385   l_po_line_id_tbl              DBMS_SQL.NUMBER_TABLE;
4386   l_req_template_name_tbl       DBMS_SQL.VARCHAR2_TABLE;
4387   l_req_template_line_num_tbl   DBMS_SQL.NUMBER_TABLE;
4388   l_inventory_item_id_tbl       DBMS_SQL.NUMBER_TABLE;
4389   l_org_id_tbl                  DBMS_SQL.NUMBER_TABLE;
4390   l_language_tbl                DBMS_SQL.VARCHAR2_TABLE;
4391   ------ End of declaring columns returned from the delete ------
4392 
4393   l_api_name                    CONSTANT VARCHAR2(30)   := 'purgeInvalidReqTmpltLines';
4394   l_continue                    BOOLEAN := TRUE;
4395   l_err_loc                     PLS_INTEGER;
4396   l_start_date                  DATE;
4397   l_end_date                    DATE;
4398   l_log_string		        VARCHAR2(2000);
4399   l_row_count                   PLS_INTEGER;
4400 BEGIN
4401   l_err_loc := 100;
4402   l_start_date := sysdate;
4403 
4404   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4405     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4406     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4407   END IF;
4408 
4409   l_continue := TRUE;
4410   WHILE l_continue LOOP
4411     l_err_loc := 200;
4412     l_po_line_id_tbl.DELETE;
4413     l_req_template_name_tbl.DELETE;
4414     l_req_template_line_num_tbl.DELETE;
4415     l_inventory_item_id_tbl.DELETE;
4416     l_org_id_tbl.DELETE;
4417     l_language_tbl.DELETE;
4418 
4419     l_err_loc := 300;
4420     DELETE FROM icx_cat_items_ctx_hdrs_tlp hdrs
4421     WHERE hdrs.source_type IN ('TEMPLATE', 'INTERNAL_TEMPLATE')
4422     AND   (
4423             -- Req template lines that are invalid.
4424             EXISTS ( SELECT 'x'
4425                      FROM po_reqexpress_lines_all prl, po_reqexpress_headers_all prh,
4426                           po_lines_all pl, po_headers_all ph
4427                      WHERE  hdrs.po_line_id = -2
4428                      AND    hdrs.inventory_item_id = nvl(prl.item_id, -2)
4429                      AND    hdrs.req_template_name = prl.express_name
4430                      AND    hdrs.req_template_line_num = prl.sequence_num
4431                      AND    hdrs.org_id = prl.org_id
4432                      AND    prl.express_name = prh.express_name
4433                      AND    prl.org_id = prh.org_id
4434                      AND    prl.po_line_id = pl.po_line_id (+)
4435                      AND    prl.po_header_id = pl.po_header_id (+)
4436                      AND    pl.po_header_id = ph.po_header_id (+)
4437                      AND    (NVL(prh.inactive_date, SYSDATE + 1) <= SYSDATE
4438                              OR (prl.po_line_id IS NOT NULL AND
4439                                  (ph.approved_date IS NULL
4440                                   OR NVL(ph.authorization_status, 'INCOMPLETE') IN ('REJECTED', 'INCOMPLETE')
4441                                   OR NVL(ph.cancel_flag, 'N') = 'Y'
4442                                   OR NVL(ph.frozen_flag, 'N') = 'Y'
4443                                   OR NVL(ph.closed_code, 'OPEN') IN ('CLOSED', 'FINALLY CLOSED')
4444                                   OR NVL(TRUNC(ph.end_date), TRUNC(SYSDATE + 1)) <= TRUNC(SYSDATE)
4445                                   OR NVL(pl.cancel_flag, 'N') = 'Y'
4446                                   OR NVL(pl.closed_code, 'OPEN') IN ('CLOSED', 'FINALLY CLOSED')
4447                                   OR NVL(TRUNC(pl.expiration_date), TRUNC(SYSDATE + 1)) <= TRUNC(SYSDATE)))))
4448             OR
4449             -- Req template lines that are deleted.
4450             NOT EXISTS ( SELECT 'x'
4451                          FROM po_reqexpress_lines_all prl
4452                          WHERE  hdrs.po_line_id = -2
4453                          AND    hdrs.inventory_item_id = nvl(prl.item_id, -2)
4454                          AND    hdrs.req_template_name = prl.express_name
4455                          AND    hdrs.req_template_line_num = prl.sequence_num
4456                          AND    hdrs.org_id = prl.org_id)
4457           )
4458     AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
4459     RETURNING po_line_id, req_template_name, req_template_line_num,
4460         inventory_item_id, org_id, language
4461     BULK COLLECT INTO l_po_line_id_tbl, l_req_template_name_tbl, l_req_template_line_num_tbl,
4462         l_inventory_item_id_tbl, l_org_id_tbl, l_language_tbl;
4463 
4464     l_err_loc := 400;
4465     l_row_count := SQL%ROWCOUNT;
4466     IF (l_row_count = 0) THEN
4467       IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4468         FND_LOG.string(FND_LOG.LEVEL_EVENT,
4469             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4470             'no rows deleted from ctx_hdrs for invalid req tmplts, so exit from the loop');
4471       END IF;
4472       EXIT;
4473     ELSIF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
4474       l_continue := FALSE;
4475       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4476         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4477             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4478             'Num. of rows deleted from ctx_hdrs for invalid req templates:' || l_row_count);
4479       END IF;
4480     END IF;
4481 
4482     l_err_loc := 500;
4483     FORALL j IN 1..l_po_line_id_tbl.COUNT
4484       DELETE FROM icx_cat_items_ctx_dtls_tlp
4485       WHERE po_line_id = l_po_line_id_tbl(j)
4486       AND req_template_name = l_req_template_name_tbl(j)
4487       AND req_template_line_num = l_req_template_line_num_tbl(j)
4488       AND inventory_item_id = l_inventory_item_id_tbl(j)
4489       AND org_id = l_org_id_tbl(j)
4490       AND language = l_language_tbl(j);
4491 
4492     l_err_loc := 600;
4493     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4494       l_err_loc := 700;
4495       COMMIT;
4496       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4497         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4498             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4499             'Commit done.');
4500       END IF;
4501     ELSE
4502       l_err_loc := 800;
4503       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4504         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4505             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4506             'Commit not done.');
4507       END IF;
4508     END IF;
4509   END LOOP;
4510 
4511   l_err_loc := 900;
4512   l_end_date := sysdate;
4513   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4514     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4515        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4516   END IF;
4517 
4518 EXCEPTION
4519   WHEN OTHERS THEN
4520     ICX_CAT_UTIL_PVT.logUnexpectedException(
4521       G_PKG_NAME, l_api_name,
4522       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4523     RAISE;
4524 END purgeInvalidReqTmpltLines;
4525 
4526 -- Purges invalid quotations
4527 -- Quotations: ICX_CAT_POPULATE_STATUS_PVT.getQuoteLineStatus returns
4528 -- ICX_CAT_POPULATE_STATUS_PVT.INVALID_FOR_POPULATE i.e -1
4529 PROCEDURE purgeInvalidQuoteLines
4530 IS
4531 
4532   ----- Start of declaring columns returned from the delete -----
4533   l_po_line_id_tbl              DBMS_SQL.NUMBER_TABLE;
4534   l_req_template_name_tbl       DBMS_SQL.VARCHAR2_TABLE;
4535   l_req_template_line_num_tbl   DBMS_SQL.NUMBER_TABLE;
4536   l_inventory_item_id_tbl       DBMS_SQL.NUMBER_TABLE;
4537   l_org_id_tbl                  DBMS_SQL.NUMBER_TABLE;
4538   l_language_tbl                DBMS_SQL.VARCHAR2_TABLE;
4539   ------ End of declaring columns returned from the delete ------
4540 
4541   l_api_name                    CONSTANT VARCHAR2(30)   := 'purgeInvalidQuoteLines';
4542   l_continue                    BOOLEAN := TRUE;
4543   l_err_loc                     PLS_INTEGER;
4544   l_start_date                  DATE;
4545   l_end_date                    DATE;
4546   l_log_string		        VARCHAR2(2000);
4547   l_row_count                   PLS_INTEGER;
4548 BEGIN
4549   l_err_loc := 100;
4550   l_start_date := sysdate;
4551 
4552   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4553     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4554     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4555   END IF;
4556 
4557   l_err_loc := 110;
4558   l_continue := TRUE;
4559   WHILE l_continue LOOP
4560     l_err_loc := 200;
4561     l_po_line_id_tbl.DELETE;
4562     l_req_template_name_tbl.DELETE;
4563     l_req_template_line_num_tbl.DELETE;
4564     l_inventory_item_id_tbl.DELETE;
4565     l_org_id_tbl.DELETE;
4566     l_language_tbl.DELETE;
4567 
4568     l_err_loc := 300;
4569     DELETE FROM icx_cat_items_ctx_hdrs_tlp hdrs
4570     WHERE hdrs.source_type = 'QUOTATION'
4571     AND   (
4572            -- Quote lines that are invalid.
4573            ICX_CAT_POPULATE_STATUS_PVT.getQuoteLineStatus(hdrs.po_line_id) = -1
4574            OR
4575            -- Quote lines that are deleted.
4576            NOT EXISTS ( SELECT 'x' FROM po_lines_all pl
4577                         WHERE  hdrs.po_line_id = pl.po_line_id)
4578           )
4579     AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
4580     RETURNING po_line_id, req_template_name, req_template_line_num,
4581         inventory_item_id, org_id, language
4582     BULK COLLECT INTO l_po_line_id_tbl, l_req_template_name_tbl, l_req_template_line_num_tbl,
4583         l_inventory_item_id_tbl, l_org_id_tbl, l_language_tbl;
4584 
4585     l_err_loc := 400;
4586     l_row_count := SQL%ROWCOUNT;
4587     IF (l_row_count = 0) THEN
4588       IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4589         FND_LOG.string(FND_LOG.LEVEL_EVENT,
4590             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4591             'no rows deleted from ctx_hdrs for invalid Quote lines, so exit from the loop');
4592       END IF;
4593       EXIT;
4594     ELSIF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
4595       l_continue := FALSE;
4596       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4597         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4598             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4599             'Num. of rows deleted from ctx_hdrs for invalid Quote lines:' || l_row_count);
4600       END IF;
4601     END IF;
4602 
4603     l_err_loc := 500;
4604     FORALL j IN 1..l_po_line_id_tbl.COUNT
4605       DELETE FROM icx_cat_items_ctx_dtls_tlp
4606       WHERE po_line_id = l_po_line_id_tbl(j)
4607       AND req_template_name = l_req_template_name_tbl(j)
4608       AND req_template_line_num = l_req_template_line_num_tbl(j)
4609       AND inventory_item_id = l_inventory_item_id_tbl(j)
4610       AND org_id = l_org_id_tbl(j)
4611       AND language = l_language_tbl(j);
4612 
4613     l_err_loc := 600;
4614     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4615       l_err_loc := 700;
4616       COMMIT;
4617       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4618         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4619             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4620             'Commit done.');
4621       END IF;
4622     ELSE
4623       l_err_loc := 800;
4624       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4625         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4626             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4627             'Commit not done.');
4628       END IF;
4629     END IF;
4630   END LOOP;
4631 
4632   l_err_loc := 900;
4633   l_end_date := sysdate;
4634   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4635     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4636        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4637   END IF;
4638 
4639   l_err_loc := 1000;
4640 EXCEPTION
4641   WHEN OTHERS THEN
4642     ICX_CAT_UTIL_PVT.logUnexpectedException(
4643       G_PKG_NAME, l_api_name,
4644       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4645     RAISE;
4646 END purgeInvalidQuoteLines;
4647 
4648 -- Purges invalid/expired blankets includes global blankets also
4649 -- Blankets:
4650 -- Header validations:
4651 -- Approved_date is null
4652 -- authorization_status in 'REJECTED', 'INCOMPLETE'
4653 -- cancel_flag = 'Y'
4654 -- frozen_flag = 'Y'
4655 -- closed_code in 'CLOSED', 'FINALLY CLOSED'
4656 -- sysdate > end_date
4657 -- Line validations:
4658 -- cancel_flag = 'Y'
4659 -- closed_code in 'CLOSED', 'FINALLY CLOSED'
4660 -- sysdate > expiration_date
4661 PROCEDURE purgeInvalidBlanketLines
4662 IS
4663 
4664   ----- Start of declaring columns returned from the delete -----
4665   l_po_line_id_tbl              DBMS_SQL.NUMBER_TABLE;
4666   l_req_template_name_tbl       DBMS_SQL.VARCHAR2_TABLE;
4667   l_req_template_line_num_tbl   DBMS_SQL.NUMBER_TABLE;
4668   l_inventory_item_id_tbl       DBMS_SQL.NUMBER_TABLE;
4669   l_org_id_tbl                  DBMS_SQL.NUMBER_TABLE;
4670   l_language_tbl                DBMS_SQL.VARCHAR2_TABLE;
4671   ------ End of declaring columns returned from the delete ------
4672 
4673   l_api_name                    CONSTANT VARCHAR2(30)   := 'purgeInvalidBlanketLines';
4674   l_continue                    BOOLEAN := TRUE;
4675   l_err_loc                     PLS_INTEGER;
4676   l_start_date                  DATE;
4677   l_end_date                    DATE;
4678   l_row_count                   PLS_INTEGER;
4679 BEGIN
4680   l_err_loc := 100;
4681   l_start_date := sysdate;
4682   IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4683     FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4684         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4685         'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
4686   END IF;
4687 
4688   l_err_loc := 110;
4689   l_continue := TRUE;
4690   WHILE l_continue LOOP
4691     l_err_loc := 200;
4692     l_po_line_id_tbl.DELETE;
4693     l_req_template_name_tbl.DELETE;
4694     l_req_template_line_num_tbl.DELETE;
4695     l_inventory_item_id_tbl.DELETE;
4696     l_org_id_tbl.DELETE;
4697     l_language_tbl.DELETE;
4698 
4699     l_err_loc := 300;
4700     DELETE FROM icx_cat_items_ctx_hdrs_tlp hdrs
4701     WHERE hdrs.source_type IN ('BLANKET', 'GLOBAL_BLANKET')
4702     AND   EXISTS ( SELECT 'x' FROM po_lines_all pl, po_headers_all ph
4703                    WHERE  hdrs.po_line_id = pl.po_line_id
4704                    AND    pl.po_header_id = ph.po_header_id
4705                    AND    (ph.approved_date IS NULL
4706                            OR NVL(ph.authorization_status, 'INCOMPLETE') IN ('REJECTED', 'INCOMPLETE')
4707                            OR NVL(ph.cancel_flag, 'N') = 'Y'
4708                            OR NVL(ph.frozen_flag, 'N') = 'Y'
4709                            OR NVL(ph.closed_code, 'OPEN') IN ('CLOSED', 'FINALLY CLOSED')
4710                            OR NVL(TRUNC(ph.end_date), TRUNC(SYSDATE + 1)) <= TRUNC(SYSDATE)
4711                            OR NVL(pl.cancel_flag, 'N') = 'Y'
4712                            OR NVL(pl.closed_code, 'OPEN') IN ('CLOSED', 'FINALLY CLOSED')
4713                            OR NVL(TRUNC(pl.expiration_date), TRUNC(SYSDATE + 1)) <= TRUNC(SYSDATE)))
4714     AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
4715     RETURNING po_line_id, req_template_name, req_template_line_num,
4716         inventory_item_id, org_id, language
4717     BULK COLLECT INTO l_po_line_id_tbl, l_req_template_name_tbl, l_req_template_line_num_tbl,
4718         l_inventory_item_id_tbl, l_org_id_tbl, l_language_tbl;
4719 
4720     l_err_loc := 400;
4721     l_row_count := SQL%ROWCOUNT;
4722     IF (l_row_count = 0) THEN
4723       IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4724         FND_LOG.string(FND_LOG.LEVEL_EVENT,
4725             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4726             'no rows deleted from ctx_hdrs for invalid blanket lines, so exit from the loop');
4727       END IF;
4728       EXIT;
4729     ELSIF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
4730       l_continue := FALSE;
4731       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4732         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4733             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4734             'Num. of rows deleted from ctx_hdrs for invalid blanket lines:' || l_row_count);
4735       END IF;
4736     END IF;
4737 
4738     l_err_loc := 500;
4739     FORALL j IN 1..l_po_line_id_tbl.COUNT
4740       DELETE FROM icx_cat_items_ctx_dtls_tlp
4741       WHERE po_line_id = l_po_line_id_tbl(j)
4742       AND req_template_name = l_req_template_name_tbl(j)
4743       AND req_template_line_num = l_req_template_line_num_tbl(j)
4744       AND inventory_item_id = l_inventory_item_id_tbl(j)
4745       AND org_id = l_org_id_tbl(j)
4746       AND language = l_language_tbl(j);
4747 
4748     l_err_loc := 600;
4749     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4750       l_err_loc := 700;
4751       COMMIT;
4752       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4753         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4754             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4755             'Commit done.');
4756       END IF;
4757     ELSE
4758       l_err_loc := 800;
4759       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4760         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4761             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4762             'Commit not done.');
4763       END IF;
4764     END IF;
4765   END LOOP;
4766 
4767   l_err_loc := 900;
4768   l_end_date := sysdate;
4769   IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4770     FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4771         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4772         ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4773   END IF;
4774 
4775   l_err_loc := 1000;
4776 EXCEPTION
4777   WHEN OTHERS THEN
4778     ICX_CAT_UTIL_PVT.logUnexpectedException(
4779       G_PKG_NAME, l_api_name,
4780       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4781     RAISE;
4782 END purgeInvalidBlanketLines;
4783 
4784 PROCEDURE purgeInvalidItems
4785 (       x_errbuf                OUT NOCOPY      VARCHAR2                ,
4786         x_retcode               OUT NOCOPY      NUMBER
4787 )
4788 IS
4789   l_api_name            CONSTANT VARCHAR2(30)   := 'purgeInvalidItems';
4790   l_err_loc             PLS_INTEGER;
4791   l_start_date          DATE;
4792   l_end_date            DATE;
4793   l_log_string		VARCHAR2(2000);
4794 BEGIN
4795   l_err_loc := 100;
4796   x_retcode := 0;
4797   x_errbuf := '';
4798 
4799   l_err_loc := 150;
4800   l_start_date := sysdate;
4801 
4802   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4803     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4804     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4805   END IF;
4806 
4807   l_err_loc := 200;
4808   ICX_CAT_UTIL_PVT.setCommitParameter(FND_API.G_TRUE);
4809 
4810   l_err_loc := 300;
4811   -- Set the batch_size if supplier needs to be updated
4812   ICX_CAT_UTIL_PVT.setBatchSize;
4813 
4814   l_err_loc := 400;
4815   purgeInvalidBlanketLines;
4816 
4817   l_err_loc := 500;
4818   purgeInvalidQuoteLines;
4819 
4820   l_err_loc := 600;
4821   purgeInvalidReqTmpltLines;
4822 
4823   l_err_loc := 700;
4824   purgeInvalidCategoryItems;
4825 
4826   l_err_loc := 800;
4827   IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4828     l_err_loc := 900;
4829     -- Call the rebuild index
4830     ICX_CAT_INTERMEDIA_INDEX_PVT.rebuild_index;
4831     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4832       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4833           ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4834           'Rebuild indexes called.');
4835     END IF;
4836   END IF;
4837 
4838   l_err_loc := 1000;
4839   l_end_date := sysdate;
4840   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4841     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4842        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4843   END IF;
4844 EXCEPTION
4845   WHEN OTHERS THEN
4846     x_retcode := 2;
4847     x_errbuf := 'Exception at ' ||
4848                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name) ||
4849                 '(l_err_loc:' || l_err_loc || '), ' || SQLERRM;
4850     ICX_CAT_UTIL_PVT.logUnexpectedException(
4851       G_PKG_NAME, l_api_name,
4852       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4853     RAISE;
4854 END purgeInvalidItems;
4855 
4856 PROCEDURE rebuildIPIntermediaIndex
4857 (       x_errbuf                OUT NOCOPY      VARCHAR2                ,
4858         x_retcode               OUT NOCOPY      NUMBER
4859 )
4860 IS
4861   l_api_name            CONSTANT VARCHAR2(30)   := 'rebuildIPIntermediaIndex';
4862   l_err_loc             PLS_INTEGER;
4863   l_start_date          DATE;
4864   l_end_date            DATE;
4865   l_log_string		VARCHAR2(2000);
4866 BEGIN
4867   l_err_loc := 100;
4868   x_retcode := 0;
4869   x_errbuf := '';
4870 
4871   l_err_loc := 200;
4872   l_start_date := sysdate;
4873 
4874   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4875     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4876     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4877   END IF;
4878 
4879   l_err_loc := 300;
4880   -- Call the rebuild index
4881   ICX_CAT_INTERMEDIA_INDEX_PVT.rebuild_index;
4882 
4883   l_err_loc := 400;
4884   l_end_date := sysdate;
4885   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4886     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4887        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4888   END IF;
4889 EXCEPTION
4890   WHEN OTHERS THEN
4891     x_retcode := 2;
4892     x_errbuf := 'Exception at ' ||
4893                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name) ||
4894                 '(l_err_loc:' || l_err_loc || '), ' || SQLERRM;
4895     ICX_CAT_UTIL_PVT.logUnexpectedException(
4896       G_PKG_NAME, l_api_name,
4897       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4898     RAISE;
4899 END rebuildIPIntermediaIndex;
4900 
4901 END ICX_CAT_POPULATE_ITEM_PVT;