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.14.12010000.2 2008/08/02 14:39:01 kkram 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           DBMS_SQL.VARCHAR2_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           DBMS_SQL.VARCHAR2_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 
3092     l_err_loc := 1300;
3093     l_action_mode := 'DELETE_SPECIFIC_CTX_DTLS';
3094     -- DELETE rows with sequence > 100 and < 10000 icx_cat_items_ctx_dtl_tlp
3095     l_start_sequence := 101;
3096     l_end_sequence := 9999;
3097     FORALL i in 1..gDBLDInventoryItemIdTbl.COUNT
3098       DELETE FROM icx_cat_items_ctx_dtls_tlp
3099       WHERE inventory_item_id = gDBLDInventoryItemIdTbl(i)
3100       AND   po_line_id = gDBLDPoLineIdTbl(i)
3101       AND   req_template_name = gDBLDReqTemplateNameTbl(i)
3102       AND   req_template_line_num = gDBLDReqTemplateLineNumTbl(i)
3103       AND   org_id = gDBLDOrgIdTbl(i)
3104       AND   language = gDBLDLanguageTbl(i)
3105       AND   sequence BETWEEN l_start_sequence AND l_end_sequence;
3106 
3107     IF (gDBLDInventoryItemIdTbl.COUNT > 0) THEN
3108       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3109         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3110             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3111             'Num. of rows deleted from ctx_dtls for base and local row changes:' ||SQL%ROWCOUNT);
3112       END IF;
3113     END IF;
3114 
3115     l_err_loc := 1350;
3116     l_action_mode := 'INSERT_CTX_DTLS';
3117     -- populate the org rows in ctx details
3118     --  sequence        ctx_desc
3119     --  10000           <orgid>
3120     --  10001           to_char(gIDOrgIdTbl(i))
3121     --  15000           </orgid>
3122     --  15001           <purchorgid> || to_char(gIDPurchasingOrgIdTbl(i)) || </purchorgid>
3123     --  15001           <purchorgid> || to_char(gDPODPurchasingOrgIdTbl(i)) || </purchorgid>
3124     FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3125       INSERT INTO icx_cat_items_ctx_dtls_tlp
3126       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3127        org_id, language, sequence, ctx_desc,
3128        last_update_login, last_updated_by, last_update_date,
3129        created_by, creation_date, internal_request_id, request_id,
3130        program_application_id, program_id, program_login_id)
3131       VALUES(gIDInventoryItemIdTbl(i), gIDPoLineIdTbl(i), gIDReqTemplateNameTbl(i), gIDReqTemplateLineNumTbl(i),
3132        gIDOrgIdTbl(i), gIDLanguageTbl(i), 10000, '<orgid>',
3133        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3134        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3135        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3136        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3137        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3138        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3139        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3140        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3141 
3142     l_err_loc := 1400;
3143     FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3144       INSERT INTO icx_cat_items_ctx_dtls_tlp
3145       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3146        org_id, language, sequence, ctx_desc,
3147        last_update_login, last_updated_by, last_update_date,
3148        created_by, creation_date, internal_request_id, request_id,
3149        program_application_id, program_id, program_login_id)
3150       VALUES(gIDInventoryItemIdTbl(i), gIDPoLineIdTbl(i), gIDReqTemplateNameTbl(i), gIDReqTemplateLineNumTbl(i),
3151        gIDOrgIdTbl(i), gIDLanguageTbl(i), 10001, to_char(gIDOrgIdTbl(i)),
3152        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3153        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3154        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3155        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3156        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3157        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3158        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3159        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3160 
3161     l_err_loc := 1450;
3162     FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3163       INSERT INTO icx_cat_items_ctx_dtls_tlp
3164       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3165        org_id, language, sequence, ctx_desc,
3166        last_update_login, last_updated_by, last_update_date,
3167        created_by, creation_date, internal_request_id, request_id,
3168        program_application_id, program_id, program_login_id)
3169       VALUES(gIDInventoryItemIdTbl(i), gIDPoLineIdTbl(i), gIDReqTemplateNameTbl(i), gIDReqTemplateLineNumTbl(i),
3170        gIDOrgIdTbl(i), gIDLanguageTbl(i), 15000, '</orgid>',
3171        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3172        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3173        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3174        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3175        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3176        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3177        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3178        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3179 
3180     IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3181       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3182         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3183             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3184             'Num. of rows inserted into ctx_dtls for org row:' ||SQL%ROWCOUNT);
3185       END IF;
3186     END IF;
3187 
3188     l_err_loc := 1460;
3189     -- Purchasing_org_id row needs to be populated for new rows i.e. gIDInventoryItemIdTbl and gDPODInventoryItemIdTbl
3190     FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3191       INSERT INTO icx_cat_items_ctx_dtls_tlp
3192       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3193        org_id, language, sequence, ctx_desc,
3194        last_update_login, last_updated_by, last_update_date,
3195        created_by, creation_date, internal_request_id, request_id,
3196        program_application_id, program_id, program_login_id)
3197       VALUES(gIDInventoryItemIdTbl(i), gIDPoLineIdTbl(i), gIDReqTemplateNameTbl(i), gIDReqTemplateLineNumTbl(i),
3198        gIDOrgIdTbl(i), gIDLanguageTbl(i), 15001, '<purchorgid>' || to_char(gIDPurchasingOrgIdTbl(i)) || '</purchorgid>',
3199        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3200        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3201        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3202        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3203        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3204        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3205        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3206        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3207 
3208     IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3209       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3210         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3211             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3212             'Num. of rows inserted into ctx_dtls for purch_org row:' ||SQL%ROWCOUNT);
3213       END IF;
3214     END IF;
3215 
3216     l_err_loc := 1500;
3217     l_action_mode := 'DELETE_PURCHORG_ROW_CTX_DTLS';
3218     -- Purchasing_org_id row needs to be populated for new rows i.e. gIDInventoryItemIdTbl and gDPODInventoryItemIdTbl
3219     FORALL i in 1..gDPODInventoryItemIdTbl.COUNT
3220       INSERT INTO icx_cat_items_ctx_dtls_tlp
3221       (inventory_item_id, po_line_id, req_template_name, req_template_line_num,
3222        org_id, language, sequence, ctx_desc,
3223        last_update_login, last_updated_by, last_update_date,
3224        created_by, creation_date, internal_request_id, request_id,
3225        program_application_id, program_id, program_login_id)
3226       VALUES(gDPODInventoryItemIdTbl(i), gDPODPoLineIdTbl(i), gDPODReqTemplateNameTbl(i), gDPODReqTemplateLineNumTbl(i),
3227        gDPODOrgIdTbl(i), gDPODLanguageTbl(i), 15001, '<purchorgid>' || to_char(gDPODPurchasingOrgIdTbl(i)) || '</purchorgid>',
3228        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3229        ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3230        ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3231        ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3232        ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3233        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3234        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3235        ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3236 
3237     IF (gDPODInventoryItemIdTbl.COUNT > 0) THEN
3238       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3239         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3240             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3241             'Num. of rows inserted into ctx_dtls for purch_org row:' ||SQL%ROWCOUNT);
3242       END IF;
3243     END IF;
3244 
3245     l_err_loc := 1550;
3246     -- Inserting rows for special attribute rows i.e. sequence between 1 and 100
3247     IF (gIDInventoryItemIdTbl.COUNT > 0 OR
3248         gDMDInventoryItemIdTbl.COUNT > 0 OR
3249         gDSDInventoryItemIdTbl.COUNT > 0 OR
3250         gDIRDInventoryItemIdTbl.COUNT > 0 OR
3251         gDSCDInventoryItemIdTbl.COUNT > 0) THEN
3252       FOR i IN 1..l_special_ctx_sql_tbl.COUNT LOOP
3253         l_err_loc := 1600;
3254         l_ctx_sqlstring_rec := l_special_ctx_sql_tbl(i);
3255         l_ctx_sql_string := l_ctx_sqlstring_rec.ctx_sql_string;
3256         l_sequence := l_ctx_sqlstring_rec.bind_sequence;
3257         IF (p_current_cursor = ICX_CAT_UTIL_PVT.g_GBPACsr_const AND i > 1) THEN
3258           -- For GBPAs enabled org we only need to populate the row with sequence 1
3259           -- diffferntly than the owning org.  The other rows i.e. between sequence 2 to 9999
3260           -- will be exact copies of owning org
3261           EXIT;
3262         END IF;
3263         l_err_loc := 1650;
3264         l_csr_handle:=DBMS_SQL.OPEN_CURSOR;
3265         l_err_loc := 1700;
3266         DBMS_SQL.PARSE(l_csr_handle, l_ctx_sql_string, DBMS_SQL.NATIVE);
3267         IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3268           l_err_loc := 1750;
3269           l_action_mode := 'INSERT_CTX_DTLS';
3270           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3271           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gIDInventoryItemIdTbl);
3272           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gIDPoLineIdTbl);
3273           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gIDReqTemplateNameTbl);
3274           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gIDReqTemplateLineNumTbl);
3275           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gIDOrgIdTbl);
3276           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gIDLanguageTbl);
3277           l_err_loc := 1800;
3278           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3279           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3280             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3281                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3282                 'special Ctx SQLS details..' ||
3283                 '; Num. of rows in dtls plsql table:' || gIDInventoryItemIdTbl.COUNT ||
3284                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3285           END IF;
3286         END IF;
3287 
3288         IF (l_sequence = 1 AND gDMDInventoryItemIdTbl.COUNT > 0) THEN
3289           l_err_loc := 1850;
3290           l_action_mode := 'DELETE_MANDATORY_ROW_CTX_DTLS';
3291           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3292           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDMDInventoryItemIdTbl);
3293           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDMDPoLineIdTbl);
3294           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDMDReqTemplateNameTbl);
3295           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDMDReqTemplateLineNumTbl);
3296           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDMDOrgIdTbl);
3297           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDMDLanguageTbl);
3298           l_err_loc := 1900;
3299           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3300           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3301             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3302                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3303                 'special Ctx SQLS, Mandatory Row details..' ||
3304                 '; Num. of rows in dtls plsql table:' || gDMDInventoryItemIdTbl.COUNT ||
3305                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3306           END IF;
3307         END IF;
3308 
3309         IF (l_sequence = 2 AND gDSDInventoryItemIdTbl.COUNT > 0) THEN
3310           l_err_loc := 1950;
3311           l_action_mode := 'DELETE_SUPPLIER_ROW_CTX_DTLS';
3312           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3313           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDSDInventoryItemIdTbl);
3314           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDSDPoLineIdTbl);
3315           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDSDReqTemplateNameTbl);
3316           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDSDReqTemplateLineNumTbl);
3317           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDSDOrgIdTbl);
3318           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDSDLanguageTbl);
3319           l_err_loc := 2000;
3320           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3321           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3322             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3323                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3324                 'special Ctx SQLS, Supplier Row details..' ||
3325                 '; Num. of rows in dtls plsql table:' || gDSDInventoryItemIdTbl.COUNT ||
3326                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3327           END IF;
3328         END IF;
3329 
3330         IF (l_sequence = 5 AND gDIRDInventoryItemIdTbl.COUNT > 0) THEN
3331           l_err_loc := 2050;
3332           l_action_mode := 'DELETE_ITEMREV_ROW_CTX_DTLS';
3333           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3334           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDIRDInventoryItemIdTbl);
3335           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDIRDPoLineIdTbl);
3336           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDIRDReqTemplateNameTbl);
3337           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDIRDReqTemplateLineNumTbl);
3338           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDIRDOrgIdTbl);
3339           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDIRDLanguageTbl);
3340           l_err_loc := 2100;
3341           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3342           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3343             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3344                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3345                 'special Ctx SQLS, ItemRev Row details..' ||
3346                 '; Num. of rows in dtls plsql table:' || gDIRDInventoryItemIdTbl.COUNT ||
3347                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3348           END IF;
3349         END IF;
3350 
3351         IF (l_sequence = 6 AND gDSCDInventoryItemIdTbl.COUNT > 0) THEN
3352           l_err_loc := 2150;
3353           l_action_mode := 'DELETE_SHOPCATG_ROW_CTX_DTLS';
3354           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_sequence);
3355           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDSCDInventoryItemIdTbl);
3356           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDSCDPoLineIdTbl);
3357           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDSCDReqTemplateNameTbl);
3358           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDSCDReqTemplateLineNumTbl);
3359           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDSCDOrgIdTbl);
3360           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDSCDLanguageTbl);
3361           l_err_loc := 2200;
3362           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3363           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3364             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3365                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3366                 'special Ctx SQLS, ShopCatg Row details..' ||
3367                 '; Num. of rows in dtls plsql table:' || gDSCDInventoryItemIdTbl.COUNT ||
3368                 ', for seq:' || l_sequence || ', Num. of rows inserted into dtls:' || l_status);
3369           END IF;
3370         END IF;
3371 
3372         l_err_loc := 2250;
3373         DBMS_SQL.CLOSE_CURSOR(l_csr_handle);
3374         l_err_loc := 10000 + i;
3375       END LOOP;
3376     END IF;
3377 
3378     l_err_loc :=2300;
3379     -- Inserting rows for base attribute rows i.e. sequence between 101 and 5000
3380     IF (p_current_cursor = ICX_CAT_UTIL_PVT.g_GBPACsr_const) THEN
3381       l_err_loc := 2400;
3382       l_action_mode := 'INSERT_CTX_DTLS';
3383       l_start_sequence := 2;
3384       l_end_sequence := 5000;
3385       -- rows with sequence between 5001 and 9999 (local attributes) will be done after the
3386       -- final call to ICX_CAT_POPULATE_CTXSTRING_PVT.populateCtxCatgAtt in
3387       FORALL i in 1..gIDInventoryItemIdTbl.COUNT
3388         INSERT INTO icx_cat_items_ctx_dtls_tlp
3389          (inventory_item_id, po_line_id, req_template_name,
3390           req_template_line_num, org_id, language,
3391           last_update_login, last_updated_by, last_update_date,
3392           created_by, creation_date, internal_request_id, request_id,
3393           program_application_id, program_id, program_login_id,
3394           sequence, ctx_desc)
3395         SELECT inventory_item_id, po_line_id, req_template_name,
3396                req_template_line_num, gIDOrgIdTbl(i), language,
3397                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3398                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3399                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3400                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3401                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3402                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3403                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3404                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3405                sequence, ctx_desc
3406         FROM icx_cat_items_ctx_dtls_tlp
3407         WHERE inventory_item_id = gIDInventoryItemIdTbl(i)
3408         AND   po_line_id = gIDPoLineIdTbl(i)
3409         AND   req_template_name = gIDReqTemplateNameTbl(i)
3410         AND   req_template_line_num = gIDReqTemplateLineNumTbl(i)
3411         AND   org_id = gIDOwningOrgIdTbl(i)
3412         AND   language = gIDLanguageTbl(i)
3413         AND   sequence BETWEEN l_start_sequence AND l_end_sequence;
3414 
3415       IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3416         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3417           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3418               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3419               'Num. of rows inserted into ctx_dtls for GBPA with seq between 2 - 5000 row:' ||SQL%ROWCOUNT);
3420         END IF;
3421       END IF;
3422       l_err_loc := 2500;
3423 
3424       l_action_mode := 'DELETE_SPECIFIC_CTX_DTLS';
3425       l_start_sequence := 101;
3426       FORALL i in 1..gDBLDInventoryItemIdTbl.COUNT
3427         INSERT INTO icx_cat_items_ctx_dtls_tlp
3428          (inventory_item_id, po_line_id, req_template_name,
3429           req_template_line_num, org_id, language,
3430           last_update_login, last_updated_by, last_update_date,
3431           created_by, creation_date, internal_request_id, request_id,
3432           program_application_id, program_id, program_login_id,
3433           sequence, ctx_desc)
3434         SELECT inventory_item_id, po_line_id, req_template_name,
3435                req_template_line_num, gDBLDOrgIdTbl(i), language,
3436                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3437                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3438                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3439                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3440                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3441                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3442                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3443                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3444                sequence, ctx_desc
3445         FROM icx_cat_items_ctx_dtls_tlp
3446         WHERE inventory_item_id = gDBLDInventoryItemIdTbl(i)
3447         AND   po_line_id = gDBLDPoLineIdTbl(i)
3448         AND   req_template_name = gDBLDReqTemplateNameTbl(i)
3449         AND   req_template_line_num = gDBLDReqTemplateLineNumTbl(i)
3450         AND   org_id = gDBLDOwningOrgIdTbl(i)
3451         AND   language = gDBLDLanguageTbl(i)
3452         AND   sequence BETWEEN l_start_sequence AND l_end_sequence;
3453 
3454       l_err_loc := 2600;
3455       IF (gDBLDInventoryItemIdTbl.COUNT > 0) THEN
3456         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3457           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3458               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3459               'Num. of rows inserted into ctx_dtls for 101 - 5000 row:' ||SQL%ROWCOUNT);
3460         END IF;
3461       END IF;
3462 
3463       l_action_mode := 'DELETE_SUPPLIER_ROW_CTX_DTLS';
3464       -- l_sequence := 2;
3465       FORALL i in 1..gDSDInventoryItemIdTbl.COUNT
3466         INSERT INTO icx_cat_items_ctx_dtls_tlp
3467          (inventory_item_id, po_line_id, req_template_name,
3468           req_template_line_num, org_id, language,
3469           last_update_login, last_updated_by, last_update_date,
3470           created_by, creation_date, internal_request_id, request_id,
3471           program_application_id, program_id, program_login_id,
3472           sequence, ctx_desc)
3473         SELECT inventory_item_id, po_line_id, req_template_name,
3474                req_template_line_num, gDSDOrgIdTbl(i), language,
3475                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3476                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3477                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3478                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3479                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3480                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3481                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3482                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3483                sequence, ctx_desc
3484         FROM icx_cat_items_ctx_dtls_tlp
3485         WHERE inventory_item_id = gDSDInventoryItemIdTbl(i)
3486         AND   po_line_id = gDSDPoLineIdTbl(i)
3487         AND   req_template_name = gDSDReqTemplateNameTbl(i)
3488         AND   req_template_line_num = gDSDReqTemplateLineNumTbl(i)
3489         AND   org_id = gDSDOwningOrgIdTbl(i)
3490         AND   language = gDSDLanguageTbl(i)
3491         AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForSupplierRow;
3492 
3493       IF (gDSDInventoryItemIdTbl.COUNT > 0) THEN
3494         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3495           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3496               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3497               'Num. of rows inserted into ctx_dtls for seq 2 row:' ||SQL%ROWCOUNT);
3498         END IF;
3499       END IF;
3500       l_err_loc := 2700;
3501 
3502       l_action_mode := 'DELETE_ITEMREV_ROW_CTX_DTLS';
3503       -- l_sequence := 5;
3504       FORALL i in 1..gDIRDInventoryItemIdTbl.COUNT
3505         INSERT INTO icx_cat_items_ctx_dtls_tlp
3506          (inventory_item_id, po_line_id, req_template_name,
3507           req_template_line_num, org_id, language,
3508           last_update_login, last_updated_by, last_update_date,
3509           created_by, creation_date, internal_request_id, request_id,
3510           program_application_id, program_id, program_login_id,
3511           sequence, ctx_desc)
3512         SELECT inventory_item_id, po_line_id, req_template_name,
3513                req_template_line_num, gDIRDOrgIdTbl(i), language,
3514                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3515                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3516                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3517                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3518                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3519                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3520                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3521                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3522                sequence, ctx_desc
3523         FROM icx_cat_items_ctx_dtls_tlp
3524         WHERE inventory_item_id = gDIRDInventoryItemIdTbl(i)
3525         AND   po_line_id = gDIRDPoLineIdTbl(i)
3526         AND   req_template_name = gDIRDReqTemplateNameTbl(i)
3527         AND   req_template_line_num = gDIRDReqTemplateLineNumTbl(i)
3528         AND   org_id = gDIRDOwningOrgIdTbl(i)
3529         AND   language = gDIRDLanguageTbl(i)
3530         AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForItemRevisionRow;
3531 
3532       l_err_loc := 2800;
3533       IF (gDIRDInventoryItemIdTbl.COUNT > 0) THEN
3534         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3535           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3536               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3537               'Num. of rows inserted into ctx_dtls for seq 5 row:' ||SQL%ROWCOUNT);
3538         END IF;
3539       END IF;
3540 
3541       l_action_mode := 'DELETE_SHOPCATG_ROW_CTX_DTLS';
3542       -- l_sequence := 6;
3543       FORALL i in 1..gDSCDInventoryItemIdTbl.COUNT
3544         INSERT INTO icx_cat_items_ctx_dtls_tlp
3545          (inventory_item_id, po_line_id, req_template_name,
3546           req_template_line_num, org_id, language,
3547           last_update_login, last_updated_by, last_update_date,
3548           created_by, creation_date, internal_request_id, request_id,
3549           program_application_id, program_id, program_login_id,
3550           sequence, ctx_desc)
3551         SELECT inventory_item_id, po_line_id, req_template_name,
3552                req_template_line_num, gDSCDOrgIdTbl(i), language,
3553                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3554                ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3555                ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3556                ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3557                ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3558                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3559                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3560                ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id,
3561                sequence, ctx_desc
3562         FROM icx_cat_items_ctx_dtls_tlp
3563         WHERE inventory_item_id = gDSCDInventoryItemIdTbl(i)
3564         AND   po_line_id = gDSCDPoLineIdTbl(i)
3565         AND   req_template_name = gDSCDReqTemplateNameTbl(i)
3566         AND   req_template_line_num = gDSCDReqTemplateLineNumTbl(i)
3567         AND   org_id = gDSCDOwningOrgIdTbl(i)
3568         AND   language = gDSCDLanguageTbl(i)
3569         AND   sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForShoppingCategoryRow;
3570 
3571       l_err_loc := 2900;
3572       IF (gDSCDInventoryItemIdTbl.COUNT > 0) THEN
3573         IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3574           FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3575               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3576               'Num. of rows inserted into ctx_dtls for seq 6 row:' ||SQL%ROWCOUNT);
3577         END IF;
3578       END IF;
3579     ELSE
3580       l_err_loc := 3000;
3581       FOR i IN 1..l_regular_ctx_sql_tbl.COUNT LOOP
3582         l_err_loc := 3100;
3583         l_ctx_sqlstring_rec := l_regular_ctx_sql_tbl(i);
3584         l_err_loc := 3200;
3585         l_csr_handle:=DBMS_SQL.OPEN_CURSOR;
3586         l_err_loc := 3300;
3587         DBMS_SQL.PARSE(l_csr_handle, l_ctx_sqlstring_rec.ctx_sql_string, DBMS_SQL.NATIVE);
3588         IF (gIDInventoryItemIdTbl.COUNT > 0) THEN
3589           l_action_mode := 'INSERT_CTX_DTLS';
3590           l_err_loc := 3400;
3591           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_ctx_sqlstring_rec.bind_sequence);
3592           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gIDInventoryItemIdTbl);
3593           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gIDPoLineIdTbl);
3594           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gIDReqTemplateNameTbl);
3595           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gIDReqTemplateLineNumTbl);
3596           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gIDOrgIdTbl);
3597           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gIDLanguageTbl);
3598           l_err_loc := 3500;
3599           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3600           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3601             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3602                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3603                 'regular Ctx SQLS details..' ||
3604                 '; Num. of rows in dtls plsql table:' || gIDInventoryItemIdTbl.COUNT ||
3605                 ', for seq:' || l_ctx_sqlstring_rec.bind_sequence ||
3606                 ', Num. of rows inserted into dtls:' || l_status);
3607           END IF;
3608         END IF;
3609         l_err_loc := 3600;
3610         IF (gDBLDInventoryItemIdTbl.COUNT > 0) THEN
3611           l_action_mode := 'DELETE_SPECIFIC_CTX_DTLS';
3612           l_err_loc := 3700;
3613           DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_ctx_sqlstring_rec.bind_sequence);
3614           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_INVENTORY_ITEM_ID', gDBLDInventoryItemIdTbl);
3615           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_PO_LINE_ID', gDBLDPoLineIdTbl);
3616           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_NAME', gDBLDReqTemplateNameTbl);
3617           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_REQ_TEMPLATE_LINE_NUM', gDBLDReqTemplateLineNumTbl);
3618           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_ORG_ID', gDBLDOrgIdTbl);
3619           DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_LANGUAGE', gDBLDLanguageTbl);
3620           l_err_loc := 3800;
3621           l_status := DBMS_SQL.EXECUTE(l_csr_handle);
3622           IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3623             FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3624                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3625                 'regular Ctx SQLS details..' ||
3626                 '; Num. of rows in dtls plsql table:' || gDBLDInventoryItemIdTbl.COUNT ||
3627                 ', for seq:' || l_ctx_sqlstring_rec.bind_sequence ||
3628                 ', Num. of rows inserted into dtls:' || l_status);
3629           END IF;
3630         END IF;
3631         l_err_loc := 3900;
3632         DBMS_SQL.CLOSE_CURSOR(l_csr_handle);
3633         l_err_loc := 20000 + i;
3634       END LOOP;
3635     END IF;  -- (p_current_cursor = ICX_CAT_UTIL_PVT.g_GBPACsr_const)
3636 
3637     l_err_loc := 4000;
3638     clearTables('ALL');
3639 
3640     l_err_loc := 4100;
3641     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
3642       COMMIT;
3643       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3644         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3645             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3646             'Commit done.');
3647       END IF;
3648     ELSE
3649       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3650         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3651             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3652             'Commit not done.');
3653       END IF;
3654     END IF;
3655     l_err_loc := 4200;
3656 
3657   END IF; -- (p_mode = 'OUTLOOP' OR gTotalRowCount >= ICX_CAT_UTIL_PVT.g_batch_size)
3658   l_err_loc := 4300;
3659 EXCEPTION
3660   WHEN OTHERS THEN
3661     logPLSQLTableRow(l_api_name, FND_LOG.LEVEL_UNEXPECTED, SQL%ROWCOUNT+1, l_action_mode);
3662     ICX_CAT_UTIL_PVT.logUnexpectedException(
3663       G_PKG_NAME, l_api_name,
3664       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
3665     RAISE;
3666 END populateItemCtxTables;
3667 
3668 PROCEDURE populateVendorNameChanges
3669 (       p_vendor_party_id       IN              NUMBER          ,
3670         p_vendor_name           IN              VARCHAR2
3671 )
3672 IS
3673   l_api_name            CONSTANT VARCHAR2(30)   := 'populateVendorNameChanges';
3674   l_err_loc             PLS_INTEGER;
3675   l_searchable          NUMBER;
3676   l_section_tag         NUMBER;
3677   l_continue            BOOLEAN := TRUE;
3678   l_rowid_tbl           DBMS_SQL.UROWID_TABLE;
3679   l_row_count           PLS_INTEGER;
3680 BEGIN
3681   l_err_loc := 100;
3682   ICX_CAT_BUILD_CTX_SQL_PVT.checkIfAttributeIsSrchble
3683                 ('SUPPLIER', l_searchable, l_section_tag);
3684 
3685   l_err_loc := 200;
3686   -- Set the batch_size if supplier needs to be updated
3687   ICX_CAT_UTIL_PVT.setBatchSize;
3688 
3689   l_err_loc := 300;
3690   -- Set the who columns
3691   ICX_CAT_UTIL_PVT.setWhoColumns(null);
3692 
3693   l_err_loc := 400;
3694   IF (l_searchable = 1) THEN
3695 
3696     l_err_loc := 500;
3697     WHILE l_continue LOOP
3698       l_err_loc := 600;
3699       l_rowid_tbl.DELETE;
3700 
3701       l_err_loc := 700;
3702       UPDATE icx_cat_items_ctx_hdrs_tlp
3703       SET ctx_desc = NULL,
3704           supplier = p_vendor_name,
3705           last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3706           last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3707           last_update_date = sysdate,
3708           internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3709           request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3710           program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3711           program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3712           program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
3713       WHERE supplier_id IN (SELECT vendor_id
3714                             FROM po_vendors
3715                             WHERE party_id = p_vendor_party_id)
3716       AND internal_request_id <> ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id
3717       AND ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
3718       RETURNING ROWID BULK COLLECT INTO l_rowid_tbl;
3719 
3720       l_err_loc := 800;
3721       l_row_count := SQL%ROWCOUNT;
3722       IF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
3723         l_err_loc := 900;
3724         l_continue := FALSE;
3725         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3726           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3727                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3728                'Num of rows updated in ctx_hdrs for supplier name change:' || l_row_count);
3729         END IF;
3730       END IF;
3731 
3732       l_err_loc := 1000;
3733       FORALL i IN 1..l_rowid_tbl.COUNT
3734         UPDATE icx_cat_items_ctx_dtls_tlp dtls
3735         SET ctx_desc = '<' || l_section_tag || '>' || replace(replace(p_vendor_name, '<', ' '), '>', ' ') || '</' || l_section_tag || '>',
3736             last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3737             last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3738             last_update_date = sysdate,
3739             internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3740             request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3741             program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3742             program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3743             program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
3744         WHERE sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForSupplierRow
3745         AND EXISTS ( SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
3746                      WHERE hdrs.po_line_id = dtls.po_line_id
3747                      AND hdrs.req_template_name = dtls.req_template_name
3748                      AND hdrs.req_template_line_num = dtls.req_template_line_num
3749                      AND hdrs.inventory_item_id = dtls.inventory_item_id
3750                      AND hdrs.org_id = dtls.org_id
3751                      AND hdrs.language = dtls.language
3752                      AND hdrs.rowid = l_rowid_tbl(i) );
3753 
3754       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3755         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3756              ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3757              'Num of rows updated in ctx_dtls for supplier name change:' ||SQL%ROWCOUNT);
3758       END IF;
3759 
3760       l_err_loc := 1100;
3761       IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
3762         l_err_loc := 1200;
3763         COMMIT;
3764         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3765           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3766               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3767               'Commit done.');
3768         END IF;
3769       ELSE
3770         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3771           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3772               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3773               'Commit not done.');
3774         END IF;
3775       END IF;
3776     END LOOP;
3777 
3778     l_err_loc := 1300;
3779     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
3780       l_err_loc := 1400;
3781       -- Call the rebuild index
3782       ICX_CAT_INTERMEDIA_INDEX_PVT.rebuild_index;
3783       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3784         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3785             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3786             'Rebuild indexes called.');
3787       END IF;
3788     END IF;
3789   ELSE
3790 
3791     l_err_loc := 1400;
3792     WHILE l_continue LOOP
3793       l_err_loc := 1500;
3794       l_rowid_tbl.DELETE;
3795 
3796       l_err_loc := 1600;
3797       UPDATE icx_cat_items_ctx_hdrs_tlp
3798       SET supplier = p_vendor_name,
3799           last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3800           last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3801           last_update_date = sysdate,
3802           internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3803           request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3804           program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3805           program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3806           program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
3807       WHERE supplier_id IN (SELECT vendor_id
3808                             FROM po_vendors
3809                             WHERE party_id = p_vendor_party_id)
3810       AND internal_request_id <> ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id
3811       AND ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size;
3812 
3813       l_err_loc := 1700;
3814       l_row_count := SQL%ROWCOUNT;
3815       IF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
3816         l_err_loc := 1800;
3817         l_continue := FALSE;
3818         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3819           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3820                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3821                'Num of rows updated in ctx_hdrs for supplier name change:' || l_row_count);
3822         END IF;
3823       END IF;
3824 
3825       l_err_loc := 1900;
3826       IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
3827         l_err_loc := 2000;
3828         COMMIT;
3829         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3830           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3831               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3832               'Commit done.');
3833         END IF;
3834       ELSE
3835         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3836           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3837               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3838               'Commit not done.');
3839         END IF;
3840       END IF;
3841     END LOOP;
3842 
3843     l_err_loc := 2100;
3844     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3845       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3846           ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3847           'Only update the supplier name on the header; Supplier is not searchable l_searchable:' || l_searchable );
3848     END IF;
3849   END IF; -- IF (l_searchable = 1) THEN
3850 
3851   l_err_loc := 2200;
3852 EXCEPTION
3853   WHEN OTHERS THEN
3854     ICX_CAT_UTIL_PVT.logUnexpectedException(
3855       G_PKG_NAME, l_api_name,
3856       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
3857     RAISE;
3858 END populateVendorNameChanges;
3859 
3860 /*
3861 Steps:
3862 1. update supplier_id, supplier_site_id and ctx_desc in icx_cat_items_ctx_hdrs_tlp
3863 2. delete and insert into icx_cat_items_ctx_dtls_tlp : sequence 1 for supid and siteid
3864 3. Check if supplier is searchable, if yes then update icx_cat_items_ctx_dtls_tlp : sequence 2 for supplier
3865 4. call rebuild_index.
3866 */
3867 PROCEDURE populateVendorMerge
3868 (       p_from_vendor_id        IN              NUMBER                  ,
3869         p_from_site_id          IN              NUMBER                  ,
3870         p_to_vendor_id          IN              NUMBER                  ,
3871         p_to_site_id            IN              NUMBER
3872 )
3873 IS
3874   l_api_name                    CONSTANT VARCHAR2(30)   := 'populateVendorMerge';
3875   l_err_loc                     PLS_INTEGER;
3876   l_to_vendor_name              po_vendors.vendor_name%TYPE;
3877   l_continue                    BOOLEAN := TRUE;
3878   l_rowid_tbl                   DBMS_SQL.UROWID_TABLE;
3879   l_rows_updated                BOOLEAN := TRUE;
3880   l_metadataTblFormed           BOOLEAN := FALSE;
3881   l_special_metadata_tbl        ICX_CAT_BUILD_CTX_SQL_PVT.g_metadata_tbl_type;
3882   l_regular_nontl_metadata_tbl  ICX_CAT_BUILD_CTX_SQL_PVT.g_metadata_tbl_type;
3883   l_regular_tl_metadata_tbl     ICX_CAT_BUILD_CTX_SQL_PVT.g_metadata_tbl_type;
3884   l_all_ctx_sql_tbl             ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_tbl_type;
3885   l_special_ctx_sql_tbl         ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_tbl_type;
3886   l_regular_ctx_sql_tbl         ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_tbl_type;
3887   l_ctx_sqlstring_rec           ICX_CAT_BUILD_CTX_SQL_PVT.g_ctx_sql_rec_type;
3888   l_csr_handle                  NUMBER;
3889   l_status                      PLS_INTEGER;
3890   l_searchable                  VARCHAR2(1) := NULL;
3891   l_metadata_rec                ICX_CAT_BUILD_CTX_SQL_PVT.g_metadata_rec_type;
3892   l_row_count                   PLS_INTEGER;
3893 BEGIN
3894   l_err_loc := 100;
3895   -- Set the batch_size if supplier needs to be updated
3896   ICX_CAT_UTIL_PVT.setBatchSize;
3897 
3898   l_err_loc := 300;
3899   -- Set the who columns
3900   ICX_CAT_UTIL_PVT.setWhoColumns(null);
3901 
3902   l_err_loc := 400;
3903 
3904   SELECT vendor_name
3905   INTO   l_to_vendor_name
3906   FROM   po_vendors
3907   WHERE  vendor_id = p_to_vendor_id;
3908 
3909   l_err_loc := 500;
3910   IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3911     FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3912         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3913         'l_to_vendor_name:' || l_to_vendor_name);
3914   END IF;
3915 
3916   l_err_loc := 600;
3917   -- open the cursor for the dynamic sql to insert the
3918   -- row with sequence 1 in icx_cat_items_ctx_dtls_tlp only once
3919   l_csr_handle := DBMS_SQL.OPEN_CURSOR;
3920 
3921   l_err_loc := 700;
3922   WHILE l_continue LOOP
3923     l_err_loc := 800;
3924     l_rowid_tbl.DELETE;
3925 
3926     l_err_loc := 900;
3927     UPDATE icx_cat_items_ctx_hdrs_tlp
3928     SET ctx_desc = NULL,
3929         supplier_id = p_to_vendor_id,
3930         supplier_site_id = p_to_site_id,
3931         supplier = l_to_vendor_name,
3932         last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3933         last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3934         last_update_date = sysdate,
3935         internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3936         request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3937         program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3938         program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3939         program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
3940     WHERE supplier_id = p_from_vendor_id
3941     AND   supplier_site_id = p_from_site_id
3942     AND   internal_request_id <> ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id
3943     AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
3944     RETURNING ROWID BULK COLLECT INTO l_rowid_tbl;
3945 
3946     l_err_loc := 1000;
3947     l_row_count := SQL%ROWCOUNT;
3948     IF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
3949       l_err_loc := 1100;
3950       l_continue := FALSE;
3951         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3952           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3953                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3954                'Num of rows updated in ctx_hdrs for vendor merge:' || l_row_count);
3955         END IF;
3956     END IF;
3957 
3958     l_err_loc := 1200;
3959 
3960     IF (l_rowid_tbl.COUNT > 0) THEN
3961       l_err_loc := 1300;
3962       -- delete the mandatory row in icx_cat_items_ctx_dtls_tlp i.e. the row with sequence = 1
3963       FORALL i IN 1..l_rowid_tbl.COUNT
3964         DELETE FROM icx_cat_items_ctx_dtls_tlp dtls
3965         WHERE sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqMandatoryBaseRow
3966         AND EXISTS ( SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
3967                      WHERE hdrs.po_line_id = dtls.po_line_id
3968                      AND hdrs.req_template_name = dtls.req_template_name
3969                      AND hdrs.req_template_line_num = dtls.req_template_line_num
3970                      AND hdrs.inventory_item_id = dtls.inventory_item_id
3971                      AND hdrs.org_id = dtls.org_id
3972                      AND hdrs.language = dtls.language
3973                      AND hdrs.rowid = l_rowid_tbl(i) );
3974 
3975       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3976         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3977              ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3978              'Num. of rows deleted from dtls for seq=1:' || SQL%ROWCOUNT);
3979       END IF;
3980 
3981       l_err_loc := 1400;
3982 
3983       IF (NOT l_metadataTblFormed) THEN
3984         l_err_loc := 1500;
3985         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3986           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3987                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3988                'populateVendorMerge: about to call buildMetaDataInfo and buildCtxSql');
3989         END IF;
3990 
3991         ICX_CAT_BUILD_CTX_SQL_PVT.buildMetadataInfo
3992                (0, l_special_metadata_tbl, l_regular_nontl_metadata_tbl, l_regular_tl_metadata_tbl);
3993         l_metadataTblFormed := TRUE;
3994 
3995         l_err_loc := 1600;
3996 
3997         ICX_CAT_BUILD_CTX_SQL_PVT.buildCtxSql
3998              (0, 'ALL', 'ROWID', l_special_metadata_tbl,
3999               l_regular_nontl_metadata_tbl, l_regular_tl_metadata_tbl,
4000               l_all_ctx_sql_tbl, l_special_ctx_sql_tbl, l_regular_ctx_sql_tbl);
4001 
4002         l_err_loc := 1700;
4003         l_ctx_sqlstring_rec := l_special_ctx_sql_tbl(1);
4004 
4005         -- parse the cursor only once
4006         l_err_loc := 1800;
4007         DBMS_SQL.PARSE(l_csr_handle, l_ctx_sqlstring_rec.ctx_sql_string, DBMS_SQL.NATIVE);
4008       END IF;
4009 
4010       l_err_loc := 1900;
4011 
4012       -- insert the mandatory row in icx_cat_items_ctx_dtls_tlp i.e. the row with sequence = 1
4013       DBMS_SQL.BIND_VARIABLE(l_csr_handle,':B_sequence', l_ctx_sqlstring_rec.bind_sequence);
4014       DBMS_SQL.BIND_ARRAY(l_csr_handle, ':B_rowid', l_rowid_tbl);
4015       l_err_loc := 2000;
4016       l_status := DBMS_SQL.EXECUTE(l_csr_handle);
4017       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4018         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4019              ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4020              'Num. of rows inserted into dtls for seq=1:' || l_status);
4021       END IF;
4022 
4023       l_err_loc := 2100;
4024 
4025       IF (l_searchable IS NULL) THEN
4026         l_err_loc := 2200;
4027         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4028           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4029                ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4030                'about to call the getAttributeDetails for supplier');
4031         END IF;
4032 
4033         ICX_CAT_BUILD_CTX_SQL_PVT.getAttributeDetails
4034             (l_special_metadata_tbl, 'SUPPLIER', l_searchable, l_metadata_rec);
4035       END IF;
4036 
4037       l_err_loc := 2300;
4038       IF (l_searchable = 'Y') THEN
4039         l_err_loc := 2400;
4040         FORALL i IN 1..l_rowid_tbl.COUNT
4041           UPDATE icx_cat_items_ctx_dtls_tlp dtls
4042           SET ctx_desc = '<' || l_metadata_rec.section_tag || '>' ||
4043                          replace(replace(l_to_vendor_name, '<', ' '), '>', ' ') ||
4044                          '</' || l_metadata_rec.section_tag || '>',
4045               last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
4046               last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
4047               last_update_date = sysdate,
4048               internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
4049               request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
4050               program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
4051               program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
4052               program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
4053           WHERE sequence = ICX_CAT_BUILD_CTX_SQL_PVT.g_seqForSupplierRow
4054           AND EXISTS ( SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
4055                        WHERE hdrs.po_line_id = dtls.po_line_id
4056                        AND hdrs.req_template_name = dtls.req_template_name
4057                        AND hdrs.req_template_line_num = dtls.req_template_line_num
4058                        AND hdrs.inventory_item_id = dtls.inventory_item_id
4059                        AND hdrs.org_id = dtls.org_id
4060                        AND hdrs.language = dtls.language
4061                        AND hdrs.rowid = l_rowid_tbl(i) );
4062       ELSE
4063         l_err_loc := 2500;
4064         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4065           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4066               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4067               'Supplier is not searchable l_searchable:' || l_searchable );
4068         END IF;
4069       END IF;
4070 
4071       l_err_loc := 2600;
4072       IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4073         l_err_loc := 2700;
4074         COMMIT;
4075         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4076           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4077               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4078               'Commit done.');
4079         END IF;
4080       ELSE
4081         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4082           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4083               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4084               'Commit not done.');
4085         END IF;
4086       END IF;
4087     END IF;  -- IF (l_rowid_tbl.COUNT > 0)
4088   END LOOP;  -- WHILE l_continue LOOP
4089 
4090   l_err_loc := 2800;
4091 
4092   -- close the cursor for the dynamic sql to insert the
4093   -- row with sequence 1 in icx_cat_items_ctx_dtls_tlp only once
4094   IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4095     FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4096         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4097         'the dynamic sql is closed');
4098   END IF;
4099   DBMS_SQL.CLOSE_CURSOR(l_csr_handle);
4100 
4101   l_err_loc := 2900;
4102   IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4103     l_err_loc := 3000;
4104     -- Call the rebuild index
4105     ICX_CAT_INTERMEDIA_INDEX_PVT.rebuild_index;
4106 
4107     l_err_loc := 3100;
4108     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4109       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4110           ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4111           'Commit done.');
4112     END IF;
4113   END IF;
4114   l_err_loc := 3200;
4115 EXCEPTION
4116   WHEN OTHERS THEN
4117     ICX_CAT_UTIL_PVT.logUnexpectedException(
4118       G_PKG_NAME, l_api_name,
4119       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4120     RAISE;
4121 END populateVendorMerge;
4122 
4123 PROCEDURE openInvalidCategoryCsr
4124 (       p_invalid_category_csr          IN OUT NOCOPY           g_csr_type
4125 )
4126 IS
4127   l_api_name    CONSTANT VARCHAR2(30)   := 'openInvalidCategoryCsr';
4128   l_err_loc     PLS_INTEGER;
4129 BEGIN
4130   l_err_loc := 100;
4131   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4132     FND_LOG.string(FND_LOG.LEVEL_PROCEDURE,
4133         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4134         'Processing cursor:' || l_api_name ||
4135         ', g_structure_id:' || ICX_CAT_UTIL_PVT.g_structure_id ||
4136         ', g_category_set_id:' || ICX_CAT_UTIL_PVT.g_category_set_id ||
4137         '; g_validate_flag:' || ICX_CAT_UTIL_PVT.g_validate_flag);
4138   END IF;
4139 
4140   -- No need of joining with icx_cat_categories_tl, because
4141   -- 1. the ip category will exist only if the profile
4142   --    POR_AUTO_CREATE_SHOPPING_CAT is set to Y
4143   -- 2. the ip category is optional for items in iprocurement.
4144   -- 3. When the mtl category gets invalid we remove all the master items
4145   --    that belonged to the mtl category.
4146   l_err_loc := 150;
4147   IF (ICX_CAT_UTIL_PVT.g_validate_flag = 'N') THEN
4148     l_err_loc := 200;
4149     OPEN p_invalid_category_csr FOR
4150       SELECT mtlb.category_id
4151       FROM mtl_categories_b mtlb
4152       WHERE mtlb.structure_id = ICX_CAT_UTIL_PVT.g_structure_id
4153       AND (NVL(mtlb.end_date_active, SYSDATE + 1) < SYSDATE
4154            OR NVL(mtlb.disable_date, SYSDATE + 1) < SYSDATE)
4155       AND EXISTS (SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
4156                   WHERE hdrs.po_category_id = mtlb.category_id
4157                   AND hdrs.source_type = 'MASTER_ITEM');
4158   ELSE
4159     l_err_loc := 300;
4160     OPEN p_invalid_category_csr FOR
4161       SELECT mtlb.category_id
4162       FROM mtl_categories_b mtlb,
4163            mtl_category_set_valid_cats mcsvc
4164       WHERE mtlb.structure_id = ICX_CAT_UTIL_PVT.g_structure_id
4165       AND (NVL(mtlb.end_date_active, SYSDATE + 1) < SYSDATE
4166            OR NVL(mtlb.disable_date, SYSDATE + 1) < SYSDATE)
4167       AND mcsvc.category_set_id = ICX_CAT_UTIL_PVT.g_category_set_id
4168       AND mcsvc.category_id = mtlb.category_id
4169       AND EXISTS (SELECT 'x' FROM icx_cat_items_ctx_hdrs_tlp hdrs
4170                   WHERE hdrs.po_category_id = mtlb.category_id
4171                   AND hdrs.source_type = 'MASTER_ITEM');
4172   END IF;
4173   l_err_loc := 400;
4174 EXCEPTION
4175   WHEN OTHERS THEN
4176     ICX_CAT_UTIL_PVT.logUnexpectedException(
4177       G_PKG_NAME, l_api_name,
4178       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4179     RAISE;
4180 END openInvalidCategoryCsr;
4181 
4182 -- Purges items in invalid/expired categories
4183 PROCEDURE purgeInvalidCategoryItems
4184 IS
4185 
4186   ----- Start of declaring columns fetched from the cursor-----
4187   l_po_category_id_tbl          DBMS_SQL.NUMBER_TABLE;
4188   l_po_line_id_tbl              DBMS_SQL.NUMBER_TABLE;
4189   l_req_template_name_tbl       DBMS_SQL.VARCHAR2_TABLE;
4190   l_req_template_line_num_tbl   DBMS_SQL.NUMBER_TABLE;
4191   l_inventory_item_id_tbl       DBMS_SQL.NUMBER_TABLE;
4192   l_org_id_tbl                  DBMS_SQL.NUMBER_TABLE;
4193   l_language_tbl                DBMS_SQL.VARCHAR2_TABLE;
4194   ------ End of declaring columns fetched from the cursor ------
4195 
4196   l_api_name                    CONSTANT VARCHAR2(30)   := 'purgeInvalidCategoryItems';
4197   l_continue                    BOOLEAN := TRUE;
4198   l_invalid_category_csr        g_csr_type;
4199   l_err_string                  VARCHAR2(4000);
4200   l_err_loc                     PLS_INTEGER;
4201   l_start_date                  DATE;
4202   l_end_date                    DATE;
4203   l_log_string		        VARCHAR2(2000);
4204   l_row_count                   PLS_INTEGER;
4205 BEGIN
4206   l_err_loc := 100;
4207   l_start_date := sysdate;
4208 
4209   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4210     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4211     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4212   END IF;
4213 
4214   l_err_loc := 150;
4215   ICX_CAT_UTIL_PVT.getPurchasingCategorySetInfo;
4216 
4217   l_err_loc := 200;
4218   openInvalidCategoryCsr(l_invalid_category_csr);
4219 
4220   l_err_loc := 300;
4221   LOOP
4222     BEGIN
4223 
4224       l_err_loc := 400;
4225       l_po_category_id_tbl.DELETE;
4226 
4227       l_err_loc := 450;
4228       FETCH l_invalid_category_csr
4229       BULK COLLECT INTO l_po_category_id_tbl
4230       LIMIT ICX_CAT_UTIL_PVT.g_batch_size;
4231 
4232       l_err_loc := 500;
4233       EXIT WHEN l_po_category_id_tbl.COUNT = 0;
4234 
4235       FOR i IN 1..l_po_category_id_tbl.COUNT LOOP
4236         l_err_loc := 600;
4237         l_continue := TRUE;
4238         WHILE l_continue LOOP
4239           l_err_loc := 700;
4240           l_po_line_id_tbl.DELETE;
4241           l_req_template_name_tbl.DELETE;
4242           l_req_template_line_num_tbl.DELETE;
4243           l_inventory_item_id_tbl.DELETE;
4244           l_org_id_tbl.DELETE;
4245           l_language_tbl.DELETE;
4246 
4247           l_err_loc := 800;
4248           DELETE FROM icx_cat_items_ctx_hdrs_tlp hdrs
4249           WHERE hdrs.source_type = 'MASTER_ITEM'
4250           AND po_category_id = l_po_category_id_tbl(i)
4251           AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
4252           RETURNING po_line_id, req_template_name, req_template_line_num,
4253               inventory_item_id, org_id, language
4254           BULK COLLECT INTO l_po_line_id_tbl, l_req_template_name_tbl, l_req_template_line_num_tbl,
4255               l_inventory_item_id_tbl, l_org_id_tbl, l_language_tbl;
4256 
4257           l_err_loc := 900;
4258           l_row_count := SQL%ROWCOUNT;
4259           IF (l_row_count = 0) THEN
4260             IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4261               FND_LOG.string(FND_LOG.LEVEL_EVENT,
4262                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4263                   'No rows deleted from ctx_hdrs for invalid category, so exit out of the loop;');
4264             END IF;
4265             EXIT;
4266           ELSIF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
4267             l_continue := FALSE;
4268             IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4269               FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4270                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4271                   'Num. of rows deleted from ctx_hdrs for invalid category:' || l_row_count);
4272             END IF;
4273           END IF;
4274 
4275           l_err_loc := 1000;
4276           FORALL j IN 1..l_po_line_id_tbl.COUNT
4277             DELETE FROM icx_cat_items_ctx_dtls_tlp
4278             WHERE po_line_id = l_po_line_id_tbl(j)
4279             AND req_template_name = l_req_template_name_tbl(j)
4280             AND req_template_line_num = l_req_template_line_num_tbl(j)
4281             AND inventory_item_id = l_inventory_item_id_tbl(j)
4282             AND org_id = l_org_id_tbl(j)
4283             AND language = l_language_tbl(j);
4284 
4285           l_err_loc := 1100;
4286           IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4287             l_err_loc := 1200;
4288             COMMIT;
4289             IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4290               FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4291                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4292                   'Commit done inside the while loop.');
4293             END IF;
4294           ELSE
4295             l_err_loc := 1300;
4296             IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4297               FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4298                   ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4299                   'Commit not done inside the while loop.');
4300             END IF;
4301           END IF;
4302         END LOOP;
4303       END LOOP;
4304 
4305       l_err_loc := 1400;
4306       -- When the po_category becomes invalid, No need of deleting the ip category
4307       -- and mapping because the po_category can still exist on a document line and
4308       -- bulkload should be able to update the document line.
4309 
4310       l_err_loc := 1500;
4311 
4312       IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4313         l_err_loc := 1600;
4314         COMMIT;
4315         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4316           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4317               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4318               'Commit done inside the fetch loop.');
4319         END IF;
4320       ELSE
4321         l_err_loc := 1700;
4322         IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4323           FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4324               ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4325               'Commit not done inside the fetch loop.');
4326         END IF;
4327       END IF;
4328 
4329       l_err_loc := 1750;
4330       EXIT WHEN l_po_category_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
4331     EXCEPTION
4332       WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
4333         l_err_string := 'ICX_CAT_POPULATE_ITEM_PVT.purgeInvalidCategoryItems' ||l_err_loc;
4334         ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
4335         CLOSE l_invalid_category_csr;
4336         openInvalidCategoryCsr(l_invalid_category_csr);
4337     END;
4338   END LOOP;
4339 
4340   l_err_loc := 1800;
4341   l_end_date := sysdate;
4342   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4343     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4344        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4345   END IF;
4346 EXCEPTION
4347   WHEN OTHERS THEN
4348     ICX_CAT_UTIL_PVT.logUnexpectedException(
4349       G_PKG_NAME, l_api_name,
4350       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4351     RAISE;
4352 END purgeInvalidCategoryItems;
4353 
4354 -- Purges invalid/expired Req Templates
4355 -- Purges the Req templates copied from blankets that are now invalid/expired
4356 PROCEDURE purgeInvalidReqTmpltLines
4357 IS
4358 
4359   ----- Start of declaring columns returned from the delete -----
4360   l_po_line_id_tbl              DBMS_SQL.NUMBER_TABLE;
4361   l_req_template_name_tbl       DBMS_SQL.VARCHAR2_TABLE;
4362   l_req_template_line_num_tbl   DBMS_SQL.NUMBER_TABLE;
4363   l_inventory_item_id_tbl       DBMS_SQL.NUMBER_TABLE;
4364   l_org_id_tbl                  DBMS_SQL.NUMBER_TABLE;
4365   l_language_tbl                DBMS_SQL.VARCHAR2_TABLE;
4366   ------ End of declaring columns returned from the delete ------
4367 
4368   l_api_name                    CONSTANT VARCHAR2(30)   := 'purgeInvalidReqTmpltLines';
4369   l_continue                    BOOLEAN := TRUE;
4370   l_err_loc                     PLS_INTEGER;
4371   l_start_date                  DATE;
4372   l_end_date                    DATE;
4373   l_log_string		        VARCHAR2(2000);
4374   l_row_count                   PLS_INTEGER;
4375 BEGIN
4376   l_err_loc := 100;
4377   l_start_date := sysdate;
4378 
4379   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4380     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4381     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4382   END IF;
4383 
4384   l_continue := TRUE;
4385   WHILE l_continue LOOP
4386     l_err_loc := 200;
4387     l_po_line_id_tbl.DELETE;
4388     l_req_template_name_tbl.DELETE;
4389     l_req_template_line_num_tbl.DELETE;
4390     l_inventory_item_id_tbl.DELETE;
4391     l_org_id_tbl.DELETE;
4392     l_language_tbl.DELETE;
4393 
4394     l_err_loc := 300;
4395     DELETE FROM icx_cat_items_ctx_hdrs_tlp hdrs
4396     WHERE hdrs.source_type IN ('TEMPLATE', 'INTERNAL_TEMPLATE')
4397     AND   (
4398             -- Req template lines that are invalid.
4399             EXISTS ( SELECT 'x'
4400                      FROM po_reqexpress_lines_all prl, po_reqexpress_headers_all prh,
4401                           po_lines_all pl, po_headers_all ph
4402                      WHERE  hdrs.po_line_id = -2
4403                      AND    hdrs.inventory_item_id = nvl(prl.item_id, -2)
4404                      AND    hdrs.req_template_name = prl.express_name
4405                      AND    hdrs.req_template_line_num = prl.sequence_num
4406                      AND    hdrs.org_id = prl.org_id
4407                      AND    prl.express_name = prh.express_name
4408                      AND    prl.org_id = prh.org_id
4409                      AND    prl.po_line_id = pl.po_line_id (+)
4410                      AND    prl.po_header_id = pl.po_header_id (+)
4411                      AND    pl.po_header_id = ph.po_header_id (+)
4412                      AND    (NVL(prh.inactive_date, SYSDATE + 1) <= SYSDATE
4413                              OR (prl.po_line_id IS NOT NULL AND
4414                                  (ph.approved_date IS NULL
4415                                   OR NVL(ph.authorization_status, 'INCOMPLETE') IN ('REJECTED', 'INCOMPLETE')
4416                                   OR NVL(ph.cancel_flag, 'N') = 'Y'
4417                                   OR NVL(ph.frozen_flag, 'N') = 'Y'
4418                                   OR NVL(ph.closed_code, 'OPEN') IN ('CLOSED', 'FINALLY CLOSED')
4419                                   OR NVL(TRUNC(ph.end_date), TRUNC(SYSDATE + 1)) <= TRUNC(SYSDATE)
4420                                   OR NVL(pl.cancel_flag, 'N') = 'Y'
4421                                   OR NVL(pl.closed_code, 'OPEN') IN ('CLOSED', 'FINALLY CLOSED')
4422                                   OR NVL(TRUNC(pl.expiration_date), TRUNC(SYSDATE + 1)) <= TRUNC(SYSDATE)))))
4423             OR
4424             -- Req template lines that are deleted.
4425             NOT EXISTS ( SELECT 'x'
4426                          FROM po_reqexpress_lines_all prl
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           )
4433     AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
4434     RETURNING po_line_id, req_template_name, req_template_line_num,
4435         inventory_item_id, org_id, language
4436     BULK COLLECT INTO l_po_line_id_tbl, l_req_template_name_tbl, l_req_template_line_num_tbl,
4437         l_inventory_item_id_tbl, l_org_id_tbl, l_language_tbl;
4438 
4439     l_err_loc := 400;
4440     l_row_count := SQL%ROWCOUNT;
4441     IF (l_row_count = 0) THEN
4442       IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4443         FND_LOG.string(FND_LOG.LEVEL_EVENT,
4444             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4445             'no rows deleted from ctx_hdrs for invalid req tmplts, so exit from the loop');
4446       END IF;
4447       EXIT;
4448     ELSIF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
4449       l_continue := FALSE;
4450       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4451         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4452             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4453             'Num. of rows deleted from ctx_hdrs for invalid req templates:' || l_row_count);
4454       END IF;
4455     END IF;
4456 
4457     l_err_loc := 500;
4458     FORALL j IN 1..l_po_line_id_tbl.COUNT
4459       DELETE FROM icx_cat_items_ctx_dtls_tlp
4460       WHERE po_line_id = l_po_line_id_tbl(j)
4461       AND req_template_name = l_req_template_name_tbl(j)
4462       AND req_template_line_num = l_req_template_line_num_tbl(j)
4463       AND inventory_item_id = l_inventory_item_id_tbl(j)
4464       AND org_id = l_org_id_tbl(j)
4465       AND language = l_language_tbl(j);
4466 
4467     l_err_loc := 600;
4468     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4469       l_err_loc := 700;
4470       COMMIT;
4471       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4472         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4473             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4474             'Commit done.');
4475       END IF;
4476     ELSE
4477       l_err_loc := 800;
4478       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4479         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4480             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4481             'Commit not done.');
4482       END IF;
4483     END IF;
4484   END LOOP;
4485 
4486   l_err_loc := 900;
4487   l_end_date := sysdate;
4488   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4489     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4490        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4491   END IF;
4492 
4493 EXCEPTION
4494   WHEN OTHERS THEN
4495     ICX_CAT_UTIL_PVT.logUnexpectedException(
4496       G_PKG_NAME, l_api_name,
4497       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4498     RAISE;
4499 END purgeInvalidReqTmpltLines;
4500 
4501 -- Purges invalid quotations
4502 -- Quotations: ICX_CAT_POPULATE_STATUS_PVT.getQuoteLineStatus returns
4503 -- ICX_CAT_POPULATE_STATUS_PVT.INVALID_FOR_POPULATE i.e -1
4504 PROCEDURE purgeInvalidQuoteLines
4505 IS
4506 
4507   ----- Start of declaring columns returned from the delete -----
4508   l_po_line_id_tbl              DBMS_SQL.NUMBER_TABLE;
4509   l_req_template_name_tbl       DBMS_SQL.VARCHAR2_TABLE;
4510   l_req_template_line_num_tbl   DBMS_SQL.NUMBER_TABLE;
4511   l_inventory_item_id_tbl       DBMS_SQL.NUMBER_TABLE;
4512   l_org_id_tbl                  DBMS_SQL.NUMBER_TABLE;
4513   l_language_tbl                DBMS_SQL.VARCHAR2_TABLE;
4514   ------ End of declaring columns returned from the delete ------
4515 
4516   l_api_name                    CONSTANT VARCHAR2(30)   := 'purgeInvalidQuoteLines';
4517   l_continue                    BOOLEAN := TRUE;
4518   l_err_loc                     PLS_INTEGER;
4519   l_start_date                  DATE;
4520   l_end_date                    DATE;
4521   l_log_string		        VARCHAR2(2000);
4522   l_row_count                   PLS_INTEGER;
4523 BEGIN
4524   l_err_loc := 100;
4525   l_start_date := sysdate;
4526 
4527   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4528     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4529     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4530   END IF;
4531 
4532   l_err_loc := 110;
4533   l_continue := TRUE;
4534   WHILE l_continue LOOP
4535     l_err_loc := 200;
4536     l_po_line_id_tbl.DELETE;
4537     l_req_template_name_tbl.DELETE;
4538     l_req_template_line_num_tbl.DELETE;
4539     l_inventory_item_id_tbl.DELETE;
4540     l_org_id_tbl.DELETE;
4541     l_language_tbl.DELETE;
4542 
4543     l_err_loc := 300;
4544     DELETE FROM icx_cat_items_ctx_hdrs_tlp hdrs
4545     WHERE hdrs.source_type = 'QUOTATION'
4546     AND   (
4547            -- Quote lines that are invalid.
4548            ICX_CAT_POPULATE_STATUS_PVT.getQuoteLineStatus(hdrs.po_line_id) = -1
4549            OR
4550            -- Quote lines that are deleted.
4551            NOT EXISTS ( SELECT 'x' FROM po_lines_all pl
4552                         WHERE  hdrs.po_line_id = pl.po_line_id)
4553           )
4554     AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
4555     RETURNING po_line_id, req_template_name, req_template_line_num,
4556         inventory_item_id, org_id, language
4557     BULK COLLECT INTO l_po_line_id_tbl, l_req_template_name_tbl, l_req_template_line_num_tbl,
4558         l_inventory_item_id_tbl, l_org_id_tbl, l_language_tbl;
4559 
4560     l_err_loc := 400;
4561     l_row_count := SQL%ROWCOUNT;
4562     IF (l_row_count = 0) THEN
4563       IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4564         FND_LOG.string(FND_LOG.LEVEL_EVENT,
4565             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4566             'no rows deleted from ctx_hdrs for invalid Quote lines, so exit from the loop');
4567       END IF;
4568       EXIT;
4569     ELSIF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
4570       l_continue := FALSE;
4571       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4572         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4573             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4574             'Num. of rows deleted from ctx_hdrs for invalid Quote lines:' || l_row_count);
4575       END IF;
4576     END IF;
4577 
4578     l_err_loc := 500;
4579     FORALL j IN 1..l_po_line_id_tbl.COUNT
4580       DELETE FROM icx_cat_items_ctx_dtls_tlp
4581       WHERE po_line_id = l_po_line_id_tbl(j)
4582       AND req_template_name = l_req_template_name_tbl(j)
4583       AND req_template_line_num = l_req_template_line_num_tbl(j)
4584       AND inventory_item_id = l_inventory_item_id_tbl(j)
4585       AND org_id = l_org_id_tbl(j)
4586       AND language = l_language_tbl(j);
4587 
4588     l_err_loc := 600;
4589     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4590       l_err_loc := 700;
4591       COMMIT;
4592       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4593         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4594             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4595             'Commit done.');
4596       END IF;
4597     ELSE
4598       l_err_loc := 800;
4599       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4600         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4601             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4602             'Commit not done.');
4603       END IF;
4604     END IF;
4605   END LOOP;
4606 
4607   l_err_loc := 900;
4608   l_end_date := sysdate;
4609   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4610     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4611        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4612   END IF;
4613 
4614   l_err_loc := 1000;
4615 EXCEPTION
4616   WHEN OTHERS THEN
4617     ICX_CAT_UTIL_PVT.logUnexpectedException(
4618       G_PKG_NAME, l_api_name,
4619       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4620     RAISE;
4621 END purgeInvalidQuoteLines;
4622 
4623 -- Purges invalid/expired blankets includes global blankets also
4624 -- Blankets:
4625 -- Header validations:
4626 -- Approved_date is null
4627 -- authorization_status in 'REJECTED', 'INCOMPLETE'
4628 -- cancel_flag = 'Y'
4629 -- frozen_flag = 'Y'
4630 -- closed_code in 'CLOSED', 'FINALLY CLOSED'
4631 -- sysdate > end_date
4632 -- Line validations:
4633 -- cancel_flag = 'Y'
4634 -- closed_code in 'CLOSED', 'FINALLY CLOSED'
4635 -- sysdate > expiration_date
4636 PROCEDURE purgeInvalidBlanketLines
4637 IS
4638 
4639   ----- Start of declaring columns returned from the delete -----
4640   l_po_line_id_tbl              DBMS_SQL.NUMBER_TABLE;
4641   l_req_template_name_tbl       DBMS_SQL.VARCHAR2_TABLE;
4642   l_req_template_line_num_tbl   DBMS_SQL.NUMBER_TABLE;
4643   l_inventory_item_id_tbl       DBMS_SQL.NUMBER_TABLE;
4644   l_org_id_tbl                  DBMS_SQL.NUMBER_TABLE;
4645   l_language_tbl                DBMS_SQL.VARCHAR2_TABLE;
4646   ------ End of declaring columns returned from the delete ------
4647 
4648   l_api_name                    CONSTANT VARCHAR2(30)   := 'purgeInvalidBlanketLines';
4649   l_continue                    BOOLEAN := TRUE;
4650   l_err_loc                     PLS_INTEGER;
4651   l_start_date                  DATE;
4652   l_end_date                    DATE;
4653   l_row_count                   PLS_INTEGER;
4654 BEGIN
4655   l_err_loc := 100;
4656   l_start_date := sysdate;
4657   IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4658     FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4659         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4660         'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
4661   END IF;
4662 
4663   l_err_loc := 110;
4664   l_continue := TRUE;
4665   WHILE l_continue LOOP
4666     l_err_loc := 200;
4667     l_po_line_id_tbl.DELETE;
4668     l_req_template_name_tbl.DELETE;
4669     l_req_template_line_num_tbl.DELETE;
4670     l_inventory_item_id_tbl.DELETE;
4671     l_org_id_tbl.DELETE;
4672     l_language_tbl.DELETE;
4673 
4674     l_err_loc := 300;
4675     DELETE FROM icx_cat_items_ctx_hdrs_tlp hdrs
4676     WHERE hdrs.source_type IN ('BLANKET', 'GLOBAL_BLANKET')
4677     AND   EXISTS ( SELECT 'x' FROM po_lines_all pl, po_headers_all ph
4678                    WHERE  hdrs.po_line_id = pl.po_line_id
4679                    AND    pl.po_header_id = ph.po_header_id
4680                    AND    (ph.approved_date IS NULL
4681                            OR NVL(ph.authorization_status, 'INCOMPLETE') IN ('REJECTED', 'INCOMPLETE')
4682                            OR NVL(ph.cancel_flag, 'N') = 'Y'
4683                            OR NVL(ph.frozen_flag, 'N') = 'Y'
4684                            OR NVL(ph.closed_code, 'OPEN') IN ('CLOSED', 'FINALLY CLOSED')
4685                            OR NVL(TRUNC(ph.end_date), TRUNC(SYSDATE + 1)) <= TRUNC(SYSDATE)
4686                            OR NVL(pl.cancel_flag, 'N') = 'Y'
4687                            OR NVL(pl.closed_code, 'OPEN') IN ('CLOSED', 'FINALLY CLOSED')
4688                            OR NVL(TRUNC(pl.expiration_date), TRUNC(SYSDATE + 1)) <= TRUNC(SYSDATE)))
4689     AND   ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
4690     RETURNING po_line_id, req_template_name, req_template_line_num,
4691         inventory_item_id, org_id, language
4692     BULK COLLECT INTO l_po_line_id_tbl, l_req_template_name_tbl, l_req_template_line_num_tbl,
4693         l_inventory_item_id_tbl, l_org_id_tbl, l_language_tbl;
4694 
4695     l_err_loc := 400;
4696     l_row_count := SQL%ROWCOUNT;
4697     IF (l_row_count = 0) THEN
4698       IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4699         FND_LOG.string(FND_LOG.LEVEL_EVENT,
4700             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4701             'no rows deleted from ctx_hdrs for invalid blanket lines, so exit from the loop');
4702       END IF;
4703       EXIT;
4704     ELSIF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size) THEN
4705       l_continue := FALSE;
4706       IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4707         FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4708             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4709             'Num. of rows deleted from ctx_hdrs for invalid blanket lines:' || l_row_count);
4710       END IF;
4711     END IF;
4712 
4713     l_err_loc := 500;
4714     FORALL j IN 1..l_po_line_id_tbl.COUNT
4715       DELETE FROM icx_cat_items_ctx_dtls_tlp
4716       WHERE po_line_id = l_po_line_id_tbl(j)
4717       AND req_template_name = l_req_template_name_tbl(j)
4718       AND req_template_line_num = l_req_template_line_num_tbl(j)
4719       AND inventory_item_id = l_inventory_item_id_tbl(j)
4720       AND org_id = l_org_id_tbl(j)
4721       AND language = l_language_tbl(j);
4722 
4723     l_err_loc := 600;
4724     IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4725       l_err_loc := 700;
4726       COMMIT;
4727       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4728         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4729             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4730             'Commit done.');
4731       END IF;
4732     ELSE
4733       l_err_loc := 800;
4734       IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4735         FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4736             ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4737             'Commit not done.');
4738       END IF;
4739     END IF;
4740   END LOOP;
4741 
4742   l_err_loc := 900;
4743   l_end_date := sysdate;
4744   IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4745     FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4746         ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4747         ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4748   END IF;
4749 
4750   l_err_loc := 1000;
4751 EXCEPTION
4752   WHEN OTHERS THEN
4753     ICX_CAT_UTIL_PVT.logUnexpectedException(
4754       G_PKG_NAME, l_api_name,
4755       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4756     RAISE;
4757 END purgeInvalidBlanketLines;
4758 
4759 PROCEDURE purgeInvalidItems
4760 (       x_errbuf                OUT NOCOPY      VARCHAR2                ,
4761         x_retcode               OUT NOCOPY      NUMBER
4762 )
4763 IS
4764   l_api_name            CONSTANT VARCHAR2(30)   := 'purgeInvalidItems';
4765   l_err_loc             PLS_INTEGER;
4766   l_start_date          DATE;
4767   l_end_date            DATE;
4768   l_log_string		VARCHAR2(2000);
4769 BEGIN
4770   l_err_loc := 100;
4771   x_retcode := 0;
4772   x_errbuf := '';
4773 
4774   l_err_loc := 150;
4775   l_start_date := sysdate;
4776 
4777   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4778     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4779     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4780   END IF;
4781 
4782   l_err_loc := 200;
4783   ICX_CAT_UTIL_PVT.setCommitParameter(FND_API.G_TRUE);
4784 
4785   l_err_loc := 300;
4786   -- Set the batch_size if supplier needs to be updated
4787   ICX_CAT_UTIL_PVT.setBatchSize;
4788 
4789   l_err_loc := 400;
4790   purgeInvalidBlanketLines;
4791 
4792   l_err_loc := 500;
4793   purgeInvalidQuoteLines;
4794 
4795   l_err_loc := 600;
4796   purgeInvalidReqTmpltLines;
4797 
4798   l_err_loc := 700;
4799   purgeInvalidCategoryItems;
4800 
4801   l_err_loc := 800;
4802   IF (FND_API.To_Boolean(ICX_CAT_UTIL_PVT.g_COMMIT)) THEN
4803     l_err_loc := 900;
4804     -- Call the rebuild index
4805     ICX_CAT_INTERMEDIA_INDEX_PVT.rebuild_index;
4806     IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4807       FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4808           ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4809           'Rebuild indexes called.');
4810     END IF;
4811   END IF;
4812 
4813   l_err_loc := 1000;
4814   l_end_date := sysdate;
4815   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4816     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4817        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4818   END IF;
4819 EXCEPTION
4820   WHEN OTHERS THEN
4821     x_retcode := 2;
4822     x_errbuf := 'Exception at ' ||
4823                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name) ||
4824                 '(l_err_loc:' || l_err_loc || '), ' || SQLERRM;
4825     ICX_CAT_UTIL_PVT.logUnexpectedException(
4826       G_PKG_NAME, l_api_name,
4827       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4828     RAISE;
4829 END purgeInvalidItems;
4830 
4831 PROCEDURE rebuildIPIntermediaIndex
4832 (       x_errbuf                OUT NOCOPY      VARCHAR2                ,
4833         x_retcode               OUT NOCOPY      NUMBER
4834 )
4835 IS
4836   l_api_name            CONSTANT VARCHAR2(30)   := 'rebuildIPIntermediaIndex';
4837   l_err_loc             PLS_INTEGER;
4838   l_start_date          DATE;
4839   l_end_date            DATE;
4840   l_log_string		VARCHAR2(2000);
4841 BEGIN
4842   l_err_loc := 100;
4843   x_retcode := 0;
4844   x_errbuf := '';
4845 
4846   l_err_loc := 200;
4847   l_start_date := sysdate;
4848 
4849   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4850     l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4851     ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4852   END IF;
4853 
4854   l_err_loc := 300;
4855   -- Call the rebuild index
4856   ICX_CAT_INTERMEDIA_INDEX_PVT.rebuild_index;
4857 
4858   l_err_loc := 400;
4859   l_end_date := sysdate;
4860   IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4861     ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4862        ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4863   END IF;
4864 EXCEPTION
4865   WHEN OTHERS THEN
4866     x_retcode := 2;
4867     x_errbuf := 'Exception at ' ||
4868                 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name) ||
4869                 '(l_err_loc:' || l_err_loc || '), ' || SQLERRM;
4870     ICX_CAT_UTIL_PVT.logUnexpectedException(
4871       G_PKG_NAME, l_api_name,
4872       ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4873     RAISE;
4874 END rebuildIPIntermediaIndex;
4875 
4876 END ICX_CAT_POPULATE_ITEM_PVT;