[Home] [Help]
PACKAGE BODY: APPS.ICX_CAT_R12_UPGRADE_PVT
Source
1 PACKAGE BODY ICX_CAT_R12_UPGRADE_PVT AS
2 /* $Header: ICXV12UB.pls 120.24.12010000.2 2008/08/02 14:38:35 kkram ship $*/
3
4 -----------------------------------------------------------
5 -- Global variables --
6 -----------------------------------------------------------
7 -- Constants
8 G_PKG_NAME CONSTANT VARCHAR2(30) := 'ICX_CAT_R12_UPGRADE_PVT';
9 g_GBPA_hdr_count PLS_INTEGER := 0;
10 g_total_row_count PLS_INTEGER := 0;
11 g_PDOI_batch_id NUMBER;
12 g_interface_source_code po_headers_interface.interface_source_code%TYPE := 'CATALOG R12 UPGRADE';
13 g_process_code po_headers_interface.process_code%TYPE := 'NEW';
14 g_new_GBPA_description CONSTANT VARCHAR2(35) := 'R12 Upgrade of Bulk-Loaded Content.';
15 g_total_bulkld_row_count PLS_INTEGER := 0;
16 g_total_ext_row_count PLS_INTEGER := 0;
17
18 -- Global constants for last successful completion dates
19 g_extract_last_run_date DATE;
20 g_bulk_last_run_date DATE;
21 g_bpa_last_run_date DATE;
22 g_quote_last_run_date DATE;
23 g_reqtmplt_last_run_date DATE;
24 g_mi_last_run_date DATE;
25 g_audsid NUMBER := USERENV('SESSIONID');
26
27 TYPE g_csr_type IS REF CURSOR;
28
29 TYPE g_po_hdrs_int_rec_type IS RECORD
30 (
31 interface_header_id NUMBER,
32 action po_headers_interface.action%TYPE,
33 org_id NUMBER,
34 document_type_code po_headers_interface.document_type_code%TYPE,
35 budget_account_segment1 po_headers_interface.budget_account_segment1%TYPE,
36 po_header_id NUMBER,
37 approval_status po_headers_interface.approval_status%TYPE,
38 vendor_id NUMBER,
39 vendor_site_id NUMBER,
40 currency_code po_headers_interface.currency_code%TYPE,
41 cpa_reference NUMBER,
42 created_language po_headers_interface.created_language%TYPE,
43 comments po_headers_interface.comments%TYPE
44 );
45
46 TYPE g_po_line_attrval_int_rec_type IS RECORD
47 (
48 interface_line_id NUMBER,
49 interface_header_id NUMBER,
50 action po_lines_interface.action%TYPE,
51 po_line_id NUMBER,
52 po_header_id NUMBER,
53 unit_price NUMBER,
54 uom_code po_lines_interface.uom_code%TYPE,
55 negotiated_by_preparer_flag po_lines_interface.negotiated_by_preparer_flag%TYPE,
56 ip_category_id NUMBER,
57 category_id NUMBER,
58 category_name po_lines_interface.category%TYPE,
59 vendor_product_num po_lines_interface.vendor_product_num%TYPE,
60 supplier_part_auxid po_lines_interface.supplier_part_auxid%TYPE,
61 item_description po_lines_interface.item_description%TYPE,
62 catalog_name po_lines_interface.catalog_name%TYPE,
63 req_template_name icx_cat_item_prices.template_id%TYPE,
64 req_template_line_num NUMBER,
65 inventory_item_id NUMBER,
66 org_id NUMBER,
67 rt_item_id NUMBER,
68 language fnd_languages.language_code%TYPE
69 );
70
71 TYPE g_po_attrvalstlp_int_rec_type IS RECORD
72 (
73 interface_header_id NUMBER,
74 interface_line_id NUMBER,
75 action po_attr_values_tlp_interface.action%TYPE,
76 po_line_id NUMBER,
77 req_template_name po_attr_values_tlp_interface.req_template_name%TYPE,
78 req_template_line_num NUMBER,
79 inventory_item_id NUMBER,
80 org_id NUMBER,
81 language po_attr_values_tlp_interface.language%TYPE,
82 check_desc_update VARCHAR2(25),
83 rt_item_id NUMBER
84 );
85
86 TYPE g_r12_upg_rec_type IS RECORD
87 (
88 rt_item_id NUMBER,
89 supplier_site_id NUMBER,
90 currency icx_cat_r12_upgrade.currency%TYPE,
91 price_contract_id NUMBER,
92 src_contract_id NUMBER,
93 cpa_reference NUMBER,
94 po_category_id icx_cat_r12_upgrade.po_category_id%TYPE,
95 po_interface_header_id NUMBER,
96 po_interface_line_id NUMBER,
97 po_header_id NUMBER,
98 po_line_id NUMBER,
99 created_language icx_cat_r12_upgrade.created_language%TYPE,
100 -- TBD extractor_updated_flag icx_cat_r12_upgrade.extractor_updated_flag%TYPE,
101 old_po_interface_line_id NUMBER
102 );
103
104 g_po_hdrs_int_rec g_po_hdrs_int_rec_type;
105 g_po_line_attrval_int_rec g_po_line_attrval_int_rec_type;
106 g_po_attrvalstlp_int_rec g_po_attrvalstlp_int_rec_type;
107 g_r12_upg_rec g_r12_upg_rec_type;
108
109 TYPE g_current_gbpa_hdr_rec_type IS RECORD
110 (
111 org_id NUMBER,
112 vendor_id NUMBER,
113 vendor_site_id NUMBER,
114 currency_code po_headers_interface.currency_code%TYPE,
115 cpa_reference NUMBER,
116 language po_headers_interface.created_language%TYPE,
117 interface_header_id NUMBER,
118 po_header_id NUMBER,
119 upg_created_language po_headers_interface.created_language%TYPE,
120 upg_cpa_reference NUMBER
121 );
122
123 g_current_gbpa_hdr_rec g_current_gbpa_hdr_rec_type;
124
125 ----------------------------------------------------
126 -- Global PL/SQL Tables --
127 ----------------------------------------------------
128 --INSERT po_headers_interface
129 gIHInterfaceHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
130 gIHActionTbl DBMS_SQL.VARCHAR2_TABLE;
131 gIHOrgIdTbl DBMS_SQL.NUMBER_TABLE;
132 gIHDocumentTypeCodeTbl DBMS_SQL.VARCHAR2_TABLE;
133 gIHBudgetAccountSegment1Tbl DBMS_SQL.VARCHAR2_TABLE;
134 gIHPoHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
135 gIHApprovalStatusTbl DBMS_SQL.VARCHAR2_TABLE;
136 gIHVendorIdTbl DBMS_SQL.NUMBER_TABLE;
137 gIHVendorSiteIdTbl DBMS_SQL.NUMBER_TABLE;
138 gIHCurrencyCodeTbl DBMS_SQL.VARCHAR2_TABLE;
139 gIHCpaReferenceTbl DBMS_SQL.NUMBER_TABLE;
140 gIHCreatedLanguageTbl DBMS_SQL.VARCHAR2_TABLE;
141 gIHCommentsTbl DBMS_SQL.VARCHAR2_TABLE;
142
143 --INSERT po_lines_interface
144 gILInterfaceLineIdTbl DBMS_SQL.NUMBER_TABLE;
145 gILInterfaceHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
146 gILActionTbl DBMS_SQL.VARCHAR2_TABLE;
147 gILPoLineIdTbl DBMS_SQL.NUMBER_TABLE;
148 gILPoHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
149 gILUnitPriceTbl DBMS_SQL.NUMBER_TABLE;
150 gILUomCodeTbl DBMS_SQL.VARCHAR2_TABLE;
151 gILNegByPrepFlagTbl DBMS_SQL.VARCHAR2_TABLE;
152 gILIpCategoryIdTbl DBMS_SQL.NUMBER_TABLE;
153 gILCategoryIdTbl DBMS_SQL.NUMBER_TABLE;
154 gILCategoryNameTbl DBMS_SQL.VARCHAR2_TABLE;
155 gILVendorProductNumTbl DBMS_SQL.VARCHAR2_TABLE;
156 gILSupplierPartAuxidTbl DBMS_SQL.VARCHAR2_TABLE;
157 gILItemDescripionTbl DBMS_SQL.VARCHAR2_TABLE;
158 gILCatalogNameTbl DBMS_SQL.VARCHAR2_TABLE;
159
160 --INSERT po_attr_values_interface
161 gIAVInterfaceHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
162 gIAVInterfaceLineIdTbl DBMS_SQL.NUMBER_TABLE;
163 gIAVActionTbl DBMS_SQL.VARCHAR2_TABLE;
164 gIAVPoLineIdTbl DBMS_SQL.NUMBER_TABLE;
165 gIAVReqTemplateNameTbl DBMS_SQL.VARCHAR2_TABLE;
166 gIAVReqTemplateLineNumTbl DBMS_SQL.NUMBER_TABLE;
167 gIAVInventoryItemIdTbl DBMS_SQL.NUMBER_TABLE;
168 gIAVOrgIdTbl DBMS_SQL.NUMBER_TABLE;
169 gIAVRtItemIdTbl DBMS_SQL.NUMBER_TABLE;
170 gIAVLanguageTbl DBMS_SQL.VARCHAR2_TABLE;
171
172 --INSERT po_attr_values_tlp_interface
173 gIAVTInterfaceHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
174 gIAVTInterfaceLineIdTbl DBMS_SQL.NUMBER_TABLE;
175 gIAVTActionTbl DBMS_SQL.VARCHAR2_TABLE;
176 gIAVTPoLineIdTbl DBMS_SQL.NUMBER_TABLE;
177 gIAVTReqTemplateNameTbl DBMS_SQL.VARCHAR2_TABLE;
178 gIAVTReqTemplateLineNumTbl DBMS_SQL.NUMBER_TABLE;
179 gIAVTInventoryItemIdTbl DBMS_SQL.NUMBER_TABLE;
180 gIAVTOrgIdTbl DBMS_SQL.NUMBER_TABLE;
181 gIAVTRtItemIdTbl DBMS_SQL.NUMBER_TABLE;
182 gIAVTLanguageTbl DBMS_SQL.VARCHAR2_TABLE;
183 gIAVTCheckDescUpdateTbl DBMS_SQL.VARCHAR2_TABLE;
184
185 --INSERT icx_cat_r12_upgrade
186 gIRURtItemIdTbl DBMS_SQL.NUMBER_TABLE;
187 gIRUSupplierSiteIdTbl DBMS_SQL.NUMBER_TABLE;
188 gIRUCurrencyTbl DBMS_SQL.VARCHAR2_TABLE;
189 gIRUCpaReferenceTbl DBMS_SQL.NUMBER_TABLE;
190 gIRUPriceContractIdTbl DBMS_SQL.NUMBER_TABLE;
191 gIRUSrcContractIdTbl DBMS_SQL.NUMBER_TABLE;
192 gIRUPoCategoryIdTbl DBMS_SQL.VARCHAR2_TABLE;
193 gIRUPoInterfaceHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
194 gIRUPoInterfaceLineIdTbl DBMS_SQL.NUMBER_TABLE;
195 gIRUCreatedLanguageTbl DBMS_SQL.VARCHAR2_TABLE;
196 -- TBD gIRUExtractorUpdatedFlagTbl DBMS_SQL.VARCHAR2_TABLE;
197
198 --UPDATE icx_cat_r12_upgrade
199 gURURtItemIdTbl DBMS_SQL.NUMBER_TABLE;
200 gURUPoCategoryIdTbl DBMS_SQL.NUMBER_TABLE;
201 gURUCpaReferenceTbl DBMS_SQL.NUMBER_TABLE;
202 gURUPriceContractIdTbl DBMS_SQL.NUMBER_TABLE;
203 gURUSrcContractIdTbl DBMS_SQL.NUMBER_TABLE;
204 gURUOldPoInterfaceLineIdTbl DBMS_SQL.NUMBER_TABLE;
205 gURUPoInterfaceHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
206 gURUPoInterfaceLineIdTbl DBMS_SQL.NUMBER_TABLE;
207 gURUPoHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
208 gURUPoLineIdTbl DBMS_SQL.NUMBER_TABLE;
209 gURUCreatedLanguageTbl DBMS_SQL.VARCHAR2_TABLE;
210
211 --DELETE icx_cat_r12_upgrade
212 gDRURtItemIdTbl DBMS_SQL.NUMBER_TABLE;
213 gDRUPoInterfaceHeaderIdTbl DBMS_SQL.NUMBER_TABLE;
214 gDRUPoInterfaceLineIdTbl DBMS_SQL.NUMBER_TABLE;
215
216 --INSERT icx_cat_fav_list_lines_tlp for catalog items
217 gIFLCFavoriteListIdTbl DBMS_SQL.NUMBER_TABLE;
218 gIFLCNewFavoriteListLineIdTbl DBMS_SQL.NUMBER_TABLE;
219 gIFLCOldFavoriteListLineIdTbl DBMS_SQL.NUMBER_TABLE;
220 gIFLCRtItemIdTbl DBMS_SQL.NUMBER_TABLE;
221 gIFLCSourceTypeTbl DBMS_SQL.VARCHAR2_TABLE;
222 gIFLCOrgIdTbl DBMS_SQL.NUMBER_TABLE;
223 gIFLCLanguageTbl DBMS_SQL.VARCHAR2_TABLE;
224
225 --INSERT icx_cat_fav_list_lines_tlp for other items
226 gIFLOFavoriteListIdTbl DBMS_SQL.NUMBER_TABLE;
227 gIFLONewFavoriteListLineIdTbl DBMS_SQL.NUMBER_TABLE;
228 gIFLOOldFavoriteListLineIdTbl DBMS_SQL.NUMBER_TABLE;
229 gIFLOOrgIdTbl DBMS_SQL.NUMBER_TABLE;
230 gIFLOLanguageTbl DBMS_SQL.VARCHAR2_TABLE;
231
232 PROCEDURE clearTables
233 ( p_action_mode IN VARCHAR2
234 )
235 IS
236 BEGIN
237 IF (p_action_mode IN ('ALL', 'INSERT_INT_HDRS')) THEN
238 --INSERT po_headers_interface
239 gIHInterfaceHeaderIdTbl.DELETE;
240 gIHActionTbl.DELETE;
241 gIHOrgIdTbl.DELETE;
242 gIHDocumentTypeCodeTbl.DELETE;
243 gIHBudgetAccountSegment1Tbl.DELETE;
244 gIHPoHeaderIdTbl.DELETE;
245 gIHApprovalStatusTbl.DELETE;
246 gIHVendorIdTbl.DELETE;
247 gIHVendorSiteIdTbl.DELETE;
248 gIHCurrencyCodeTbl.DELETE;
249 gIHCpaReferenceTbl.DELETE;
250 gIHCreatedLanguageTbl.DELETE;
251 gIHCommentsTbl.DELETE;
252 END IF;
253
254 IF (p_action_mode IN ('ALL', 'INSERT_INT_LINES')) THEN
255 --INSERT po_lines_interface
256 gILInterfaceLineIdTbl.DELETE;
257 gILInterfaceHeaderIdTbl.DELETE;
258 gILActionTbl.DELETE;
259 gILPoLineIdTbl.DELETE;
260 gILPoHeaderIdTbl.DELETE;
261 gILUnitPriceTbl.DELETE;
262 gILUomCodeTbl.DELETE;
263 gILNegByPrepFlagTbl.DELETE;
264 gILIpCategoryIdTbl.DELETE;
265 gILCategoryIdTbl.DELETE;
266 gILCategoryNameTbl.DELETE;
267 gILVendorProductNumTbl.DELETE;
268 gILSupplierPartAuxidTbl.DELETE;
269 gILItemDescripionTbl.DELETE;
270 gILCatalogNameTbl.DELETE;
271 END IF;
272
273 IF (p_action_mode IN ('ALL', 'INSERT_INT_ATTR_VALS')) THEN
274 --INSERT po_attr_values_interface
275 gIAVInterfaceHeaderIdTbl.DELETE;
276 gIAVInterfaceLineIdTbl.DELETE;
277 gIAVActionTbl.DELETE;
278 gIAVPoLineIdTbl.DELETE;
279 gIAVReqTemplateNameTbl.DELETE;
280 gIAVReqTemplateLineNumTbl.DELETE;
281 gIAVInventoryItemIdTbl.DELETE;
282 gIAVOrgIdTbl.DELETE;
283 gIAVRtItemIdTbl.DELETE;
284 gIAVLanguageTbl.DELETE;
285 END IF;
286
287 IF (p_action_mode IN ('ALL', 'INSERT_INT_ATTR_VALS_TLP')) THEN
288 --INSERT po_attr_values_tlp_interface
289 gIAVTInterfaceHeaderIdTbl.DELETE;
290 gIAVTInterfaceLineIdTbl.DELETE;
291 gIAVTActionTbl.DELETE;
292 gIAVTPoLineIdTbl.DELETE;
293 gIAVTReqTemplateNameTbl.DELETE;
294 gIAVTReqTemplateLineNumTbl.DELETE;
295 gIAVTInventoryItemIdTbl.DELETE;
296 gIAVTOrgIdTbl.DELETE;
297 gIAVTRtItemIdTbl.DELETE;
298 gIAVTLanguageTbl.DELETE;
299 gIAVTCheckDescUpdateTbl.DELETE;
300 END IF;
301
302 IF (p_action_mode IN ('ALL', 'INSERT_R12_UPGRADE')) THEN
303 --INSERT icx_cat_r12_upgrade
304 gIRURtItemIdTbl.DELETE;
305 gIRUSupplierSiteIdTbl.DELETE;
306 gIRUCurrencyTbl.DELETE;
307 gIRUCpaReferenceTbl.DELETE;
308 gIRUPriceContractIdTbl.DELETE;
309 gIRUSrcContractIdTbl.DELETE;
310 gIRUPoCategoryIdTbl.DELETE;
311 gIRUPoInterfaceHeaderIdTbl.DELETE;
312 gIRUPoInterfaceLineIdTbl.DELETE;
313 gIRUCreatedLanguageTbl.DELETE;
314 -- TBD gIRUExtractorUpdatedFlagTbl.DELETE;
315 END IF;
316
317 IF (p_action_mode IN ('ALL', 'UPDATE_R12_UPGRADE')) THEN
318 --UPDATE icx_cat_r12_upgrade
319 gURURtItemIdTbl.DELETE;
320 gURUPoCategoryIdTbl.DELETE;
321 gURUCpaReferenceTbl.DELETE;
322 gURUPriceContractIdTbl.DELETE;
323 gURUSrcContractIdTbl.DELETE;
324 gURUOldPoInterfaceLineIdTbl.DELETE;
325 gURUPoInterfaceHeaderIdTbl.DELETE;
326 gURUPoInterfaceLineIdTbl.DELETE;
327 gURUPoHeaderIdTbl.DELETE;
328 gURUPoLineIdTbl.DELETE;
329 gURUCreatedLanguageTbl.DELETE;
330 END IF;
331
332 IF (p_action_mode IN ('ALL', 'DELETE_R12_UPGRADE')) THEN
333 --DELETE icx_cat_r12_upgrade
334 gDRURtItemIdTbl.DELETE;
335 gDRUPoInterfaceHeaderIdTbl.DELETE;
336 gDRUPoInterfaceLineIdTbl.DELETE;
337 END IF;
338
339 IF (p_action_mode IN ('ALL', 'INSERT_FAV_LINES_CATALOG')) THEN
340 --INSERT icx_cat_fav_list_lines_tlp for catalog items
341 gIFLCFavoriteListIdTbl.DELETE;
342 gIFLCNewFavoriteListLineIdTbl.DELETE;
343 gIFLCOldFavoriteListLineIdTbl.DELETE;
344 gIFLCRtItemIdTbl.DELETE;
345 gIFLCSourceTypeTbl.DELETE;
346 gIFLCOrgIdTbl.DELETE;
347 gIFLCLanguageTbl.DELETE;
348 END IF;
349
350 IF (p_action_mode IN ('ALL', 'INSERT_FAV_LINES_OTHER')) THEN
351 --INSERT icx_cat_fav_list_lines_tlp for other items
352 gIFLOFavoriteListIdTbl.DELETE;
353 gIFLONewFavoriteListLineIdTbl.DELETE;
354 gIFLOOldFavoriteListLineIdTbl.DELETE;
355 gIFLOOrgIdTbl.DELETE;
356 gIFLOLanguageTbl.DELETE;
357 END IF;
358 END clearTables;
359
360 /*
361 FUNCTION logPLSQLTableRow(p_index IN PLS_INTEGER,
362 p_action_mode IN VARCHAR2)
363 RETURN VARCHAR2
364 IS
365 l_string VARCHAR2(4000);
366 BEGIN
367 l_string := 'logPLSQLTableRow('||p_action_mode||')['||p_index||']--';
368 IF (p_action_mode = 'INSERT_INT_HDRS') THEN
369 --INSERT po_headers_interface
370 l_string := l_string || ' gIHInterfaceHeaderIdTbl: ' ||
371 ICX_CAT_UTIL_PVT.getTableElement(gIHInterfaceHeaderIdTbl, p_index) || ', ';
372 l_string := l_string || ' gIHActionTbl: ' ||
373 ICX_CAT_UTIL_PVT.getTableElement(gIHActionTbl, p_index) || ', ';
374 l_string := l_string || ' gIHOrgIdTbl: ' ||
375 ICX_CAT_UTIL_PVT.getTableElement(gIHOrgIdTbl, p_index) || ', ';
376 l_string := l_string || ' gIHDocumentTypeCodeTbl: ' ||
377 ICX_CAT_UTIL_PVT.getTableElement(gIHDocumentTypeCodeTbl, p_index) || ', ';
378 l_string := l_string || ' gIHBudgetAccountSegment1Tbl: ' ||
379 ICX_CAT_UTIL_PVT.getTableElement(gIHBudgetAccountSegment1Tbl, p_index) || ', ';
380 l_string := l_string || ' gIHPoHeaderIdTbl: ' ||
381 ICX_CAT_UTIL_PVT.getTableElement(gIHPoHeaderIdTbl, p_index) || ', ';
382 l_string := l_string || ' gIHApprovalStatusTbl: ' ||
383 ICX_CAT_UTIL_PVT.getTableElement(gIHApprovalStatusTbl, p_index) || ', ';
384 l_string := l_string || ' gIHVendorIdTbl: ' ||
385 ICX_CAT_UTIL_PVT.getTableElement(gIHVendorIdTbl, p_index) || ', ';
386 l_string := l_string || ' gIHVendorSiteIdTbl: ' ||
387 ICX_CAT_UTIL_PVT.getTableElement(gIHVendorSiteIdTbl, p_index) || ', ';
388 l_string := l_string || ' gIHCurrencyCodeTbl: ' ||
389 ICX_CAT_UTIL_PVT.getTableElement(gIHCurrencyCodeTbl, p_index) || ', ';
390 l_string := l_string || ' gIHCpaReferenceTbl: ' ||
391 ICX_CAT_UTIL_PVT.getTableElement(gIHCpaReferenceTbl, p_index) || ', ';
392 l_string := l_string || ' gIHCreatedLanguageTbl: ' ||
393 ICX_CAT_UTIL_PVT.getTableElement(gIHCreatedLanguageTbl, p_index) || ', ';
394 l_string := l_string || ' gIHCommentsTbl: ' ||
395 ICX_CAT_UTIL_PVT.getTableElement(gIHCommentsTbl, p_index) || ', ';
396 END IF;
397
398 IF (p_action_mode = 'INSERT_INT_LINES') THEN
399 --INSERT po_lines_interface
400 l_string := l_string || ' gILInterfaceLineIdTbl: ' ||
401 ICX_CAT_UTIL_PVT.getTableElement(gILInterfaceLineIdTbl, p_index) || ', ';
402 l_string := l_string || ' gILInterfaceHeaderIdTbl: ' ||
403 ICX_CAT_UTIL_PVT.getTableElement(gILInterfaceHeaderIdTbl, p_index) || ', ';
404 l_string := l_string || ' gILActionTbl: ' ||
405 ICX_CAT_UTIL_PVT.getTableElement(gILActionTbl, p_index) || ', ';
406 l_string := l_string || ' gILPoLineIdTbl: ' ||
407 ICX_CAT_UTIL_PVT.getTableElement(gILPoLineIdTbl, p_index) || ', ';
408 l_string := l_string || ' gILPoHeaderIdTbl: ' ||
409 ICX_CAT_UTIL_PVT.getTableElement(gILPoHeaderIdTbl, p_index) || ', ';
410 l_string := l_string || ' gILUnitPriceTbl: ' ||
411 ICX_CAT_UTIL_PVT.getTableElement(gILUnitPriceTbl, p_index) || ', ';
412 l_string := l_string || ' gILUomCodeTbl: ' ||
413 ICX_CAT_UTIL_PVT.getTableElement(gILUomCodeTbl, p_index) || ', ';
414 l_string := l_string || ' gILNegByPrepFlagTbl: ' ||
415 ICX_CAT_UTIL_PVT.getTableElement(gILNegByPrepFlagTbl, p_index) || ', ';
416 l_string := l_string || ' gILIpCategoryIdTbl: ' ||
417 ICX_CAT_UTIL_PVT.getTableElement(gILIpCategoryIdTbl, p_index) || ', ';
418 l_string := l_string || ' gILCategoryIdTbl: ' ||
419 ICX_CAT_UTIL_PVT.getTableElement(gILCategoryIdTbl, p_index) || ', ';
420 l_string := l_string || ' gILCategoryNameTbl: ' ||
421 ICX_CAT_UTIL_PVT.getTableElement(gILCategoryNameTbl, p_index) || ', ';
422 l_string := l_string || ' gILVendorProductNumTbl: ' ||
423 ICX_CAT_UTIL_PVT.getTableElement(gILVendorProductNumTbl, p_index) || ', ';
424 l_string := l_string || ' gILSupplierPartAuxidTbl: ' ||
425 ICX_CAT_UTIL_PVT.getTableElement(gILSupplierPartAuxidTbl, p_index) || ', ';
426 l_string := l_string || ' gILItemDescripionTbl: ' ||
427 ICX_CAT_UTIL_PVT.getTableElement(gILItemDescripionTbl, p_index) || ', ';
428 l_string := l_string || ' gILCatalogNameTbl: ' ||
429 ICX_CAT_UTIL_PVT.getTableElement(gILCatalogNameTbl, p_index) || ', ';
430
431 END IF;
432
433 IF (p_action_mode = 'INSERT_INT_ATTR_VALS') THEN
434 --INSERT po_attr_values_interface
435 l_string := l_string || ' gIAVInterfaceHeaderIdTbl: ' ||
436 ICX_CAT_UTIL_PVT.getTableElement(gIAVInterfaceHeaderIdTbl, p_index) || ', ';
437 l_string := l_string || ' gIAVInterfaceLineIdTbl: ' ||
438 ICX_CAT_UTIL_PVT.getTableElement(gIAVInterfaceLineIdTbl, p_index) || ', ';
439 l_string := l_string || ' gIAVActionTbl: ' ||
440 ICX_CAT_UTIL_PVT.getTableElement(gIAVActionTbl, p_index) || ', ';
441 l_string := l_string || ' gIAVPoLineIdTbl: ' ||
442 ICX_CAT_UTIL_PVT.getTableElement(gIAVPoLineIdTbl, p_index) || ', ';
443 l_string := l_string || ' gIAVReqTemplateNameTbl: ' ||
444 ICX_CAT_UTIL_PVT.getTableElement(gIAVReqTemplateNameTbl, p_index) || ', ';
445 l_string := l_string || ' gIAVReqTemplateLineNumTbl: ' ||
446 ICX_CAT_UTIL_PVT.getTableElement(gIAVReqTemplateLineNumTbl, p_index) || ', ';
447 l_string := l_string || ' gIAVInventoryItemIdTbl: ' ||
448 ICX_CAT_UTIL_PVT.getTableElement(gIAVInventoryItemIdTbl, p_index) || ', ';
449 l_string := l_string || ' gIAVOrgIdTbl: ' ||
450 ICX_CAT_UTIL_PVT.getTableElement(gIAVOrgIdTbl, p_index) || ', ';
451 l_string := l_string || ' gIAVRtItemIdTbl: ' ||
452 ICX_CAT_UTIL_PVT.getTableElement(gIAVRtItemIdTbl, p_index) || ', ';
453 l_string := l_string || ' gIAVLanguageTbl: ' ||
454 ICX_CAT_UTIL_PVT.getTableElement(gIAVLanguageTbl, p_index) || ', ';
455 END IF;
456
457 IF (p_action_mode = 'INSERT_INT_ATTR_VALS_TLP') THEN
458 --INSERT po_attr_values_tlp_interface
459 l_string := l_string || ' gIAVTInterfaceHeaderIdTbl: ' ||
460 ICX_CAT_UTIL_PVT.getTableElement(gIAVTInterfaceHeaderIdTbl, p_index) || ', ';
461 l_string := l_string || ' gIAVTInterfaceLineIdTbl: ' ||
462 ICX_CAT_UTIL_PVT.getTableElement(gIAVTInterfaceLineIdTbl, p_index) || ', ';
463 l_string := l_string || ' gIAVTActionTbl: ' ||
464 ICX_CAT_UTIL_PVT.getTableElement(gIAVTActionTbl, p_index) || ', ';
465 l_string := l_string || ' gIAVTPoLineIdTbl: ' ||
466 ICX_CAT_UTIL_PVT.getTableElement(gIAVTPoLineIdTbl, p_index) || ', ';
467 l_string := l_string || ' gIAVTReqTemplateNameTbl: ' ||
468 ICX_CAT_UTIL_PVT.getTableElement(gIAVTReqTemplateNameTbl, p_index) || ', ';
469 l_string := l_string || ' gIAVTReqTemplateLineNumTbl: ' ||
470 ICX_CAT_UTIL_PVT.getTableElement(gIAVTReqTemplateLineNumTbl, p_index) || ', ';
471 l_string := l_string || ' gIAVTInventoryItemIdTbl: ' ||
472 ICX_CAT_UTIL_PVT.getTableElement(gIAVTInventoryItemIdTbl, p_index) || ', ';
473 l_string := l_string || ' gIAVTOrgIdTbl: ' ||
474 ICX_CAT_UTIL_PVT.getTableElement(gIAVTOrgIdTbl, p_index) || ', ';
475 l_string := l_string || ' gIAVTRtItemIdTbl: ' ||
476 ICX_CAT_UTIL_PVT.getTableElement(gIAVTRtItemIdTbl, p_index) || ', ';
477 l_string := l_string || ' gIAVTLanguageTbl: ' ||
478 ICX_CAT_UTIL_PVT.getTableElement(gIAVTLanguageTbl, p_index) || ', ';
479 l_string := l_string || ' gIAVTCheckDescUpdateTbl: ' ||
480 ICX_CAT_UTIL_PVT.getTableElement(gIAVTCheckDescUpdateTbl, p_index) || ', ';
481 END IF;
482
483 IF (p_action_mode = 'INSERT_R12_UPGRADE') THEN
484 --INSERT icx_cat_r12_upgrade
485 l_string := l_string || ' gIRURtItemIdTbl: ' ||
486 ICX_CAT_UTIL_PVT.getTableElement(gIRURtItemIdTbl, p_index) || ', ';
487 l_string := l_string || ' gIRUSupplierSiteIdTbl: ' ||
488 ICX_CAT_UTIL_PVT.getTableElement(gIRUSupplierSiteIdTbl, p_index) || ', ';
489 l_string := l_string || ' gIRUCurrencyTbl: ' ||
490 ICX_CAT_UTIL_PVT.getTableElement(gIRUCurrencyTbl, p_index) || ', ';
491 l_string := l_string || ' gIRUCpaReferenceTbl: ' ||
492 ICX_CAT_UTIL_PVT.getTableElement(gIRUCpaReferenceTbl, p_index) || ', ';
493 l_string := l_string || ' gIRUPriceContractIdTbl: ' ||
494 ICX_CAT_UTIL_PVT.getTableElement(gIRUPriceContractIdTbl, p_index) || ', ';
495 l_string := l_string || ' gIRUSrcContractIdTbl: ' ||
496 ICX_CAT_UTIL_PVT.getTableElement(gIRUSrcContractIdTbl, p_index) || ', ';
497 l_string := l_string || ' gIRUPoCategoryIdTbl: ' ||
498 ICX_CAT_UTIL_PVT.getTableElement(gIRUPoCategoryIdTbl, p_index) || ', ';
499 l_string := l_string || ' gIRUPoInterfaceHeaderIdTbl: ' ||
500 ICX_CAT_UTIL_PVT.getTableElement(gIRUPoInterfaceHeaderIdTbl, p_index) || ', ';
501 l_string := l_string || ' gIRUPoInterfaceLineIdTbl: ' ||
502 ICX_CAT_UTIL_PVT.getTableElement(gIRUPoInterfaceLineIdTbl, p_index) || ', ';
503 l_string := l_string || ' gIRUCreatedLanguageTbl: ' ||
504 ICX_CAT_UTIL_PVT.getTableElement(gIRUCreatedLanguageTbl, p_index) || ', ';
505 -- TBD l_string := l_string || ' gIRUExtractorUpdatedFlagTbl: ' ||
506 -- TBD ICX_CAT_UTIL_PVT.getTableElement(gIRUExtractorUpdatedFlagTbl, p_index) || ', ';
507 END IF;
508
509 IF (p_action_mode = 'UPDATE_R12_UPGRADE') THEN
510 --UPDATE icx_cat_r12_upgrade
511 l_string := l_string || ' gURURtItemIdTbl: ' ||
512 ICX_CAT_UTIL_PVT.getTableElement(gURURtItemIdTbl, p_index) || ', ';
513 l_string := l_string || ' gURUPoCategoryIdTbl: ' ||
514 ICX_CAT_UTIL_PVT.getTableElement(gURUPoCategoryIdTbl, p_index) || ', ';
515 l_string := l_string || ' gURUCpaReferenceTbl: ' ||
516 ICX_CAT_UTIL_PVT.getTableElement(gURUCpaReferenceTbl, p_index) || ', ';
517 l_string := l_string || ' gURUPriceContractIdTbl: ' ||
518 ICX_CAT_UTIL_PVT.getTableElement(gURUPriceContractIdTbl, p_index) || ', ';
519 l_string := l_string || ' gURUSrcContractIdTbl: ' ||
520 ICX_CAT_UTIL_PVT.getTableElement(gURUSrcContractIdTbl, p_index) || ', ';
521 l_string := l_string || ' gURUOldPoInterfaceLineIdTbl: ' ||
522 ICX_CAT_UTIL_PVT.getTableElement(gURUOldPoInterfaceLineIdTbl, p_index) || ', ';
523 l_string := l_string || ' gURUPoInterfaceHeaderIdTbl: ' ||
524 ICX_CAT_UTIL_PVT.getTableElement(gURUPoInterfaceHeaderIdTbl, p_index) || ', ';
525 l_string := l_string || ' gURUPoInterfaceLineIdTbl: ' ||
526 ICX_CAT_UTIL_PVT.getTableElement(gURUPoInterfaceLineIdTbl, p_index) || ', ';
527 l_string := l_string || ' gURUPoHeaderIdTbl: ' ||
528 ICX_CAT_UTIL_PVT.getTableElement(gURUPoHeaderIdTbl, p_index) || ', ';
529 l_string := l_string || ' gURUPoLineIdTbl: ' ||
530 ICX_CAT_UTIL_PVT.getTableElement(gURUPoLineIdTbl, p_index) || ', ';
531 l_string := l_string || ' gURUCreatedLanguageTbl: ' ||
532 ICX_CAT_UTIL_PVT.getTableElement(gURUCreatedLanguageTbl, p_index) || ', ';
533 END IF;
534
535 IF (p_action_mode = 'DELETE_R12_UPGRADE') THEN
536 --DELETE icx_cat_r12_upgrade
537 l_string := l_string || ' gDRURtItemIdTbl: ' ||
538 ICX_CAT_UTIL_PVT.getTableElement(gDRURtItemIdTbl, p_index) || ', ';
539 l_string := l_string || ' gDRUPoInterfaceHeaderIdTbl: ' ||
540 ICX_CAT_UTIL_PVT.getTableElement(gDRUPoInterfaceHeaderIdTbl, p_index) || ', ';
541 l_string := l_string || ' gDRUPoInterfaceLineIdTbl: ' ||
542 ICX_CAT_UTIL_PVT.getTableElement(gDRUPoInterfaceLineIdTbl, p_index) || ', ';
543 END IF;
544
545 IF (p_action_mode = 'INSERT_FAV_LINES_CATALOG') THEN
546 --INSERT icx_cat_fav_list_lines_tlp for catalog items
547 l_string := l_string || ' gIFLCFavoriteListIdTbl: ' ||
548 ICX_CAT_UTIL_PVT.getTableElement(gIFLCFavoriteListIdTbl, p_index) || ', ';
549 l_string := l_string || ' gIFLCNewFavoriteListLineIdTbl: ' ||
550 ICX_CAT_UTIL_PVT.getTableElement(gIFLCNewFavoriteListLineIdTbl, p_index) || ', ';
551 l_string := l_string || ' gIFLCOldFavoriteListLineIdTbl: ' ||
552 ICX_CAT_UTIL_PVT.getTableElement(gIFLCOldFavoriteListLineIdTbl, p_index) || ', ';
553 l_string := l_string || ' gIFLCRtItemIdTbl: ' ||
554 ICX_CAT_UTIL_PVT.getTableElement(gIFLCRtItemIdTbl, p_index) || ', ';
555 l_string := l_string || ' gIFLCSourceTypeTbl: ' ||
556 ICX_CAT_UTIL_PVT.getTableElement(gIFLCSourceTypeTbl, p_index) || ', ';
557 l_string := l_string || ' gIFLCOrgIdTbl: ' ||
558 ICX_CAT_UTIL_PVT.getTableElement(gIFLCOrgIdTbl, p_index) || ', ';
559 l_string := l_string || ' gIFLCLanguageTbl: ' ||
560 ICX_CAT_UTIL_PVT.getTableElement(gIFLCLanguageTbl, p_index) || ', ';
561 END IF;
562
563 IF (p_action_mode = 'INSERT_FAV_LINES_OTHER') THEN
564 --INSERT icx_cat_fav_list_lines_tlp for other items
565 l_string := l_string || ' gIFLOFavoriteListIdTbl: ' ||
566 ICX_CAT_UTIL_PVT.getTableElement(gIFLOFavoriteListIdTbl, p_index) || ', ';
567 l_string := l_string || ' gIFLONewFavoriteListLineIdTbl: ' ||
568 ICX_CAT_UTIL_PVT.getTableElement(gIFLONewFavoriteListLineIdTbl, p_index) || ', ';
569 l_string := l_string || ' gIFLOOldFavoriteListLineIdTbl: ' ||
570 ICX_CAT_UTIL_PVT.getTableElement(gIFLOOldFavoriteListLineIdTbl, p_index) || ', ';
571 l_string := l_string || ' gIFLOOrgIdTbl: ' ||
572 ICX_CAT_UTIL_PVT.getTableElement(gIFLOOrgIdTbl, p_index) || ', ';
573 l_string := l_string || ' gIFLOLanguageTbl: ' ||
574 ICX_CAT_UTIL_PVT.getTableElement(gIFLOLanguageTbl, p_index) || ', ';
575 END IF;
576
577 RETURN l_string;
578
579 END logPLSQLTableRow;
580 */
581
582 PROCEDURE logPLSQLTableRow
583 ( p_api_name IN VARCHAR2 ,
584 p_log_level IN NUMBER ,
585 p_index IN NUMBER ,
586 p_action_mode IN VARCHAR2
587 )
588 IS
589 l_log_string VARCHAR2(4000);
590 l_err_loc PLS_INTEGER;
591 l_module_name VARCHAR2(80);
592 BEGIN
593 l_err_loc := 100;
594 IF (p_log_level >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
595 l_err_loc := 200;
596 l_module_name := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, p_api_name);
597
598 l_err_loc := 300;
599 l_log_string := 'logPLSQLTableRow('||p_action_mode||')['||p_index||']--';
600 FND_LOG.string(p_log_level, l_module_name, l_log_string);
601
602 l_err_loc := 400;
603
604 IF (p_action_mode = 'INSERT_INT_HDRS') THEN
605 l_err_loc := 500;
606 -- INSERT po_headers_interface
607 l_log_string := ' gIHInterfaceHeaderIdTbl: ' ||
608 ICX_CAT_UTIL_PVT.getTableElement(gIHInterfaceHeaderIdTbl, p_index) || '; ';
609 FND_LOG.string(p_log_level, l_module_name, l_log_string);
610
611 l_log_string := ' gIHActionTbl: ' ||
612 ICX_CAT_UTIL_PVT.getTableElement(gIHActionTbl, p_index) || '; ';
613 FND_LOG.string(p_log_level, l_module_name, l_log_string);
614
615 l_log_string := ' gIHOrgIdTbl: ' ||
616 ICX_CAT_UTIL_PVT.getTableElement(gIHOrgIdTbl, p_index) || '; ';
617 FND_LOG.string(p_log_level, l_module_name, l_log_string);
618
619 l_log_string := ' gIHDocumentTypeCodeTbl: ' ||
620 ICX_CAT_UTIL_PVT.getTableElement(gIHDocumentTypeCodeTbl, p_index) || '; ';
621 FND_LOG.string(p_log_level, l_module_name, l_log_string);
622
623 l_log_string := ' gIHBudgetAccountSegment1Tbl: ' ||
624 ICX_CAT_UTIL_PVT.getTableElement(gIHBudgetAccountSegment1Tbl, p_index) || '; ';
625 FND_LOG.string(p_log_level, l_module_name, l_log_string);
626
627 l_log_string := ' gIHPoHeaderIdTbl: ' ||
628 ICX_CAT_UTIL_PVT.getTableElement(gIHPoHeaderIdTbl, p_index) || '; ';
629 FND_LOG.string(p_log_level, l_module_name, l_log_string);
630
631 l_log_string := ' gIHApprovalStatusTbl: ' ||
632 ICX_CAT_UTIL_PVT.getTableElement(gIHApprovalStatusTbl, p_index) || '; ';
633 FND_LOG.string(p_log_level, l_module_name, l_log_string);
634
635 l_log_string := ' gIHVendorIdTbl: ' ||
636 ICX_CAT_UTIL_PVT.getTableElement(gIHVendorIdTbl, p_index) || '; ';
637 FND_LOG.string(p_log_level, l_module_name, l_log_string);
638
639 l_log_string := ' gIHVendorSiteIdTbl: ' ||
640 ICX_CAT_UTIL_PVT.getTableElement(gIHVendorSiteIdTbl, p_index) || '; ';
641 FND_LOG.string(p_log_level, l_module_name, l_log_string);
642
643 l_log_string := ' gIHCurrencyCodeTbl: ' ||
644 ICX_CAT_UTIL_PVT.getTableElement(gIHCurrencyCodeTbl, p_index) || '; ';
645 FND_LOG.string(p_log_level, l_module_name, l_log_string);
646
647 l_log_string := ' gIHCpaReferenceTbl: ' ||
648 ICX_CAT_UTIL_PVT.getTableElement(gIHCpaReferenceTbl, p_index) || '; ';
649 FND_LOG.string(p_log_level, l_module_name, l_log_string);
650
651 l_log_string := ' gIHCreatedLanguageTbl: ' ||
652 ICX_CAT_UTIL_PVT.getTableElement(gIHCreatedLanguageTbl, p_index) || '; ';
653 FND_LOG.string(p_log_level, l_module_name, l_log_string);
654
655 l_log_string := ' gIHCommentsTbl: ' ||
656 ICX_CAT_UTIL_PVT.getTableElement(gIHCommentsTbl, p_index) || '; ';
657 FND_LOG.string(p_log_level, l_module_name, l_log_string);
658
659 END IF;
660
661 l_err_loc := 600;
662
663 IF (p_action_mode = 'INSERT_INT_LINES') THEN
664 l_err_loc := 700;
665 -- INSERT po_lines_interface
666 l_log_string := ' gILInterfaceLineIdTbl: ' ||
667 ICX_CAT_UTIL_PVT.getTableElement(gILInterfaceLineIdTbl, p_index) || '; ';
668 FND_LOG.string(p_log_level, l_module_name, l_log_string);
669
670 l_log_string := ' gILInterfaceHeaderIdTbl: ' ||
671 ICX_CAT_UTIL_PVT.getTableElement(gILInterfaceHeaderIdTbl, p_index) || '; ';
672 FND_LOG.string(p_log_level, l_module_name, l_log_string);
673
674 l_log_string := ' gILActionTbl: ' ||
675 ICX_CAT_UTIL_PVT.getTableElement(gILActionTbl, p_index) || '; ';
676 FND_LOG.string(p_log_level, l_module_name, l_log_string);
677
678 l_log_string := ' gILPoLineIdTbl: ' ||
679 ICX_CAT_UTIL_PVT.getTableElement(gILPoLineIdTbl, p_index) || '; ';
680 FND_LOG.string(p_log_level, l_module_name, l_log_string);
681
682 l_log_string := ' gILPoHeaderIdTbl: ' ||
683 ICX_CAT_UTIL_PVT.getTableElement(gILPoHeaderIdTbl, p_index) || '; ';
684 FND_LOG.string(p_log_level, l_module_name, l_log_string);
685
686 l_log_string := ' gILUnitPriceTbl: ' ||
687 ICX_CAT_UTIL_PVT.getTableElement(gILUnitPriceTbl, p_index) || '; ';
688 FND_LOG.string(p_log_level, l_module_name, l_log_string);
689
690 l_log_string := ' gILUomCodeTbl: ' ||
691 ICX_CAT_UTIL_PVT.getTableElement(gILUomCodeTbl, p_index) || '; ';
692 FND_LOG.string(p_log_level, l_module_name, l_log_string);
693
694 l_log_string := ' gILNegByPrepFlagTbl: ' ||
695 ICX_CAT_UTIL_PVT.getTableElement(gILNegByPrepFlagTbl, p_index) || '; ';
696 FND_LOG.string(p_log_level, l_module_name, l_log_string);
697
698 l_log_string := ' gILIpCategoryIdTbl: ' ||
699 ICX_CAT_UTIL_PVT.getTableElement(gILIpCategoryIdTbl, p_index) || '; ';
700 FND_LOG.string(p_log_level, l_module_name, l_log_string);
701
702 l_log_string := ' gILCategoryIdTbl: ' ||
703 ICX_CAT_UTIL_PVT.getTableElement(gILCategoryIdTbl, p_index) || '; ';
704 FND_LOG.string(p_log_level, l_module_name, l_log_string);
705
706 l_log_string := ' gILCategoryNameTbl: ' ||
707 ICX_CAT_UTIL_PVT.getTableElement(gILCategoryNameTbl, p_index) || '; ';
708 FND_LOG.string(p_log_level, l_module_name, l_log_string);
709
710 l_log_string := ' gILVendorProductNumTbl: ' ||
711 ICX_CAT_UTIL_PVT.getTableElement(gILVendorProductNumTbl, p_index) || '; ';
712 FND_LOG.string(p_log_level, l_module_name, l_log_string);
713
714 l_log_string := ' gILSupplierPartAuxidTbl: ' ||
715 ICX_CAT_UTIL_PVT.getTableElement(gILSupplierPartAuxidTbl, p_index) || '; ';
716 FND_LOG.string(p_log_level, l_module_name, l_log_string);
717
718 l_log_string := ' gILItemDescripionTbl: ' ||
719 ICX_CAT_UTIL_PVT.getTableElement(gILItemDescripionTbl, p_index) || '; ';
720 FND_LOG.string(p_log_level, l_module_name, l_log_string);
721
722 l_log_string := ' gILCatalogNameTbl: ' ||
723 ICX_CAT_UTIL_PVT.getTableElement(gILCatalogNameTbl, p_index) || '; ';
724 FND_LOG.string(p_log_level, l_module_name, l_log_string);
725
726 END IF;
727
728 l_err_loc := 800;
729
730 IF (p_action_mode = 'INSERT_INT_ATTR_VALS') THEN
731 l_err_loc := 900;
732 -- INSERT po_attr_values_interface
733 l_log_string := ' gIAVInterfaceHeaderIdTbl: ' ||
734 ICX_CAT_UTIL_PVT.getTableElement(gIAVInterfaceHeaderIdTbl, p_index) || '; ';
735 FND_LOG.string(p_log_level, l_module_name, l_log_string);
736
737 l_log_string := ' gIAVInterfaceLineIdTbl: ' ||
738 ICX_CAT_UTIL_PVT.getTableElement(gIAVInterfaceLineIdTbl, p_index) || '; ';
739 FND_LOG.string(p_log_level, l_module_name, l_log_string);
740
741 l_log_string := ' gIAVActionTbl: ' ||
742 ICX_CAT_UTIL_PVT.getTableElement(gIAVActionTbl, p_index) || '; ';
743 FND_LOG.string(p_log_level, l_module_name, l_log_string);
744
745 l_log_string := ' gIAVPoLineIdTbl: ' ||
746 ICX_CAT_UTIL_PVT.getTableElement(gIAVPoLineIdTbl, p_index) || '; ';
747 FND_LOG.string(p_log_level, l_module_name, l_log_string);
748
749 l_log_string := ' gIAVReqTemplateNameTbl: ' ||
750 ICX_CAT_UTIL_PVT.getTableElement(gIAVReqTemplateNameTbl, p_index) || '; ';
751 FND_LOG.string(p_log_level, l_module_name, l_log_string);
752
753 l_log_string := ' gIAVReqTemplateLineNumTbl: ' ||
754 ICX_CAT_UTIL_PVT.getTableElement(gIAVReqTemplateLineNumTbl, p_index) || '; ';
755 FND_LOG.string(p_log_level, l_module_name, l_log_string);
756
757 l_log_string := ' gIAVInventoryItemIdTbl: ' ||
758 ICX_CAT_UTIL_PVT.getTableElement(gIAVInventoryItemIdTbl, p_index) || '; ';
759 FND_LOG.string(p_log_level, l_module_name, l_log_string);
760
761 l_log_string := ' gIAVOrgIdTbl: ' ||
762 ICX_CAT_UTIL_PVT.getTableElement(gIAVOrgIdTbl, p_index) || '; ';
763 FND_LOG.string(p_log_level, l_module_name, l_log_string);
764
765 l_log_string := ' gIAVRtItemIdTbl: ' ||
766 ICX_CAT_UTIL_PVT.getTableElement(gIAVRtItemIdTbl, p_index) || '; ';
767 FND_LOG.string(p_log_level, l_module_name, l_log_string);
768
769 l_log_string := ' gIAVLanguageTbl: ' ||
770 ICX_CAT_UTIL_PVT.getTableElement(gIAVLanguageTbl, p_index) || '; ';
771 FND_LOG.string(p_log_level, l_module_name, l_log_string);
772
773 END IF;
774
775 l_err_loc := 1000;
776
777 IF (p_action_mode = 'INSERT_INT_ATTR_VALS_TLP') THEN
778 l_err_loc := 1100;
779 -- INSERT po_attr_values_tlp_interface
780 l_log_string := ' gIAVTInterfaceHeaderIdTbl: ' ||
781 ICX_CAT_UTIL_PVT.getTableElement(gIAVTInterfaceHeaderIdTbl, p_index) || '; ';
782 FND_LOG.string(p_log_level, l_module_name, l_log_string);
783
784 l_log_string := ' gIAVTInterfaceLineIdTbl: ' ||
785 ICX_CAT_UTIL_PVT.getTableElement(gIAVTInterfaceLineIdTbl, p_index) || '; ';
786 FND_LOG.string(p_log_level, l_module_name, l_log_string);
787
788 l_log_string := ' gIAVTActionTbl: ' ||
789 ICX_CAT_UTIL_PVT.getTableElement(gIAVTActionTbl, p_index) || '; ';
790 FND_LOG.string(p_log_level, l_module_name, l_log_string);
791
792 l_log_string := ' gIAVTPoLineIdTbl: ' ||
793 ICX_CAT_UTIL_PVT.getTableElement(gIAVTPoLineIdTbl, p_index) || '; ';
794 FND_LOG.string(p_log_level, l_module_name, l_log_string);
795
796 l_log_string := ' gIAVTReqTemplateNameTbl: ' ||
797 ICX_CAT_UTIL_PVT.getTableElement(gIAVTReqTemplateNameTbl, p_index) || '; ';
798 FND_LOG.string(p_log_level, l_module_name, l_log_string);
799
800 l_log_string := ' gIAVTReqTemplateLineNumTbl: ' ||
801 ICX_CAT_UTIL_PVT.getTableElement(gIAVTReqTemplateLineNumTbl, p_index) || '; ';
802 FND_LOG.string(p_log_level, l_module_name, l_log_string);
803
804 l_log_string := ' gIAVTInventoryItemIdTbl: ' ||
805 ICX_CAT_UTIL_PVT.getTableElement(gIAVTInventoryItemIdTbl, p_index) || '; ';
806 FND_LOG.string(p_log_level, l_module_name, l_log_string);
807
808 l_log_string := ' gIAVTOrgIdTbl: ' ||
809 ICX_CAT_UTIL_PVT.getTableElement(gIAVTOrgIdTbl, p_index) || '; ';
810 FND_LOG.string(p_log_level, l_module_name, l_log_string);
811
812 l_log_string := ' gIAVTRtItemIdTbl: ' ||
813 ICX_CAT_UTIL_PVT.getTableElement(gIAVTRtItemIdTbl, p_index) || '; ';
814 FND_LOG.string(p_log_level, l_module_name, l_log_string);
815
816 l_log_string := ' gIAVTLanguageTbl: ' ||
817 ICX_CAT_UTIL_PVT.getTableElement(gIAVTLanguageTbl, p_index) || '; ';
818 FND_LOG.string(p_log_level, l_module_name, l_log_string);
819
820 l_log_string := ' gIAVTCheckDescUpdateTbl: ' ||
821 ICX_CAT_UTIL_PVT.getTableElement(gIAVTCheckDescUpdateTbl, p_index) || '; ';
822 FND_LOG.string(p_log_level, l_module_name, l_log_string);
823
824 END IF;
825
826 l_err_loc := 1200;
827
828 IF (p_action_mode = 'INSERT_R12_UPGRADE') THEN
829 l_err_loc := 1300;
830 -- INSERT icx_cat_r12_upgrade
831 l_log_string := ' gIRURtItemIdTbl: ' ||
832 ICX_CAT_UTIL_PVT.getTableElement(gIRURtItemIdTbl, p_index) || '; ';
833 FND_LOG.string(p_log_level, l_module_name, l_log_string);
834
835 l_log_string := ' gIRUSupplierSiteIdTbl: ' ||
836 ICX_CAT_UTIL_PVT.getTableElement(gIRUSupplierSiteIdTbl, p_index) || '; ';
837 FND_LOG.string(p_log_level, l_module_name, l_log_string);
838
839 l_log_string := ' gIRUCurrencyTbl: ' ||
840 ICX_CAT_UTIL_PVT.getTableElement(gIRUCurrencyTbl, p_index) || '; ';
841 FND_LOG.string(p_log_level, l_module_name, l_log_string);
842
843 l_log_string := ' gIRUCpaReferenceTbl: ' ||
844 ICX_CAT_UTIL_PVT.getTableElement(gIRUCpaReferenceTbl, p_index) || '; ';
845 FND_LOG.string(p_log_level, l_module_name, l_log_string);
846
847 l_log_string := ' gIRUPriceContractIdTbl: ' ||
848 ICX_CAT_UTIL_PVT.getTableElement(gIRUPriceContractIdTbl, p_index) || '; ';
849 FND_LOG.string(p_log_level, l_module_name, l_log_string);
850
851 l_log_string := ' gIRUSrcContractIdTbl: ' ||
852 ICX_CAT_UTIL_PVT.getTableElement(gIRUSrcContractIdTbl, p_index) || '; ';
853 FND_LOG.string(p_log_level, l_module_name, l_log_string);
854
855 l_log_string := ' gIRUPoCategoryIdTbl: ' ||
856 ICX_CAT_UTIL_PVT.getTableElement(gIRUPoCategoryIdTbl, p_index) || '; ';
857 FND_LOG.string(p_log_level, l_module_name, l_log_string);
858
859 l_log_string := ' gIRUPoInterfaceHeaderIdTbl: ' ||
860 ICX_CAT_UTIL_PVT.getTableElement(gIRUPoInterfaceHeaderIdTbl, p_index) || '; ';
861 FND_LOG.string(p_log_level, l_module_name, l_log_string);
862
863 l_log_string := ' gIRUPoInterfaceLineIdTbl: ' ||
864 ICX_CAT_UTIL_PVT.getTableElement(gIRUPoInterfaceLineIdTbl, p_index) || '; ';
865 FND_LOG.string(p_log_level, l_module_name, l_log_string);
866
867 l_log_string := ' gIRUCreatedLanguageTbl: ' ||
868 ICX_CAT_UTIL_PVT.getTableElement(gIRUCreatedLanguageTbl, p_index) || '; ';
869 FND_LOG.string(p_log_level, l_module_name, l_log_string);
870
871 END IF;
872
873 l_err_loc := 1400;
874
875 IF (p_action_mode = 'UPDATE_R12_UPGRADE') THEN
876 l_err_loc := 1500;
877 -- UPDATE icx_cat_r12_upgrade
878 l_log_string := ' gURURtItemIdTbl: ' ||
879 ICX_CAT_UTIL_PVT.getTableElement(gURURtItemIdTbl, p_index) || '; ';
880 FND_LOG.string(p_log_level, l_module_name, l_log_string);
881
882 l_log_string := ' gURUPoCategoryIdTbl: ' ||
883 ICX_CAT_UTIL_PVT.getTableElement(gURUPoCategoryIdTbl, p_index) || '; ';
884 FND_LOG.string(p_log_level, l_module_name, l_log_string);
885
886 l_log_string := ' gURUCpaReferenceTbl: ' ||
887 ICX_CAT_UTIL_PVT.getTableElement(gURUCpaReferenceTbl, p_index) || '; ';
888 FND_LOG.string(p_log_level, l_module_name, l_log_string);
889
890 l_log_string := ' gURUPriceContractIdTbl: ' ||
891 ICX_CAT_UTIL_PVT.getTableElement(gURUPriceContractIdTbl, p_index) || '; ';
892 FND_LOG.string(p_log_level, l_module_name, l_log_string);
893
894 l_log_string := ' gURUSrcContractIdTbl: ' ||
895 ICX_CAT_UTIL_PVT.getTableElement(gURUSrcContractIdTbl, p_index) || '; ';
896 FND_LOG.string(p_log_level, l_module_name, l_log_string);
897
898 l_log_string := ' gURUOldPoInterfaceLineIdTbl: ' ||
899 ICX_CAT_UTIL_PVT.getTableElement(gURUOldPoInterfaceLineIdTbl, p_index) || '; ';
900 FND_LOG.string(p_log_level, l_module_name, l_log_string);
901
902 l_log_string := ' gURUPoInterfaceHeaderIdTbl: ' ||
903 ICX_CAT_UTIL_PVT.getTableElement(gURUPoInterfaceHeaderIdTbl, p_index) || '; ';
904 FND_LOG.string(p_log_level, l_module_name, l_log_string);
905
906 l_log_string := ' gURUPoInterfaceLineIdTbl: ' ||
907 ICX_CAT_UTIL_PVT.getTableElement(gURUPoInterfaceLineIdTbl, p_index) || '; ';
908 FND_LOG.string(p_log_level, l_module_name, l_log_string);
909
910 l_log_string := ' gURUPoHeaderIdTbl: ' ||
911 ICX_CAT_UTIL_PVT.getTableElement(gURUPoHeaderIdTbl, p_index) || '; ';
912 FND_LOG.string(p_log_level, l_module_name, l_log_string);
913
914 l_log_string := ' gURUPoLineIdTbl: ' ||
915 ICX_CAT_UTIL_PVT.getTableElement(gURUPoLineIdTbl, p_index) || '; ';
916 FND_LOG.string(p_log_level, l_module_name, l_log_string);
917
918 l_log_string := ' gURUCreatedLanguageTbl: ' ||
919 ICX_CAT_UTIL_PVT.getTableElement(gURUCreatedLanguageTbl, p_index) || '; ';
920 FND_LOG.string(p_log_level, l_module_name, l_log_string);
921
922 END IF;
923
924 l_err_loc := 1600;
925
926 IF (p_action_mode = 'DELETE_R12_UPGRADE') THEN
927 l_err_loc := 1700;
928 -- DELETE icx_cat_r12_upgrade
929 l_log_string := ' gDRURtItemIdTbl: ' ||
930 ICX_CAT_UTIL_PVT.getTableElement(gDRURtItemIdTbl, p_index) || '; ';
931 FND_LOG.string(p_log_level, l_module_name, l_log_string);
932
933 l_log_string := ' gDRUPoInterfaceHeaderIdTbl: ' ||
934 ICX_CAT_UTIL_PVT.getTableElement(gDRUPoInterfaceHeaderIdTbl, p_index) || '; ';
935 FND_LOG.string(p_log_level, l_module_name, l_log_string);
936
937 l_log_string := ' gDRUPoInterfaceLineIdTbl: ' ||
938 ICX_CAT_UTIL_PVT.getTableElement(gDRUPoInterfaceLineIdTbl, p_index) || '; ';
939 FND_LOG.string(p_log_level, l_module_name, l_log_string);
940
941 END IF;
942
943 l_err_loc := 1800;
944
945 IF (p_action_mode = 'INSERT_FAV_LINES_CATALOG') THEN
946 l_err_loc := 1900;
947 --INSERT icx_cat_fav_list_lines_tlp for catalog items
948 l_log_string := ' gIFLCFavoriteListIdTbl: ' ||
949 ICX_CAT_UTIL_PVT.getTableElement(gIFLCFavoriteListIdTbl, p_index) || '; ';
950 FND_LOG.string(p_log_level, l_module_name, l_log_string);
951
952 l_log_string := ' gIFLCNewFavoriteListLineIdTbl: ' ||
953 ICX_CAT_UTIL_PVT.getTableElement(gIFLCNewFavoriteListLineIdTbl, p_index) || '; ';
954 FND_LOG.string(p_log_level, l_module_name, l_log_string);
955
956 l_log_string := ' gIFLCOldFavoriteListLineIdTbl: ' ||
957 ICX_CAT_UTIL_PVT.getTableElement(gIFLCOldFavoriteListLineIdTbl, p_index) || '; ';
958 FND_LOG.string(p_log_level, l_module_name, l_log_string);
959
960 l_log_string := ' gIFLCRtItemIdTbl: ' ||
961 ICX_CAT_UTIL_PVT.getTableElement(gIFLCRtItemIdTbl, p_index) || '; ';
962 FND_LOG.string(p_log_level, l_module_name, l_log_string);
963
964 l_log_string := ' gIFLCSourceTypeTbl: ' ||
965 ICX_CAT_UTIL_PVT.getTableElement(gIFLCSourceTypeTbl, p_index) || '; ';
966 FND_LOG.string(p_log_level, l_module_name, l_log_string);
967
968 l_log_string := ' gIFLCOrgIdTbl: ' ||
969 ICX_CAT_UTIL_PVT.getTableElement(gIFLCOrgIdTbl, p_index) || '; ';
970 FND_LOG.string(p_log_level, l_module_name, l_log_string);
971
972 l_log_string := ' gIFLCLanguageTbl: ' ||
973 ICX_CAT_UTIL_PVT.getTableElement(gIFLCLanguageTbl, p_index) || '; ';
974 FND_LOG.string(p_log_level, l_module_name, l_log_string);
975
976 END IF;
977
978 l_err_loc := 2000;
979
980 IF (p_action_mode = 'INSERT_FAV_LINES_OTHER') THEN
981 l_err_loc := 2100;
982 --INSERT icx_cat_fav_list_lines_tlp for other items
983 l_log_string := ' gIFLOFavoriteListIdTbl: ' ||
984 ICX_CAT_UTIL_PVT.getTableElement(gIFLOFavoriteListIdTbl, p_index) || '; ';
985 FND_LOG.string(p_log_level, l_module_name, l_log_string);
986
987 l_log_string := ' gIFLONewFavoriteListLineIdTbl: ' ||
988 ICX_CAT_UTIL_PVT.getTableElement(gIFLONewFavoriteListLineIdTbl, p_index) || '; ';
989 FND_LOG.string(p_log_level, l_module_name, l_log_string);
990
991 l_log_string := ' gIFLOOldFavoriteListLineIdTbl: ' ||
992 ICX_CAT_UTIL_PVT.getTableElement(gIFLOOldFavoriteListLineIdTbl, p_index) || '; ';
993 FND_LOG.string(p_log_level, l_module_name, l_log_string);
994
995 l_log_string := ' gIFLOOrgIdTbl: ' ||
996 ICX_CAT_UTIL_PVT.getTableElement(gIFLOOrgIdTbl, p_index) || '; ';
997 FND_LOG.string(p_log_level, l_module_name, l_log_string);
998
999 l_log_string := ' gIFLOLanguageTbl: ' ||
1000 ICX_CAT_UTIL_PVT.getTableElement(gIFLOLanguageTbl, p_index) || '; ';
1001 FND_LOG.string(p_log_level, l_module_name, l_log_string);
1002
1003 END IF;
1004
1005 l_err_loc := 2200;
1006
1007 END IF;
1008
1009 l_err_loc := 2400;
1010 END logPLSQLTableRow;
1011
1012 FUNCTION getNextInterfaceHdrIdFromSeq
1013 RETURN NUMBER
1014 IS
1015
1016 l_interface_header_id NUMBER;
1017 l_api_name CONSTANT VARCHAR2(30) := 'getNextInterfaceHdrIdFromSeq';
1018 l_err_loc PLS_INTEGER;
1019 BEGIN
1020 l_err_loc := 100;
1021 SELECT po_headers_interface_s.NEXTVAL
1022 INTO l_interface_header_id
1023 FROM DUAL;
1024
1025 l_err_loc := 110;
1026 RETURN l_interface_header_id;
1027 EXCEPTION
1028 WHEN OTHERS THEN
1029 ICX_CAT_UTIL_PVT.logUnexpectedException(
1030 G_PKG_NAME, l_api_name,
1031 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1032 RAISE;
1033 END getNextInterfaceHdrIdFromSeq;
1034
1035 FUNCTION getNextInterfaceLineIdFromSeq
1036 RETURN NUMBER
1037 IS
1038
1039 l_interface_line_id NUMBER;
1040 l_api_name CONSTANT VARCHAR2(30) := 'getNextInterfaceLineIdFromSeq';
1041 l_err_loc PLS_INTEGER;
1042 BEGIN
1043 l_err_loc := 100;
1044 SELECT po_lines_interface_s.NEXTVAL
1045 INTO l_interface_line_id
1046 FROM DUAL;
1047
1048 l_err_loc := 110;
1049 RETURN l_interface_line_id;
1050 EXCEPTION
1051 WHEN OTHERS THEN
1052 ICX_CAT_UTIL_PVT.logUnexpectedException(
1053 G_PKG_NAME, l_api_name,
1054 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1055 RAISE;
1056 END getNextInterfaceLineIdFromSeq;
1057
1058 FUNCTION getNextFavListLineIdFromSeq
1059 RETURN NUMBER
1060 IS
1061
1062 l_favorite_list_line_id NUMBER;
1063 l_api_name CONSTANT VARCHAR2(30) := 'getNextFavListLineIdFromSeq';
1064 l_err_loc PLS_INTEGER;
1065 BEGIN
1066 l_err_loc := 100;
1067 SELECT por_favorite_list_lines_s.NEXTVAL
1068 INTO l_favorite_list_line_id
1069 FROM DUAL;
1070
1071 l_err_loc := 110;
1072 RETURN l_favorite_list_line_id;
1073 EXCEPTION
1074 WHEN OTHERS THEN
1075 ICX_CAT_UTIL_PVT.logUnexpectedException(
1076 G_PKG_NAME, l_api_name,
1077 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1078 RAISE;
1079 END getNextFavListLineIdFromSeq;
1080
1081 FUNCTION getPOAttrValuesTLPAction
1082 ( p_po_line_id IN NUMBER ,
1083 p_req_template_name IN VARCHAR2 ,
1084 p_req_template_line_num IN NUMBER ,
1085 p_org_id IN NUMBER ,
1086 p_language IN VARCHAR2
1087 )
1088 RETURN VARCHAR2
1089 IS
1090
1091 l_action po_attr_values_tlp_interface.action%TYPE;
1092 l_api_name CONSTANT VARCHAR2(30) := 'getPOAttrValuesTLPAction';
1093 l_err_loc PLS_INTEGER;
1094 BEGIN
1095 l_err_loc := 100;
1096 SELECT 'UPDATE'
1097 INTO l_action
1098 FROM po_attribute_values_tlp
1099 WHERE po_line_id = p_po_line_id
1100 AND req_template_name = p_req_template_name
1101 AND req_template_line_num = p_req_template_line_num
1102 AND org_id = p_org_id
1103 AND language = p_language;
1104
1105 l_err_loc := 110;
1106 RETURN l_action;
1107
1108 EXCEPTION
1109 WHEN OTHERS THEN
1110 RETURN 'ADD';
1111 END getPOAttrValuesTLPAction;
1112
1113 PROCEDURE insertPOHeadersInterface
1114 IS
1115 l_api_name CONSTANT VARCHAR2(30) := 'insertPOHeadersInterface';
1116 l_err_loc PLS_INTEGER;
1117 l_index PLS_INTEGER;
1118 BEGIN
1119 l_err_loc := 100;
1120 g_total_row_count := g_total_row_count + 1;
1121 l_index := gIHInterfaceHeaderIdTbl.COUNT + 1;
1122
1123 l_err_loc := 110;
1124 gIHInterfaceHeaderIdTbl(l_index) := g_po_hdrs_int_rec.interface_header_id;
1125 gIHActionTbl(l_index) := g_po_hdrs_int_rec.action;
1126 gIHOrgIdTbl(l_index) := g_po_hdrs_int_rec.org_id;
1127 gIHDocumentTypeCodeTbl(l_index) := g_po_hdrs_int_rec.document_type_code;
1128 -- Only used when processing req templates during data migration
1129 l_err_loc := 120;
1130 gIHBudgetAccountSegment1Tbl(l_index) := g_po_hdrs_int_rec.budget_account_segment1;
1131 gIHPoHeaderIdTbl(l_index) := g_po_hdrs_int_rec.po_header_id;
1132 gIHApprovalStatusTbl(l_index) := g_po_hdrs_int_rec.approval_status;
1133 gIHVendorIdTbl(l_index) := g_po_hdrs_int_rec.vendor_id;
1134 gIHVendorSiteIdTbl(l_index) := g_po_hdrs_int_rec.vendor_site_id;
1135 l_err_loc := 140;
1136 gIHCurrencyCodeTbl(l_index) := g_po_hdrs_int_rec.currency_code;
1137 l_err_loc := 160;
1138 gIHCpaReferenceTbl(l_index) := g_po_hdrs_int_rec.cpa_reference;
1139 gIHCreatedLanguageTbl(l_index) := g_po_hdrs_int_rec.created_language;
1140 l_err_loc := 180;
1141 gIHCommentsTbl(l_index) := g_po_hdrs_int_rec.comments;
1142
1143 l_err_loc := 200;
1144 EXCEPTION
1145 WHEN OTHERS THEN
1146 ICX_CAT_UTIL_PVT.logUnexpectedException(
1147 G_PKG_NAME, l_api_name,
1148 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1149 RAISE;
1150 END insertPOHeadersInterface;
1151
1152 PROCEDURE insertPOLinesInterface
1153 IS
1154 l_api_name CONSTANT VARCHAR2(30) := 'insertPOLinesInterface';
1155 l_err_loc PLS_INTEGER;
1156 l_index PLS_INTEGER;
1157 BEGIN
1158 l_err_loc := 100;
1159 g_total_row_count := g_total_row_count + 1;
1160 l_index := gILInterfaceHeaderIdTbl.COUNT + 1;
1161
1162 l_err_loc := 110;
1163 gILInterfaceHeaderIdTbl(l_index) := g_po_line_attrval_int_rec.interface_header_id;
1164 gILInterfaceLineIdTbl(l_index) := g_po_line_attrval_int_rec.interface_line_id;
1165 gILActionTbl(l_index) := g_po_line_attrval_int_rec.action;
1166 gILPoLineIdTbl(l_index) := g_po_line_attrval_int_rec.po_line_id;
1167 gILPoHeaderIdTbl(l_index) := g_po_line_attrval_int_rec.po_header_id;
1168 gILUnitPriceTbl(l_index) := g_po_line_attrval_int_rec.unit_price;
1169 l_err_loc := 120;
1170 gILUomCodeTbl(l_index) := g_po_line_attrval_int_rec.uom_code;
1171 gILNegByPrepFlagTbl(l_index) := g_po_line_attrval_int_rec.negotiated_by_preparer_flag;
1172 gILIpCategoryIdTbl(l_index) := g_po_line_attrval_int_rec.ip_category_id;
1173 gILCategoryIdTbl(l_index) := g_po_line_attrval_int_rec.category_id;
1174 l_err_loc := 140;
1175 gILCategoryNameTbl(l_index) := g_po_line_attrval_int_rec.category_name;
1176 l_err_loc := 160;
1177 gILVendorProductNumTbl(l_index) := g_po_line_attrval_int_rec.vendor_product_num;
1178 gILSupplierPartAuxidTbl(l_index) := g_po_line_attrval_int_rec.supplier_part_auxid;
1179 l_err_loc := 180;
1180 gILItemDescripionTbl(l_index) := g_po_line_attrval_int_rec.item_description;
1181 gILCatalogNameTbl(l_index) := g_po_line_attrval_int_rec.catalog_name;
1182
1183 l_err_loc := 200;
1184 EXCEPTION
1185 WHEN OTHERS THEN
1186 ICX_CAT_UTIL_PVT.logUnexpectedException(
1187 G_PKG_NAME, l_api_name,
1188 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1189 RAISE;
1190 END insertPOLinesInterface;
1191
1192 PROCEDURE insertPOAttrValsInterface
1193 IS
1194 l_api_name CONSTANT VARCHAR2(30) := 'insertPOAttrValsInterface';
1195 l_err_loc PLS_INTEGER;
1196 l_index PLS_INTEGER;
1197 BEGIN
1198 l_err_loc := 100;
1199 g_total_row_count := g_total_row_count + 1;
1200 l_index := gIAVInterfaceHeaderIdTbl.COUNT + 1;
1201
1202 l_err_loc := 110;
1203 gIAVInterfaceHeaderIdTbl(l_index) := g_po_line_attrval_int_rec.interface_header_id;
1204 gIAVInterfaceLineIdTbl(l_index) := g_po_line_attrval_int_rec.interface_line_id;
1205 gIAVActionTbl(l_index) := g_po_line_attrval_int_rec.action;
1206 gIAVPoLineIdTbl(l_index) := g_po_line_attrval_int_rec.po_line_id;
1207 gIAVReqTemplateNameTbl(l_index) := g_po_line_attrval_int_rec.req_template_name;
1208 gIAVReqTemplateLineNumTbl(l_index) := g_po_line_attrval_int_rec.req_template_line_num;
1209 gIAVInventoryItemIdTbl(l_index) := g_po_line_attrval_int_rec.inventory_item_id;
1210 gIAVOrgIdTbl(l_index) := g_po_line_attrval_int_rec.org_id;
1211 gIAVRtItemIdTbl(l_index) := g_po_line_attrval_int_rec.rt_item_id;
1212 gIAVLanguageTbl(l_index) := g_po_line_attrval_int_rec.language;
1213 l_err_loc := 120;
1214 EXCEPTION
1215 WHEN OTHERS THEN
1216 ICX_CAT_UTIL_PVT.logUnexpectedException(
1217 G_PKG_NAME, l_api_name,
1218 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1219 RAISE;
1220 END insertPOAttrValsInterface;
1221
1222 PROCEDURE insertPOAttrValsTLPInterface
1223 IS
1224 l_api_name CONSTANT VARCHAR2(30) := 'insertPOAttrValsTLPInterface';
1225 l_err_loc PLS_INTEGER;
1226 l_index PLS_INTEGER;
1227 BEGIN
1228 l_err_loc := 100;
1229 g_total_row_count := g_total_row_count + 1;
1230 l_index := gIAVTInterfaceHeaderIdTbl.COUNT + 1;
1231
1232 l_err_loc := 110;
1233 gIAVTInterfaceHeaderIdTbl(l_index) := g_po_attrvalstlp_int_rec.interface_header_id;
1234 gIAVTInterfaceLineIdTbl(l_index) := g_po_attrvalstlp_int_rec.interface_line_id;
1235 gIAVTActionTbl(l_index) := g_po_attrvalstlp_int_rec.action;
1236 gIAVTPoLineIdTbl(l_index) := g_po_attrvalstlp_int_rec.po_line_id;
1237 gIAVTReqTemplateNameTbl(l_index) := g_po_attrvalstlp_int_rec.req_template_name;
1238 gIAVTReqTemplateLineNumTbl(l_index) := g_po_attrvalstlp_int_rec.req_template_line_num;
1239 gIAVTInventoryItemIdTbl(l_index) := g_po_attrvalstlp_int_rec.inventory_item_id;
1240 gIAVTOrgIdTbl(l_index) := g_po_attrvalstlp_int_rec.org_id;
1241 gIAVTRtItemIdTbl(l_index) := g_po_attrvalstlp_int_rec.rt_item_id;
1242 gIAVTLanguageTbl(l_index) := g_po_attrvalstlp_int_rec.language;
1243 gIAVTCheckDescUpdateTbl(l_index) := g_po_attrvalstlp_int_rec.check_desc_update;
1244 l_err_loc := 120;
1245 EXCEPTION
1246 WHEN OTHERS THEN
1247 ICX_CAT_UTIL_PVT.logUnexpectedException(
1248 G_PKG_NAME, l_api_name,
1249 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1250 RAISE;
1251 END insertPOAttrValsTLPInterface;
1252
1253 PROCEDURE insertR12Upgrade
1254 IS
1255 l_api_name CONSTANT VARCHAR2(30) := 'insertR12Upgrade';
1256 l_err_loc PLS_INTEGER;
1257 l_index PLS_INTEGER;
1258 BEGIN
1259 l_err_loc := 100;
1260 g_total_row_count := g_total_row_count + 1;
1261 l_index := gIRURtItemIdTbl.COUNT + 1;
1262
1263 l_err_loc := 110;
1264 gIRURtItemIdTbl(l_index) := g_r12_upg_rec.rt_item_id;
1265 gIRUSupplierSiteIdTbl(l_index) := g_r12_upg_rec.supplier_site_id;
1266 gIRUCurrencyTbl(l_index) := g_r12_upg_rec.currency;
1267 l_err_loc := 120;
1268 gIRUCpaReferenceTbl(l_index) := g_r12_upg_rec.cpa_reference;
1269 gIRUPriceContractIdTbl(l_index) := g_r12_upg_rec.price_contract_id;
1270 l_err_loc := 140;
1271 gIRUSrcContractIdTbl(l_index) := g_r12_upg_rec.src_contract_id;
1272 gIRUPoCategoryIdTbl(l_index) := g_r12_upg_rec.po_category_id;
1273 l_err_loc := 160;
1274 gIRUPoInterfaceHeaderIdTbl(l_index) := g_r12_upg_rec.po_interface_header_id;
1275 gIRUPoInterfaceLineIdTbl(l_index) := g_r12_upg_rec.po_interface_line_id;
1276 gIRUCreatedLanguageTbl(l_index) := g_r12_upg_rec.created_language;
1277 -- TBD gIRUExtractorUpdatedFlagTbl(l_index) := g_r12_upg_rec.extractor_updated_flag;
1278 l_err_loc := 200;
1279 EXCEPTION
1280 WHEN OTHERS THEN
1281 ICX_CAT_UTIL_PVT.logUnexpectedException(
1282 G_PKG_NAME, l_api_name,
1283 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1284 RAISE;
1285 END insertR12Upgrade;
1286
1287 -- TBD
1288 -- Also needs to take care of po_category_id changes during delta processing
1289 -- po_category_id could have changed since pre-upgrade was run last time.
1290 -- due to category changes or mapping changes (TBD).
1291 PROCEDURE updateR12Upgrade
1292 IS
1293 l_api_name CONSTANT VARCHAR2(30) := 'updateR12Upgrade';
1294 l_err_loc PLS_INTEGER;
1295 l_index PLS_INTEGER;
1296 BEGIN
1297 l_err_loc := 100;
1298 g_total_row_count := g_total_row_count + 1;
1299 l_index := gURURtItemIdTbl.COUNT + 1;
1300
1301 l_err_loc := 110;
1302 gURURtItemIdTbl(l_index) := g_r12_upg_rec.rt_item_id;
1303 gURUPoCategoryIdTbl(l_index) := g_r12_upg_rec.po_category_id;
1304 gURUCpaReferenceTbl(l_index) := g_r12_upg_rec.cpa_reference;
1305 gURUPriceContractIdTbl(l_index) := g_r12_upg_rec.price_contract_id;
1306 gURUSrcContractIdTbl(l_index) := g_r12_upg_rec.src_contract_id;
1307 gURUOldPoInterfaceLineIdTbl(l_index) := g_r12_upg_rec.old_po_interface_line_id;
1308 gURUPoInterfaceHeaderIdTbl(l_index) := g_r12_upg_rec.po_interface_header_id;
1309 gURUPoInterfaceLineIdTbl(l_index) := g_r12_upg_rec.po_interface_line_id;
1310 gURUPoHeaderIdTbl(l_index) := g_r12_upg_rec.po_header_id;
1311 gURUPoLineIdTbl(l_index) := g_r12_upg_rec.po_line_id;
1312 gURUCreatedLanguageTbl(l_index) := g_r12_upg_rec.created_language;
1313 l_err_loc := 120;
1314 EXCEPTION
1315 WHEN OTHERS THEN
1316 ICX_CAT_UTIL_PVT.logUnexpectedException(
1317 G_PKG_NAME, l_api_name,
1318 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1319 RAISE;
1320 END updateR12Upgrade;
1321
1322 PROCEDURE deleteR12Upgrade
1323 IS
1324 l_api_name CONSTANT VARCHAR2(30) := 'deleteR12Upgrade';
1325 l_err_loc PLS_INTEGER;
1326 l_index PLS_INTEGER;
1327 BEGIN
1328 l_err_loc := 100;
1329 g_total_row_count := g_total_row_count + 1;
1330 l_index := gDRURtItemIdTbl.COUNT + 1;
1331
1332 l_err_loc := 110;
1333 gDRURtItemIdTbl(l_index) := g_r12_upg_rec.rt_item_id;
1334 gDRUPoInterfaceHeaderIdTbl(l_index) := g_r12_upg_rec.po_interface_header_id;
1335 gDRUPoInterfaceLineIdTbl(l_index) := g_r12_upg_rec.po_interface_line_id;
1336 l_err_loc := 120;
1337 EXCEPTION
1338 WHEN OTHERS THEN
1339 ICX_CAT_UTIL_PVT.logUnexpectedException(
1340 G_PKG_NAME, l_api_name,
1341 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1342 RAISE;
1343 END deleteR12Upgrade;
1344
1345 PROCEDURE createGBPAHeader
1346 IS
1347 l_api_name CONSTANT VARCHAR2(30) := 'createGBPAHeader';
1348 l_err_loc PLS_INTEGER;
1349 BEGIN
1350 l_err_loc := 100;
1351 EXCEPTION
1352 WHEN OTHERS THEN
1353 ICX_CAT_UTIL_PVT.logUnexpectedException(
1354 G_PKG_NAME, l_api_name,
1355 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
1356 RAISE;
1357 END createGBPAHeader;
1358
1359 PROCEDURE populatePOInterfaceTables
1360 ( p_mode IN VARCHAR2
1361 )
1362 IS
1363 l_api_name CONSTANT VARCHAR2(30) := 'populatePOInterfaceTables';
1364 l_err_loc PLS_INTEGER;
1365 l_action_mode VARCHAR2(80);
1366 BEGIN
1367 l_err_loc := 100;
1368
1369 l_err_loc := 110;
1370 IF (p_mode = 'OUTLOOP' OR g_total_row_count >= ICX_CAT_UTIL_PVT.g_batch_size) THEN
1371 l_err_loc := 120;
1372 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1373 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1374 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1375 'Enter populatePOInterfaceTables(' || p_mode || ')g_total_row_count : ' ||
1376 g_total_row_count);
1377 END IF;
1378
1379 g_total_row_count := 0;
1380
1381 l_err_loc := 130;
1382 l_action_mode := 'INSERT_INT_HDRS';
1383 -- Note: Copy of CPA attributes to GBPA will be done by PO.
1384 FORALL i in 1..gIHInterfaceHeaderIdTbl.COUNT
1385 INSERT INTO po_headers_interface
1386 (interface_header_id, batch_id, interface_source_code, process_code,
1387 action, org_id, document_type_code, budget_account_segment1, po_header_id,
1388 approval_status, vendor_id, vendor_site_id, currency_code,
1389 cpa_reference, created_language, comments, vendor_name, vendor_site_code)
1390 SELECT gIHInterfaceHeaderIdTbl(i), g_PDOI_batch_id, g_interface_source_code, g_process_code,
1391 gIHActionTbl(i), gIHOrgIdTbl(i), gIHDocumentTypeCodeTbl(i), gIHBudgetAccountSegment1Tbl(i), gIHPoHeaderIdTbl(i),
1392 gIHApprovalStatusTbl(i), doc.vendor_id, doc.vendor_site_id, gIHCurrencyCodeTbl(i),
1393 gIHCpaReferenceTbl(i), gIHCreatedLanguageTbl(i), gIHCommentsTbl(i),
1394 supp.vendor_name, site.vendor_site_code
1395 FROM (
1396 SELECT gIHVendorIdTbl(i) vendor_id, gIHVendorSiteIdTbl(i) vendor_site_id
1397 FROM DUAL
1398 ) doc,
1399 po_vendors supp, po_vendor_sites_all site
1400 WHERE supp.vendor_id (+) = doc.vendor_id
1401 AND site.vendor_site_id (+) = doc.vendor_site_id;
1402
1403 l_err_loc := 140;
1404 IF (gIHInterfaceHeaderIdTbl.COUNT > 0) THEN
1405 l_err_loc := 150;
1406 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1407 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1408 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1409 'No: of rows inserted into po_headers_interface:' ||SQL%ROWCOUNT);
1410 END IF;
1411 END IF;
1412
1413 l_err_loc := 160;
1414 clearTables(l_action_mode);
1415
1416 l_err_loc := 170;
1417 l_action_mode := 'INSERT_INT_LINES';
1418 FORALL i in 1..gILInterfaceHeaderIdTbl.COUNT
1419 INSERT INTO po_lines_interface
1420 (interface_line_id, interface_header_id, process_code, action,
1421 po_line_id, po_header_id, unit_price,
1422 uom_code, negotiated_by_preparer_flag, ip_category_id, category_id, category,
1423 vendor_product_num, supplier_part_auxid, item_description, catalog_name)
1424 VALUES(gILInterfaceLineIdTbl(i), gILInterfaceHeaderIdTbl(i), g_process_code, gILActionTbl(i),
1425 gILPoLineIdTbl(i), gILPoHeaderIdTbl(i), gILUnitPriceTbl(i),
1426 gILUomCodeTbl(i), gILNegByPrepFlagTbl(i), gILIpCategoryIdTbl(i), gILCategoryIdTbl(i), gILCategoryNameTbl(i),
1427 gILVendorProductNumTbl(i), gILSupplierPartAuxidTbl(i), gILItemDescripionTbl(i), gILCatalogNameTbl(i));
1428
1429 l_err_loc := 180;
1430 IF (gILInterfaceHeaderIdTbl.COUNT > 0) THEN
1431 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1432 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1433 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1434 'No: of rows inserted into po_lines_interface:' ||SQL%ROWCOUNT);
1435 END IF;
1436 END IF;
1437
1438 l_err_loc := 190;
1439 clearTables(l_action_mode);
1440
1441 l_err_loc := 200;
1442 l_action_mode := 'INSERT_INT_ATTR_VALS';
1443 FORALL i in 1..gIAVInterfaceHeaderIdTbl.COUNT
1444 INSERT INTO po_attr_values_interface
1445 (interface_attr_values_id, interface_header_id,
1446 interface_line_id, process_code, action,
1447 po_line_id, req_template_name, req_template_line_num,
1448 inventory_item_id, org_id,
1449 ip_category_id, manufacturer_part_num, thumbnail_image,
1450 supplier_url,manufacturer_url, attachment_url,
1451 unspsc, availability, lead_time, picture,
1452 text_base_attribute1, text_base_attribute2, text_base_attribute3,
1453 text_base_attribute4, text_base_attribute5, text_base_attribute6,
1454 text_base_attribute7, text_base_attribute8, text_base_attribute9,
1455 text_base_attribute10, text_base_attribute11, text_base_attribute12,
1456 text_base_attribute13, text_base_attribute14, text_base_attribute15,
1457 text_base_attribute16, text_base_attribute17, text_base_attribute18,
1458 text_base_attribute19, text_base_attribute20, text_base_attribute21,
1459 text_base_attribute22, text_base_attribute23, text_base_attribute24,
1460 text_base_attribute25, text_base_attribute26, text_base_attribute27,
1461 text_base_attribute28, text_base_attribute29, text_base_attribute30,
1462 text_base_attribute31, text_base_attribute32, text_base_attribute33,
1463 text_base_attribute34, text_base_attribute35, text_base_attribute36,
1464 text_base_attribute37, text_base_attribute38, text_base_attribute39,
1465 text_base_attribute40, text_base_attribute41, text_base_attribute42,
1466 text_base_attribute43, text_base_attribute44, text_base_attribute45,
1467 text_base_attribute46, text_base_attribute47, text_base_attribute48,
1468 text_base_attribute49, text_base_attribute50, text_base_attribute51,
1469 text_base_attribute52, text_base_attribute53, text_base_attribute54,
1470 text_base_attribute55, text_base_attribute56, text_base_attribute57,
1471 text_base_attribute58, text_base_attribute59, text_base_attribute60,
1472 text_base_attribute61, text_base_attribute62, text_base_attribute63,
1473 text_base_attribute64, text_base_attribute65, text_base_attribute66,
1474 text_base_attribute67, text_base_attribute68, text_base_attribute69,
1475 text_base_attribute70, text_base_attribute71, text_base_attribute72,
1476 text_base_attribute73, text_base_attribute74, text_base_attribute75,
1477 text_base_attribute76, text_base_attribute77, text_base_attribute78,
1478 text_base_attribute79, text_base_attribute80, text_base_attribute81,
1479 text_base_attribute82, text_base_attribute83, text_base_attribute84,
1480 text_base_attribute85, text_base_attribute86, text_base_attribute87,
1481 text_base_attribute88, text_base_attribute89, text_base_attribute90,
1482 text_base_attribute91, text_base_attribute92, text_base_attribute93,
1483 text_base_attribute94, text_base_attribute95, text_base_attribute96,
1484 text_base_attribute97, text_base_attribute98, text_base_attribute99,
1485 text_base_attribute100, num_base_attribute1, num_base_attribute2,
1486 num_base_attribute3, num_base_attribute4, num_base_attribute5,
1487 num_base_attribute6, num_base_attribute7, num_base_attribute8,
1488 num_base_attribute9, num_base_attribute10, num_base_attribute11,
1489 num_base_attribute12, num_base_attribute13, num_base_attribute14,
1490 num_base_attribute15, num_base_attribute16, num_base_attribute17,
1491 num_base_attribute18, num_base_attribute19, num_base_attribute20,
1492 num_base_attribute21, num_base_attribute22, num_base_attribute23,
1493 num_base_attribute24, num_base_attribute25, num_base_attribute26,
1494 num_base_attribute27, num_base_attribute28, num_base_attribute29,
1495 num_base_attribute30, num_base_attribute31, num_base_attribute32,
1496 num_base_attribute33, num_base_attribute34, num_base_attribute35,
1497 num_base_attribute36, num_base_attribute37, num_base_attribute38,
1498 num_base_attribute39, num_base_attribute40, num_base_attribute41,
1499 num_base_attribute42, num_base_attribute43, num_base_attribute44,
1500 num_base_attribute45, num_base_attribute46, num_base_attribute47,
1501 num_base_attribute48, num_base_attribute49, num_base_attribute50,
1502 num_base_attribute51, num_base_attribute52, num_base_attribute53,
1503 num_base_attribute54, num_base_attribute55, num_base_attribute56,
1504 num_base_attribute57, num_base_attribute58, num_base_attribute59,
1505 num_base_attribute60, num_base_attribute61, num_base_attribute62,
1506 num_base_attribute63, num_base_attribute64, num_base_attribute65,
1507 num_base_attribute66, num_base_attribute67, num_base_attribute68,
1508 num_base_attribute69, num_base_attribute70, num_base_attribute71,
1509 num_base_attribute72, num_base_attribute73, num_base_attribute74,
1510 num_base_attribute75, num_base_attribute76, num_base_attribute77,
1511 num_base_attribute78, num_base_attribute79, num_base_attribute80,
1512 num_base_attribute81, num_base_attribute82, num_base_attribute83,
1513 num_base_attribute84, num_base_attribute85, num_base_attribute86,
1514 num_base_attribute87, num_base_attribute88, num_base_attribute89,
1515 num_base_attribute90, num_base_attribute91, num_base_attribute92,
1516 num_base_attribute93, num_base_attribute94, num_base_attribute95,
1517 num_base_attribute96, num_base_attribute97, num_base_attribute98,
1518 num_base_attribute99, num_base_attribute100, text_cat_attribute1,
1519 text_cat_attribute2, text_cat_attribute3, text_cat_attribute4,
1520 text_cat_attribute5, text_cat_attribute6, text_cat_attribute7,
1521 text_cat_attribute8, text_cat_attribute9, text_cat_attribute10,
1522 text_cat_attribute11, text_cat_attribute12, text_cat_attribute13,
1523 text_cat_attribute14, text_cat_attribute15, text_cat_attribute16,
1524 text_cat_attribute17, text_cat_attribute18, text_cat_attribute19,
1525 text_cat_attribute20, text_cat_attribute21, text_cat_attribute22,
1526 text_cat_attribute23, text_cat_attribute24, text_cat_attribute25,
1527 text_cat_attribute26, text_cat_attribute27, text_cat_attribute28,
1528 text_cat_attribute29, text_cat_attribute30, text_cat_attribute31,
1529 text_cat_attribute32, text_cat_attribute33, text_cat_attribute34,
1530 text_cat_attribute35, text_cat_attribute36, text_cat_attribute37,
1531 text_cat_attribute38, text_cat_attribute39, text_cat_attribute40,
1532 text_cat_attribute41, text_cat_attribute42, text_cat_attribute43,
1533 text_cat_attribute44, text_cat_attribute45, text_cat_attribute46,
1534 text_cat_attribute47, text_cat_attribute48, text_cat_attribute49,
1535 text_cat_attribute50, num_cat_attribute1, num_cat_attribute2,
1536 num_cat_attribute3, num_cat_attribute4, num_cat_attribute5,
1537 num_cat_attribute6, num_cat_attribute7, num_cat_attribute8,
1538 num_cat_attribute9, num_cat_attribute10, num_cat_attribute11,
1539 num_cat_attribute12, num_cat_attribute13, num_cat_attribute14,
1540 num_cat_attribute15, num_cat_attribute16, num_cat_attribute17,
1541 num_cat_attribute18, num_cat_attribute19, num_cat_attribute20,
1542 num_cat_attribute21, num_cat_attribute22, num_cat_attribute23,
1543 num_cat_attribute24, num_cat_attribute25, num_cat_attribute26,
1544 num_cat_attribute27, num_cat_attribute28, num_cat_attribute29,
1545 num_cat_attribute30, num_cat_attribute31, num_cat_attribute32,
1546 num_cat_attribute33, num_cat_attribute34, num_cat_attribute35,
1547 num_cat_attribute36, num_cat_attribute37, num_cat_attribute38,
1548 num_cat_attribute39, num_cat_attribute40, num_cat_attribute41,
1549 num_cat_attribute42, num_cat_attribute43, num_cat_attribute44,
1550 num_cat_attribute45, num_cat_attribute46, num_cat_attribute47,
1551 num_cat_attribute48, num_cat_attribute49, num_cat_attribute50)
1552 SELECT po_attr_values_interface_s.NEXTVAL, gIAVInterfaceHeaderIdTbl(i),
1553 gIAVInterfaceLineIdTbl(i), g_process_code, gIAVActionTbl(i),
1554 gIAVPoLineIdTbl(i), gIAVReqTemplateNameTbl(i), gIAVReqTemplateLineNumTbl(i),
1555 gIAVInventoryItemIdTbl(i), gIAVOrgIdTbl(i),
1556 baseAtt.primary_category_id, baseAtt.manufacturer_part_num, baseAtt.thumbnail_image,
1557 baseAtt.supplier_url, baseAtt.manufacturer_url, baseAtt.attachment_url,
1558 baseAtt.unspsc_code, baseAtt.availability, baseAtt.lead_time, baseAtt.picture,
1559 baseAtt.text_base_attribute1, baseAtt.text_base_attribute2, baseAtt.text_base_attribute3,
1560 baseAtt.text_base_attribute4, baseAtt.text_base_attribute5, baseAtt.text_base_attribute6,
1561 baseAtt.text_base_attribute7, baseAtt.text_base_attribute8, baseAtt.text_base_attribute9,
1562 baseAtt.text_base_attribute10, baseAtt.text_base_attribute11, baseAtt.text_base_attribute12,
1563 baseAtt.text_base_attribute13, baseAtt.text_base_attribute14, baseAtt.text_base_attribute15,
1564 baseAtt.text_base_attribute16, baseAtt.text_base_attribute17, baseAtt.text_base_attribute18,
1565 baseAtt.text_base_attribute19, baseAtt.text_base_attribute20, baseAtt.text_base_attribute21,
1566 baseAtt.text_base_attribute22, baseAtt.text_base_attribute23, baseAtt.text_base_attribute24,
1567 baseAtt.text_base_attribute25, baseAtt.text_base_attribute26, baseAtt.text_base_attribute27,
1568 baseAtt.text_base_attribute28, baseAtt.text_base_attribute29, baseAtt.text_base_attribute30,
1569 baseAtt.text_base_attribute31, baseAtt.text_base_attribute32, baseAtt.text_base_attribute33,
1570 baseAtt.text_base_attribute34, baseAtt.text_base_attribute35, baseAtt.text_base_attribute36,
1571 baseAtt.text_base_attribute37, baseAtt.text_base_attribute38, baseAtt.text_base_attribute39,
1572 baseAtt.text_base_attribute40, baseAtt.text_base_attribute41, baseAtt.text_base_attribute42,
1573 baseAtt.text_base_attribute43, baseAtt.text_base_attribute44, baseAtt.text_base_attribute45,
1574 baseAtt.text_base_attribute46, baseAtt.text_base_attribute47, baseAtt.text_base_attribute48,
1575 baseAtt.text_base_attribute49, baseAtt.text_base_attribute50, baseAtt.text_base_attribute51,
1576 baseAtt.text_base_attribute52, baseAtt.text_base_attribute53, baseAtt.text_base_attribute54,
1577 baseAtt.text_base_attribute55, baseAtt.text_base_attribute56, baseAtt.text_base_attribute57,
1578 baseAtt.text_base_attribute58, baseAtt.text_base_attribute59, baseAtt.text_base_attribute60,
1579 baseAtt.text_base_attribute61, baseAtt.text_base_attribute62, baseAtt.text_base_attribute63,
1580 baseAtt.text_base_attribute64, baseAtt.text_base_attribute65, baseAtt.text_base_attribute66,
1581 baseAtt.text_base_attribute67, baseAtt.text_base_attribute68, baseAtt.text_base_attribute69,
1582 baseAtt.text_base_attribute70, baseAtt.text_base_attribute71, baseAtt.text_base_attribute72,
1583 baseAtt.text_base_attribute73, baseAtt.text_base_attribute74, baseAtt.text_base_attribute75,
1584 baseAtt.text_base_attribute76, baseAtt.text_base_attribute77, baseAtt.text_base_attribute78,
1585 baseAtt.text_base_attribute79, baseAtt.text_base_attribute80, baseAtt.text_base_attribute81,
1586 baseAtt.text_base_attribute82, baseAtt.text_base_attribute83, baseAtt.text_base_attribute84,
1587 baseAtt.text_base_attribute85, baseAtt.text_base_attribute86, baseAtt.text_base_attribute87,
1588 baseAtt.text_base_attribute88, baseAtt.text_base_attribute89, baseAtt.text_base_attribute90,
1589 baseAtt.text_base_attribute91, baseAtt.text_base_attribute92, baseAtt.text_base_attribute93,
1590 baseAtt.text_base_attribute94, baseAtt.text_base_attribute95, baseAtt.text_base_attribute96,
1591 baseAtt.text_base_attribute97, baseAtt.text_base_attribute98, baseAtt.text_base_attribute99,
1592 baseAtt.text_base_attribute100, baseAtt.num_base_attribute1, baseAtt.num_base_attribute2,
1593 baseAtt.num_base_attribute3, baseAtt.num_base_attribute4, baseAtt.num_base_attribute5,
1594 baseAtt.num_base_attribute6, baseAtt.num_base_attribute7, baseAtt.num_base_attribute8,
1595 baseAtt.num_base_attribute9, baseAtt.num_base_attribute10, baseAtt.num_base_attribute11,
1596 baseAtt.num_base_attribute12, baseAtt.num_base_attribute13, baseAtt.num_base_attribute14,
1597 baseAtt.num_base_attribute15, baseAtt.num_base_attribute16, baseAtt.num_base_attribute17,
1598 baseAtt.num_base_attribute18, baseAtt.num_base_attribute19, baseAtt.num_base_attribute20,
1599 baseAtt.num_base_attribute21, baseAtt.num_base_attribute22, baseAtt.num_base_attribute23,
1600 baseAtt.num_base_attribute24, baseAtt.num_base_attribute25, baseAtt.num_base_attribute26,
1601 baseAtt.num_base_attribute27, baseAtt.num_base_attribute28, baseAtt.num_base_attribute29,
1602 baseAtt.num_base_attribute30, baseAtt.num_base_attribute31, baseAtt.num_base_attribute32,
1603 baseAtt.num_base_attribute33, baseAtt.num_base_attribute34, baseAtt.num_base_attribute35,
1604 baseAtt.num_base_attribute36, baseAtt.num_base_attribute37, baseAtt.num_base_attribute38,
1605 baseAtt.num_base_attribute39, baseAtt.num_base_attribute40, baseAtt.num_base_attribute41,
1606 baseAtt.num_base_attribute42, baseAtt.num_base_attribute43, baseAtt.num_base_attribute44,
1607 baseAtt.num_base_attribute45, baseAtt.num_base_attribute46, baseAtt.num_base_attribute47,
1608 baseAtt.num_base_attribute48, baseAtt.num_base_attribute49, baseAtt.num_base_attribute50,
1609 baseAtt.num_base_attribute51, baseAtt.num_base_attribute52, baseAtt.num_base_attribute53,
1610 baseAtt.num_base_attribute54, baseAtt.num_base_attribute55, baseAtt.num_base_attribute56,
1611 baseAtt.num_base_attribute57, baseAtt.num_base_attribute58, baseAtt.num_base_attribute59,
1612 baseAtt.num_base_attribute60, baseAtt.num_base_attribute61, baseAtt.num_base_attribute62,
1613 baseAtt.num_base_attribute63, baseAtt.num_base_attribute64, baseAtt.num_base_attribute65,
1614 baseAtt.num_base_attribute66, baseAtt.num_base_attribute67, baseAtt.num_base_attribute68,
1615 baseAtt.num_base_attribute69, baseAtt.num_base_attribute70, baseAtt.num_base_attribute71,
1616 baseAtt.num_base_attribute72, baseAtt.num_base_attribute73, baseAtt.num_base_attribute74,
1617 baseAtt.num_base_attribute75, baseAtt.num_base_attribute76, baseAtt.num_base_attribute77,
1618 baseAtt.num_base_attribute78, baseAtt.num_base_attribute79, baseAtt.num_base_attribute80,
1619 baseAtt.num_base_attribute81, baseAtt.num_base_attribute82, baseAtt.num_base_attribute83,
1620 baseAtt.num_base_attribute84, baseAtt.num_base_attribute85, baseAtt.num_base_attribute86,
1621 baseAtt.num_base_attribute87, baseAtt.num_base_attribute88, baseAtt.num_base_attribute89,
1622 baseAtt.num_base_attribute90, baseAtt.num_base_attribute91, baseAtt.num_base_attribute92,
1623 baseAtt.num_base_attribute93, baseAtt.num_base_attribute94, baseAtt.num_base_attribute95,
1624 baseAtt.num_base_attribute96, baseAtt.num_base_attribute97, baseAtt.num_base_attribute98,
1625 baseAtt.num_base_attribute99, baseAtt.num_base_attribute100, catAtt.text_cat_attribute1,
1626 catAtt.text_cat_attribute2, catAtt.text_cat_attribute3, catAtt.text_cat_attribute4,
1627 catAtt.text_cat_attribute5, catAtt.text_cat_attribute6, catAtt.text_cat_attribute7,
1628 catAtt.text_cat_attribute8, catAtt.text_cat_attribute9, catAtt.text_cat_attribute10,
1629 catAtt.text_cat_attribute11, catAtt.text_cat_attribute12, catAtt.text_cat_attribute13,
1630 catAtt.text_cat_attribute14, catAtt.text_cat_attribute15, catAtt.text_cat_attribute16,
1631 catAtt.text_cat_attribute17, catAtt.text_cat_attribute18, catAtt.text_cat_attribute19,
1632 catAtt.text_cat_attribute20, catAtt.text_cat_attribute21, catAtt.text_cat_attribute22,
1633 catAtt.text_cat_attribute23, catAtt.text_cat_attribute24, catAtt.text_cat_attribute25,
1634 catAtt.text_cat_attribute26, catAtt.text_cat_attribute27, catAtt.text_cat_attribute28,
1635 catAtt.text_cat_attribute29, catAtt.text_cat_attribute30, catAtt.text_cat_attribute31,
1636 catAtt.text_cat_attribute32, catAtt.text_cat_attribute33, catAtt.text_cat_attribute34,
1637 catAtt.text_cat_attribute35, catAtt.text_cat_attribute36, catAtt.text_cat_attribute37,
1638 catAtt.text_cat_attribute38, catAtt.text_cat_attribute39, catAtt.text_cat_attribute40,
1639 catAtt.text_cat_attribute41, catAtt.text_cat_attribute42, catAtt.text_cat_attribute43,
1640 catAtt.text_cat_attribute44, catAtt.text_cat_attribute45, catAtt.text_cat_attribute46,
1641 catAtt.text_cat_attribute47, catAtt.text_cat_attribute48, catAtt.text_cat_attribute49,
1642 catAtt.text_cat_attribute50, catAtt.num_cat_attribute1, catAtt.num_cat_attribute2,
1643 catAtt.num_cat_attribute3, catAtt.num_cat_attribute4, catAtt.num_cat_attribute5,
1644 catAtt.num_cat_attribute6, catAtt.num_cat_attribute7, catAtt.num_cat_attribute8,
1645 catAtt.num_cat_attribute9, catAtt.num_cat_attribute10, catAtt.num_cat_attribute11,
1646 catAtt.num_cat_attribute12, catAtt.num_cat_attribute13, catAtt.num_cat_attribute14,
1647 catAtt.num_cat_attribute15, catAtt.num_cat_attribute16, catAtt.num_cat_attribute17,
1648 catAtt.num_cat_attribute18, catAtt.num_cat_attribute19, catAtt.num_cat_attribute20,
1649 catAtt.num_cat_attribute21, catAtt.num_cat_attribute22, catAtt.num_cat_attribute23,
1650 catAtt.num_cat_attribute24, catAtt.num_cat_attribute25, catAtt.num_cat_attribute26,
1651 catAtt.num_cat_attribute27, catAtt.num_cat_attribute28, catAtt.num_cat_attribute29,
1652 catAtt.num_cat_attribute30, catAtt.num_cat_attribute31, catAtt.num_cat_attribute32,
1653 catAtt.num_cat_attribute33, catAtt.num_cat_attribute34, catAtt.num_cat_attribute35,
1654 catAtt.num_cat_attribute36, catAtt.num_cat_attribute37, catAtt.num_cat_attribute38,
1655 catAtt.num_cat_attribute39, catAtt.num_cat_attribute40, catAtt.num_cat_attribute41,
1656 catAtt.num_cat_attribute42, catAtt.num_cat_attribute43, catAtt.num_cat_attribute44,
1657 catAtt.num_cat_attribute45, catAtt.num_cat_attribute46, catAtt.num_cat_attribute47,
1658 catAtt.num_cat_attribute48, catAtt.num_cat_attribute49, catAtt.num_cat_attribute50
1659 FROM icx_cat_items_tlp baseAtt, icx_cat_ext_items_tlp catAtt
1660 WHERE baseAtt.rt_item_id = catAtt.rt_item_id
1661 AND baseAtt.language = catAtt.language
1662 AND baseAtt.rt_item_id = gIAVRtItemIdTbl(i)
1663 AND baseAtt.language = gIAVLanguageTbl(i);
1664
1665 l_err_loc := 210;
1666 IF (gIAVInterfaceHeaderIdTbl.COUNT > 0) THEN
1667 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1668 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1669 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1670 'No: of rows inserted into po_attr_values_interface:' ||SQL%ROWCOUNT);
1671 END IF;
1672 END IF;
1673
1674 l_err_loc := 220;
1675 clearTables(l_action_mode);
1676
1677 l_err_loc := 230;
1678 l_action_mode := 'INSERT_INT_ATTR_VALS_TLP';
1679 FORALL i in 1..gIAVTInterfaceHeaderIdTbl.COUNT
1680 INSERT INTO po_attr_values_tlp_interface
1681 (interface_attr_values_tlp_id, interface_header_id,
1682 interface_line_id, action, process_code,
1683 po_line_id, req_template_name, req_template_line_num,
1684 inventory_item_id, org_id, language,
1685 ip_category_id, description, manufacturer,
1686 comments, alias, long_description,
1687 tl_text_base_attribute1, tl_text_base_attribute2, tl_text_base_attribute3,
1688 tl_text_base_attribute4, tl_text_base_attribute5, tl_text_base_attribute6,
1689 tl_text_base_attribute7, tl_text_base_attribute8, tl_text_base_attribute9,
1690 tl_text_base_attribute10, tl_text_base_attribute11, tl_text_base_attribute12,
1691 tl_text_base_attribute13, tl_text_base_attribute14, tl_text_base_attribute15,
1692 tl_text_base_attribute16, tl_text_base_attribute17, tl_text_base_attribute18,
1693 tl_text_base_attribute19, tl_text_base_attribute20, tl_text_base_attribute21,
1694 tl_text_base_attribute22, tl_text_base_attribute23, tl_text_base_attribute24,
1695 tl_text_base_attribute25, tl_text_base_attribute26, tl_text_base_attribute27,
1696 tl_text_base_attribute28, tl_text_base_attribute29, tl_text_base_attribute30,
1697 tl_text_base_attribute31, tl_text_base_attribute32, tl_text_base_attribute33,
1698 tl_text_base_attribute34, tl_text_base_attribute35, tl_text_base_attribute36,
1699 tl_text_base_attribute37, tl_text_base_attribute38, tl_text_base_attribute39,
1700 tl_text_base_attribute40, tl_text_base_attribute41, tl_text_base_attribute42,
1701 tl_text_base_attribute43, tl_text_base_attribute44, tl_text_base_attribute45,
1702 tl_text_base_attribute46, tl_text_base_attribute47, tl_text_base_attribute48,
1703 tl_text_base_attribute49, tl_text_base_attribute50, tl_text_base_attribute51,
1704 tl_text_base_attribute52, tl_text_base_attribute53, tl_text_base_attribute54,
1705 tl_text_base_attribute55, tl_text_base_attribute56, tl_text_base_attribute57,
1706 tl_text_base_attribute58, tl_text_base_attribute59, tl_text_base_attribute60,
1707 tl_text_base_attribute61, tl_text_base_attribute62, tl_text_base_attribute63,
1708 tl_text_base_attribute64, tl_text_base_attribute65, tl_text_base_attribute66,
1709 tl_text_base_attribute67, tl_text_base_attribute68, tl_text_base_attribute69,
1710 tl_text_base_attribute70, tl_text_base_attribute71, tl_text_base_attribute72,
1711 tl_text_base_attribute73, tl_text_base_attribute74, tl_text_base_attribute75,
1712 tl_text_base_attribute76, tl_text_base_attribute77, tl_text_base_attribute78,
1713 tl_text_base_attribute79, tl_text_base_attribute80, tl_text_base_attribute81,
1714 tl_text_base_attribute82, tl_text_base_attribute83, tl_text_base_attribute84,
1715 tl_text_base_attribute85, tl_text_base_attribute86, tl_text_base_attribute87,
1716 tl_text_base_attribute88, tl_text_base_attribute89, tl_text_base_attribute90,
1717 tl_text_base_attribute91, tl_text_base_attribute92, tl_text_base_attribute93,
1718 tl_text_base_attribute94, tl_text_base_attribute95, tl_text_base_attribute96,
1719 tl_text_base_attribute97, tl_text_base_attribute98, tl_text_base_attribute99,
1720 tl_text_base_attribute100, tl_text_cat_attribute1, tl_text_cat_attribute2,
1721 tl_text_cat_attribute3, tl_text_cat_attribute4, tl_text_cat_attribute5,
1722 tl_text_cat_attribute6, tl_text_cat_attribute7, tl_text_cat_attribute8,
1723 tl_text_cat_attribute9, tl_text_cat_attribute10, tl_text_cat_attribute11,
1724 tl_text_cat_attribute12, tl_text_cat_attribute13, tl_text_cat_attribute14,
1725 tl_text_cat_attribute15, tl_text_cat_attribute16, tl_text_cat_attribute17,
1726 tl_text_cat_attribute18, tl_text_cat_attribute19, tl_text_cat_attribute20,
1727 tl_text_cat_attribute21, tl_text_cat_attribute22, tl_text_cat_attribute23,
1728 tl_text_cat_attribute24, tl_text_cat_attribute25, tl_text_cat_attribute26,
1729 tl_text_cat_attribute27, tl_text_cat_attribute28, tl_text_cat_attribute29,
1730 tl_text_cat_attribute30, tl_text_cat_attribute31, tl_text_cat_attribute32,
1731 tl_text_cat_attribute33, tl_text_cat_attribute34, tl_text_cat_attribute35,
1732 tl_text_cat_attribute36, tl_text_cat_attribute37, tl_text_cat_attribute38,
1733 tl_text_cat_attribute39, tl_text_cat_attribute40, tl_text_cat_attribute41,
1734 tl_text_cat_attribute42, tl_text_cat_attribute43, tl_text_cat_attribute44,
1735 tl_text_cat_attribute45, tl_text_cat_attribute46, tl_text_cat_attribute47,
1736 tl_text_cat_attribute48, tl_text_cat_attribute49, tl_text_cat_attribute50)
1737 SELECT po_attr_values_tlp_interface_s.NEXTVAL, gIAVTInterfaceHeaderIdTbl(i),
1738 gIAVTInterfaceLineIdTbl(i), gIAVTActionTbl(i), g_process_code,
1739 gIAVTPoLineIdTbl(i), gIAVTReqTemplateNameTbl(i), gIAVTReqTemplateLineNumTbl(i),
1740 gIAVTInventoryItemIdTbl(i), gIAVTOrgIdTbl(i), gIAVTLanguageTbl(i), baseAtt.primary_category_id,
1741 -- DECODE(gIAVTCheckDescUpdateTbl(i), ICX_CAT_UTIL_PVT.g_update_description, SUBSTRB(baseAtt.description, 1, 240), NULL),
1742 SUBSTRB(baseAtt.description, 1, 240),
1743 baseAtt.manufacturer, baseAtt.comments, baseAtt.alias, baseAtt.long_description,
1744 baseAtt.tl_text_base_attribute1, baseAtt.tl_text_base_attribute2, baseAtt.tl_text_base_attribute3,
1745 baseAtt.tl_text_base_attribute4, baseAtt.tl_text_base_attribute5, baseAtt.tl_text_base_attribute6,
1746 baseAtt.tl_text_base_attribute7, baseAtt.tl_text_base_attribute8, baseAtt.tl_text_base_attribute9,
1747 baseAtt.tl_text_base_attribute10, baseAtt.tl_text_base_attribute11, baseAtt.tl_text_base_attribute12,
1748 baseAtt.tl_text_base_attribute13, baseAtt.tl_text_base_attribute14, baseAtt.tl_text_base_attribute15,
1749 baseAtt.tl_text_base_attribute16, baseAtt.tl_text_base_attribute17, baseAtt.tl_text_base_attribute18,
1750 baseAtt.tl_text_base_attribute19, baseAtt.tl_text_base_attribute20, baseAtt.tl_text_base_attribute21,
1751 baseAtt.tl_text_base_attribute22, baseAtt.tl_text_base_attribute23, baseAtt.tl_text_base_attribute24,
1752 baseAtt.tl_text_base_attribute25, baseAtt.tl_text_base_attribute26, baseAtt.tl_text_base_attribute27,
1753 baseAtt.tl_text_base_attribute28, baseAtt.tl_text_base_attribute29, baseAtt.tl_text_base_attribute30,
1754 baseAtt.tl_text_base_attribute31, baseAtt.tl_text_base_attribute32, baseAtt.tl_text_base_attribute33,
1755 baseAtt.tl_text_base_attribute34, baseAtt.tl_text_base_attribute35, baseAtt.tl_text_base_attribute36,
1756 baseAtt.tl_text_base_attribute37, baseAtt.tl_text_base_attribute38, baseAtt.tl_text_base_attribute39,
1757 baseAtt.tl_text_base_attribute40, baseAtt.tl_text_base_attribute41, baseAtt.tl_text_base_attribute42,
1758 baseAtt.tl_text_base_attribute43, baseAtt.tl_text_base_attribute44, baseAtt.tl_text_base_attribute45,
1759 baseAtt.tl_text_base_attribute46, baseAtt.tl_text_base_attribute47, baseAtt.tl_text_base_attribute48,
1760 baseAtt.tl_text_base_attribute49, baseAtt.tl_text_base_attribute50, baseAtt.tl_text_base_attribute51,
1761 baseAtt.tl_text_base_attribute52, baseAtt.tl_text_base_attribute53, baseAtt.tl_text_base_attribute54,
1762 baseAtt.tl_text_base_attribute55, baseAtt.tl_text_base_attribute56, baseAtt.tl_text_base_attribute57,
1763 baseAtt.tl_text_base_attribute58, baseAtt.tl_text_base_attribute59, baseAtt.tl_text_base_attribute60,
1764 baseAtt.tl_text_base_attribute61, baseAtt.tl_text_base_attribute62, baseAtt.tl_text_base_attribute63,
1765 baseAtt.tl_text_base_attribute64, baseAtt.tl_text_base_attribute65, baseAtt.tl_text_base_attribute66,
1766 baseAtt.tl_text_base_attribute67, baseAtt.tl_text_base_attribute68, baseAtt.tl_text_base_attribute69,
1767 baseAtt.tl_text_base_attribute70, baseAtt.tl_text_base_attribute71, baseAtt.tl_text_base_attribute72,
1768 baseAtt.tl_text_base_attribute73, baseAtt.tl_text_base_attribute74, baseAtt.tl_text_base_attribute75,
1769 baseAtt.tl_text_base_attribute76, baseAtt.tl_text_base_attribute77, baseAtt.tl_text_base_attribute78,
1770 baseAtt.tl_text_base_attribute79, baseAtt.tl_text_base_attribute80, baseAtt.tl_text_base_attribute81,
1771 baseAtt.tl_text_base_attribute82, baseAtt.tl_text_base_attribute83, baseAtt.tl_text_base_attribute84,
1772 baseAtt.tl_text_base_attribute85, baseAtt.tl_text_base_attribute86, baseAtt.tl_text_base_attribute87,
1773 baseAtt.tl_text_base_attribute88, baseAtt.tl_text_base_attribute89, baseAtt.tl_text_base_attribute90,
1774 baseAtt.tl_text_base_attribute91, baseAtt.tl_text_base_attribute92, baseAtt.tl_text_base_attribute93,
1775 baseAtt.tl_text_base_attribute94, baseAtt.tl_text_base_attribute95, baseAtt.tl_text_base_attribute96,
1776 baseAtt.tl_text_base_attribute97, baseAtt.tl_text_base_attribute98, baseAtt.tl_text_base_attribute99,
1777 baseAtt.tl_text_base_attribute100, catAtt.tl_text_cat_attribute1, catAtt.tl_text_cat_attribute2,
1778 catAtt.tl_text_cat_attribute3, catAtt.tl_text_cat_attribute4, catAtt.tl_text_cat_attribute5,
1779 catAtt.tl_text_cat_attribute6, catAtt.tl_text_cat_attribute7, catAtt.tl_text_cat_attribute8,
1780 catAtt.tl_text_cat_attribute9, catAtt.tl_text_cat_attribute10, catAtt.tl_text_cat_attribute11,
1781 catAtt.tl_text_cat_attribute12, catAtt.tl_text_cat_attribute13, catAtt.tl_text_cat_attribute14,
1782 catAtt.tl_text_cat_attribute15, catAtt.tl_text_cat_attribute16, catAtt.tl_text_cat_attribute17,
1783 catAtt.tl_text_cat_attribute18, catAtt.tl_text_cat_attribute19, catAtt.tl_text_cat_attribute20,
1784 catAtt.tl_text_cat_attribute21, catAtt.tl_text_cat_attribute22, catAtt.tl_text_cat_attribute23,
1785 catAtt.tl_text_cat_attribute24, catAtt.tl_text_cat_attribute25, catAtt.tl_text_cat_attribute26,
1786 catAtt.tl_text_cat_attribute27, catAtt.tl_text_cat_attribute28, catAtt.tl_text_cat_attribute29,
1787 catAtt.tl_text_cat_attribute30, catAtt.tl_text_cat_attribute31, catAtt.tl_text_cat_attribute32,
1788 catAtt.tl_text_cat_attribute33, catAtt.tl_text_cat_attribute34, catAtt.tl_text_cat_attribute35,
1789 catAtt.tl_text_cat_attribute36, catAtt.tl_text_cat_attribute37, catAtt.tl_text_cat_attribute38,
1790 catAtt.tl_text_cat_attribute39, catAtt.tl_text_cat_attribute40, catAtt.tl_text_cat_attribute41,
1791 catAtt.tl_text_cat_attribute42, catAtt.tl_text_cat_attribute43, catAtt.tl_text_cat_attribute44,
1792 catAtt.tl_text_cat_attribute45, catAtt.tl_text_cat_attribute46, catAtt.tl_text_cat_attribute47,
1793 catAtt.tl_text_cat_attribute48, catAtt.tl_text_cat_attribute49, catAtt.tl_text_cat_attribute50
1794 FROM icx_cat_items_tlp baseAtt, icx_cat_ext_items_tlp catAtt
1795 WHERE baseAtt.rt_item_id = catAtt.rt_item_id
1796 AND baseAtt.language = catAtt.language
1797 AND baseAtt.rt_item_id = gIAVTRtItemIdTbl(i)
1798 AND baseAtt.language = gIAVTLanguageTbl(i);
1799
1800 l_err_loc := 240;
1801 IF (gIAVTInterfaceHeaderIdTbl.COUNT > 0) THEN
1802 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1803 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1804 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1805 'No: of rows inserted into po_attr_values_tlp_interface:' ||SQL%ROWCOUNT);
1806 END IF;
1807 END IF;
1808
1809 l_err_loc := 250;
1810 clearTables(l_action_mode);
1811
1812 l_err_loc := 260;
1813 l_action_mode := 'INSERT_R12_UPGRADE';
1814 FORALL i in 1..gIRURtItemIdTbl.COUNT
1815 INSERT INTO icx_cat_r12_upgrade
1816 (supplier_site_id, currency, cpa_reference,
1817 price_contract_id, src_contract_id, po_category_id,
1818 rt_item_id, po_interface_header_id, po_interface_line_id,
1819 created_language,
1820 last_update_login, last_updated_by, last_update_date,
1821 created_by, creation_date, internal_request_id, request_id,
1822 program_application_id, program_id, program_login_id)
1823 VALUES
1824 (gIRUSupplierSiteIdTbl(i), gIRUCurrencyTbl(i), gIRUCpaReferenceTbl(i),
1825 gIRUPriceContractIdTbl(i), gIRUSrcContractIdTbl(i), gIRUPoCategoryIdTbl(i),
1826 gIRURtItemIdTbl(i), gIRUPoInterfaceHeaderIdTbl(i), gIRUPoInterfaceLineIdTbl(i),
1827 gIRUCreatedLanguageTbl(i),
1828 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
1829 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
1830 ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
1831 ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
1832 ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
1833 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
1834 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
1835 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
1836
1837 l_err_loc := 270;
1838 IF (gIRURtItemIdTbl.COUNT > 0) THEN
1839 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1840 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1841 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1842 'No: of rows inserted into icx_cat_r12_upgrade:' ||SQL%ROWCOUNT);
1843 END IF;
1844 END IF;
1845
1846 l_err_loc := 280;
1847 clearTables(l_action_mode);
1848
1849 l_err_loc := 290;
1850 l_action_mode := 'UPDATE_R12_UPGRADE';
1851 FORALL i in 1..gURURtItemIdTbl.COUNT
1852 UPDATE icx_cat_r12_upgrade
1853 SET po_interface_header_id = gURUPoInterfaceHeaderIdTbl(i),
1854 po_interface_line_id = gURUPoInterfaceLineIdTbl(i),
1855 po_category_id = gURUPoCategoryIdTbl(i),
1856 cpa_reference = gURUCpaReferenceTbl(i),
1857 price_contract_id = gURUPriceContractIdTbl(i),
1858 src_contract_id = gURUSrcContractIdTbl(i),
1859 po_header_id = gURUPoHeaderIdTbl(i),
1860 po_line_id = gURUPoLineIdTbl(i),
1861 created_language = gURUCreatedLanguageTbl(i),
1862 last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
1863 last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
1864 last_update_date = sysdate,
1865 internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
1866 request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
1867 program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
1868 program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
1869 program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
1870 WHERE po_interface_line_id = gURUOldPoInterfaceLineIdTbl(i)
1871 AND rt_item_id = gURURtItemIdTbl(i);
1872
1873 l_err_loc := 300;
1874 IF (gURURtItemIdTbl.COUNT > 0) THEN
1875 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1876 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1877 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1878 'No: of rows updated in icx_cat_r12_upgrade:' ||SQL%ROWCOUNT);
1879 END IF;
1880 END IF;
1881
1882 l_err_loc := 310;
1883 clearTables(l_action_mode);
1884
1885 l_err_loc := 320;
1886 l_action_mode := 'DELETE_R12_UPGRADE';
1887 FORALL i in 1..gDRURtItemIdTbl.COUNT
1888 DELETE FROM icx_cat_r12_upgrade
1889 WHERE rt_item_id = gDRURtItemIdTbl(i)
1890 AND po_interface_header_id = gDRUPoInterfaceHeaderIdTbl(i)
1891 AND po_interface_line_id = gDRUPoInterfaceLineIdTbl(i);
1892
1893 l_err_loc := 330;
1894 IF (gDRURtItemIdTbl.COUNT > 0) THEN
1895 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1896 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1897 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1898 'No: of rows deleted from icx_cat_r12_upgrade:' ||SQL%ROWCOUNT);
1899 END IF;
1900 END IF;
1901
1902 l_err_loc := 340;
1903 clearTables(l_action_mode);
1904
1905 l_err_loc := 350;
1906 l_action_mode := 'INSERT_FAV_LINES_CATALOG';
1907 FORALL i in 1..gIFLCFavoriteListIdTbl.COUNT
1908 INSERT INTO icx_cat_fav_list_lines_tlp
1909 (
1910 favorite_list_line_id, favorite_list_id,
1911 last_update_date, last_updated_by, last_update_login,
1912 creation_date, created_by,
1913 po_line_id, inventory_item_id,
1914 item_description, rfq_required_flag,
1915 req_template_name, req_template_line_num,
1916 org_id, language, source_type
1917 )
1918 SELECT
1919 gIFLCNewFavoriteListLineIdTbl(i), gIFLCFavoriteListIdTbl(i),
1920 fav.last_update_date, fav.last_updated_by, fav.last_update_login,
1921 NVL(fav.creation_date, fav.last_update_date),
1922 NVL(fav.created_by, fav.last_updated_by),
1923 NVL(fav.source_doc_line_id, -2) po_line_id,
1924 NVL(fav.item_id, -2) inventory_item_id,
1925 fav.item_description, fav.rfq_required_flag,
1926 NVL(fav.template_name, '-2') req_template_name,
1927 NVL(fav.template_line_num, -2) req_template_line_num,
1928 gIFLCOrgIdTbl(i), gIFLCLanguageTbl(i),
1929 gIFLCSourceTypeTbl(i)
1930 FROM por_favorite_list_lines fav
1931 WHERE favorite_list_line_id = gIFLCOldFavoriteListLineIdTbl(i)
1932 AND favorite_list_id = gIFLCFavoriteListIdTbl(i);
1933
1934 l_err_loc := 360;
1935 IF (gIFLCFavoriteListIdTbl.COUNT > 0) THEN
1936 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
1937 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
1938 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
1939 'No: of rows inserted into icx_cat_fav_list_lines_tlp for catalog items:' ||SQL%ROWCOUNT);
1940 END IF;
1941 END IF;
1942
1943 l_err_loc := 370;
1944 clearTables(l_action_mode);
1945
1946 l_err_loc := 380;
1947 l_action_mode := 'INSERT_FAV_LINES_OTHER';
1948 FORALL i in 1..gIFLOFavoriteListIdTbl.COUNT
1949 INSERT INTO icx_cat_fav_list_lines_tlp
1950 (
1951 favorite_list_line_id, favorite_list_id,
1952 last_update_date, last_updated_by, last_update_login,
1953 creation_date, created_by,
1954 po_header_id, po_line_id, inventory_item_id,
1955 item_description, line_type_id,
1956 item_revision, po_category_id, unit_meas_lookup_code,
1957 unit_price, suggested_vendor_id, suggested_vendor_name,
1958 suggested_vendor_site_id, suggested_vendor_site,
1959 suggested_vendor_contact_id, suggested_vendor_contact,
1960 supplier_url, suggested_buyer_id,
1961 suggested_buyer, supplier_item_num,
1962 manufacturer_id, manufacturer_name, manufacturer_part_number,
1963 rfq_required_flag, attribute_category,
1964 attribute1, attribute2, attribute3, attribute4, attribute5,
1965 attribute6, attribute7, attribute8, attribute9, attribute10,
1966 attribute11, attribute12, attribute13, attribute14, attribute15,
1967 po_category_name, suggested_vendor_contact_phone, new_supplier,
1968 req_template_name, req_template_line_num,
1969 currency, rate_type, rate, rate_date,
1970 noncat_template_id, suggested_vendor_contact_fax,
1971 suggested_vendor_contact_email,
1972 negotiated_by_preparer_flag, thumbnail_image,
1973 org_id, language, source_type, amount
1974 )
1975 SELECT
1976 gIFLONewFavoriteListLineIdTbl(i), gIFLOFavoriteListIdTbl(i),
1977 fav.last_update_date, fav.last_updated_by, fav.last_update_login,
1978 NVL(fav.creation_date, fav.last_update_date),
1979 NVL(fav.created_by, fav.last_updated_by),
1980 fav.source_doc_header_id po_header_id,
1981 fav.source_doc_line_id po_line_id,
1982 fav.item_id inventory_item_id,
1983 fav.item_description,
1984 NVL(fav.line_type_id, 1) line_type_id,
1985 fav.item_revision, fav.category_id, fav.unit_meas_lookup_code,
1986 DECODE(NVL(line_types.order_type_lookup_code, 'QUANTITY'),
1987 'QUANTITY', fav.unit_price, NULL) unit_price,
1988 fav.suggested_vendor_id, fav.suggested_vendor_name,
1989 fav.suggested_vendor_site_id, fav.suggested_vendor_site,
1990 fav.suggested_vendor_contact_id, fav.suggested_vendor_contact,
1991 fav.supplier_url, fav.suggested_buyer_id,
1992 fav.suggested_buyer, fav.supplier_item_num,
1993 fav.manufacturer_id, fav.manufacturer_name, fav.manufacturer_part_number,
1994 fav.rfq_required_flag, fav.attribute_category,
1995 fav.attribute1, fav.attribute2, fav.attribute3, fav.attribute4, fav.attribute5,
1996 fav.attribute6, fav.attribute7, fav.attribute8, fav.attribute9, fav.attribute10,
1997 fav.attribute11, fav.attribute12, fav.attribute13, fav.attribute14, fav.attribute15,
1998 fav.category, fav.suggested_vendor_contact_phone, fav.new_supplier,
1999 fav.template_name req_template_name,
2000 fav.template_line_num req_template_line_num,
2001 NVL(fav.currency, gsob.currency_code) currency,
2002 fav.rate_type, fav.rate, fav.rate_date,
2003 fav.noncat_template_id, fav.suggested_vendor_contact_fax,
2004 fav.suggested_vendor_contact_email,
2005 fav.negotiated_by_preparer_flag, fav.thumbnail_image,
2006 gIFLOOrgIdTbl(i), gIFLOLanguageTbl(i),
2007 NVL(fav.item_type, 'NONCATALOG') source_type,
2008 DECODE(NVL(line_types.order_type_lookup_code, 'QUANTITY'),
2009 'QUANTITY', NULL, fav.unit_price) amount
2010 FROM por_favorite_list_lines fav, po_line_types_b line_types,
2011 financials_system_params_all fsp, gl_sets_of_books gsob
2012 WHERE favorite_list_line_id = gIFLOOldFavoriteListLineIdTbl(i)
2013 AND favorite_list_id = gIFLOFavoriteListIdTbl(i)
2014 AND fav.line_type_id = line_types.line_type_id (+)
2015 AND fsp.org_id = gIFLOOrgIdTbl(i)
2016 AND fsp.set_of_books_id = gsob.set_of_books_id;
2017
2018 l_err_loc := 390;
2019 IF (gIFLOFavoriteListIdTbl.COUNT > 0) THEN
2020 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2021 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2022 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2023 'No: of rows inserted into icx_cat_fav_list_lines_tlp for other items:' ||SQL%ROWCOUNT);
2024 END IF;
2025 END IF;
2026
2027 l_err_loc := 400;
2028 clearTables(l_action_mode);
2029
2030 l_err_loc := 440;
2031 COMMIT;
2032 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2033 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
2034 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2035 'Commit done.');
2036 END IF;
2037
2038 END IF; --(p_mode = 'OUTLOOP' OR g_total_row_count >= ICX_CAT_UTIL_PVT.g_batch_size)
2039 EXCEPTION
2040 WHEN OTHERS THEN
2041 logPLSQLTableRow(l_api_name, FND_LOG.LEVEL_UNEXPECTED, SQL%ROWCOUNT+1, l_action_mode);
2042 ICX_CAT_UTIL_PVT.logUnexpectedException(
2043 G_PKG_NAME, l_api_name,
2044 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2045 RAISE;
2046 END populatePOInterfaceTables;
2047
2048 PROCEDURE openBlanketsAndQuotesHdrsCsr
2049 ( p_start_po_header_id IN NUMBER ,
2050 p_blanketAndQuoteHdrs_csr IN OUT NOCOPY g_csr_type
2051 )
2052 IS
2053 l_api_name CONSTANT VARCHAR2(30) := 'openBlanketsAndQuotesHdrsCsr';
2054 l_err_loc PLS_INTEGER;
2055 BEGIN
2056 l_err_loc := 100;
2057 --No need of getting Hdrs with price_type=GLOBAL_AGREEMENT because
2058 --these are only for enabled orgs. For enabled orgs we don't need to
2059 --populate the attribute and attribute values tlp
2060 IF (g_extract_last_run_date IS NULL) THEN
2061 OPEN p_blanketAndQuoteHdrs_csr FOR
2062 SELECT distinct p.contract_id po_header_id, p.price_type, p.org_id
2063 FROM icx_cat_item_prices p
2064 WHERE p.price_type IN ('BLANKET', 'QUOTATION')
2065 AND p.contract_id >= p_start_po_header_id
2066 ORDER BY p.contract_id;
2067 ELSE
2068 l_err_loc := 120;
2069 OPEN p_blanketAndQuoteHdrs_csr FOR
2070 SELECT distinct p.contract_id po_header_id, p.price_type, p.org_id
2071 FROM icx_cat_item_prices p, icx_cat_items_tlp itemtlp,
2072 icx_cat_items_b itemsb, icx_cat_ext_items_tlp exttlp
2073 WHERE p.price_type IN ('BLANKET', 'QUOTATION')
2074 AND p.contract_id >= p_start_po_header_id
2075 AND itemtlp.rt_item_id = p.rt_item_id
2076 AND itemsb.rt_item_id = p.rt_item_id
2077 AND itemtlp.rt_item_id = exttlp.rt_item_id
2078 AND itemtlp.language = exttlp.language
2079 AND (itemsb.last_update_date > g_extract_last_run_date
2080 OR itemtlp.last_update_date > g_extract_last_run_date
2081 OR exttlp.last_update_date > g_extract_last_run_date
2082 OR p.last_update_date > g_extract_last_run_date)
2083 ORDER BY p.contract_id;
2084 END IF;
2085
2086 l_err_loc := 130;
2087
2088 EXCEPTION
2089 WHEN OTHERS THEN
2090 ICX_CAT_UTIL_PVT.logUnexpectedException(
2091 G_PKG_NAME, l_api_name,
2092 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2093 RAISE;
2094 END openBlanketsAndQuotesHdrsCsr;
2095
2096 PROCEDURE openBlanketsAndQuotesLinesCsr
2097 ( p_start_po_line_id IN NUMBER ,
2098 p_blanketAndQuoteLines_csr IN OUT NOCOPY g_csr_type
2099 )
2100 IS
2101 l_api_name CONSTANT VARCHAR2(30) := 'openBlanketsAndQuotesLinesCsr';
2102 l_err_loc PLS_INTEGER;
2103 BEGIN
2104 l_err_loc := 100;
2105 --No need of getting lines with price_type=GLOBAL_AGREEMENT because
2106 --these are only for enabled orgs. For enabled orgs we don't need to
2107 --populate the attribute and attribute values tlp
2108 IF (g_extract_last_run_date IS NULL) THEN
2109 OPEN p_blanketAndQuoteLines_csr FOR
2110 SELECT p.rt_item_id, itemtlp.language, p.price_type,
2111 phi.interface_header_id, p.contract_id po_header_id, p.contract_line_id po_line_id,
2112 p.inventory_item_id, p.org_id,
2113 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
2114 itemsb.catalog_name, itemtlp.primary_category_id,
2115 getPOAttrValuesTLPAction(p.contract_line_id, '-2' ,-2, p.org_id, itemtlp.language)
2116 FROM icx_cat_item_prices p, icx_cat_items_tlp itemtlp,
2117 icx_cat_items_b itemsb, po_headers_interface phi
2118 WHERE p.price_type IN ('BLANKET', 'QUOTATION')
2119 AND p.contract_line_id >= p_start_po_line_id
2120 AND itemtlp.rt_item_id = p.rt_item_id
2121 AND itemsb.rt_item_id = p.rt_item_id
2122 AND p.contract_id = phi.po_header_id
2123 AND phi.batch_id = g_PDOI_batch_id
2124 ORDER BY p.contract_line_id, p.rt_item_id, itemtlp.language;
2125 ELSE
2126 l_err_loc := 120;
2127 OPEN p_blanketAndQuoteLines_csr FOR
2128 SELECT p.rt_item_id, itemtlp.language, p.price_type,
2129 phi.interface_header_id, p.contract_id po_header_id, p.contract_line_id po_line_id,
2130 p.inventory_item_id, p.org_id,
2131 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
2132 itemsb.catalog_name, itemtlp.primary_category_id,
2133 getPOAttrValuesTLPAction(p.contract_line_id, '-2' ,-2, p.org_id, itemtlp.language)
2134 FROM icx_cat_item_prices p, icx_cat_items_tlp itemtlp,
2135 icx_cat_items_b itemsb, icx_cat_ext_items_tlp exttlp, po_headers_interface phi
2136 WHERE p.price_type IN ('BLANKET', 'QUOTATION')
2137 AND p.contract_line_id >= p_start_po_line_id
2138 AND itemtlp.rt_item_id = p.rt_item_id
2139 AND itemsb.rt_item_id = p.rt_item_id
2140 AND itemtlp.rt_item_id = exttlp.rt_item_id
2141 AND itemtlp.language = exttlp.language
2142 AND p.contract_id = phi.po_header_id
2143 AND phi.batch_id = g_PDOI_batch_id
2144 AND (itemsb.last_update_date > g_extract_last_run_date
2145 OR itemtlp.last_update_date > g_extract_last_run_date
2146 OR exttlp.last_update_date > g_extract_last_run_date
2147 OR p.last_update_date > g_extract_last_run_date)
2148 ORDER BY contract_line_id, p.rt_item_id, itemtlp.language;
2149 END IF;
2150
2151 l_err_loc := 130;
2152
2153 EXCEPTION
2154 WHEN OTHERS THEN
2155 ICX_CAT_UTIL_PVT.logUnexpectedException(
2156 G_PKG_NAME, l_api_name,
2157 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2158 RAISE;
2159 END openBlanketsAndQuotesLinesCsr;
2160
2161 PROCEDURE processBlanketsAndQuotes
2162 IS
2163
2164 ----- Start of declaring columns selected in the cursor -----
2165
2166 l_po_header_id_tbl DBMS_SQL.NUMBER_TABLE;
2167 l_price_type_tbl DBMS_SQL.VARCHAR2_TABLE;
2168 l_org_id_tbl DBMS_SQL.NUMBER_TABLE;
2169 l_rt_item_id_tbl DBMS_SQL.NUMBER_TABLE;
2170 l_language_tbl DBMS_SQL.VARCHAR2_TABLE;
2171 l_interface_header_id_tbl DBMS_SQL.NUMBER_TABLE;
2172 l_po_line_id_tbl DBMS_SQL.NUMBER_TABLE;
2173 l_inventory_item_id_tbl DBMS_SQL.NUMBER_TABLE;
2174 l_supplier_part_auxid_tbl DBMS_SQL.VARCHAR2_TABLE;
2175 l_catalog_name_tbl DBMS_SQL.VARCHAR2_TABLE;
2176 l_primary_category_id_tbl DBMS_SQL.NUMBER_TABLE;
2177 l_attr_val_tlp_action_tbl DBMS_SQL.VARCHAR2_TABLE;
2178
2179 ------ End of declaring columns selected in the cursor ------
2180
2181 l_api_name CONSTANT VARCHAR2(30) := 'processBlanketsAndQuotes';
2182 l_err_loc PLS_INTEGER;
2183 l_err_string VARCHAR2(4000);
2184 l_start_po_header_id NUMBER;
2185 l_start_po_line_id NUMBER;
2186 l_batch_count PLS_INTEGER;
2187 l_prev_po_line_id NUMBER;
2188 l_interface_header_id NUMBER;
2189 l_interface_line_id NUMBER;
2190 l_ext_row_count PLS_INTEGER;
2191 l_blanketAndQuoteHdr_csr g_csr_type;
2192 l_blanketAndQuoteLine_csr g_csr_type;
2193 l_start_date DATE;
2194 l_end_date DATE;
2195 l_log_string VARCHAR2(2000);
2196
2197 BEGIN
2198 l_err_loc := 100;
2199 l_start_date := sysdate;
2200
2201 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2202 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2203 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2204 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
2205 END IF;
2206
2207 l_start_po_header_id := 0;
2208 l_batch_count := 0;
2209 l_ext_row_count := 0;
2210
2211 l_err_loc := 120;
2212 openBlanketsAndQuotesHdrsCsr(l_start_po_header_id, l_blanketAndQuoteHdr_csr);
2213
2214 l_err_loc := 130;
2215 LOOP
2216 l_po_header_id_tbl.DELETE;
2217 l_price_type_tbl.DELETE;
2218 l_org_id_tbl.DELETE;
2219
2220 BEGIN
2221 l_err_loc := 140;
2222 FETCH l_blanketAndQuoteHdr_csr BULK COLLECT INTO
2223 l_po_header_id_tbl, l_price_type_tbl, l_org_id_tbl
2224 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
2225
2226 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2227 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2228 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2229 'Total no: of blankets and quotes headers fetched from the cursor:' ||
2230 l_po_header_id_tbl.COUNT);
2231 END IF;
2232
2233 l_err_loc := 160;
2234 EXIT WHEN l_po_header_id_tbl.COUNT = 0;
2235
2236 l_err_loc := 170;
2237 l_batch_count := l_batch_count + 1;
2238
2239 l_err_loc := 180;
2240 --Save the last po_header_id processed, so that re-open of cursor will start from the saved po_header_id.
2241 l_start_po_header_id := l_po_header_id_tbl(l_po_header_id_tbl.COUNT);
2242
2243 l_err_loc := 190;
2244 l_ext_row_count := l_ext_row_count + l_po_header_id_tbl.COUNT;
2245
2246 l_err_loc := 200;
2247 FOR i in 1..l_po_header_id_tbl.COUNT LOOP
2248 l_err_loc := 210;
2249
2250 l_err_loc := 220;
2251 --Process and start assigning the current values in pl/sql table to global pl/sql table
2252 l_interface_header_id := getNextInterfaceHdrIdFromSeq;
2253
2254 l_err_loc := 230;
2255 g_po_hdrs_int_rec.interface_header_id := l_interface_header_id;
2256 g_po_hdrs_int_rec.action := 'UPDATE';
2257 g_po_hdrs_int_rec.org_id := l_org_id_tbl(i);
2258 g_po_hdrs_int_rec.document_type_code := l_price_type_tbl(i);
2259 g_po_hdrs_int_rec.budget_account_segment1 := null;
2260 g_po_hdrs_int_rec.po_header_id := l_po_header_id_tbl(i);
2261 --Will have some value when moving bulk-loaded items
2262 --For moving the extracted item attributes, the following will be null in po_headers_interface
2263 --as these are already set in po_headers_all
2264 g_po_hdrs_int_rec.approval_status := null;
2265 g_po_hdrs_int_rec.vendor_id := null;
2266 g_po_hdrs_int_rec.vendor_site_id := null;
2267 g_po_hdrs_int_rec.currency_code := null;
2268 g_po_hdrs_int_rec.cpa_reference := null;
2269 g_po_hdrs_int_rec.created_language := null;
2270 g_po_hdrs_int_rec.comments := null;
2271
2272 l_err_loc := 240;
2273 insertPOHeadersInterface;
2274
2275 l_err_loc := 320;
2276 populatePOInterfaceTables('INLOOP');
2277 END LOOP; --FOR LOOP of l_po_header_id_tbl
2278
2279 l_err_loc := 330;
2280 EXIT WHEN l_po_header_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
2281
2282 l_err_loc := 340;
2283 EXCEPTION
2284 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
2285 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
2286 || '-' || l_err_loc
2287 || ', Total processeded batches:' || l_batch_count
2288 || ', Cursor will be reopened with l_po_header_id_tbl:' || l_start_po_header_id;
2289 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
2290 CLOSE l_blanketAndQuoteHdr_csr;
2291 openBlanketsAndQuotesHdrsCsr(l_start_po_header_id, l_blanketAndQuoteHdr_csr);
2292 END;
2293 END LOOP; --CURSOR LOOP
2294
2295 l_err_loc := 370;
2296 populatePOInterfaceTables('OUTLOOP');
2297
2298 IF (l_blanketAndQuoteHdr_csr%ISOPEN) THEN
2299 CLOSE l_blanketAndQuoteHdr_csr;
2300 END IF;
2301
2302 l_err_loc := 380;
2303 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2304 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2305 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2306 'processBlanketsAndQuotes Headers done; '||
2307 'Total no: of batches processed:' || l_batch_count ||
2308 ', Total no: of blankets and quotes headers processed:' || l_ext_row_count);
2309 END IF;
2310
2311 l_start_po_line_id := 0;
2312 l_batch_count := 0;
2313 l_ext_row_count := 0;
2314 --Assign the previous po_line_id to some dummy values
2315 l_prev_po_line_id := -1212;
2316
2317 l_err_loc := 120;
2318 openBlanketsAndQuotesLinesCsr(l_start_po_line_id, l_blanketAndQuoteLine_csr);
2319
2320 l_err_loc := 130;
2321 LOOP
2322 l_rt_item_id_tbl.DELETE;
2323 l_language_tbl.DELETE;
2324 l_price_type_tbl.DELETE;
2325 l_interface_header_id_tbl.DELETE;
2326 l_po_header_id_tbl.DELETE;
2327 l_po_line_id_tbl.DELETE;
2328 l_inventory_item_id_tbl.DELETE;
2329 l_org_id_tbl.DELETE;
2330 l_supplier_part_auxid_tbl.DELETE;
2331 l_catalog_name_tbl.DELETE;
2332 l_primary_category_id_tbl.DELETE;
2333 l_attr_val_tlp_action_tbl.DELETE;
2334
2335 BEGIN
2336 l_err_loc := 140;
2337 FETCH l_blanketAndQuoteLine_csr BULK COLLECT INTO
2338 l_rt_item_id_tbl, l_language_tbl, l_price_type_tbl,
2339 l_interface_header_id_tbl, l_po_header_id_tbl, l_po_line_id_tbl,
2340 l_inventory_item_id_tbl, l_org_id_tbl, l_supplier_part_auxid_tbl,
2341 l_catalog_name_tbl, l_primary_category_id_tbl,
2342 l_attr_val_tlp_action_tbl
2343 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
2344
2345 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2346 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2347 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2348 'Total no: of blankets and quotes lines fetched from the cursor:' ||
2349 l_po_line_id_tbl.COUNT);
2350 END IF;
2351
2352 l_err_loc := 160;
2353 EXIT WHEN l_po_line_id_tbl.COUNT = 0;
2354
2355 l_err_loc := 170;
2356 l_batch_count := l_batch_count + 1;
2357
2358 l_err_loc := 180;
2359 --Save the last po_line_id processed, so that re-open of cursor will start from the saved po_line_id.
2360 l_start_po_line_id := l_po_line_id_tbl(l_po_line_id_tbl.COUNT);
2361
2362 l_err_loc := 190;
2363 l_ext_row_count := l_ext_row_count + l_po_line_id_tbl.COUNT;
2364
2365 l_err_loc := 200;
2366 FOR i in 1..l_po_line_id_tbl.COUNT LOOP
2367 l_err_loc := 250;
2368 IF (l_prev_po_line_id <> l_po_line_id_tbl(i)) THEN
2369 l_interface_line_id := getNextInterfaceLineIdFromSeq;
2370 l_err_loc := 260;
2371
2372 g_po_line_attrval_int_rec.interface_line_id := l_interface_line_id;
2373 g_po_line_attrval_int_rec.interface_header_id := l_interface_header_id_tbl(i);
2374 g_po_line_attrval_int_rec.action := 'UPDATE';
2375 g_po_line_attrval_int_rec.po_line_id := l_po_line_id_tbl(i);
2376 g_po_line_attrval_int_rec.po_header_id := l_po_header_id_tbl(i);
2377 g_po_line_attrval_int_rec.req_template_name := TO_CHAR(ICX_CAT_UTIL_PVT.g_NULL_NUMBER);
2378 g_po_line_attrval_int_rec.req_template_line_num := TO_NUMBER(ICX_CAT_UTIL_PVT.g_NULL_NUMBER);
2379 g_po_line_attrval_int_rec.inventory_item_id := l_inventory_item_id_tbl(i);
2380 g_po_line_attrval_int_rec.org_id := l_org_id_tbl(i);
2381 g_po_line_attrval_int_rec.rt_item_id := l_rt_item_id_tbl(i);
2382 g_po_line_attrval_int_rec.language := l_language_tbl(i);
2383 g_po_line_attrval_int_rec.supplier_part_auxid := l_supplier_part_auxid_tbl(i);
2384 g_po_line_attrval_int_rec.catalog_name := l_catalog_name_tbl(i);
2385 g_po_line_attrval_int_rec.ip_category_id := l_primary_category_id_tbl(i);
2386 --Put the following to null, because we cannot update these for
2387 --extracted items in po_lines_all and po_attribute_values
2388 g_po_line_attrval_int_rec.unit_price := null;
2389 g_po_line_attrval_int_rec.uom_code := null;
2390 g_po_line_attrval_int_rec.negotiated_by_preparer_flag := null;
2391 g_po_line_attrval_int_rec.category_id := null;
2392 g_po_line_attrval_int_rec.category_name := null;
2393 g_po_line_attrval_int_rec.vendor_product_num := null;
2394 g_po_line_attrval_int_rec.item_description := null;
2395
2396 l_err_loc := 270;
2397 insertPOLinesInterface;
2398 insertPOAttrValsInterface;
2399 END IF;
2400
2401 l_err_loc := 280;
2402 g_po_attrvalstlp_int_rec.interface_header_id := l_interface_header_id_tbl(i);
2403 g_po_attrvalstlp_int_rec.interface_line_id := l_interface_line_id;
2404 g_po_attrvalstlp_int_rec.action := l_attr_val_tlp_action_tbl(i);
2405 g_po_attrvalstlp_int_rec.po_line_id := l_po_line_id_tbl(i);
2406 g_po_attrvalstlp_int_rec.req_template_name := TO_CHAR(ICX_CAT_UTIL_PVT.g_NULL_NUMBER);
2407 g_po_attrvalstlp_int_rec.req_template_line_num := TO_NUMBER(ICX_CAT_UTIL_PVT.g_NULL_NUMBER);
2408 g_po_attrvalstlp_int_rec.inventory_item_id := l_inventory_item_id_tbl(i);
2409 g_po_attrvalstlp_int_rec.org_id := l_org_id_tbl(i);
2410 g_po_attrvalstlp_int_rec.language := l_language_tbl(i);
2411 IF (l_language_tbl(i) = ICX_CAT_UTIL_PVT.g_base_language) THEN
2412 g_po_attrvalstlp_int_rec.check_desc_update := ICX_CAT_UTIL_PVT.g_donot_update_description;
2413 ELSE
2414 g_po_attrvalstlp_int_rec.check_desc_update := ICX_CAT_UTIL_PVT.g_update_description;
2415 END IF;
2416 g_po_attrvalstlp_int_rec.rt_item_id := l_rt_item_id_tbl(i);
2417
2418 l_err_loc := 290;
2419 insertPOAttrValsTLPInterface;
2420
2421 l_err_loc := 300;
2422 /* TO BE WORKED ON
2423 -- Statement level log
2424 fnd_file.put_line(fnd_file.log, g_pkg_name || '.' || l_api_name || ';' || logCurrentRow);
2425 */
2426
2427 l_err_loc := 310;
2428 l_prev_po_line_id := l_po_line_id_tbl(i);
2429
2430 l_err_loc := 320;
2431 populatePOInterfaceTables('INLOOP');
2432 END LOOP; --FOR LOOP of l_po_line_id_tbl
2433
2434 l_err_loc := 330;
2435 EXIT WHEN l_po_line_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
2436
2437 l_err_loc := 340;
2438 EXCEPTION
2439 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
2440 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
2441 || '-' || l_err_loc
2442 || ', Total processeded batches:' || l_batch_count
2443 || ', Cursor will be reopened with po_line_id:' || l_start_po_line_id;
2444 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
2445 CLOSE l_blanketAndQuoteLine_csr;
2446 openBlanketsAndQuotesLinesCsr(l_start_po_line_id, l_blanketAndQuoteLine_csr);
2447 END;
2448 END LOOP; --CURSOR LOOP
2449
2450 l_err_loc := 370;
2451 populatePOInterfaceTables('OUTLOOP');
2452
2453 IF (l_blanketAndQuoteLine_csr%ISOPEN) THEN
2454 CLOSE l_blanketAndQuoteLine_csr;
2455 END IF;
2456
2457 l_err_loc := 380;
2458 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2459 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2460 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2461 'done. '||
2462 'Total no: of batches processed:' || l_batch_count ||
2463 ', Total no: of blankets and quotes lines processed:' || l_ext_row_count);
2464 END IF;
2465
2466 l_end_date := sysdate;
2467 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2468 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2469 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2470 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
2471 END IF;
2472 EXCEPTION
2473 WHEN OTHERS THEN
2474 ICX_CAT_UTIL_PVT.logUnexpectedException(
2475 G_PKG_NAME, l_api_name,
2476 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2477 raise;
2478 END processBlanketsAndQuotes;
2479
2480 PROCEDURE openReqTemplatesHdrsCsr
2481 ( p_start_template_id IN VARCHAR2 ,
2482 p_reqTemplateHdrs_csr IN OUT NOCOPY g_csr_type
2483 )
2484 IS
2485 l_api_name CONSTANT VARCHAR2(30) := 'openReqTemplatesHdrsCsr';
2486 l_err_loc PLS_INTEGER;
2487 BEGIN
2488 l_err_loc := 100;
2489 IF (g_extract_last_run_date IS NULL) THEN
2490 OPEN p_reqTemplateHdrs_csr FOR
2491 SELECT distinct p.template_id, p.org_id
2492 FROM icx_cat_item_prices p
2493 WHERE p.price_type IN ('TEMPLATE', 'INTERNAL_TEMPLATE')
2494 AND p.template_id >= p_start_template_id
2495 ORDER BY p.template_id;
2496 ELSE
2497 l_err_loc := 200;
2498 OPEN p_reqTemplateHdrs_csr FOR
2499 SELECT distinct p.template_id, p.org_id
2500 FROM icx_cat_item_prices p, icx_cat_items_tlp itemtlp,
2501 icx_cat_items_b itemsb, icx_cat_ext_items_tlp exttlp
2502 WHERE p.price_type IN ('TEMPLATE', 'INTERNAL_TEMPLATE')
2503 AND p.template_id >= p_start_template_id
2504 AND itemtlp.rt_item_id = p.rt_item_id
2505 AND itemsb.rt_item_id = p.rt_item_id
2506 AND itemtlp.rt_item_id = exttlp.rt_item_id
2507 AND itemtlp.language = exttlp.language
2508 AND (itemsb.last_update_date > g_extract_last_run_date
2509 OR itemtlp.last_update_date > g_extract_last_run_date
2510 OR exttlp.last_update_date > g_extract_last_run_date
2511 OR p.last_update_date > g_extract_last_run_date)
2512 ORDER BY p.template_id;
2513 END IF;
2514
2515 l_err_loc := 300;
2516
2517 EXCEPTION
2518 WHEN OTHERS THEN
2519 ICX_CAT_UTIL_PVT.logUnexpectedException(
2520 G_PKG_NAME, l_api_name,
2521 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2522 RAISE;
2523 END openReqTemplatesHdrsCsr;
2524
2525 PROCEDURE openReqTemplatesLinesCsr
2526 ( p_start_rt_item_id IN NUMBER ,
2527 p_reqTemplateLines_csr IN OUT NOCOPY g_csr_type
2528 )
2529 IS
2530 l_api_name CONSTANT VARCHAR2(30) := 'openReqTemplatesLinesCsr';
2531 l_err_loc PLS_INTEGER;
2532 BEGIN
2533 l_err_loc := 100;
2534 IF (g_extract_last_run_date IS NULL) THEN
2535 OPEN p_reqTemplateLines_csr FOR
2536 SELECT p.rt_item_id, itemtlp.language, phi.interface_header_id,
2537 p.template_id req_template_name, p.template_line_id req_template_line_num,
2538 p.inventory_item_id, p.org_id,
2539 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
2540 itemsb.catalog_name, itemtlp.primary_category_id,
2541 getPOAttrValuesTLPAction(-2, p.template_id, p.template_line_id, p.org_id, itemtlp.language)
2542 FROM icx_cat_item_prices p, icx_cat_items_tlp itemtlp,
2543 icx_cat_items_b itemsb, po_headers_interface phi
2544 WHERE p.price_type IN ('TEMPLATE', 'INTERNAL_TEMPLATE')
2545 AND p.rt_item_id >= p_start_rt_item_id
2546 AND itemtlp.rt_item_id = p.rt_item_id
2547 AND itemsb.rt_item_id = p.rt_item_id
2548 AND p.template_id = phi.budget_account_segment1
2549 AND p.org_id = phi.org_id
2550 AND phi.batch_id = g_PDOI_batch_id
2551 ORDER BY p.rt_item_id, itemtlp.language;
2552 ELSE
2553 l_err_loc := 200;
2554 OPEN p_reqTemplateLines_csr FOR
2555 SELECT p.rt_item_id, itemtlp.language, phi.interface_header_id,
2556 p.template_id req_template_name, p.template_line_id req_template_line_num,
2557 p.inventory_item_id, p.org_id,
2558 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
2559 itemsb.catalog_name, itemtlp.primary_category_id,
2560 getPOAttrValuesTLPAction(-2, p.template_id, p.template_line_id, p.org_id, itemtlp.language)
2561 FROM icx_cat_item_prices p, icx_cat_items_tlp itemtlp,
2562 icx_cat_items_b itemsb, icx_cat_ext_items_tlp exttlp, po_headers_interface phi
2563 WHERE p.price_type IN ('TEMPLATE', 'INTERNAL_TEMPLATE')
2564 AND p.rt_item_id >= p_start_rt_item_id
2565 AND itemtlp.rt_item_id = p.rt_item_id
2566 AND itemsb.rt_item_id = p.rt_item_id
2567 AND itemtlp.rt_item_id = exttlp.rt_item_id
2568 AND itemtlp.language = exttlp.language
2569 AND p.template_id = phi.budget_account_segment1
2570 AND p.org_id = phi.org_id
2571 AND phi.batch_id = g_PDOI_batch_id
2572 AND (itemsb.last_update_date > g_extract_last_run_date
2573 OR itemtlp.last_update_date > g_extract_last_run_date
2574 OR exttlp.last_update_date > g_extract_last_run_date
2575 OR p.last_update_date > g_extract_last_run_date)
2576 ORDER BY p.rt_item_id, itemtlp.language;
2577 END IF;
2578
2579 l_err_loc := 300;
2580
2581 EXCEPTION
2582 WHEN OTHERS THEN
2583 ICX_CAT_UTIL_PVT.logUnexpectedException(
2584 G_PKG_NAME, l_api_name,
2585 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2586 RAISE;
2587 END openReqTemplatesLinesCsr;
2588
2589 PROCEDURE processReqTemplates
2590 IS
2591
2592 ----- Start of declaring columns selected in the cursor -----
2593
2594 l_req_template_name_tbl DBMS_SQL.VARCHAR2_TABLE;
2595 l_org_id_tbl DBMS_SQL.NUMBER_TABLE;
2596 l_rt_item_id_tbl DBMS_SQL.NUMBER_TABLE;
2597 l_language_tbl DBMS_SQL.VARCHAR2_TABLE;
2598 l_interface_header_id_tbl DBMS_SQL.NUMBER_TABLE;
2599 l_req_template_line_num_tbl DBMS_SQL.NUMBER_TABLE;
2600 l_inventory_item_id_tbl DBMS_SQL.NUMBER_TABLE;
2601 l_supplier_part_auxid_tbl DBMS_SQL.VARCHAR2_TABLE;
2602 l_catalog_name_tbl DBMS_SQL.VARCHAR2_TABLE;
2603 l_primary_category_id_tbl DBMS_SQL.NUMBER_TABLE;
2604 l_attr_val_tlp_action_tbl DBMS_SQL.VARCHAR2_TABLE;
2605
2606 ------ End of declaring columns selected in the cursor ------
2607
2608 l_api_name CONSTANT VARCHAR2(30) := 'processReqTemplates';
2609 l_err_loc PLS_INTEGER;
2610 l_err_string VARCHAR2(4000);
2611 l_start_template_id icx_cat_item_prices.template_id%TYPE;
2612 l_start_rt_item_id NUMBER;
2613 l_batch_count PLS_INTEGER;
2614 l_prev_rt_item_id NUMBER;
2615 l_interface_header_id NUMBER;
2616 l_interface_line_id NUMBER;
2617 l_ext_row_count PLS_INTEGER;
2618 l_reqTemplateHdr_csr g_csr_type;
2619 l_reqTemplateLine_csr g_csr_type;
2620 l_start_date DATE;
2621 l_end_date DATE;
2622 l_log_string VARCHAR2(2000);
2623
2624 BEGIN
2625 l_err_loc := 100;
2626 l_start_date := sysdate;
2627
2628 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2629 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2630 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2631 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
2632 END IF;
2633
2634 l_start_template_id := '-2';
2635 l_batch_count := 0;
2636 l_ext_row_count := 0;
2637
2638 l_err_loc := 200;
2639 openReqTemplatesHdrsCsr(l_start_template_id, l_reqTemplateHdr_csr);
2640
2641 l_err_loc := 300;
2642 LOOP
2643 l_req_template_name_tbl.DELETE;
2644 l_org_id_tbl.DELETE;
2645
2646 BEGIN
2647 l_err_loc := 400;
2648 FETCH l_reqTemplateHdr_csr BULK COLLECT INTO
2649 l_req_template_name_tbl, l_org_id_tbl
2650 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
2651
2652 l_err_loc := 410;
2653 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2654 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2655 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2656 'Total no: of Req Templates headers fetched from the cursor:' ||
2657 l_req_template_name_tbl.COUNT);
2658 END IF;
2659
2660 l_err_loc := 500;
2661 EXIT WHEN l_req_template_name_tbl.COUNT = 0;
2662
2663 l_err_loc := 600;
2664 l_batch_count := l_batch_count + 1;
2665
2666 l_err_loc := 700;
2667 --Save the last template_id processed, so that re-open of cursor will start from the saved template_id.
2668 l_start_template_id := l_req_template_name_tbl(l_req_template_name_tbl.COUNT);
2669
2670 l_err_loc := 800;
2671 l_ext_row_count := l_ext_row_count + l_req_template_name_tbl.COUNT;
2672
2673 l_err_loc := 900;
2674 FOR i in 1..l_req_template_name_tbl.COUNT LOOP
2675 l_err_loc := 1000;
2676 --Process and start assigning the current values in pl/sql table to global pl/sql table
2677 l_interface_header_id := getNextInterfaceHdrIdFromSeq;
2678
2679 l_err_loc := 1100;
2680 g_po_hdrs_int_rec.interface_header_id := l_interface_header_id;
2681 g_po_hdrs_int_rec.action := 'REQTEMPLATE';
2682 g_po_hdrs_int_rec.org_id := l_org_id_tbl(i);
2683 -- Just used by data migration to get the interface header id from po_headers_interface
2684 g_po_hdrs_int_rec.budget_account_segment1 := l_req_template_name_tbl(i);
2685 g_po_hdrs_int_rec.document_type_code := null;
2686 g_po_hdrs_int_rec.po_header_id := null;
2687 --Will have some value when moving bulk-loaded items
2688 --For moving the extracted item attributes, the following will be null in po_headers_interface
2689 --as these are already set in po_headers_all
2690 g_po_hdrs_int_rec.approval_status := null;
2691 g_po_hdrs_int_rec.vendor_id := null;
2692 g_po_hdrs_int_rec.vendor_site_id := null;
2693 g_po_hdrs_int_rec.currency_code := null;
2694 g_po_hdrs_int_rec.cpa_reference := null;
2695 g_po_hdrs_int_rec.created_language := null;
2696 g_po_hdrs_int_rec.comments := null;
2697
2698 l_err_loc := 1200;
2699 insertPOHeadersInterface;
2700
2701 l_err_loc := 1300;
2702 populatePOInterfaceTables('INLOOP');
2703 END LOOP; --FOR LOOP of l_req_template_name_tbl
2704
2705 l_err_loc := 1400;
2706 EXIT WHEN l_req_template_name_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
2707
2708 l_err_loc := 1500;
2709 EXCEPTION
2710 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
2711 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
2712 || '-' || l_err_loc
2713 || ', Total processeded batches:' || l_batch_count
2714 || ', Cursor will be reopened with l_req_template_name_tbl:' || l_start_template_id;
2715 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
2716 CLOSE l_reqTemplateHdr_csr;
2717 openReqTemplatesHdrsCsr(l_start_template_id, l_reqTemplateHdr_csr);
2718 END;
2719 END LOOP; --CURSOR LOOP
2720
2721 l_err_loc := 1600;
2722 populatePOInterfaceTables('OUTLOOP');
2723
2724 l_err_loc := 1700;
2725 IF (l_reqTemplateHdr_csr%ISOPEN) THEN
2726 CLOSE l_reqTemplateHdr_csr;
2727 END IF;
2728
2729 l_err_loc := 1800;
2730 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2731 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2732 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2733 'processReqTemplates Headers done; ' ||
2734 'Total no: of batches processed:' || l_batch_count ||
2735 ', Total no: of Req Templates headers processed:' || l_ext_row_count);
2736 END IF;
2737
2738 l_start_rt_item_id := 0;
2739 l_batch_count := 0;
2740 l_ext_row_count := 0;
2741 --Assign the previous po_line_id to some dummy values
2742 l_prev_rt_item_id := -1212;
2743
2744 l_err_loc := 1900;
2745 openReqTemplatesLinesCsr(l_start_rt_item_id, l_reqTemplateLine_csr);
2746
2747 l_err_loc := 2000;
2748 LOOP
2749 l_rt_item_id_tbl.DELETE;
2750 l_language_tbl.DELETE;
2751 l_interface_header_id_tbl.DELETE;
2752 l_req_template_name_tbl.DELETE;
2753 l_req_template_line_num_tbl.DELETE;
2754 l_inventory_item_id_tbl.DELETE;
2755 l_org_id_tbl.DELETE;
2756 l_supplier_part_auxid_tbl.DELETE;
2757 l_catalog_name_tbl.DELETE;
2758 l_primary_category_id_tbl.DELETE;
2759 l_attr_val_tlp_action_tbl.DELETE;
2760
2761 BEGIN
2762 l_err_loc := 2100;
2763 FETCH l_reqTemplateLine_csr BULK COLLECT INTO
2764 l_rt_item_id_tbl, l_language_tbl, l_interface_header_id_tbl,
2765 l_req_template_name_tbl, l_req_template_line_num_tbl,
2766 l_inventory_item_id_tbl, l_org_id_tbl, l_supplier_part_auxid_tbl,
2767 l_catalog_name_tbl, l_primary_category_id_tbl,
2768 l_attr_val_tlp_action_tbl
2769 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
2770
2771 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2772 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2773 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2774 'Total no: of Req Templates lines fetched from the cursor:' ||
2775 l_rt_item_id_tbl.COUNT);
2776 END IF;
2777
2778 l_err_loc := 2200;
2779 EXIT WHEN l_rt_item_id_tbl.COUNT = 0;
2780
2781 l_err_loc := 2300;
2782 l_batch_count := l_batch_count + 1;
2783
2784 l_err_loc := 2400;
2785 --Save the last rt_item_id processed, so that re-open of cursor will start from the saved rt_item_id.
2786 l_start_rt_item_id := l_rt_item_id_tbl(l_rt_item_id_tbl.COUNT);
2787
2788 l_err_loc := 2500;
2789 l_ext_row_count := l_ext_row_count + l_rt_item_id_tbl.COUNT;
2790
2791 l_err_loc := 2600;
2792 FOR i in 1..l_rt_item_id_tbl.COUNT LOOP
2793 l_err_loc := 2700;
2794 IF (l_prev_rt_item_id <> l_rt_item_id_tbl(i)) THEN
2795 l_interface_line_id := getNextInterfaceLineIdFromSeq;
2796
2797 l_err_loc := 2800;
2798 g_po_line_attrval_int_rec.interface_line_id := l_interface_line_id;
2799 g_po_line_attrval_int_rec.interface_header_id := l_interface_header_id_tbl(i);
2800 g_po_line_attrval_int_rec.req_template_name := l_req_template_name_tbl(i);
2801 g_po_line_attrval_int_rec.req_template_line_num := l_req_template_line_num_tbl(i);
2802 g_po_line_attrval_int_rec.inventory_item_id := l_inventory_item_id_tbl(i);
2803 g_po_line_attrval_int_rec.org_id := l_org_id_tbl(i);
2804 g_po_line_attrval_int_rec.rt_item_id := l_rt_item_id_tbl(i);
2805 g_po_line_attrval_int_rec.language := l_language_tbl(i);
2806 g_po_line_attrval_int_rec.supplier_part_auxid := l_supplier_part_auxid_tbl(i);
2807 g_po_line_attrval_int_rec.catalog_name := l_catalog_name_tbl(i);
2808 g_po_line_attrval_int_rec.ip_category_id := l_primary_category_id_tbl(i);
2809 --The following will be null in po_lines_interface
2810 --when moving item attributes for req templates
2811 g_po_line_attrval_int_rec.po_header_id := null;
2812 g_po_line_attrval_int_rec.unit_price := null;
2813 g_po_line_attrval_int_rec.uom_code := null;
2814 g_po_line_attrval_int_rec.negotiated_by_preparer_flag := null;
2815 g_po_line_attrval_int_rec.category_id := null;
2816 g_po_line_attrval_int_rec.category_name := null;
2817 g_po_line_attrval_int_rec.vendor_product_num := null;
2818 g_po_line_attrval_int_rec.item_description := null;
2819
2820 l_err_loc := 2900;
2821 g_po_line_attrval_int_rec.po_line_id := null;
2822 g_po_line_attrval_int_rec.action := 'REQTEMPLATE';
2823 insertPOLinesInterface;
2824
2825 g_po_line_attrval_int_rec.po_line_id := TO_NUMBER(ICX_CAT_UTIL_PVT.g_NULL_NUMBER);
2826 g_po_line_attrval_int_rec.action := 'UPDATE';
2827 insertPOAttrValsInterface;
2828 END IF;
2829
2830 l_err_loc := 3000;
2831 g_po_attrvalstlp_int_rec.interface_header_id := l_interface_header_id_tbl(i);
2832 g_po_attrvalstlp_int_rec.interface_line_id := l_interface_line_id;
2833 g_po_attrvalstlp_int_rec.action := l_attr_val_tlp_action_tbl(i);
2834 g_po_attrvalstlp_int_rec.po_line_id := TO_NUMBER(ICX_CAT_UTIL_PVT.g_NULL_NUMBER);
2835 g_po_attrvalstlp_int_rec.req_template_name := l_req_template_name_tbl(i);
2836 g_po_attrvalstlp_int_rec.req_template_line_num := l_req_template_line_num_tbl(i);
2837 g_po_attrvalstlp_int_rec.inventory_item_id := l_inventory_item_id_tbl(i);
2838 g_po_attrvalstlp_int_rec.org_id := l_org_id_tbl(i);
2839 g_po_attrvalstlp_int_rec.language := l_language_tbl(i);
2840 IF (l_language_tbl(i) = ICX_CAT_UTIL_PVT.g_base_language) THEN
2841 g_po_attrvalstlp_int_rec.check_desc_update := ICX_CAT_UTIL_PVT.g_donot_update_description;
2842 ELSE
2843 g_po_attrvalstlp_int_rec.check_desc_update := ICX_CAT_UTIL_PVT.g_update_description;
2844 END IF;
2845 g_po_attrvalstlp_int_rec.rt_item_id := l_rt_item_id_tbl(i);
2846
2847 l_err_loc := 3100;
2848 insertPOAttrValsTLPInterface;
2849
2850 l_err_loc := 3200;
2851 /* TO BE WORKED ON
2852 -- Statement level log
2853 fnd_file.put_line(fnd_file.log, g_pkg_name || '.' || l_api_name || ';' || logCurrentRow);
2854 */
2855
2856 l_err_loc := 3300;
2857 l_prev_rt_item_id := l_rt_item_id_tbl(i);
2858
2859 l_err_loc := 3400;
2860 populatePOInterfaceTables('INLOOP');
2861 END LOOP; --FOR LOOP of l_rt_item_id_tbl
2862
2863 l_err_loc := 3500;
2864 EXIT WHEN l_rt_item_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
2865
2866 l_err_loc := 3600;
2867 EXCEPTION
2868 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
2869 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
2870 || '-' || l_err_loc
2871 || ', Total processeded batches:' || l_batch_count
2872 || ', Cursor will be reopened with po_line_id:' || l_start_rt_item_id;
2873 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
2874 CLOSE l_reqTemplateLine_csr;
2875 openReqTemplatesLinesCsr(l_start_rt_item_id, l_reqTemplateLine_csr);
2876 END;
2877 END LOOP; --CURSOR LOOP
2878
2879 l_err_loc := 3700;
2880 populatePOInterfaceTables('OUTLOOP');
2881
2882 l_err_loc := 3800;
2883 IF (l_reqTemplateLine_csr%ISOPEN) THEN
2884 CLOSE l_reqTemplateLine_csr;
2885 END IF;
2886
2887 l_err_loc := 3900;
2888 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2889 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2890 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2891 'done. ' ||
2892 'Total no: of batches processed:' || l_batch_count ||
2893 ', Total no: of Req Templates lines processed:' || l_ext_row_count);
2894 END IF;
2895
2896 l_end_date := sysdate;
2897 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
2898 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
2899 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
2900 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
2901 END IF;
2902 EXCEPTION
2903 WHEN OTHERS THEN
2904 ICX_CAT_UTIL_PVT.logUnexpectedException(
2905 G_PKG_NAME, l_api_name,
2906 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2907 raise;
2908 END processReqTemplates;
2909
2910 PROCEDURE moveExtItemsBaseAndLocalAttr
2911 IS
2912 l_api_name CONSTANT VARCHAR2(30) := 'moveExtItemsBaseAndLocalAttr';
2913 l_err_loc PLS_INTEGER;
2914 BEGIN
2915 l_err_loc := 100;
2916 --Comments: Three different procedures needed to:
2917 --1. Process Blankets and Quotations:
2918 -- Populate po headers, lines, attributes and attributes_tlp interface tables.
2919 --2. Process Requisition templates:
2920 -- populate po attributes and attributes_tlp interface tables
2921 -- and dummy lines in po headers interface for each express_name and org_id
2922 -- and dummy lines in po_lines interface for each line in a requisition template (express_name).
2923 processBlanketsAndQuotes;
2924
2925 l_err_loc := 200;
2926 processReqTemplates;
2927
2928 l_err_loc := 300;
2929 EXCEPTION
2930 WHEN OTHERS THEN
2931 ICX_CAT_UTIL_PVT.logUnexpectedException(
2932 G_PKG_NAME, l_api_name,
2933 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
2934 raise;
2935 END moveExtItemsBaseAndLocalAttr;
2936
2937 PROCEDURE openContractAutoSourcingCsr
2938 ( p_contractAutoSourcing_csr IN OUT NOCOPY g_csr_type
2939 )
2940 IS
2941 l_api_name CONSTANT VARCHAR2(30) := 'openContractAutoSourcingCsr';
2942 l_err_loc PLS_INTEGER;
2943 BEGIN
2944 l_err_loc := 100;
2945 IF (g_bulk_last_run_date IS NULL) THEN
2946 l_err_loc := 110;
2947 -- Added NVL to org_id, supplier, site and currency
2948 OPEN p_contractAutoSourcing_csr FOR
2949 SELECT NVL(price.org_id, -2), NVL(itemtlp.supplier_id, -2), NVL(price.supplier_site_id, -2),
2950 NVL(price.currency, '-2'), NVL(price.contract_id, -2) contract_id,
2951 NVL(map.external_source_key, '-2') po_category_id
2952 FROM icx_cat_item_prices price,
2953 icx_cat_items_tlp itemtlp,
2954 icx_por_category_order_map map
2955 WHERE price.price_type = 'BULKLOAD'
2956 AND price.rt_item_id = itemtlp.rt_item_id
2957 AND NOT EXISTS (SELECT 'extracted price'
2958 FROM icx_cat_item_prices priceIn
2959 WHERE priceIn.rt_item_id = price.rt_item_id
2960 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
2961 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
2962 AND itemtlp.primary_category_id = map.rt_category_id (+)
2963 GROUP BY price.org_id, itemtlp.supplier_id, price.supplier_site_id,
2964 price.currency, price.contract_id, map.external_source_key
2965 ORDER BY price.org_id;
2966 ELSE
2967 l_err_loc := 120;
2968 OPEN p_contractAutoSourcing_csr FOR
2969 SELECT NVL(price.org_id, -2), NVL(itemtlp.supplier_id, -2), NVL(price.supplier_site_id, -2),
2970 NVL(price.currency, '-2'), NVL(price.contract_id, -2) contract_id,
2971 NVL(map.external_source_key, '-2') po_category_id
2972 FROM icx_cat_item_prices price,
2973 icx_cat_items_tlp itemtlp,
2974 icx_por_category_order_map map,
2975 icx_cat_items_b itemb,
2976 icx_cat_ext_items_tlp extitemtlp,
2977 icx_cat_r12_upgrade upg
2978 WHERE price.price_type = 'BULKLOAD'
2979 AND price.rt_item_id = itemtlp.rt_item_id
2980 AND NOT EXISTS (SELECT 'extracted price'
2981 FROM icx_cat_item_prices priceIn
2982 WHERE priceIn.rt_item_id = price.rt_item_id
2983 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
2984 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
2985 AND itemtlp.primary_category_id = map.rt_category_id (+)
2986 AND price.rt_item_id = itemb.rt_item_id
2987 AND price.rt_item_id = extitemtlp.rt_item_id
2988 AND itemtlp.language = extitemtlp.language
2989 AND price.rt_item_id = upg.rt_item_id (+)
2990 AND price.supplier_site_id = upg.supplier_site_id (+)
2991 AND price.currency = upg.currency (+)
2992 AND price.contract_id = upg.price_contract_id (+)
2993 AND ( -- Last update changes in items / price tables
2994 (itemb.last_update_date > g_bulk_last_run_date
2995 OR itemtlp.last_update_date > g_bulk_last_run_date
2996 OR extitemtlp.last_update_date > g_bulk_last_run_date
2997 OR price.last_update_date > g_bulk_last_run_date)
2998 OR -- The items that errored out in the previous run
2999 (upg.po_header_id is null
3000 OR upg.po_line_id is null))
3001 GROUP BY price.org_id, itemtlp.supplier_id, price.supplier_site_id,
3002 price.currency, price.contract_id, map.external_source_key
3003 ORDER BY price.org_id;
3004 END IF;
3005
3006 l_err_loc := 130;
3007 EXCEPTION
3008 WHEN OTHERS THEN
3009 ICX_CAT_UTIL_PVT.logUnexpectedException(
3010 G_PKG_NAME, l_api_name,
3011 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
3012 RAISE;
3013 END openContractAutoSourcingCsr;
3014
3015 PROCEDURE contractAutoSourcing
3016 IS
3017
3018 ----- Start of declaring columns selected in the cursor -----
3019
3020 l_org_id_tbl DBMS_SQL.NUMBER_TABLE;
3021 l_supplier_id_tbl DBMS_SQL.NUMBER_TABLE;
3022 l_supplier_site_id_tbl DBMS_SQL.NUMBER_TABLE;
3023 l_currency_tbl DBMS_SQL.VARCHAR2_TABLE;
3024 l_contract_id_tbl DBMS_SQL.NUMBER_TABLE;
3025 l_po_category_id_tbl DBMS_SQL.VARCHAR2_TABLE;
3026
3027 ------ End of declaring columns selected in the cursor ------
3028
3029 l_api_name CONSTANT VARCHAR2(30) := 'contractAutoSourcing';
3030 l_err_loc PLS_INTEGER;
3031 l_prev_org_id NUMBER := -1212;
3032
3033 l_supplier_site_id NUMBER := NULL;
3034 l_supplier_contact_id NUMBER := NULL;
3035 l_source_organization_id NUMBER := NULL;
3036 l_source_subinventory VARCHAR2(10) := '';
3037 l_document_header_id NUMBER := NULL;
3038 l_document_line_id NUMBER := NULL;
3039 l_document_type_code po_headers_all.type_lookup_code%TYPE := '';
3040 l_document_line_num NUMBER := NULL;
3041 l_buyer_id NUMBER := NULL;
3042 l_vendor_product_num po_lines_all.vendor_product_num%TYPE := '';
3043 l_purchasing_uom PO_LINES_ALL.unit_meas_lookup_code%TYPE := '';
3044 l_icx_schema_name VARCHAR2(30) := NULL;
3045
3046 l_as_index PLS_INTEGER := 0;
3047 l_as_org_id_tbl DBMS_SQL.NUMBER_TABLE;
3048 l_as_supplier_id_tbl DBMS_SQL.NUMBER_TABLE;
3049 l_as_supplier_site_id_tbl DBMS_SQL.NUMBER_TABLE;
3050 l_as_currency_tbl DBMS_SQL.VARCHAR2_TABLE;
3051 l_as_contract_id_tbl DBMS_SQL.NUMBER_TABLE;
3052 l_as_po_category_id_tbl DBMS_SQL.VARCHAR2_TABLE;
3053 l_contractAutoSourcing_csr g_csr_type;
3054 l_start_date DATE;
3055 l_end_date DATE;
3056 l_log_string VARCHAR2(2000);
3057
3058 BEGIN
3059 l_err_loc := 100;
3060
3061 l_err_loc := 110;
3062 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3063 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3064 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3065 'Start =======');
3066 END IF;
3067
3068 l_err_loc := 120;
3069 openContractAutoSourcingCsr(l_contractAutoSourcing_csr);
3070
3071 l_err_loc := 130;
3072 --Not expecting a huge number of GBPA header's that will be returned from the cursor.
3073 --Considering the fact that we are grouping by on supplier_id, org_id, supplier_site_id, currency and language
3074 FETCH l_contractAutoSourcing_csr BULK COLLECT INTO
3075 l_org_id_tbl, l_supplier_id_tbl, l_supplier_site_id_tbl,
3076 l_currency_tbl, l_contract_id_tbl, l_po_category_id_tbl;
3077
3078 l_err_loc := 140;
3079 CLOSE l_contractAutoSourcing_csr;
3080
3081 l_err_loc := 150;
3082 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3083 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3084 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3085 'Total no: of distinct contract auto source attributes found:' || l_org_id_tbl.COUNT);
3086 END IF;
3087
3088 l_err_loc := 160;
3089 FOR i in 1..l_org_id_tbl.COUNT LOOP
3090
3091 l_err_loc := 170;
3092 IF (l_org_id_tbl(i) <> ICX_CAT_UTIL_PVT.g_NULL_NUMBER AND
3093 l_supplier_site_id_tbl(i) <> ICX_CAT_UTIL_PVT.g_NULL_NUMBER AND
3094 l_po_category_id_tbl(i) <> ICX_CAT_UTIL_PVT.g_NULL_CHAR)
3095 THEN
3096 l_err_loc := 190;
3097 -- Set the org context if the org has changed
3098 IF (l_prev_org_id <> l_org_id_tbl(i)) THEN
3099 l_err_loc := 210;
3100 MO_GLOBAL.set_policy_context('S', l_org_id_tbl(i));
3101 END IF;
3102
3103 l_err_loc := 220;
3104 -- Try to find a suitable source document for the given attributes
3105 l_supplier_site_id := l_supplier_site_id_tbl(i);
3106
3107 IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3108 l_start_date := sysdate;
3109 l_log_string := 'About to call po_autosource_sv.autosource at:' ||
3110 TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ||
3111 '; Parameter passed: l_currency_tbl:' || l_currency_tbl(i) ||
3112 ', l_supplier_id_tbl:' || l_supplier_id_tbl(i) ||
3113 ', l_supplier_site_id:' || l_supplier_site_id ||
3114 ', l_org_id_tbl:' || l_org_id_tbl(i) ||
3115 ', l_po_category_id_tbl:' || l_po_category_id_tbl(i) ;
3116 FND_LOG.string(FND_LOG.LEVEL_EVENT,
3117 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3118 l_log_string);
3119 END IF;
3120
3121 po_autosource_sv.autosource
3122 (x_mode => 'DOCUMENT',
3123 x_destination_doc_type => 'REQ',
3124 x_item_id => NULL,
3125 x_commodity_id => l_po_category_id_tbl(i),
3126 x_dest_organization_id => TO_NUMBER(NULL),
3127 x_dest_subinventory => NULL,
3128 x_autosource_date => TO_DATE(NULL),
3129 x_item_rev => NULL,
3130 x_currency_code => l_currency_tbl(i),
3131 x_vendor_id => l_supplier_id_tbl(i),
3132 x_vendor_site_id => l_supplier_site_id,
3133 x_vendor_contact_id => l_supplier_contact_id,
3134 x_source_organization_id => l_source_organization_id,
3135 x_source_subinventory => l_source_subinventory,
3136 x_document_header_id => l_document_header_id,
3137 x_document_line_id => l_document_line_id,
3138 x_document_type_code => l_document_type_code,
3139 x_document_line_num => l_document_line_num,
3140 x_buyer_id => l_buyer_id,
3141 x_vendor_product_num => l_vendor_product_num,
3142 x_purchasing_uom => l_purchasing_uom);
3143
3144 l_err_loc := 230;
3145
3146 IF (FND_LOG.LEVEL_EVENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3147 l_end_date := sysdate;
3148 l_log_string := ' done in:' ||
3149 ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date) ||
3150 '; Values returned: l_document_header_id:' || l_document_header_id ||
3151 ', l_document_type_code:' || l_document_type_code ||
3152 ', l_supplier_site_id:' || l_supplier_site_id ||
3153 ', l_document_line_id:' || l_document_line_id ||
3154 ', l_document_line_num:' || l_document_line_num ||
3155 ', l_vendor_product_num:' || l_vendor_product_num ||
3156 ', l_purchasing_uom:' || l_purchasing_uom ;
3157 FND_LOG.string(FND_LOG.LEVEL_EVENT,
3158 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3159 l_log_string);
3160 END IF;
3161
3162 IF (l_document_header_id IS NULL) THEN
3163 l_document_header_id := ICX_CAT_UTIL_PVT.g_NULL_NUMBER;
3164 END IF;
3165 ELSE
3166 l_err_loc := 240;
3167 -- Just insert into the icx_cat_r12_upgrade_autosource
3168 l_document_header_id := l_contract_id_tbl(i);
3169 END IF;
3170
3171 l_err_loc := 270;
3172 l_as_index := l_as_index + 1;
3173 l_as_org_id_tbl(l_as_index) := l_org_id_tbl(i);
3174 l_as_supplier_id_tbl(l_as_index) := l_supplier_id_tbl(i);
3175 l_as_supplier_site_id_tbl(l_as_index) := l_supplier_site_id_tbl(i);
3176 l_as_currency_tbl(l_as_index) := l_currency_tbl(i);
3177 l_as_contract_id_tbl(l_as_index) := l_document_header_id;
3178 l_as_po_category_id_tbl(l_as_index) := l_po_category_id_tbl(i);
3179
3180 l_err_loc := 280;
3181 l_prev_org_id := l_org_id_tbl(i);
3182 END LOOP; --FOR LOOP of l_org_id_tbl
3183
3184 l_err_loc := 285;
3185 l_icx_schema_name := ICX_CAT_UTIL_PVT.getIcxSchemaName;
3186
3187 l_err_loc := 290;
3188 EXECUTE IMMEDIATE
3189 'TRUNCATE TABLE '|| l_icx_schema_name ||'.icx_cat_r12_upg_autosource';
3190
3191 l_err_loc := 295;
3192 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3193 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3194 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3195 'truncate table icx_cat_r12_upg_autosource done:');
3196 END IF;
3197
3198 l_err_loc := 300;
3199 FORALL i IN 1..l_as_org_id_tbl.COUNT
3200 INSERT INTO icx_cat_r12_upg_autosource
3201 (org_id, supplier_id, supplier_site_id, currency,
3202 contract_id, po_category_id,
3203 last_update_login, last_updated_by, last_update_date,
3204 created_by, creation_date, internal_request_id, request_id,
3205 program_application_id, program_id, program_login_id)
3206 VALUES
3207 (l_as_org_id_tbl(i), l_as_supplier_id_tbl(i),
3208 l_as_supplier_site_id_tbl(i), l_as_currency_tbl(i),
3209 l_as_contract_id_tbl(i), l_as_po_category_id_tbl(i),
3210 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
3211 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
3212 ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
3213 ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
3214 ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
3215 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
3216 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
3217 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id);
3218
3219 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3220 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3221 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3222 'No: of rows inserted in autosource:' || SQL%ROWCOUNT);
3223 END IF;
3224
3225 l_err_loc := 305;
3226 COMMIT;
3227
3228 l_err_loc := 310;
3229 l_as_org_id_tbl.DELETE;
3230 l_as_supplier_id_tbl.DELETE;
3231 l_as_supplier_site_id_tbl.DELETE;
3232 l_as_currency_tbl.DELETE;
3233 l_as_contract_id_tbl.DELETE;
3234 l_as_po_category_id_tbl.DELETE;
3235
3236 l_err_loc := 320;
3237 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3238 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3239 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3240 'done.');
3241 END IF;
3242
3243 EXCEPTION
3244 WHEN OTHERS THEN
3245 ICX_CAT_UTIL_PVT.logUnexpectedException(
3246 G_PKG_NAME, l_api_name,
3247 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
3248 raise;
3249 END contractAutoSourcing;
3250
3251 PROCEDURE checkAndProcessGBPALines
3252 IS
3253 -- outer join with icx_cat_r12_upgrade, on rt_item_id (i.e. org_id and supplier_id),
3254 -- supplier_site_id, currency and contract_id (pricing attributes)
3255 -- join with contract_id needed because the items with the same combination of the above
3256 -- could exist in two contracts.
3257 -- outer join needed: because we need to find the items that were already processed in
3258 -- processGBPALines and the rows in the current cursor are just translations.
3259 -- We need price_type, to getthe price_contract_id and src_contract_id
3260 -- because if autosource returned a contract_id
3261 -- then src.contract_id will not be same as price.contract_id.
3262 CURSOR checkAndProcessGBPALinesCsr(p_org_id NUMBER, p_supplier_id NUMBER,
3263 p_supplier_site_id NUMBER, p_currency VARCHAR2,
3264 p_cpa_reference NUMBER, p_language VARCHAR2,
3265 p_start_rt_item_id NUMBER) IS
3266 SELECT itemtlp.rt_item_id, price.unit_price, price.unit_of_measure,
3267 DECODE(NVL(price.negotiated_by_preparer_flag, '1'), '0', 'N', 'Y'),
3268 itemtlp.primary_category_id, NVL(map.external_source_key, '-2') po_category_id,
3269 SUBSTRB(itemtlp.supplier_part_num, 1, 25) supplier_part_num,
3270 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
3271 SUBSTRB(itemtlp.description, 1, 240) description, itemsb.catalog_name,
3272 upg.po_interface_header_id, upg.created_language, upg.po_interface_line_id,
3273 price.price_type, itemtlp.primary_category_name
3274 FROM icx_cat_item_prices price, icx_cat_items_tlp itemtlp, icx_cat_items_b itemsb,
3275 icx_por_category_order_map map, icx_cat_r12_upg_autosource src,
3276 icx_cat_r12_upgrade upg
3277 WHERE price.price_type = 'BULKLOAD'
3278 AND price.rt_item_id = itemtlp.rt_item_id
3279 AND price.rt_item_id = itemsb.rt_item_id
3280 AND NOT EXISTS (SELECT 'extracted price'
3281 FROM icx_cat_item_prices priceIn
3282 WHERE priceIn.rt_item_id = price.rt_item_id
3283 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
3284 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
3285 AND itemtlp.primary_category_id = map.rt_category_id (+)
3286 AND itemtlp.org_id = src.org_id
3287 AND itemtlp.supplier_id = src.supplier_id
3288 AND price.supplier_site_id = src.supplier_site_id
3289 AND price.currency = src.currency
3290 AND NVL(map.external_source_key, '-2') = src.po_category_id
3291 AND price.rt_item_id = upg.rt_item_id (+)
3292 AND price.supplier_site_id = upg.supplier_site_id (+)
3293 AND price.currency = upg.currency (+)
3294 AND price.contract_id = upg.price_contract_id (+)
3295 AND itemtlp.rt_item_id >= p_start_rt_item_id
3296 AND itemtlp.language = p_language
3297 AND src.org_id = p_org_id
3298 AND src.supplier_id = p_supplier_id
3299 AND src.supplier_site_id = p_supplier_site_id
3300 AND src.currency = p_currency
3301 AND src.contract_id = p_cpa_reference
3302 UNION ALL
3303 SELECT itemtlp.rt_item_id, price.unit_price, price.unit_of_measure,
3304 DECODE(NVL(price.negotiated_by_preparer_flag, '1'), '0', 'N', 'Y'),
3305 itemtlp.primary_category_id, NVL(map.external_source_key, '-2') po_category_id,
3306 SUBSTRB(itemtlp.supplier_part_num, 1, 25) supplier_part_num,
3307 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
3308 SUBSTRB(itemtlp.description, 1, 240) description, itemsb.catalog_name,
3309 upg.po_interface_header_id, upg.created_language, upg.po_interface_line_id,
3310 price.price_type, itemtlp.primary_category_name
3311 FROM icx_cat_item_prices price, icx_cat_items_tlp itemtlp, icx_cat_items_b itemsb,
3312 icx_por_category_order_map map, icx_cat_r12_upgrade upg
3313 WHERE price.price_type = 'CONTRACT'
3314 AND price.rt_item_id = itemtlp.rt_item_id
3315 AND price.rt_item_id = itemsb.rt_item_id
3316 AND NOT EXISTS (SELECT 'extracted price'
3317 FROM icx_cat_item_prices priceIn
3318 WHERE priceIn.rt_item_id = price.rt_item_id
3319 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
3320 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
3321 AND itemtlp.primary_category_id = map.rt_category_id (+)
3322 AND price.rt_item_id = upg.rt_item_id (+)
3323 AND price.supplier_site_id = upg.supplier_site_id (+)
3324 AND price.currency = upg.currency (+)
3325 AND price.contract_id = upg.price_contract_id (+)
3326 AND itemtlp.rt_item_id >= p_start_rt_item_id
3327 AND itemtlp.language = p_language
3328 AND itemtlp.org_id = p_org_id
3329 AND itemtlp.supplier_id = p_supplier_id
3330 AND price.supplier_site_id = p_supplier_site_id
3331 AND price.currency = p_currency
3332 AND price.contract_id = p_cpa_reference
3333 ORDER BY 1;
3334
3335 ----- Start of declaring columns selected in the cursor -----
3336
3337 l_rt_item_id_tbl DBMS_SQL.NUMBER_TABLE;
3338 l_unit_price_tbl DBMS_SQL.NUMBER_TABLE;
3339 l_unit_of_measure_tbl DBMS_SQL.VARCHAR2_TABLE;
3340 l_neg_by_prep_flag_tbl DBMS_SQL.VARCHAR2_TABLE;
3341 l_primary_category_id_tbl DBMS_SQL.NUMBER_TABLE;
3342 l_po_category_id_tbl DBMS_SQL.VARCHAR2_TABLE;
3343 l_supp_part_num_tbl DBMS_SQL.VARCHAR2_TABLE;
3344 l_supp_part_auxid_tbl DBMS_SQL.VARCHAR2_TABLE;
3345 l_description_tbl DBMS_SQL.VARCHAR2_TABLE;
3346 l_catalog_name_tbl DBMS_SQL.VARCHAR2_TABLE;
3347 l_po_interface_header_id_tbl DBMS_SQL.NUMBER_TABLE;
3348 l_upg_created_language_tbl DBMS_SQL.VARCHAR2_TABLE;
3349 l_po_interface_line_id_tbl DBMS_SQL.NUMBER_TABLE;
3350 l_price_type_tbl DBMS_SQL.VARCHAR2_TABLE;
3351 l_primary_category_name_tbl DBMS_SQL.VARCHAR2_TABLE;
3352
3353 ------ End of declaring columns selected in the cursor ------
3354
3355 l_api_name CONSTANT VARCHAR2(30) := 'checkAndProcessGBPALines';
3356 l_err_loc PLS_INTEGER;
3357 l_err_string VARCHAR2(4000);
3358 l_start_rt_item_id NUMBER;
3359 l_batch_count PLS_INTEGER;
3360 l_item_row_count PLS_INTEGER;
3361 l_interface_line_id NUMBER;
3362 l_interface_header_id NUMBER;
3363 l_po_category_id NUMBER;
3364 l_start_date DATE;
3365 l_end_date DATE;
3366 l_log_string VARCHAR2(2000);
3367 l_log_index NUMBER := 1;
3368 BEGIN
3369 l_err_loc := 100;
3370 l_start_date := sysdate;
3371
3372 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3373 l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
3374 ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
3375 END IF;
3376
3377 l_err_loc := 110;
3378 l_start_rt_item_id := 0;
3379 l_batch_count := 0;
3380 l_item_row_count := 0;
3381
3382 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3383 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3384 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3385 'Current Values in g_current_gbpa_hdr_rec:'||
3386 ', org_id:' ||g_current_gbpa_hdr_rec.org_id ||
3387 ', supplier_id:' ||g_current_gbpa_hdr_rec.vendor_id ||
3388 ', supplier_site_id:' ||g_current_gbpa_hdr_rec.vendor_site_id ||
3389 ', currency:' ||g_current_gbpa_hdr_rec.currency_code ||
3390 ', gbpa_cpa_reference:' ||g_current_gbpa_hdr_rec.cpa_reference ||
3391 ', language:' ||g_current_gbpa_hdr_rec.language ||
3392 ', interface_header_id:' ||g_current_gbpa_hdr_rec.interface_header_id );
3393 END IF;
3394
3395 -- line_type will be defaulted by PDOI.
3396 l_err_loc := 120;
3397 OPEN checkAndProcessGBPALinesCsr(g_current_gbpa_hdr_rec.org_id, g_current_gbpa_hdr_rec.vendor_id,
3398 g_current_gbpa_hdr_rec.vendor_site_id, g_current_gbpa_hdr_rec.currency_code,
3399 g_current_gbpa_hdr_rec.cpa_reference, g_current_gbpa_hdr_rec.language,
3400 l_start_rt_item_id);
3401 LOOP
3402 l_err_loc := 130;
3403 l_rt_item_id_tbl.DELETE;
3404 l_unit_price_tbl.DELETE;
3405 l_unit_of_measure_tbl.DELETE;
3406 l_neg_by_prep_flag_tbl.DELETE;
3407 l_primary_category_id_tbl.DELETE;
3408 l_po_category_id_tbl.DELETE;
3409 l_supp_part_num_tbl.DELETE;
3410 l_supp_part_auxid_tbl.DELETE;
3411 l_description_tbl.DELETE;
3412 l_catalog_name_tbl.DELETE;
3413 l_po_interface_header_id_tbl.DELETE;
3414 l_upg_created_language_tbl.DELETE;
3415 l_po_interface_line_id_tbl.DELETE;
3416 l_price_type_tbl.DELETE;
3417 l_primary_category_name_tbl.DELETE;
3418
3419 BEGIN
3420 l_err_loc := 140;
3421 FETCH checkAndProcessGBPALinesCsr BULK COLLECT INTO
3422 l_rt_item_id_tbl, l_unit_price_tbl, l_unit_of_measure_tbl,
3423 l_neg_by_prep_flag_tbl, l_primary_category_id_tbl, l_po_category_id_tbl,
3424 l_supp_part_num_tbl, l_supp_part_auxid_tbl, l_description_tbl, l_catalog_name_tbl,
3425 l_po_interface_header_id_tbl, l_upg_created_language_tbl, l_po_interface_line_id_tbl,
3426 l_price_type_tbl, l_primary_category_name_tbl
3427 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
3428
3429 l_err_loc := 160;
3430 EXIT WHEN l_rt_item_id_tbl.COUNT = 0;
3431
3432 l_err_loc := 170;
3433 l_batch_count := l_batch_count + 1;
3434
3435 l_err_loc := 180;
3436 --Save the last rt_item_id processed,
3437 --so that re-open of cursor will start from the saved rt_item_id.
3438 l_start_rt_item_id := l_rt_item_id_tbl(l_rt_item_id_tbl.COUNT);
3439
3440 l_err_loc := 190;
3441 l_item_row_count := l_item_row_count + l_rt_item_id_tbl.COUNT;
3442
3443 l_err_loc := 200;
3444 FOR i in 1..l_rt_item_id_tbl.COUNT LOOP
3445 l_log_index := i;
3446 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3447 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3448 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3449 'Values fetched from the cursor; '||
3450 'l_rt_item_id_tbl:' || l_rt_item_id_tbl(i) ||
3451 ', l_supp_part_num_tbl:' || l_supp_part_num_tbl(i) ||
3452 ', item language:' || g_current_gbpa_hdr_rec.language ||
3453 ', l_price_type_tbl:' || l_price_type_tbl(i) ||
3454 ', l_po_interface_header_id_tbl:' || l_po_interface_header_id_tbl(i) ||
3455 ', l_upg_created_language_tbl:' || l_upg_created_language_tbl(i) ||
3456 ', l_po_interface_line_id_tbl:' || l_po_interface_line_id_tbl(i));
3457 END IF;
3458
3459 l_err_loc := 210;
3460 IF (l_po_interface_header_id_tbl(i) IS NULL) THEN
3461 IF (l_interface_header_id IS NULL) THEN
3462 --Create the header record only once for the
3463 --current combination of header attributes
3464 l_interface_header_id := getNextInterfaceHdrIdFromSeq;
3465 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3466 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3467 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3468 'about to create a new po_header_id with the following values' ||
3469 '--> l_interface_header_id set to :' || l_interface_header_id ||
3470 ', org_id:' || g_current_gbpa_hdr_rec.org_id ||
3471 ', vendor_id:' || g_current_gbpa_hdr_rec.vendor_id ||
3472 ', vendor_site_id:' || g_current_gbpa_hdr_rec.vendor_site_id ||
3473 ', currency_code:' || g_current_gbpa_hdr_rec.currency_code ||
3474 ', language:' || g_current_gbpa_hdr_rec.language);
3475 END IF;
3476
3477 l_err_loc := 215;
3478 g_po_hdrs_int_rec.interface_header_id := l_interface_header_id;
3479 g_po_hdrs_int_rec.action := 'ORIGINAL';
3480 g_po_hdrs_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
3481 g_po_hdrs_int_rec.document_type_code := 'BLANKET';
3482 g_po_hdrs_int_rec.budget_account_segment1 := null;
3483 g_po_hdrs_int_rec.po_header_id := null;
3484 g_po_hdrs_int_rec.approval_status := 'IN PROCESS';
3485 g_po_hdrs_int_rec.vendor_id := g_current_gbpa_hdr_rec.vendor_id;
3486 g_po_hdrs_int_rec.vendor_site_id := g_current_gbpa_hdr_rec.vendor_site_id;
3487 l_err_loc := 220;
3488 g_po_hdrs_int_rec.currency_code := g_current_gbpa_hdr_rec.currency_code;
3489 g_po_hdrs_int_rec.created_language := g_current_gbpa_hdr_rec.language;
3490 g_po_hdrs_int_rec.comments := g_new_GBPA_description;
3491
3492 l_err_loc := 230;
3493 IF (g_current_gbpa_hdr_rec.cpa_reference <> ICX_CAT_UTIL_PVT.g_NULL_NUMBER) THEN
3494 g_po_hdrs_int_rec.cpa_reference := g_current_gbpa_hdr_rec.cpa_reference;
3495 ELSE
3496 g_po_hdrs_int_rec.cpa_reference := null;
3497 END IF;
3498
3499 l_err_loc := 240;
3500 g_GBPA_hdr_count := g_GBPA_hdr_count + 1;
3501 insertPOHeadersInterface;
3502 END IF;
3503
3504 l_err_loc := 250;
3505 --Get the next interfaceLineId to be used in po_lines_interface,
3506 --po_attr_values_interface and po_attr_values_tlp_interface
3507 l_interface_line_id := getNextInterfaceLineIdFromSeq;
3508
3509 l_err_loc := 260;
3510 l_po_category_id := TO_NUMBER(l_po_category_id_tbl(i));
3511
3512 l_err_loc := 270;
3513 --Put the current values into g_po_line_attrval_int_rec for
3514 --po_lines_interface and po_attr_values_interface
3515 g_po_line_attrval_int_rec.interface_line_id := l_interface_line_id;
3516 g_po_line_attrval_int_rec.interface_header_id := l_interface_header_id;
3517 g_po_line_attrval_int_rec.action := 'ADD';
3518 g_po_line_attrval_int_rec.po_line_id := null;
3519 g_po_line_attrval_int_rec.po_header_id := null;
3520 l_err_loc := 272;
3521 g_po_line_attrval_int_rec.unit_price := l_unit_price_tbl(i);
3522 g_po_line_attrval_int_rec.uom_code := l_unit_of_measure_tbl(i);
3523 g_po_line_attrval_int_rec.negotiated_by_preparer_flag := l_neg_by_prep_flag_tbl(i);
3524 g_po_line_attrval_int_rec.ip_category_id := l_primary_category_id_tbl(i);
3525 g_po_line_attrval_int_rec.category_id := l_po_category_id;
3526 l_err_loc := 274;
3527 g_po_line_attrval_int_rec.category_name := l_primary_category_name_tbl(i);
3528 l_err_loc := 276;
3529 g_po_line_attrval_int_rec.vendor_product_num := l_supp_part_num_tbl(i);
3530 g_po_line_attrval_int_rec.supplier_part_auxid := l_supp_part_auxid_tbl(i);
3531 l_err_loc := 278;
3532 g_po_line_attrval_int_rec.item_description := l_description_tbl(i);
3533 l_err_loc := 280;
3534 g_po_line_attrval_int_rec.catalog_name := l_catalog_name_tbl(i);
3535 g_po_line_attrval_int_rec.req_template_name := '-2';
3536 g_po_line_attrval_int_rec.req_template_line_num := -2;
3537 g_po_line_attrval_int_rec.inventory_item_id := -2;
3538 g_po_line_attrval_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
3539 g_po_line_attrval_int_rec.rt_item_id := l_rt_item_id_tbl(i);
3540 g_po_line_attrval_int_rec.language := g_current_gbpa_hdr_rec.language;
3541
3542 l_err_loc := 282;
3543 -- Put the current values into g_po_attrvalstlp_int_rec for
3544 -- po_attr_values_tlp_interface
3545 g_po_attrvalstlp_int_rec.interface_header_id := l_interface_header_id;
3546 g_po_attrvalstlp_int_rec.interface_line_id := l_interface_line_id;
3547
3548 l_err_loc := 284;
3549 g_r12_upg_rec.rt_item_id := l_rt_item_id_tbl(i);
3550 g_r12_upg_rec.supplier_site_id := g_current_gbpa_hdr_rec.vendor_site_id;
3551 g_r12_upg_rec.currency := g_current_gbpa_hdr_rec.currency_code;
3552 -- icx_cat_r12_upgrade.price_contract_id is same as the contract_id in price table
3553 -- icx_cat_r12_upgrade.src_contract_id is same as the contract_id returned from autosource
3554 -- Need both contract_ids to figure out any changes in the source document during delta processing.
3555 l_err_loc := 285;
3556 IF (l_price_type_tbl(i) = 'BULKLOAD') THEN
3557 g_r12_upg_rec.price_contract_id := -2;
3558 g_r12_upg_rec.src_contract_id := g_current_gbpa_hdr_rec.cpa_reference;
3559 ELSE
3560 g_r12_upg_rec.price_contract_id := g_current_gbpa_hdr_rec.cpa_reference;
3561 g_r12_upg_rec.src_contract_id := -2;
3562 END IF;
3563 g_r12_upg_rec.cpa_reference := g_current_gbpa_hdr_rec.cpa_reference;
3564 l_err_loc := 287;
3565 g_r12_upg_rec.po_category_id := l_po_category_id_tbl(i);
3566 g_r12_upg_rec.po_interface_header_id := l_interface_header_id;
3567 g_r12_upg_rec.po_interface_line_id := l_interface_line_id;
3568 g_r12_upg_rec.created_language := g_current_gbpa_hdr_rec.language;
3569 -- TBD g_r12_upg_rec.extractor_updated_flag := 'N';
3570
3571 l_err_loc := 289;
3572 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3573 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3574 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3575 'inserting into lines, attr_values and r12 upgrade');
3576 END IF;
3577 l_err_loc := 290;
3578 --Add the current value to the global pl/sql tables
3579 insertPOLinesInterface;
3580 l_err_loc := 292;
3581 insertPOAttrValsInterface;
3582 l_err_loc := 294;
3583 insertR12Upgrade;
3584 ELSE --l_po_interface_header_id_tbl(i) IS NOT NULL
3585 --i.e. upg.rt_item_id = price.rt_item_id and
3586 --upg.created_language <> g_current_gbpa_hdr_rec.language
3587 --i.e. this is a translation row of an item already inserted
3588 --into po_lines_interface and po_attr_values_interface in processGBPALines
3589 --Put the current values into g_po_attrvalstlp_int_rec for it to be inserted into
3590 --po_attr_values_tlp_interface
3591 l_err_loc := 296;
3592 g_po_attrvalstlp_int_rec.interface_header_id := l_po_interface_header_id_tbl(i) ;
3593 g_po_attrvalstlp_int_rec.interface_line_id := l_po_interface_line_id_tbl(i);
3594 END IF;
3595
3596 g_po_attrvalstlp_int_rec.action := 'ADD';
3597 g_po_attrvalstlp_int_rec.po_line_id := null;
3598 g_po_attrvalstlp_int_rec.req_template_name := '-2';
3599 g_po_attrvalstlp_int_rec.req_template_line_num := -2;
3600 g_po_attrvalstlp_int_rec.inventory_item_id := -2;
3601 g_po_attrvalstlp_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
3602 l_err_loc := 297;
3603 g_po_attrvalstlp_int_rec.language := g_current_gbpa_hdr_rec.language;
3604 g_po_attrvalstlp_int_rec.check_desc_update := ICX_CAT_UTIL_PVT.g_update_description;
3605 g_po_attrvalstlp_int_rec.rt_item_id := l_rt_item_id_tbl(i);
3606
3607 l_err_loc := 298;
3608 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3609 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3610 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3611 'inserting only into attr_values_tlp');
3612 END IF;
3613 l_err_loc := 299;
3614 --Add the current value to the global pl/sql tables
3615 insertPOAttrValsTLPInterface;
3616
3617 l_err_loc := 300;
3618 populatePOInterfaceTables('INLOOP');
3619 END LOOP; --FOR LOOP of l_rt_item_id_tbl
3620
3621 l_err_loc := 310;
3622 EXIT WHEN l_rt_item_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
3623 EXCEPTION
3624 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
3625 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
3626 || '-' || l_err_loc
3627 || ', Total processeded batches:' || l_batch_count
3628 || ', Cursor will be reopened with rt_item_id:' || l_start_rt_item_id;
3629 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
3630 l_err_loc := 330;
3631 IF (checkAndProcessGBPALinesCsr%ISOPEN) THEN
3632 CLOSE checkAndProcessGBPALinesCsr;
3633 OPEN checkAndProcessGBPALinesCsr
3634 (g_current_gbpa_hdr_rec.org_id, g_current_gbpa_hdr_rec.vendor_id,
3635 g_current_gbpa_hdr_rec.vendor_site_id, g_current_gbpa_hdr_rec.currency_code,
3636 g_current_gbpa_hdr_rec.cpa_reference, g_current_gbpa_hdr_rec.language,
3637 l_start_rt_item_id);
3638 END IF;
3639 END;
3640 END LOOP; --CURSOR LOOP
3641
3642 l_err_loc := 350;
3643 populatePOInterfaceTables('OUTLOOP');
3644
3645 IF (checkAndProcessGBPALinesCsr%ISOPEN) THEN
3646 CLOSE checkAndProcessGBPALinesCsr;
3647 END IF;
3648
3649 l_err_loc := 360;
3650 g_total_bulkld_row_count := g_total_bulkld_row_count + l_item_row_count;
3651
3652 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3653 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3654 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3655 'done; '||
3656 'Total no: of batches processed:' || l_batch_count ||
3657 ', Total no: of bulkloaded items processed:' || l_item_row_count);
3658 END IF;
3659
3660 l_end_date := sysdate;
3661 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3662 ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
3663 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
3664 END IF;
3665 EXCEPTION
3666 WHEN OTHERS THEN
3667 ICX_CAT_UTIL_PVT.logUnexpectedException(
3668 G_PKG_NAME, l_api_name,
3669 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
3670
3671 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3672 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3673 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3674 'Current Values in g_current_gbpa_hdr_rec:'||
3675 ', org_id:' ||g_current_gbpa_hdr_rec.org_id ||
3676 ', supplier_id:' ||g_current_gbpa_hdr_rec.vendor_id ||
3677 ', supplier_site_id:' ||g_current_gbpa_hdr_rec.vendor_site_id ||
3678 ', currency:' ||g_current_gbpa_hdr_rec.currency_code ||
3679 ', gbpa_cpa_reference:' ||g_current_gbpa_hdr_rec.cpa_reference ||
3680 ', language:' ||g_current_gbpa_hdr_rec.language ||
3681 ', interface_header_id:' ||g_current_gbpa_hdr_rec.interface_header_id );
3682 END IF;
3683
3684 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3685 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3686 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3687 'Values fetched from the cursor; '||
3688 'l_rt_item_id_tbl:' || l_rt_item_id_tbl(l_log_index) ||
3689 ', l_supp_part_num_tbl:' || l_supp_part_num_tbl(l_log_index) ||
3690 ', l_supp_part_auxid_tbl:' || l_supp_part_auxid_tbl(l_log_index) ||
3691 ', l_unit_price_tbl:' || l_unit_price_tbl(l_log_index) ||
3692 ', l_unit_of_measure_tbl:' || l_unit_of_measure_tbl(l_log_index) ||
3693 ', l_neg_by_prep_flag_tbl:' || l_neg_by_prep_flag_tbl(l_log_index) ||
3694 ', l_primary_category_id_tbl:' || l_primary_category_id_tbl(l_log_index) ||
3695 ', l_po_category_id_tbl:' || l_po_category_id_tbl(l_log_index) ||
3696 ', l_price_type_tbl:' || l_price_type_tbl(l_log_index) ||
3697 ', l_po_interface_header_id_tbl:' || l_po_interface_header_id_tbl(l_log_index) ||
3698 ', l_upg_created_language_tbl:' || l_upg_created_language_tbl(l_log_index) ||
3699 ', l_po_interface_line_id_tbl:' || l_po_interface_line_id_tbl(l_log_index));
3700 END IF;
3701
3702 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3703 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
3704 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3705 'Values fetched from the cursor; '||
3706 'l_description_tbl:' || l_description_tbl(l_log_index) ||
3707 ', l_catalog_name_tbl:' || l_catalog_name_tbl(l_log_index) ||
3708 ', l_primary_category_name_tbl:' || l_primary_category_name_tbl(l_log_index));
3709 END IF;
3710
3711 raise;
3712 END checkAndProcessGBPALines;
3713
3714 PROCEDURE processGBPALines
3715 IS
3716 -- We need price_type, to getthe price_contract_id and src_contract_id
3717 -- because if autosource returned a contract_id
3718 -- then src.contract_id will not be same as price.contract_id.
3719 CURSOR processGBPALinesCsr(p_org_id NUMBER, p_supplier_id NUMBER,
3720 p_supplier_site_id NUMBER, p_currency VARCHAR2,
3721 p_cpa_reference NUMBER, p_language VARCHAR2,
3722 p_start_rt_item_id NUMBER) IS
3723 SELECT itemtlp.rt_item_id, price.unit_price, price.unit_of_measure,
3724 DECODE(NVL(price.negotiated_by_preparer_flag, '1'), '0', 'N', 'Y') negotiated_by_preparer_flag,
3725 itemtlp.primary_category_id, NVL(map.external_source_key, '-2') po_category_id,
3726 SUBSTRB(itemtlp.supplier_part_num, 1, 25) supplier_part_num,
3727 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
3728 SUBSTRB(itemtlp.description, 1, 240) description,
3729 itemsb.catalog_name, price.price_type, itemtlp.primary_category_name
3730 FROM icx_cat_item_prices price, icx_cat_items_tlp itemtlp, icx_cat_items_b itemsb,
3731 icx_por_category_order_map map, icx_cat_r12_upg_autosource src
3732 WHERE price.price_type = 'BULKLOAD'
3733 AND price.rt_item_id = itemtlp.rt_item_id
3734 AND price.rt_item_id = itemsb.rt_item_id
3735 AND NOT EXISTS (SELECT 'extracted price'
3736 FROM icx_cat_item_prices priceIn
3737 WHERE priceIn.rt_item_id = price.rt_item_id
3738 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
3739 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
3740 AND itemtlp.primary_category_id = map.rt_category_id (+)
3741 AND itemtlp.org_id = src.org_id
3742 AND itemtlp.supplier_id = src.supplier_id
3743 AND price.supplier_site_id = src.supplier_site_id
3744 AND price.currency = src.currency
3745 AND NVL(map.external_source_key, '-2') = src.po_category_id
3746 AND itemtlp.rt_item_id >= p_start_rt_item_id
3747 AND itemtlp.language = p_language
3748 AND src.org_id = p_org_id
3749 AND src.supplier_id = p_supplier_id
3750 AND src.supplier_site_id = p_supplier_site_id
3751 AND src.currency = p_currency
3752 AND src.contract_id = p_cpa_reference
3753 UNION ALL
3754 SELECT itemtlp.rt_item_id, price.unit_price, price.unit_of_measure,
3755 DECODE(NVL(price.negotiated_by_preparer_flag, '1'), '0', 'N', 'Y') negotiated_by_preparer_flag,
3756 itemtlp.primary_category_id, NVL(map.external_source_key, '-2') po_category_id,
3757 SUBSTRB(itemtlp.supplier_part_num, 1, 25) supplier_part_num,
3758 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
3759 SUBSTRB(itemtlp.description, 1, 240) description,
3760 itemsb.catalog_name, price.price_type, itemtlp.primary_category_name
3761 FROM icx_cat_item_prices price, icx_cat_items_tlp itemtlp, icx_cat_items_b itemsb,
3762 icx_por_category_order_map map
3763 WHERE price.price_type = 'CONTRACT'
3764 AND price.rt_item_id = itemtlp.rt_item_id
3765 AND price.rt_item_id = itemsb.rt_item_id
3766 AND NOT EXISTS (SELECT 'extracted price'
3767 FROM icx_cat_item_prices priceIn
3768 WHERE priceIn.rt_item_id = price.rt_item_id
3769 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
3770 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
3771 AND itemtlp.primary_category_id = map.rt_category_id (+)
3772 AND itemtlp.rt_item_id >= p_start_rt_item_id
3773 AND itemtlp.language = p_language
3774 AND itemtlp.org_id = p_org_id
3775 AND itemtlp.supplier_id = p_supplier_id
3776 AND price.supplier_site_id = p_supplier_site_id
3777 AND price.currency = p_currency
3778 AND price.contract_id = p_cpa_reference
3779 ORDER BY 1;
3780
3781 ----- Start of declaring columns selected in the cursor -----
3782
3783 l_rt_item_id_tbl DBMS_SQL.NUMBER_TABLE;
3784 l_unit_price_tbl DBMS_SQL.NUMBER_TABLE;
3785 l_unit_of_measure_tbl DBMS_SQL.VARCHAR2_TABLE;
3786 l_neg_by_prep_flag_tbl DBMS_SQL.VARCHAR2_TABLE;
3787 l_primary_category_id_tbl DBMS_SQL.NUMBER_TABLE;
3788 l_po_category_id_tbl DBMS_SQL.VARCHAR2_TABLE;
3789 l_supp_part_num_tbl DBMS_SQL.VARCHAR2_TABLE;
3790 l_supp_part_auxid_tbl DBMS_SQL.VARCHAR2_TABLE;
3791 l_description_tbl DBMS_SQL.VARCHAR2_TABLE;
3792 l_catalog_name_tbl DBMS_SQL.VARCHAR2_TABLE;
3793 l_price_type_tbl DBMS_SQL.VARCHAR2_TABLE;
3794 l_primary_category_name_tbl DBMS_SQL.VARCHAR2_TABLE;
3795
3796 ------ End of declaring columns selected in the cursor ------
3797
3798 l_api_name CONSTANT VARCHAR2(30) := 'processGBPALines';
3799 l_err_loc PLS_INTEGER;
3800 l_err_string VARCHAR2(4000);
3801 l_start_rt_item_id NUMBER;
3802 l_batch_count PLS_INTEGER;
3803 l_item_row_count PLS_INTEGER;
3804 l_interface_line_id NUMBER;
3805 l_po_category_id NUMBER;
3806 l_start_date DATE;
3807 l_end_date DATE;
3808 l_log_string VARCHAR2(2000);
3809 l_log_index NUMBER := 1;
3810 BEGIN
3811 l_err_loc := 100;
3812 l_start_date := sysdate;
3813
3814 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3815 l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
3816 ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
3817 END IF;
3818
3819 l_err_loc := 110;
3820 l_start_rt_item_id := 0;
3821 l_batch_count := 0;
3822 l_item_row_count := 0;
3823
3824 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3825 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3826 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3827 'Current Values in g_current_gbpa_hdr_rec:'||
3828 ', org_id:' ||g_current_gbpa_hdr_rec.org_id ||
3829 ', supplier_id:' ||g_current_gbpa_hdr_rec.vendor_id ||
3830 ', supplier_site_id:' ||g_current_gbpa_hdr_rec.vendor_site_id ||
3831 ', currency:' ||g_current_gbpa_hdr_rec.currency_code ||
3832 ', gbpa_cpa_reference:' ||g_current_gbpa_hdr_rec.cpa_reference ||
3833 ', language:' ||g_current_gbpa_hdr_rec.language ||
3834 ', interface_header_id:' ||g_current_gbpa_hdr_rec.interface_header_id );
3835 END IF;
3836
3837 l_err_loc := 120;
3838 --line_type will be defaulted by PDOI.
3839 OPEN processGBPALinesCsr(g_current_gbpa_hdr_rec.org_id, g_current_gbpa_hdr_rec.vendor_id,
3840 g_current_gbpa_hdr_rec.vendor_site_id, g_current_gbpa_hdr_rec.currency_code,
3841 g_current_gbpa_hdr_rec.cpa_reference, g_current_gbpa_hdr_rec.language,
3842 l_start_rt_item_id);
3843 LOOP
3844 l_err_loc := 130;
3845 l_rt_item_id_tbl.DELETE;
3846 l_unit_price_tbl.DELETE;
3847 l_unit_of_measure_tbl.DELETE;
3848 l_neg_by_prep_flag_tbl.DELETE;
3849 l_primary_category_id_tbl.DELETE;
3850 l_po_category_id_tbl.DELETE;
3851 l_supp_part_num_tbl.DELETE;
3852 l_supp_part_auxid_tbl.DELETE;
3853 l_description_tbl.DELETE;
3854 l_catalog_name_tbl.DELETE;
3855 l_price_type_tbl.DELETE;
3856 l_primary_category_name_tbl.DELETE;
3857
3858 BEGIN
3859 l_err_loc := 140;
3860 FETCH processGBPALinesCsr BULK COLLECT INTO
3861 l_rt_item_id_tbl, l_unit_price_tbl, l_unit_of_measure_tbl,
3862 l_neg_by_prep_flag_tbl, l_primary_category_id_tbl,
3863 l_po_category_id_tbl, l_supp_part_num_tbl,
3864 l_supp_part_auxid_tbl, l_description_tbl,
3865 l_catalog_name_tbl, l_price_type_tbl,
3866 l_primary_category_name_tbl
3867 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
3868
3869 l_err_loc := 160;
3870 EXIT WHEN l_rt_item_id_tbl.COUNT = 0;
3871
3872 l_err_loc := 170;
3873 l_batch_count := l_batch_count + 1;
3874
3875 l_err_loc := 180;
3876 --Save the last rt_item_id processed,
3877 --so that re-open of cursor will start from the saved rt_item_id.
3878 l_start_rt_item_id := l_rt_item_id_tbl(l_rt_item_id_tbl.COUNT);
3879
3880 l_err_loc := 190;
3881 l_item_row_count := l_item_row_count + l_rt_item_id_tbl.COUNT;
3882
3883 l_err_loc := 200;
3884 FOR i in 1..l_rt_item_id_tbl.COUNT LOOP
3885 l_log_index := i;
3886 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3887 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3888 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3889 'Values fetched from the cursor; '||
3890 'l_rt_item_id_tbl:' || l_rt_item_id_tbl(i) ||
3891 ', l_supp_part_num_tbl:' || l_supp_part_num_tbl(i) ||
3892 ', item language:' || g_current_gbpa_hdr_rec.language ||
3893 ', l_price_type_tbl:' || l_price_type_tbl(i) );
3894 END IF;
3895
3896 l_err_loc := 210;
3897 --Get the next interfaceLineId to be used in po_lines_interface,
3898 --po_attr_values_interface and po_attr_values_tlp_interface
3899 l_interface_line_id := getNextInterfaceLineIdFromSeq;
3900
3901 l_err_loc := 220;
3902 l_po_category_id := TO_NUMBER(l_po_category_id_tbl(i));
3903
3904 l_err_loc := 230;
3905 --Put the current values into g_po_line_attrval_int_rec for
3906 --po_lines_interface and po_attr_values_interface
3907 g_po_line_attrval_int_rec.interface_line_id := l_interface_line_id;
3908 g_po_line_attrval_int_rec.interface_header_id := g_current_gbpa_hdr_rec.interface_header_id ;
3909 g_po_line_attrval_int_rec.action := 'ADD';
3910 g_po_line_attrval_int_rec.po_line_id := null;
3911 g_po_line_attrval_int_rec.po_header_id := null;
3912 g_po_line_attrval_int_rec.unit_price := l_unit_price_tbl(i);
3913 l_err_loc := 232;
3914 g_po_line_attrval_int_rec.uom_code := l_unit_of_measure_tbl(i);
3915 g_po_line_attrval_int_rec.negotiated_by_preparer_flag := l_neg_by_prep_flag_tbl(i);
3916 g_po_line_attrval_int_rec.ip_category_id := l_primary_category_id_tbl(i);
3917 g_po_line_attrval_int_rec.category_id := l_po_category_id;
3918 l_err_loc := 234;
3919 g_po_line_attrval_int_rec.category_name := l_primary_category_name_tbl(i);
3920 l_err_loc := 236;
3921 g_po_line_attrval_int_rec.vendor_product_num := l_supp_part_num_tbl(i);
3922 g_po_line_attrval_int_rec.supplier_part_auxid := l_supp_part_auxid_tbl(i);
3923 l_err_loc := 238;
3924 g_po_line_attrval_int_rec.item_description := l_description_tbl(i);
3925 g_po_line_attrval_int_rec.catalog_name := l_catalog_name_tbl(i);
3926 g_po_line_attrval_int_rec.req_template_name := '-2';
3927 g_po_line_attrval_int_rec.req_template_line_num := -2;
3928 g_po_line_attrval_int_rec.inventory_item_id := -2;
3929 g_po_line_attrval_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
3930 g_po_line_attrval_int_rec.rt_item_id := l_rt_item_id_tbl(i);
3931 g_po_line_attrval_int_rec.language := g_current_gbpa_hdr_rec.language;
3932
3933 l_err_loc := 240;
3934 --Put the current values into g_po_attrvalstlp_int_rec for
3935 --po_attr_values_tlp_interface
3936 g_po_attrvalstlp_int_rec.interface_header_id := g_current_gbpa_hdr_rec.interface_header_id ;
3937 g_po_attrvalstlp_int_rec.interface_line_id := l_interface_line_id;
3938 g_po_attrvalstlp_int_rec.action := 'ADD';
3939 g_po_attrvalstlp_int_rec.po_line_id := null;
3940 g_po_attrvalstlp_int_rec.req_template_name := '-2';
3941 g_po_attrvalstlp_int_rec.req_template_line_num := -2;
3942 g_po_attrvalstlp_int_rec.inventory_item_id := -2;
3943 g_po_attrvalstlp_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
3944 l_err_loc := 242;
3945 g_po_attrvalstlp_int_rec.language := g_current_gbpa_hdr_rec.language;
3946 g_po_attrvalstlp_int_rec.check_desc_update := ICX_CAT_UTIL_PVT.g_update_description;
3947 g_po_attrvalstlp_int_rec.rt_item_id := l_rt_item_id_tbl(i);
3948
3949 l_err_loc := 244;
3950 g_r12_upg_rec.rt_item_id := l_rt_item_id_tbl(i);
3951 g_r12_upg_rec.supplier_site_id := g_current_gbpa_hdr_rec.vendor_site_id;
3952 g_r12_upg_rec.currency := g_current_gbpa_hdr_rec.currency_code;
3953 -- icx_cat_r12_upgrade.price_contract_id is same as the contract_id in price table
3954 -- icx_cat_r12_upgrade.src_contract_id is same as the contract_id returned from autosource
3955 -- Need both contract_ids to figure out any changes in the source document during delta processing.
3956 l_err_loc := 246;
3957 IF (l_price_type_tbl(i) = 'BULKLOAD') THEN
3958 g_r12_upg_rec.price_contract_id := -2;
3959 g_r12_upg_rec.src_contract_id := g_current_gbpa_hdr_rec.cpa_reference;
3960 ELSE
3961 l_err_loc := 248;
3962 g_r12_upg_rec.price_contract_id := g_current_gbpa_hdr_rec.cpa_reference;
3963 g_r12_upg_rec.src_contract_id := -2;
3964 END IF;
3965 l_err_loc := 250;
3966 g_r12_upg_rec.cpa_reference := g_current_gbpa_hdr_rec.cpa_reference;
3967 g_r12_upg_rec.po_category_id := l_po_category_id_tbl(i);
3968 g_r12_upg_rec.po_interface_header_id := g_current_gbpa_hdr_rec.interface_header_id;
3969 g_r12_upg_rec.po_interface_line_id := l_interface_line_id;
3970 l_err_loc := 252;
3971 g_r12_upg_rec.created_language := g_current_gbpa_hdr_rec.language;
3972 -- TBD g_r12_upg_rec.extractor_updated_flag := 'N';
3973
3974 l_err_loc := 254;
3975 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
3976 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
3977 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
3978 'inserting into lines, attr_values, attr_values_tlp and r12 upgrade');
3979 END IF;
3980 --Add the current value to the global pl/sql tables
3981 l_err_loc := 256;
3982 insertPOLinesInterface;
3983 l_err_loc := 258;
3984 insertPOAttrValsInterface;
3985 l_err_loc := 260;
3986 insertPOAttrValsTLPInterface;
3987 l_err_loc := 262;
3988 insertR12Upgrade;
3989
3990 l_err_loc := 300;
3991 populatePOInterfaceTables('INLOOP');
3992 END LOOP; --FOR LOOP of l_rt_item_id_tbl
3993
3994 l_err_loc := 310;
3995 EXIT WHEN l_rt_item_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
3996 EXCEPTION
3997 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
3998 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
3999 || '-' || l_err_loc
4000 || ', Total processeded batches:' || l_batch_count
4001 || ', Cursor will be reopened with rt_item_id:' || l_start_rt_item_id;
4002 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
4003 l_err_loc := 330;
4004 IF (processGBPALinesCsr%ISOPEN) THEN
4005 CLOSE processGBPALinesCsr;
4006 OPEN processGBPALinesCsr
4007 (g_current_gbpa_hdr_rec.org_id, g_current_gbpa_hdr_rec.vendor_id,
4008 g_current_gbpa_hdr_rec.vendor_site_id, g_current_gbpa_hdr_rec.currency_code,
4009 g_current_gbpa_hdr_rec.cpa_reference, g_current_gbpa_hdr_rec.language,
4010 l_start_rt_item_id);
4011 END IF;
4012 END;
4013 END LOOP; --CURSOR LOOP
4014
4015 l_err_loc := 350;
4016 populatePOInterfaceTables('OUTLOOP');
4017
4018 IF (processGBPALinesCsr%ISOPEN) THEN
4019 CLOSE processGBPALinesCsr;
4020 END IF;
4021
4022 l_err_loc := 360;
4023 g_total_bulkld_row_count := g_total_bulkld_row_count + l_item_row_count;
4024
4025 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4026 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4027 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4028 'done; '||
4029 'Total no: of batches processed:' ||l_batch_count ||
4030 ', Total no: of bulkloaded items processed:' ||l_item_row_count);
4031 END IF;
4032
4033 l_end_date := sysdate;
4034 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4035 ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
4036 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
4037 END IF;
4038
4039 EXCEPTION
4040 WHEN OTHERS THEN
4041 ICX_CAT_UTIL_PVT.logUnexpectedException(
4042 G_PKG_NAME, l_api_name,
4043 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4044
4045 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4046 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4047 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4048 'Current Values in g_current_gbpa_hdr_rec:'||
4049 ', org_id:' ||g_current_gbpa_hdr_rec.org_id ||
4050 ', supplier_id:' ||g_current_gbpa_hdr_rec.vendor_id ||
4051 ', supplier_site_id:' ||g_current_gbpa_hdr_rec.vendor_site_id ||
4052 ', currency:' ||g_current_gbpa_hdr_rec.currency_code ||
4053 ', gbpa_cpa_reference:' ||g_current_gbpa_hdr_rec.cpa_reference ||
4054 ', language:' ||g_current_gbpa_hdr_rec.language ||
4055 ', interface_header_id:' ||g_current_gbpa_hdr_rec.interface_header_id );
4056 END IF;
4057
4058 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4059 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4060 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4061 'Values fetched from the cursor; '||
4062 'l_rt_item_id_tbl:' || l_rt_item_id_tbl(l_log_index) ||
4063 ', l_supp_part_num_tbl:' || l_supp_part_num_tbl(l_log_index) ||
4064 ', l_supp_part_auxid_tbl:' || l_supp_part_auxid_tbl(l_log_index) ||
4065 ', l_unit_price_tbl:' || l_unit_price_tbl(l_log_index) ||
4066 ', l_unit_of_measure_tbl:' || l_unit_of_measure_tbl(l_log_index) ||
4067 ', l_neg_by_prep_flag_tbl:' || l_neg_by_prep_flag_tbl(l_log_index) ||
4068 ', l_primary_category_id_tbl:' || l_primary_category_id_tbl(l_log_index) ||
4069 ', l_po_category_id_tbl:' || l_po_category_id_tbl(l_log_index) ||
4070 ', l_price_type_tbl:' || l_price_type_tbl(l_log_index) );
4071 END IF;
4072
4073 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4074 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4075 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4076 'Values fetched from the cursor; '||
4077 'l_description_tbl:' || l_description_tbl(l_log_index) ||
4078 ', l_catalog_name_tbl:' || l_catalog_name_tbl(l_log_index) ||
4079 ', l_primary_category_name_tbl:' || l_primary_category_name_tbl(l_log_index));
4080 END IF;
4081
4082 raise;
4083 END processGBPALines;
4084
4085 PROCEDURE createGBPAsForBlkldItems
4086 IS
4087 -- Join with icx_cat_r12_upg_autosource on org_id, supplier_id,
4088 -- supplier_site_id, currency and po_category_id
4089 -- Group on org_id, supplier_id, supplier_site_id, currency, contract_id and language.
4090 -- Cannot group on po_category_id because the number of GBPA to be created will increase
4091 -- depending on po_category_id.
4092 -- We need price_contract_id, because if autosource returned a contract_id
4093 -- then src.contract_id will not be same as price.contract_id.
4094 -- Added the decode for supplier and supplier_site_code, because of some corrupt data
4095 -- that exists on the internal envs (also on gevt11i).
4096 -- The details: supplier_site_id = -2 but supplier_site_code is not null
4097 -- supplier_id = -2 but supplier is not null
4098 CURSOR createGBPAHdrsForBlkldItemsCsr IS
4099 SELECT doc.*,
4100 COUNT(*) count
4101 FROM (
4102 SELECT src.org_id org_id, src.supplier_id supplier_id,
4103 src.supplier_site_id supplier_site_id, src.currency currency,
4104 src.contract_id gbpa_cpa_reference,
4105 itemtlp.language language
4106 FROM icx_cat_r12_upg_autosource src, icx_cat_item_prices price,
4107 icx_cat_items_tlp itemtlp, icx_por_category_order_map map
4108 WHERE price.price_type = 'BULKLOAD'
4109 AND price.rt_item_id = itemtlp.rt_item_id
4110 AND NOT EXISTS (SELECT 'extracted price'
4111 FROM icx_cat_item_prices priceIn
4112 WHERE priceIn.rt_item_id = price.rt_item_id
4113 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
4114 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
4115 AND itemtlp.primary_category_id = map.rt_category_id (+)
4116 AND itemtlp.org_id = src.org_id
4117 AND itemtlp.supplier_id = src.supplier_id
4118 AND price.supplier_site_id = src.supplier_site_id
4119 AND price.currency = src.currency
4120 AND NVL(map.external_source_key, '-2') = src.po_category_id
4121 UNION ALL
4122 -- Added NVL to org_id, supplier, site and currency
4123 SELECT NVL(itemtlp.org_id, -2) org_id, NVL(itemtlp.supplier_id, -2) supplier_id,
4124 NVL(price.supplier_site_id, -2) supplier_site_id, NVL(price.currency, '-2') currency,
4125 price.contract_id gbpa_cpa_reference,
4126 itemtlp.language language
4127 FROM icx_cat_item_prices price, icx_cat_items_tlp itemtlp
4128 WHERE price.price_type = 'CONTRACT'
4129 AND price.rt_item_id = itemtlp.rt_item_id
4130 AND NOT EXISTS (SELECT 'extracted price'
4131 FROM icx_cat_item_prices priceIn
4132 WHERE priceIn.rt_item_id = price.rt_item_id
4133 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
4134 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
4135 ) doc
4136 GROUP BY doc.org_id, doc.supplier_id, doc.supplier_site_id,
4137 doc.currency, doc.gbpa_cpa_reference,
4138 doc.language
4139 ORDER BY doc.org_id, doc.supplier_id, doc.supplier_site_id,
4140 doc.currency, doc.gbpa_cpa_reference,
4141 count DESC, doc.language;
4142
4143 ----- Start of declaring columns selected in the cursor -----
4144 l_org_id_tbl DBMS_SQL.NUMBER_TABLE;
4145 l_supplier_id_tbl DBMS_SQL.NUMBER_TABLE;
4146 l_supplier_site_id_tbl DBMS_SQL.NUMBER_TABLE;
4147 l_currency_tbl DBMS_SQL.VARCHAR2_TABLE;
4148 l_gbpa_cpa_reference_tbl DBMS_SQL.NUMBER_TABLE;
4149 l_language_tbl DBMS_SQL.VARCHAR2_TABLE;
4150 l_count_tbl DBMS_SQL.NUMBER_TABLE;
4151
4152 ------ End of declaring columns selected in the cursor ------
4153
4154 l_api_name CONSTANT VARCHAR2(30) := 'createGBPAsForBlkldItems';
4155 l_err_loc PLS_INTEGER;
4156 l_prev_org_id NUMBER;
4157 l_prev_supplier_id NUMBER;
4158 l_prev_supplier_site_id NUMBER;
4159 l_prev_currency icx_cat_item_prices.currency%TYPE;
4160 l_prev_contract_id NUMBER;
4161 l_interface_header_id NUMBER;
4162 l_start_date DATE;
4163 l_end_date DATE;
4164 l_log_string VARCHAR2(2000);
4165 BEGIN
4166 l_err_loc := 100;
4167 l_start_date := sysdate;
4168
4169 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4170 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4171 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4172 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
4173 END IF;
4174
4175 l_err_loc := 110;
4176 -- Perform the contract auto sourcing
4177 contractAutoSourcing;
4178
4179 l_err_loc := 115;
4180 --Assign the previous values to some dummy values
4181 l_prev_org_id := -1212;
4182 l_prev_supplier_id := -1212;
4183 l_prev_supplier_site_id := -1212;
4184 l_prev_currency := '-12';
4185 l_prev_contract_id := -1212;
4186
4187 l_err_loc := 118;
4188 OPEN createGBPAHdrsForBlkldItemsCsr;
4189
4190 l_err_loc := 120;
4191 --Not expecting a huge number of GBPA header's that will be returned from the cursor.
4192 --Considering the fact that we are grouping by on supplier_id, org_id, supplier_site_id, currency and language
4193 FETCH createGBPAHdrsForBlkldItemsCsr BULK COLLECT INTO
4194 l_org_id_tbl, l_supplier_id_tbl, l_supplier_site_id_tbl,
4195 l_currency_tbl, l_gbpa_cpa_reference_tbl,
4196 l_language_tbl, l_count_tbl;
4197
4198 l_err_loc := 130;
4199 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4200 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4201 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4202 'Total no: of distinct GBPA headers attributes found:' || l_org_id_tbl.COUNT);
4203 END IF;
4204
4205 l_err_loc := 140;
4206 FOR i in 1..l_org_id_tbl.COUNT LOOP
4207 l_err_loc := 150;
4208 g_current_gbpa_hdr_rec.org_id := l_org_id_tbl(i);
4209 g_current_gbpa_hdr_rec.vendor_id := l_supplier_id_tbl(i);
4210 g_current_gbpa_hdr_rec.vendor_site_id := l_supplier_site_id_tbl(i);
4211 g_current_gbpa_hdr_rec.currency_code := l_currency_tbl(i);
4212 -- g_current_gbpa_hdr_rec.price_contract_id := l_price_contract_id_tbl(i);
4213 -- g_current_gbpa_hdr_rec.src_contract_id := l_src_contract_id_tbl(i);
4214 g_current_gbpa_hdr_rec.language := l_language_tbl(i);
4215 g_current_gbpa_hdr_rec.cpa_reference := l_gbpa_cpa_reference_tbl(i);
4216 g_current_gbpa_hdr_rec.interface_header_id := null;
4217 g_current_gbpa_hdr_rec.po_header_id := null;
4218 g_current_gbpa_hdr_rec.upg_created_language := null;
4219 g_current_gbpa_hdr_rec.upg_cpa_reference := null;
4220
4221 l_err_loc := 154;
4222 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4223 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4224 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4225 'Previous Values:'||
4226 ', l_prev_org_id:' ||l_prev_org_id ||
4227 ', l_prev_supplier_id:' ||l_prev_supplier_id ||
4228 ', l_prev_supplier_site_id:' ||l_prev_supplier_site_id ||
4229 ', l_prev_currency:' ||l_prev_currency ||
4230 ', l_prev_contract_id:' ||l_prev_contract_id);
4231 END IF;
4232
4233 l_err_loc := 160;
4234 IF (l_prev_org_id = l_org_id_tbl(i) AND
4235 l_prev_supplier_id = l_supplier_id_tbl(i) AND
4236 l_prev_supplier_site_id = l_supplier_site_id_tbl(i) AND
4237 l_prev_currency = l_currency_tbl(i) AND
4238 l_prev_contract_id = l_gbpa_cpa_reference_tbl(i) )
4239 THEN
4240 --All the GBPA header attributes are the same except the language
4241 --which means the lines in the current GBPA header needs to be checked
4242 --for the following two cases:
4243 --1> Some lines may be translations in the previous GBPA header
4244 --2> Some lines may need a new GBPA header to be created with the
4245 -- current language as the created language
4246 l_err_loc := 170;
4247 checkAndProcessGBPALines;
4248 ELSE
4249 l_err_loc := 180;
4250 l_interface_header_id := getNextInterfaceHdrIdFromSeq;
4251
4252 l_err_loc := 190;
4253 g_po_hdrs_int_rec.interface_header_id := l_interface_header_id;
4254 g_po_hdrs_int_rec.action := 'ORIGINAL';
4255 g_po_hdrs_int_rec.org_id := l_org_id_tbl(i);
4256 g_po_hdrs_int_rec.document_type_code := 'BLANKET';
4257 g_po_hdrs_int_rec.budget_account_segment1 := null;
4258 g_po_hdrs_int_rec.po_header_id := null;
4259 g_po_hdrs_int_rec.approval_status := 'IN PROCESS';
4260 g_po_hdrs_int_rec.vendor_id := l_supplier_id_tbl(i);
4261 g_po_hdrs_int_rec.vendor_site_id := l_supplier_site_id_tbl(i);
4262 g_po_hdrs_int_rec.currency_code := l_currency_tbl(i);
4263 g_po_hdrs_int_rec.created_language := l_language_tbl(i);
4264 g_po_hdrs_int_rec.comments := g_new_GBPA_description;
4265
4266 l_err_loc := 200;
4267 IF (l_gbpa_cpa_reference_tbl(i) <> ICX_CAT_UTIL_PVT.g_NULL_NUMBER) THEN
4268 g_po_hdrs_int_rec.cpa_reference := l_gbpa_cpa_reference_tbl(i);
4269 ELSE
4270 g_po_hdrs_int_rec.cpa_reference := null;
4271 END IF;
4272
4273 l_err_loc := 210;
4274 g_GBPA_hdr_count := g_GBPA_hdr_count + 1;
4275 insertPOHeadersInterface;
4276
4277 l_err_loc := 220;
4278 g_current_gbpa_hdr_rec.interface_header_id := l_interface_header_id;
4279 processGBPALines;
4280 END IF;
4281
4282 l_err_loc := 230;
4283 l_prev_org_id := l_org_id_tbl(i);
4284 l_prev_supplier_id := l_supplier_id_tbl(i);
4285 l_prev_supplier_site_id := l_supplier_site_id_tbl(i);
4286 l_prev_currency := l_currency_tbl(i);
4287 l_prev_contract_id := l_gbpa_cpa_reference_tbl(i);
4288 END LOOP; --FOR LOOP of l_org_id_tbl
4289
4290 l_err_loc := 240;
4291 CLOSE createGBPAHdrsForBlkldItemsCsr;
4292
4293 l_err_loc := 250;
4294 l_end_date := sysdate;
4295 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4296 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4297 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4298 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date) ||
4299 '; Total no: of GBPA headers created:' || g_GBPA_hdr_count ||
4300 ', Total no: of bulkload items processed:' || g_total_bulkld_row_count);
4301 END IF;
4302 EXCEPTION
4303 WHEN OTHERS THEN
4304 ICX_CAT_UTIL_PVT.logUnexpectedException(
4305 G_PKG_NAME, l_api_name,
4306 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
4307 raise;
4308 END createGBPAsForBlkldItems;
4309
4310 FUNCTION getGBPAHeaderId(p_org_id IN NUMBER,
4311 p_supplier_id IN NUMBER,
4312 p_supplier_site_id IN NUMBER,
4313 p_currency IN VARCHAR2,
4314 p_cpa_reference IN NUMBER,
4315 p_created_language IN VARCHAR2)
4316 RETURN NUMBER
4317 IS
4318 l_po_interface_header_id NUMBER;
4319 l_po_header_id NUMBER;
4320 BEGIN
4321 SELECT po_interface_header_id, po_header_id
4322 INTO l_po_interface_header_id, l_po_header_id
4323 FROM icx_cat_r12_upgrade upg, icx_cat_items_b b
4324 WHERE b.rt_item_id = upg.rt_item_id
4325 AND b.org_id = p_org_id
4326 AND b.supplier_id = p_supplier_id
4327 AND upg.supplier_site_id = p_supplier_site_id
4328 AND upg.currency = p_currency
4329 AND upg.cpa_reference = p_cpa_reference
4330 AND upg.created_language = p_created_language
4331 AND rownum < 2;
4332
4333 RETURN l_po_header_id;
4334 EXCEPTION
4335 WHEN OTHERS THEN
4336 RETURN NULL;
4337 END getGBPAHeaderId;
4338
4339 PROCEDURE processGBPALinesForDelta
4340 IS
4341 -- We need price_contract_id, because if autosource returned a contract_id
4342 -- then src.contract_id will not be same as price.contract_id.
4343 -- Added p_po_header_id to differentiate between two hdr groups which has
4344 -- everything the same, but one hdr row has null inteface_header_id and the
4345 -- other one has a value. The data could be re-created if a hdr set has 4 items,
4346 -- that needs to be updated during delta and delta also 4 items that were added
4347 -- but fall into the same hdr group.
4348 CURSOR processGBPALinesForDeltaCsr(p_org_id NUMBER, p_supplier_id NUMBER,
4349 p_supplier_site_id NUMBER, p_currency VARCHAR2,
4350 p_cpa_reference NUMBER, p_language VARCHAR2,
4351 p_start_rt_item_id NUMBER, p_po_header_id NUMBER
4352 ) IS
4353 SELECT itemtlp.rt_item_id, price.unit_price, price.unit_of_measure,
4354 DECODE(NVL(price.negotiated_by_preparer_flag, '1'), '0', 'N', 'Y'),
4355 itemtlp.primary_category_id, NVL(map.external_source_key, '-2') po_category_id,
4356 SUBSTRB(itemtlp.supplier_part_num, 1, 25) supplier_part_num,
4357 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
4358 SUBSTRB(itemtlp.description, 1, 240) description, itemb.catalog_name,
4359 upg.po_interface_header_id, upg.po_interface_line_id,
4360 upg.po_header_id, upg.po_line_id, upg.created_language,
4361 upg.po_category_id old_po_catgegory_id,
4362 DECODE(attr.ATTRIBUTE_VALUES_TLP_ID, NULL, 'ADD', 'UPDATE') attr_val_tlp_action,
4363 price.price_type, itemtlp.primary_category_name
4364 FROM icx_cat_r12_upg_autosource src, icx_cat_item_prices price,
4365 icx_cat_items_tlp itemtlp, icx_por_category_order_map map,
4366 icx_cat_items_b itemb, icx_cat_ext_items_tlp extitemtlp,
4367 icx_cat_r12_upgrade upg, po_attribute_values_tlp attr
4368 WHERE price.price_type = 'BULKLOAD'
4369 AND price.rt_item_id = itemtlp.rt_item_id
4370 AND NOT EXISTS (SELECT 'extracted price'
4371 FROM icx_cat_item_prices priceIn
4372 WHERE priceIn.rt_item_id = price.rt_item_id
4373 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
4374 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
4375 AND itemtlp.primary_category_id = map.rt_category_id (+)
4376 AND itemtlp.org_id = src.org_id
4377 AND itemtlp.supplier_id = src.supplier_id
4378 AND price.supplier_site_id = src.supplier_site_id
4379 AND price.currency = src.currency
4380 AND NVL(map.external_source_key, '-2') = src.po_category_id
4381 AND price.rt_item_id = itemb.rt_item_id
4382 AND price.rt_item_id = extitemtlp.rt_item_id
4383 AND itemtlp.language = extitemtlp.language
4384 AND price.rt_item_id = upg.rt_item_id (+)
4385 AND price.supplier_site_id = upg.supplier_site_id (+)
4386 AND price.currency = upg.currency (+)
4387 AND price.contract_id = upg.price_contract_id (+)
4388 AND (upg.po_header_id IS NULL AND p_po_header_id IS NULL OR upg.po_header_id = p_po_header_id)
4389 AND ( -- Last update changes in items / price tables
4390 (itemb.last_update_date > g_bulk_last_run_date
4391 OR itemtlp.last_update_date > g_bulk_last_run_date
4392 OR extitemtlp.last_update_date > g_bulk_last_run_date
4393 OR price.last_update_date > g_bulk_last_run_date)
4394 OR -- The items that errored out in the previous run
4395 (upg.po_header_id is null
4396 OR upg.po_line_id is null))
4397 AND itemtlp.rt_item_id >= p_start_rt_item_id
4398 AND itemtlp.language = p_language
4399 AND src.org_id = p_org_id
4400 AND src.supplier_id = p_supplier_id
4401 AND src.supplier_site_id = p_supplier_site_id
4402 AND src.currency = p_currency
4403 AND src.contract_id = p_cpa_reference
4404 AND attr.po_line_id (+) = upg.po_line_id
4405 AND attr.req_template_name (+) = '-2'
4406 AND attr.req_template_line_num (+) = -2
4407 AND attr.org_id (+) = p_org_id
4408 AND attr.language (+) = p_language
4409 UNION ALL
4410 SELECT itemtlp.rt_item_id, price.unit_price, price.unit_of_measure,
4411 DECODE(NVL(price.negotiated_by_preparer_flag, '1'), '0', 'N', 'Y'),
4412 itemtlp.primary_category_id, NVL(map.external_source_key, '-2') po_category_id,
4413 SUBSTRB(itemtlp.supplier_part_num, 1, 25) supplier_part_num,
4414 DECODE(itemtlp.supplier_part_auxid, '##NULL##', null, itemtlp.supplier_part_auxid),
4415 SUBSTRB(itemtlp.description, 1, 240) description, itemb.catalog_name,
4416 upg.po_interface_header_id, upg.po_interface_line_id,
4417 upg.po_header_id, upg.po_line_id, upg.created_language,
4418 upg.po_category_id old_po_catgegory_id,
4419 DECODE(attr.ATTRIBUTE_VALUES_TLP_ID, NULL, 'ADD', 'UPDATE') attr_val_tlp_action,
4420 price.price_type, itemtlp.primary_category_name
4421 FROM icx_cat_item_prices price, icx_cat_items_tlp itemtlp,
4422 icx_por_category_order_map map,
4423 icx_cat_items_b itemb, icx_cat_ext_items_tlp extitemtlp,
4424 icx_cat_r12_upgrade upg, po_attribute_values_tlp attr
4425 WHERE price.price_type = 'CONTRACT'
4426 AND price.rt_item_id = itemtlp.rt_item_id
4427 AND NOT EXISTS (SELECT 'extracted price'
4428 FROM icx_cat_item_prices priceIn
4429 WHERE priceIn.rt_item_id = price.rt_item_id
4430 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
4431 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
4432 AND itemtlp.primary_category_id = map.rt_category_id (+)
4433 AND price.rt_item_id = itemb.rt_item_id
4434 AND price.rt_item_id = extitemtlp.rt_item_id
4435 AND itemtlp.language = extitemtlp.language
4436 AND price.rt_item_id = upg.rt_item_id (+)
4437 AND price.supplier_site_id = upg.supplier_site_id (+)
4438 AND price.currency = upg.currency (+)
4439 AND price.contract_id = upg.price_contract_id (+)
4440 AND (upg.po_header_id IS NULL AND p_po_header_id IS NULL OR upg.po_header_id = p_po_header_id)
4441 AND ( -- Last update changes in items / price tables
4442 (itemb.last_update_date > g_bulk_last_run_date
4443 OR itemtlp.last_update_date > g_bulk_last_run_date
4444 OR extitemtlp.last_update_date > g_bulk_last_run_date
4445 OR price.last_update_date > g_bulk_last_run_date)
4446 OR -- The items that errored out in the previous run
4447 (upg.po_header_id is null
4448 OR upg.po_line_id is null))
4449 AND itemtlp.rt_item_id >= p_start_rt_item_id
4450 AND itemtlp.language = p_language
4451 AND itemtlp.org_id = p_org_id
4452 AND itemtlp.supplier_id = p_supplier_id
4453 AND price.supplier_site_id = p_supplier_site_id
4454 AND price.currency = p_currency
4455 AND price.contract_id = p_cpa_reference
4456 AND attr.po_line_id (+) = upg.po_line_id
4457 AND attr.req_template_name (+) = '-2'
4458 AND attr.req_template_line_num (+) = -2
4459 AND attr.org_id (+) = p_org_id
4460 AND attr.language (+) = p_language
4461 ORDER BY 1;
4462
4463 ----- Start of declaring columns selected in the cursor -----
4464
4465 l_rt_item_id_tbl DBMS_SQL.NUMBER_TABLE;
4466 l_unit_price_tbl DBMS_SQL.NUMBER_TABLE;
4467 l_unit_of_measure_tbl DBMS_SQL.VARCHAR2_TABLE;
4468 l_neg_by_prep_flag_tbl DBMS_SQL.VARCHAR2_TABLE;
4469 l_primary_category_id_tbl DBMS_SQL.NUMBER_TABLE;
4470 l_po_category_id_tbl DBMS_SQL.NUMBER_TABLE;
4471 l_supp_part_num_tbl DBMS_SQL.VARCHAR2_TABLE;
4472 l_supp_part_auxid_tbl DBMS_SQL.VARCHAR2_TABLE;
4473 l_description_tbl DBMS_SQL.VARCHAR2_TABLE;
4474 l_catalog_name_tbl DBMS_SQL.VARCHAR2_TABLE;
4475 l_po_interface_header_id_tbl DBMS_SQL.NUMBER_TABLE;
4476 l_po_interface_line_id_tbl DBMS_SQL.NUMBER_TABLE;
4477 l_po_header_id_tbl DBMS_SQL.NUMBER_TABLE;
4478 l_po_line_id_tbl DBMS_SQL.NUMBER_TABLE;
4479 l_created_language_tbl DBMS_SQL.VARCHAR2_TABLE;
4480 l_old_po_category_id_tbl DBMS_SQL.NUMBER_TABLE;
4481 l_attr_val_tlp_action_tbl DBMS_SQL.VARCHAR2_TABLE;
4482 l_price_type_tbl DBMS_SQL.VARCHAR2_TABLE;
4483 l_primary_category_name_tbl DBMS_SQL.VARCHAR2_TABLE;
4484
4485 ------ End of declaring columns selected in the cursor ------
4486
4487 l_api_name CONSTANT VARCHAR2(30) := 'processGBPALinesForDelta';
4488 l_err_loc PLS_INTEGER;
4489 l_err_string VARCHAR2(4000);
4490 l_start_rt_item_id NUMBER;
4491 l_batch_count PLS_INTEGER;
4492 l_item_row_count PLS_INTEGER;
4493 l_interface_line_id NUMBER;
4494 l_interface_header_id NUMBER;
4495 l_po_header_id NUMBER;
4496 l_lines_po_header_id NUMBER;
4497 l_line_deleted BOOLEAN := FALSE;
4498 l_dml_reqd_in_lines BOOLEAN := TRUE;
4499 l_dml_reqd_in_r12Upgrade BOOLEAN := TRUE;
4500 l_createR12UpgradeRow BOOLEAN := TRUE;
4501 l_firstRow BOOLEAN := TRUE;
4502 l_del_interface_header_id NUMBER;
4503 l_del_interface_line_id NUMBER;
4504 l_start_date DATE;
4505 l_end_date DATE;
4506 l_log_string VARCHAR2(2000);
4507 l_log_index NUMBER := 1;
4508 BEGIN
4509 l_err_loc := 100;
4510 l_start_rt_item_id := 0;
4511 l_batch_count := 0;
4512 l_item_row_count := 0;
4513 l_start_date := sysdate;
4514
4515 l_err_loc := 110;
4516 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4517 l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ;
4518 ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, l_log_string);
4519 END IF;
4520
4521 l_err_loc := 120;
4522 --line_type will be defaulted by PDOI.
4523 OPEN processGBPALinesForDeltaCsr
4524 (g_current_gbpa_hdr_rec.org_id, g_current_gbpa_hdr_rec.vendor_id,
4525 g_current_gbpa_hdr_rec.vendor_site_id, g_current_gbpa_hdr_rec.currency_code,
4526 g_current_gbpa_hdr_rec.cpa_reference, g_current_gbpa_hdr_rec.language,
4527 l_start_rt_item_id, g_current_gbpa_hdr_rec.po_header_id);
4528 LOOP
4529 l_err_loc := 130;
4530 l_rt_item_id_tbl.DELETE;
4531 l_unit_price_tbl.DELETE;
4532 l_unit_of_measure_tbl.DELETE;
4533 l_neg_by_prep_flag_tbl.DELETE;
4534 l_primary_category_id_tbl.DELETE;
4535 l_po_category_id_tbl.DELETE;
4536 l_supp_part_num_tbl.DELETE;
4537 l_supp_part_auxid_tbl.DELETE;
4538 l_description_tbl.DELETE;
4539 l_catalog_name_tbl.DELETE;
4540 l_po_interface_header_id_tbl.DELETE;
4541 l_po_interface_line_id_tbl.DELETE;
4542 l_po_header_id_tbl.DELETE;
4543 l_po_line_id_tbl.DELETE;
4544 l_created_language_tbl.DELETE;
4545 l_old_po_category_id_tbl.DELETE;
4546 l_attr_val_tlp_action_tbl.DELETE;
4547 l_price_type_tbl.DELETE;
4548 l_primary_category_name_tbl.DELETE;
4549
4550 BEGIN
4551 l_err_loc := 140;
4552 FETCH processGBPALinesForDeltaCsr BULK COLLECT INTO
4553 l_rt_item_id_tbl, l_unit_price_tbl, l_unit_of_measure_tbl,
4554 l_neg_by_prep_flag_tbl, l_primary_category_id_tbl, l_po_category_id_tbl,
4555 l_supp_part_num_tbl, l_supp_part_auxid_tbl, l_description_tbl,
4556 l_catalog_name_tbl,
4557 l_po_interface_header_id_tbl, l_po_interface_line_id_tbl,
4558 l_po_header_id_tbl, l_po_line_id_tbl, l_created_language_tbl,
4559 l_old_po_category_id_tbl, l_attr_val_tlp_action_tbl, l_price_type_tbl,
4560 l_primary_category_name_tbl
4561 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
4562
4563 l_err_loc := 150;
4564 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4565 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4566 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4567 'Total no: of records fetced from the cursor:' || l_rt_item_id_tbl.COUNT);
4568 END IF;
4569
4570 l_err_loc := 160;
4571 EXIT WHEN l_rt_item_id_tbl.COUNT = 0;
4572
4573 l_err_loc := 170;
4574 l_batch_count := l_batch_count + 1;
4575
4576 l_err_loc := 180;
4577 --Save the last rt_item_id processed,
4578 --so that re-open of cursor will start from the saved rt_item_id.
4579 l_start_rt_item_id := l_rt_item_id_tbl(l_rt_item_id_tbl.COUNT);
4580
4581 l_err_loc := 190;
4582 l_item_row_count := l_item_row_count + l_rt_item_id_tbl.COUNT;
4583
4584 l_err_loc := 200;
4585 FOR i in 1..l_rt_item_id_tbl.COUNT LOOP
4586 l_log_index := i;
4587 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4588 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
4589 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4590 'Values fetched from the cursor; '||
4591 'l_rt_item_id_tbl:' || l_rt_item_id_tbl(i) ||
4592 ', l_supp_part_num_tbl:' || l_supp_part_num_tbl(i) ||
4593 ', l_price_type_tbl:' || l_price_type_tbl(i) ||
4594 ', l_po_interface_header_id_tbl:' || l_po_interface_header_id_tbl(i) ||
4595 ', l_po_interface_line_id_tbl:' || l_po_interface_line_id_tbl(i) ||
4596 ', l_po_header_id_tbl:' || l_po_header_id_tbl(i) ||
4597 ', l_po_line_id_tbl:' || l_po_line_id_tbl(i) ||
4598 ', l_created_language_tbl:' || l_created_language_tbl(i) ||
4599 ', l_po_category_id_tbl:' || l_po_category_id_tbl(i) ||
4600 ', l_old_po_category_id_tbl:' || l_old_po_category_id_tbl(i) ||
4601 ', new_source:' || g_current_gbpa_hdr_rec.cpa_reference ||
4602 ', old_source:' || g_current_gbpa_hdr_rec.upg_cpa_reference ||
4603 ', l_attr_val_tlp_action_tbl:' || l_attr_val_tlp_action_tbl(i) );
4604 END IF;
4605
4606 -- Possible header rows to be processed during delta
4607 -- 1. Errored headers or lines during previous run of upgrade
4608 -- 2. New rows added after the upgrade
4609 -- 3. Changed rows after the upgrade.
4610 -- 4. Errored lines in the previous run of upgrade i.e. error happened during creation of lines
4611 -------------------------------------------------------------------------------------------------------------
4612 -- hdr.poInthdrId | hdr.poHdrId | curr_pointHdrId | createdLang | Lang
4613 -------------------------------------------------------------------------------------------------------------
4614 -- 1. Errored headers and lines during previous run of upgrade
4615 -- 123 _ 123 US US
4616 -- 123 _ 921 US N
4617 -------------------------------------------------------------------------------------------------------------
4618 -- 2. New rows added after the upgrade
4619 -- _ _ _ _ US
4620 -- _ _ 922 US N
4621 -------------------------------------------------------------------------------------------------------------
4622 -- 3. Changed rows after the upgrade.
4623 -- 124 321 124 US N
4624 -- 124 321 923 US US
4625 -------------------------------------------------------------------------------------------------------------
4626 -- 4. Errored lines in the previous run of upgrade i.e. error happened during creation of lines
4627 -- 125 322 125 US US
4628 -- 125 322 924 US N
4629 -------------------------------------------------------------------------------------------------------------
4630
4631 l_err_loc := 210;
4632 IF ( (g_current_gbpa_hdr_rec.interface_header_id IS NULL AND
4633 l_po_interface_header_id_tbl(i) IS NULL) OR
4634 (g_current_gbpa_hdr_rec.interface_header_id IS NOT NULL AND
4635 l_po_interface_header_id_tbl(i) IS NOT NULL AND
4636 g_current_gbpa_hdr_rec.interface_header_id = l_po_interface_header_id_tbl(i)))
4637 THEN
4638 -- i.e. both the interface_header_id from the lines cursor and from the headers cursors are the same
4639 -- We need to insert rows in po_headers_interface, po_lines_interface, po_attr_values_interface
4640 -- and po_attr_values_tlp_interface
4641 -- IF interface_header_id from the headers cursor is null then insert into icx_cat_r12_upgrade table
4642 -- IF interface_header_id from the headers cursor is not null then update icx_cat_r12_upgrade table
4643 IF (l_firstRow) THEN
4644 --Create the header record only once for the
4645 --current combination of header attributes
4646 l_err_loc := 212;
4647 l_interface_header_id := getNextInterfaceHdrIdFromSeq;
4648 g_po_hdrs_int_rec.interface_header_id := l_interface_header_id;
4649 g_po_hdrs_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
4650 g_po_hdrs_int_rec.document_type_code := 'BLANKET';
4651 g_po_hdrs_int_rec.budget_account_segment1 := null;
4652 g_po_hdrs_int_rec.approval_status := 'IN PROCESS';
4653 g_po_hdrs_int_rec.vendor_id := g_current_gbpa_hdr_rec.vendor_id;
4654 g_po_hdrs_int_rec.vendor_site_id := g_current_gbpa_hdr_rec.vendor_site_id;
4655 g_po_hdrs_int_rec.currency_code := g_current_gbpa_hdr_rec.currency_code;
4656 g_po_hdrs_int_rec.comments := g_new_GBPA_description;
4657
4658 l_err_loc := 216;
4659 IF (g_current_gbpa_hdr_rec.cpa_reference <> ICX_CAT_UTIL_PVT.g_NULL_NUMBER) THEN
4660 g_po_hdrs_int_rec.cpa_reference := g_current_gbpa_hdr_rec.cpa_reference;
4661 ELSE
4662 g_po_hdrs_int_rec.cpa_reference := null;
4663 END IF;
4664
4665 IF (g_current_gbpa_hdr_rec.po_header_id IS NULL OR
4666 (g_current_gbpa_hdr_rec.po_header_id IS NOT NULL AND
4667 g_current_gbpa_hdr_rec.cpa_reference <> g_current_gbpa_hdr_rec.upg_cpa_reference)) THEN
4668 -- If the po_header is null OR the source has changed then
4669 -- Create a new header i.e the action can be ORIGINAL
4670 -- Before creating a new header check if a header was already created for the same header attributes
4671 -- in the previous run of upgrade.
4672 l_err_loc := 218;
4673 l_po_header_id := getGBPAHeaderId(g_current_gbpa_hdr_rec.org_id,
4674 g_current_gbpa_hdr_rec.vendor_id,
4675 g_current_gbpa_hdr_rec.vendor_site_id,
4676 g_current_gbpa_hdr_rec.currency_code,
4677 g_current_gbpa_hdr_rec.cpa_reference,
4678 g_current_gbpa_hdr_rec.language);
4679
4680 l_err_loc := 220;
4681 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4682 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4683 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4684 'l_po_header_id returned from ' ||
4685 'getGBPAHeaderId(orgId=>' || g_current_gbpa_hdr_rec.org_id ||
4686 ', suppId=>' || g_current_gbpa_hdr_rec.vendor_id ||
4687 ', siteId=>' || g_current_gbpa_hdr_rec.vendor_site_id ||
4688 ', curr=>' || g_current_gbpa_hdr_rec.currency_code ||
4689 ', cpaReference=>' || g_current_gbpa_hdr_rec.cpa_reference ||
4690 ', creatLang=>' || g_current_gbpa_hdr_rec.language ||
4691 '):' ||l_po_header_id);
4692 END IF;
4693
4694 l_err_loc := 222;
4695 IF (l_po_header_id IS NULL) THEN
4696 --A new GBPA header needs to be created.
4697 g_po_hdrs_int_rec.action := 'ORIGINAL';
4698 g_po_hdrs_int_rec.po_header_id := null;
4699 g_po_hdrs_int_rec.created_language := g_current_gbpa_hdr_rec.language;
4700 l_lines_po_header_id := null;
4701 ELSE
4702 l_err_loc := 224;
4703 g_po_hdrs_int_rec.action := 'UPDATE';
4704 g_po_hdrs_int_rec.po_header_id := l_po_header_id;
4705 g_po_hdrs_int_rec.created_language := g_current_gbpa_hdr_rec.language;
4706 l_lines_po_header_id := l_po_header_id;
4707 END IF;
4708 ELSE
4709 -- i.e. g_current_gbpa_hdr_rec.po_header_id IS NOT NULL
4710 -- AND the source is also same as it was during the earlier run of upgrade.
4711 l_err_loc := 226;
4712 g_po_hdrs_int_rec.action := 'UPDATE';
4713 g_po_hdrs_int_rec.po_header_id := g_current_gbpa_hdr_rec.po_header_id;
4714 g_po_hdrs_int_rec.created_language := g_current_gbpa_hdr_rec.upg_created_language;
4715 l_lines_po_header_id := g_current_gbpa_hdr_rec.po_header_id;
4716 END IF; -- g_current_gbpa_hdr_rec.po_header_id IS NULL
4717 l_err_loc := 227;
4718 g_GBPA_hdr_count := g_GBPA_hdr_count + 1;
4719
4720 l_err_loc := 228;
4721 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4722 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4723 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4724 'inserting into headers_interface; total_hdr_count:' ||g_GBPA_hdr_count ||
4725 ', g_po_hdrs_int_rec.action:' || g_po_hdrs_int_rec.action ||
4726 ', g_po_hdrs_int_rec.po_header_id:' || g_po_hdrs_int_rec.po_header_id ||
4727 ', created_language:' || g_po_hdrs_int_rec.created_language ||
4728 ', comments:' || g_po_hdrs_int_rec.comments ||
4729 ', l_interface_header_id:' ||l_interface_header_id ||
4730 ', g_po_hdrs_int_rec.cpa_reference:' || g_po_hdrs_int_rec.cpa_reference ||
4731 ', g_current_gbpa_hdr_rec.cpa_reference:' || g_current_gbpa_hdr_rec.cpa_reference ||
4732 ', g_current_gbpa_hdr_rec.po_header_id:' ||g_current_gbpa_hdr_rec.po_header_id);
4733 END IF;
4734 l_err_loc := 230;
4735 insertPOHeadersInterface;
4736 l_firstRow := FALSE;
4737 END IF; -- IF (l_firstRow)
4738
4739 l_line_deleted := FALSE;
4740 IF (l_po_header_id_tbl(i) IS NOT NULL AND l_po_line_id_tbl(i) IS NOT NULL) THEN
4741 -- If category changed but the source before and after is -2,
4742 -- then there is no need of deleting the line, So here we only check for the change in source
4743 -- before deleting the line.
4744 -- Check for auto source change
4745 -- due to category change / autosource api returned different source in the previous run of upgrade.
4746 IF (g_current_gbpa_hdr_rec.cpa_reference <> g_current_gbpa_hdr_rec.upg_cpa_reference) THEN
4747 -- The row needs to be deleted.
4748 -- so insert a header row with update action
4749 -- insert a line with delete action.
4750
4751 IF (l_del_interface_header_id IS NULL) THEN
4752 l_del_interface_header_id := getNextInterfaceHdrIdFromSeq;
4753
4754 l_err_loc := 232;
4755 g_po_hdrs_int_rec.interface_header_id := l_del_interface_header_id;
4756 g_po_hdrs_int_rec.action := 'UPDATE';
4757 g_po_hdrs_int_rec.document_type_code := 'BLANKET';
4758 g_po_hdrs_int_rec.budget_account_segment1 := null;
4759 g_po_hdrs_int_rec.po_header_id := l_po_header_id_tbl(i);
4760 g_po_hdrs_int_rec.approval_status := 'IN PROCESS';
4761 g_po_hdrs_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
4762 --The rest of the values can be inserted as null in po_headers_interface
4763 --i.e. we are not touching the values that are alreay present in po_headers_all
4764 g_po_hdrs_int_rec.vendor_id := null;
4765 g_po_hdrs_int_rec.vendor_site_id := null;
4766 g_po_hdrs_int_rec.currency_code := null;
4767 g_po_hdrs_int_rec.cpa_reference := null;
4768 g_po_hdrs_int_rec.created_language := null;
4769 g_po_hdrs_int_rec.comments := null;
4770
4771 l_err_loc := 234;
4772 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4773 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4774 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4775 'inserting into headers interface for delete of lines'||
4776 ', l_del_interface_header_id:' || l_del_interface_header_id ||
4777 ', g_po_hdrs_int_rec.action:' || g_po_hdrs_int_rec.action ||
4778 ', g_po_hdrs_int_rec.po_header_id:' || g_po_hdrs_int_rec.po_header_id ||
4779 ', created_language:' || g_po_hdrs_int_rec.created_language ||
4780 ', comments:' || g_po_hdrs_int_rec.comments ||
4781 ', g_po_hdrs_int_rec.cpa_reference:' || g_po_hdrs_int_rec.cpa_reference ||
4782 ', g_current_gbpa_hdr_rec.upg_cpa_reference:' || g_current_gbpa_hdr_rec.upg_cpa_reference ||
4783 ', g_current_gbpa_hdr_rec.cpa_reference:' || g_current_gbpa_hdr_rec.cpa_reference ||
4784 ', g_current_gbpa_hdr_rec.po_header_id:' ||g_current_gbpa_hdr_rec.po_header_id ||
4785 ', l_po_header_id_tbl:' || l_po_header_id_tbl(i) );
4786 END IF;
4787 l_err_loc := 236;
4788 insertPOHeadersInterface;
4789 END IF; -- IF (l_del_interface_header_id IS NULL)
4790
4791 l_del_interface_line_id := getNextInterfaceLineIdFromSeq;
4792 l_err_loc := 238;
4793 --Put the current values into g_po_line_attrval_int_rec for po_lines_interface
4794 g_po_line_attrval_int_rec.interface_header_id := l_del_interface_header_id;
4795 g_po_line_attrval_int_rec.interface_line_id := l_del_interface_line_id;
4796 g_po_line_attrval_int_rec.action := 'DELETE';
4797 g_po_line_attrval_int_rec.po_line_id := l_po_line_id_tbl(i);
4798 g_po_line_attrval_int_rec.po_header_id := l_po_header_id_tbl(i);
4799 --Put the rest as null
4800 g_po_line_attrval_int_rec.unit_price := null;
4801 g_po_line_attrval_int_rec.uom_code := null;
4802 g_po_line_attrval_int_rec.negotiated_by_preparer_flag := null;
4803 g_po_line_attrval_int_rec.ip_category_id := null;
4804 g_po_line_attrval_int_rec.category_id := null;
4805 g_po_line_attrval_int_rec.category_name := null;
4806 g_po_line_attrval_int_rec.vendor_product_num := null;
4807 g_po_line_attrval_int_rec.supplier_part_auxid := null;
4808 g_po_line_attrval_int_rec.item_description := null;
4809 g_po_line_attrval_int_rec.catalog_name := null;
4810
4811 l_err_loc := 240;
4812 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4813 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4814 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4815 'inserting into lines interface with DELETE action' ||
4816 ', l_del_interface_line_id:' || l_del_interface_line_id ||
4817 ', po_line_id: ' || g_po_line_attrval_int_rec.po_line_id ||
4818 ', rt_item_id: ' || l_rt_item_id_tbl(i) ||
4819 ', l_po_category_id_tbl:' || l_po_category_id_tbl(i) ||
4820 ', l_old_po_category_id_tbl:' || l_old_po_category_id_tbl(i) );
4821 END IF;
4822 l_err_loc := 242;
4823 insertPOLinesInterface;
4824 l_line_deleted := TRUE;
4825 END IF; -- IF (g_current_gbpa_hdr_rec.cpa_reference <> g_current_gbpa_hdr_rec.upg_cpa_reference)
4826 END IF; -- IF (l_po_header_id_tbl(i) IS NOT NULL AND l_po_line_id_tbl(i) IS NOT NULL)
4827
4828 -- For all the following cases we need to create the lines:
4829 -- 1. po_header_id is null
4830 -- 2. po_header_id is not null and created_language = language
4831 -- (This will also cover the case when po_line_id is null i.e the header got created
4832 -- but line was not created because of errors in line.
4833 -- 3. current line is a delete.
4834 IF (g_current_gbpa_hdr_rec.po_header_id IS NULL OR
4835 (g_current_gbpa_hdr_rec.po_header_id IS NOT NULL AND
4836 g_current_gbpa_hdr_rec.upg_created_language = g_current_gbpa_hdr_rec.language) OR
4837 l_line_deleted)
4838 THEN
4839 l_dml_reqd_in_lines := TRUE;
4840 ELSE
4841 l_dml_reqd_in_lines := FALSE;
4842 END IF;
4843 -- Figure out if the row needs to be inserted / updated in icx_cat_r12_upgrade table
4844 l_dml_reqd_in_r12Upgrade := TRUE;
4845 IF (l_po_interface_line_id_tbl(i) IS NULL) THEN
4846 l_createR12UpgradeRow := TRUE;
4847 ELSE
4848 l_createR12UpgradeRow := FALSE;
4849 END IF;
4850 ELSE
4851 -- g_current_gbpa_hdr_rec.interface_header_id <> l_po_interface_header_id_tbl(i)
4852 -- possible case:
4853 -- The lines in this cursor are translations of the earlier header lines
4854 -- (so only need to insert into po_attr_values_tlp_interface)
4855 -- l_dml_reqd_in_lines := FALSE;
4856 -- IF po_header_id is not null and created_language = the current row language, then
4857 -- insert into lines are attr values tables.
4858 l_dml_reqd_in_r12Upgrade := FALSE;
4859 IF (l_po_header_id_tbl(i) IS NOT NULL AND
4860 l_created_language_tbl(i) = g_current_gbpa_hdr_rec.language)
4861 THEN
4862 l_dml_reqd_in_lines := TRUE;
4863 l_lines_po_header_id := l_po_header_id_tbl(i);
4864 ELSE
4865 l_dml_reqd_in_lines := FALSE;
4866 END IF;
4867 l_line_deleted := FALSE;
4868 END IF;
4869
4870 IF (l_dml_reqd_in_r12Upgrade) THEN
4871 l_interface_line_id := getNextInterfaceLineIdFromSeq;
4872 -- Put the current values into g_r12_upg_rec for
4873 -- icx_cat_r12_upgrade (insert/update will be depending on l_createR12UpgradeRow)
4874 l_err_loc := 244;
4875 g_r12_upg_rec.rt_item_id := l_rt_item_id_tbl(i);
4876 g_r12_upg_rec.supplier_site_id := g_current_gbpa_hdr_rec.vendor_site_id;
4877 g_r12_upg_rec.currency := g_current_gbpa_hdr_rec.currency_code;
4878 -- icx_cat_r12_upgrade.price_contract_id is same as the contract_id in price table
4879 -- icx_cat_r12_upgrade.src_contract_id is same as the contract_id returned from autosource
4880 -- Need both contract_ids to figure out any changes in the source document during delta processing.
4881 l_err_loc := 246;
4882 IF (l_price_type_tbl(i) = 'BULKLOAD') THEN
4883 g_r12_upg_rec.price_contract_id := -2;
4884 g_r12_upg_rec.src_contract_id := g_current_gbpa_hdr_rec.cpa_reference;
4885 ELSE
4886 g_r12_upg_rec.price_contract_id := g_current_gbpa_hdr_rec.cpa_reference;
4887 g_r12_upg_rec.src_contract_id := -2;
4888 END IF;
4889 l_err_loc := 248;
4890 g_r12_upg_rec.cpa_reference := g_current_gbpa_hdr_rec.cpa_reference;
4891 g_r12_upg_rec.po_category_id := l_po_category_id_tbl(i);
4892 g_r12_upg_rec.old_po_interface_line_id := l_po_interface_line_id_tbl(i);
4893 g_r12_upg_rec.po_interface_header_id := l_interface_header_id;
4894 g_r12_upg_rec.po_interface_line_id := l_interface_line_id;
4895 l_err_loc := 250;
4896 IF (l_createR12UpgradeRow) THEN
4897 g_r12_upg_rec.created_language := g_current_gbpa_hdr_rec.language;
4898 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4899 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4900 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4901 'inserting into r12 upgrade');
4902 END IF;
4903 insertR12Upgrade;
4904 ELSE
4905 l_err_loc := 252;
4906 IF (l_line_deleted) THEN
4907 -- So that the po_line_id is null in po_attr_values_tlp_interface
4908 -- when translation is inserted for a deleted line
4909 -- (Note: the line was deleted due to source / category change)
4910 g_r12_upg_rec.po_line_id := null;
4911 g_r12_upg_rec.po_header_id := null;
4912 g_r12_upg_rec.created_language := null;
4913 ELSE
4914 l_err_loc := 254;
4915 g_r12_upg_rec.po_line_id := l_po_line_id_tbl(i);
4916 g_r12_upg_rec.po_header_id := l_po_header_id_tbl(i);
4917 g_r12_upg_rec.created_language := l_created_language_tbl(i);
4918 END IF;
4919
4920 l_err_loc := 256;
4921 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4922 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4923 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4924 'updating r12 upgrade' ||
4925 ', old interface_header_id:' || g_current_gbpa_hdr_rec.interface_header_id ||
4926 ', old interface_line_id: ' || l_po_interface_line_id_tbl(i) ||
4927 ', old_cpa_reference: ' || g_current_gbpa_hdr_rec.upg_cpa_reference ||
4928 ', new_cpa_reference: ' || g_current_gbpa_hdr_rec.cpa_reference ||
4929 ', old_po_category_id: ' || l_old_po_category_id_tbl(i) ||
4930 ', new_po_category_id: ' || l_po_category_id_tbl(i) ||
4931 ', g_r12_upg_rec.po_line_id:' || g_r12_upg_rec.po_line_id ||
4932 ', g_r12_upg_rec.po_header_id: ' || g_r12_upg_rec.po_header_id ||
4933 ', g_r12_upg_rec.created_language:' || g_r12_upg_rec.created_language ||
4934 ', g_current_gbpa_hdr_rec.po_header_id:' || g_current_gbpa_hdr_rec.po_header_id ||
4935 ', g_current_gbpa_hdr_rec.upg_created_language:' || g_current_gbpa_hdr_rec.upg_created_language );
4936 END IF;
4937 --update the po_interface_header_id and po_interface_line_id
4938 --in icx_cat_r12_upgrade with the new ones.
4939 l_err_loc := 258;
4940 updateR12Upgrade;
4941 END IF;
4942 ELSE
4943 l_interface_header_id := l_po_interface_header_id_tbl(i) ;
4944 l_interface_line_id := l_po_interface_line_id_tbl(i);
4945 END IF;
4946
4947 IF (l_dml_reqd_in_lines) THEN
4948 l_err_loc := 260;
4949 -- Put the current values into g_po_line_attrval_int_rec for
4950 -- po_lines_interface and po_attr_values_interface
4951 g_po_line_attrval_int_rec.interface_line_id := l_interface_line_id;
4952 g_po_line_attrval_int_rec.interface_header_id := l_interface_header_id;
4953 IF (l_po_line_id_tbl(i) IS NULL OR l_line_deleted) THEN
4954 g_po_line_attrval_int_rec.action := 'ADD';
4955 g_po_line_attrval_int_rec.po_line_id := null;
4956 ELSE
4957 g_po_line_attrval_int_rec.action := 'UPDATE';
4958 g_po_line_attrval_int_rec.po_line_id := l_po_line_id_tbl(i);
4959 END IF;
4960 g_po_line_attrval_int_rec.po_header_id := l_lines_po_header_id;
4961 l_err_loc := 262;
4962 g_po_line_attrval_int_rec.unit_price := l_unit_price_tbl(i);
4963 g_po_line_attrval_int_rec.uom_code := l_unit_of_measure_tbl(i);
4964 g_po_line_attrval_int_rec.negotiated_by_preparer_flag := l_neg_by_prep_flag_tbl(i);
4965 g_po_line_attrval_int_rec.ip_category_id := l_primary_category_id_tbl(i);
4966 -- TO BE CHECKED
4967 l_err_loc := 263;
4968 g_po_line_attrval_int_rec.category_id := l_po_category_id_tbl(i);
4969 l_err_loc := 264;
4970 g_po_line_attrval_int_rec.category_name := l_primary_category_name_tbl(i);
4971 l_err_loc := 266;
4972 g_po_line_attrval_int_rec.vendor_product_num := l_supp_part_num_tbl(i);
4973 g_po_line_attrval_int_rec.supplier_part_auxid := l_supp_part_auxid_tbl(i);
4974 g_po_line_attrval_int_rec.req_template_name := '-2';
4975 g_po_line_attrval_int_rec.req_template_line_num := -2;
4976 g_po_line_attrval_int_rec.inventory_item_id := -2;
4977 g_po_line_attrval_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
4978 g_po_line_attrval_int_rec.rt_item_id := l_rt_item_id_tbl(i);
4979 g_po_line_attrval_int_rec.language := g_current_gbpa_hdr_rec.language;
4980 l_err_loc := 268;
4981 g_po_line_attrval_int_rec.item_description := l_description_tbl(i);
4982 g_po_line_attrval_int_rec.catalog_name := l_catalog_name_tbl(i);
4983
4984 l_err_loc := 270;
4985 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
4986 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
4987 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
4988 'inserting into lines and attr_values with action:' ||
4989 g_po_line_attrval_int_rec.action ||
4990 ', l_rt_item_id_tbl(i): ' || l_rt_item_id_tbl(i) ||
4991 ', interface_line_id: ' || g_po_line_attrval_int_rec.interface_line_id ||
4992 ', interface_header_id: ' || g_po_line_attrval_int_rec.interface_header_id );
4993 END IF;
4994 --Add the current value to the global pl/sql tables
4995 l_err_loc := 272;
4996 insertPOLinesInterface;
4997 l_err_loc := 274;
4998 insertPOAttrValsInterface;
4999 END IF; -- IF (l_dml_reqd_in_lines)
5000
5001 -- Always need to insert into po_attr_values_tlp_interface
5002 -- Put the current values into g_po_attrvalstlp_int_rec for
5003 -- po_attr_values_tlp_interface
5004 l_err_loc := 276;
5005 g_po_attrvalstlp_int_rec.interface_header_id := l_interface_header_id;
5006 g_po_attrvalstlp_int_rec.interface_line_id := l_interface_line_id;
5007 l_err_loc := 278;
5008 IF (l_po_line_id_tbl(i) IS NULL OR l_line_deleted) THEN
5009 g_po_attrvalstlp_int_rec.action := 'ADD';
5010 g_po_attrvalstlp_int_rec.po_line_id := null;
5011 ELSE
5012 l_err_loc := 280;
5013 g_po_attrvalstlp_int_rec.action := l_attr_val_tlp_action_tbl(i);
5014 g_po_attrvalstlp_int_rec.po_line_id := l_po_line_id_tbl(i);
5015 END IF;
5016 l_err_loc := 282;
5017 g_po_attrvalstlp_int_rec.req_template_name := '-2';
5018 g_po_attrvalstlp_int_rec.req_template_line_num := -2;
5019 g_po_attrvalstlp_int_rec.inventory_item_id := -2;
5020 g_po_attrvalstlp_int_rec.org_id := g_current_gbpa_hdr_rec.org_id;
5021 g_po_attrvalstlp_int_rec.language := g_current_gbpa_hdr_rec.language;
5022 g_po_attrvalstlp_int_rec.check_desc_update := ICX_CAT_UTIL_PVT.g_update_description;
5023 g_po_attrvalstlp_int_rec.rt_item_id := l_rt_item_id_tbl(i);
5024
5025 l_err_loc := 290;
5026 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5027 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5028 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5029 'inserting into attr_values_tlp with action:' || g_po_attrvalstlp_int_rec.action ||
5030 ', g_po_attrvalstlp_int_rec.po_line_id: ' || g_po_attrvalstlp_int_rec.po_line_id ||
5031 ', g_current_gbpa_hdr_rec.language: ' || g_current_gbpa_hdr_rec.language ||
5032 ', g_current_gbpa_hdr_rec.upg_created_language: ' || g_current_gbpa_hdr_rec.upg_created_language ||
5033 ', l_rt_item_id_tbl(i): ' || l_rt_item_id_tbl(i) ||
5034 ', interface_line_id: ' || g_po_attrvalstlp_int_rec.interface_line_id ||
5035 ', interface_header_id: ' || g_po_attrvalstlp_int_rec.interface_header_id );
5036 END IF;
5037 l_err_loc := 292;
5038 --Add the current value to the global pl/sql tables
5039 insertPOAttrValsTLPInterface;
5040
5041 l_err_loc := 300;
5042 populatePOInterfaceTables('INLOOP');
5043 END LOOP; --FOR LOOP of l_rt_item_id_tbl
5044
5045 l_err_loc := 310;
5046 EXIT WHEN l_rt_item_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
5047 EXCEPTION
5048 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
5049 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
5050 || '-' || l_err_loc
5051 || ', Total processeded batches:' || l_batch_count
5052 || ', Cursor will be reopened with rt_item_id:' || l_start_rt_item_id;
5053 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
5054 l_err_loc := 330;
5055 IF (processGBPALinesForDeltaCsr%ISOPEN) THEN
5056 CLOSE processGBPALinesForDeltaCsr;
5057 OPEN processGBPALinesForDeltaCsr
5058 (g_current_gbpa_hdr_rec.org_id, g_current_gbpa_hdr_rec.vendor_id,
5059 g_current_gbpa_hdr_rec.vendor_site_id, g_current_gbpa_hdr_rec.currency_code,
5060 g_current_gbpa_hdr_rec.cpa_reference, g_current_gbpa_hdr_rec.language,
5061 l_start_rt_item_id, g_current_gbpa_hdr_rec.po_header_id);
5062 END IF;
5063 END;
5064 END LOOP; --CURSOR LOOP
5065
5066 l_err_loc := 350;
5067 populatePOInterfaceTables('OUTLOOP');
5068
5069 IF (processGBPALinesForDeltaCsr%ISOPEN) THEN
5070 CLOSE processGBPALinesForDeltaCsr;
5071 END IF;
5072
5073 l_err_loc := 360;
5074 g_total_bulkld_row_count := g_total_bulkld_row_count + l_item_row_count;
5075
5076 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5077 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5078 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5079 'done; '||
5080 'Total no: of batches processed:' ||l_batch_count ||
5081 ', Total no: of bulkloaded items processed:' ||l_item_row_count);
5082 END IF;
5083
5084 l_end_date := sysdate;
5085 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5086 ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name,
5087 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
5088 END IF;
5089 EXCEPTION
5090 WHEN OTHERS THEN
5091 ICX_CAT_UTIL_PVT.logUnexpectedException(
5092 G_PKG_NAME, l_api_name,
5093 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
5094
5095 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5096 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5097 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5098 'Current Values in g_current_gbpa_hdr_rec:'||
5099 ', org_id:' ||g_current_gbpa_hdr_rec.org_id ||
5100 ', supplier_id:' ||g_current_gbpa_hdr_rec.vendor_id ||
5101 ', supplier_site_id:' ||g_current_gbpa_hdr_rec.vendor_site_id ||
5102 ', currency:' ||g_current_gbpa_hdr_rec.currency_code ||
5103 ', gbpa_cpa_reference:' ||g_current_gbpa_hdr_rec.cpa_reference ||
5104 ', language:' ||g_current_gbpa_hdr_rec.language ||
5105 ', interface_header_id:' ||g_current_gbpa_hdr_rec.interface_header_id ||
5106 ', po_header_id:' ||g_current_gbpa_hdr_rec.po_header_id ||
5107 ', upg_created_language:' ||g_current_gbpa_hdr_rec.upg_created_language ||
5108 ', upg_cpa_reference:' ||g_current_gbpa_hdr_rec.upg_cpa_reference );
5109 END IF;
5110
5111 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5112 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5113 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5114 'Values fetched from the cursor; '||
5115 'l_rt_item_id_tbl:' || l_rt_item_id_tbl(l_log_index) ||
5116 ', l_supp_part_num_tbl:' || l_supp_part_num_tbl(l_log_index) ||
5117 ', l_supp_part_auxid_tbl:' || l_supp_part_auxid_tbl(l_log_index) ||
5118 ', l_unit_price_tbl:' || l_unit_price_tbl(l_log_index) ||
5119 ', l_unit_of_measure_tbl:' || l_unit_of_measure_tbl(l_log_index) ||
5120 ', l_neg_by_prep_flag_tbl:' || l_neg_by_prep_flag_tbl(l_log_index) ||
5121 ', l_primary_category_id_tbl:' || l_primary_category_id_tbl(l_log_index) ||
5122 ', l_po_category_id_tbl:' || l_po_category_id_tbl(l_log_index) ||
5123 ', l_old_po_category_id_tbl:' || l_old_po_category_id_tbl(l_log_index) ||
5124 ', l_price_type_tbl:' || l_price_type_tbl(l_log_index) );
5125 END IF;
5126
5127 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5128 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5129 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5130 'Values fetched from the cursor; '||
5131 'l_description_tbl:' || l_description_tbl(l_log_index) ||
5132 ', l_catalog_name_tbl:' || l_catalog_name_tbl(l_log_index) ||
5133 ', l_primary_category_name_tbl:' || l_primary_category_name_tbl(l_log_index) ||
5134 ', l_po_interface_header_id_tbl:' || l_po_interface_header_id_tbl(l_log_index) ||
5135 ', l_po_interface_line_id_tbl:' || l_po_interface_line_id_tbl(l_log_index) ||
5136 ', l_po_header_id_tbl:' || l_po_header_id_tbl(l_log_index) ||
5137 ', l_po_line_id_tbl:' || l_po_line_id_tbl(l_log_index) ||
5138 ', l_created_language_tbl:' || l_created_language_tbl(l_log_index) ||
5139 ', l_attr_val_tlp_action_tbl:' || l_attr_val_tlp_action_tbl(l_log_index));
5140 END IF;
5141
5142 raise;
5143 END processGBPALinesForDelta;
5144
5145 PROCEDURE checkUpdateInGBPAForDelta
5146 IS
5147
5148 -- Added the decode for supplier and supplier_site_code, because of some corrupt data
5149 -- that exists on the internal envs (also on gevt11i).
5150 -- The details: supplier_site_id = -2 but supplier_site_code is not null
5151 -- supplier_id = -2 but supplier is not null
5152 -- note that here we need to do nvl for upg.cpa_reference
5153 -- because for new lines the outer join to upg will not return any rows and hence upg.cpa_reference will be null
5154 -- for these guys. but in the table (upg) the cpa_reference is not null (it is actually -2) and since we are
5155 -- grouping these rows on upg.cpa_reference we need both to be -2
5156 CURSOR checkUpdateInGBPAForDeltaCsr IS
5157 SELECT doc.*,
5158 COUNT(*) count
5159 FROM (
5160 SELECT src.org_id org_id, src.supplier_id supplier_id,
5161 src.supplier_site_id supplier_site_id, src.currency currency,
5162 src.contract_id gbpa_cpa_reference,
5163 itemtlp.language language,
5164 upg.po_interface_header_id,
5165 upg.po_header_id, upg.created_language,
5166 nvl(upg.cpa_reference, -2) upg_cpa_reference
5167 FROM icx_cat_r12_upg_autosource src, icx_cat_item_prices price,
5168 icx_cat_items_tlp itemtlp, icx_por_category_order_map map,
5169 icx_cat_items_b itemb, icx_cat_ext_items_tlp extitemtlp,
5170 icx_cat_r12_upgrade upg
5171 WHERE price.price_type = 'BULKLOAD'
5172 AND price.rt_item_id = itemtlp.rt_item_id
5173 AND NOT EXISTS (SELECT 'extracted price'
5174 FROM icx_cat_item_prices priceIn
5175 WHERE priceIn.rt_item_id = price.rt_item_id
5176 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
5177 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
5178 AND itemtlp.primary_category_id = map.rt_category_id (+)
5179 AND itemtlp.org_id = src.org_id
5180 AND itemtlp.supplier_id = src.supplier_id
5181 AND price.supplier_site_id = src.supplier_site_id
5182 AND price.currency = src.currency
5183 AND NVL(map.external_source_key, '-2') = src.po_category_id
5184 AND price.rt_item_id = itemb.rt_item_id
5185 AND price.rt_item_id = extitemtlp.rt_item_id
5186 AND itemtlp.language = extitemtlp.language
5187 AND price.rt_item_id = upg.rt_item_id (+)
5188 AND price.supplier_site_id = upg.supplier_site_id (+)
5189 AND price.currency = upg.currency (+)
5190 AND price.contract_id = upg.price_contract_id (+)
5191 AND ( -- Last update changes in items / price tables
5192 (itemb.last_update_date > g_bulk_last_run_date
5193 OR itemtlp.last_update_date > g_bulk_last_run_date
5194 OR extitemtlp.last_update_date > g_bulk_last_run_date
5195 OR price.last_update_date > g_bulk_last_run_date)
5196 OR -- The items that errored out in the previous run
5197 (upg.po_header_id is null
5198 OR upg.po_line_id is null))
5199 UNION ALL
5200 -- Added NVL to org_id, supplier, site and currency
5201 SELECT NVL(itemtlp.org_id, -2) org_id, NVL(itemtlp.supplier_id, -2) supplier_id,
5202 NVL(price.supplier_site_id, -2) supplier_site_id, NVL(price.currency, '-2') currency,
5203 price.contract_id gbpa_cpa_reference,
5204 itemtlp.language language,
5205 upg.po_interface_header_id,
5206 upg.po_header_id, upg.created_language,
5207 nvl(upg.cpa_reference, -2) upg_cpa_reference
5208 FROM icx_cat_item_prices price, icx_cat_items_tlp itemtlp,
5209 icx_cat_items_b itemb, icx_cat_ext_items_tlp extitemtlp,
5210 icx_cat_r12_upgrade upg
5211 WHERE price.price_type = 'CONTRACT'
5212 AND price.rt_item_id = itemtlp.rt_item_id
5213 AND NOT EXISTS (SELECT 'extracted price'
5214 FROM icx_cat_item_prices priceIn
5215 WHERE priceIn.rt_item_id = price.rt_item_id
5216 AND priceIn.price_type IN ('BLANKET', 'GLOBAL_AGREEMENT', 'QUOTATION',
5217 'INTERNAL_TEMPLATE', 'TEMPLATE', 'ASL'))
5218 AND price.rt_item_id = itemb.rt_item_id
5219 AND price.rt_item_id = extitemtlp.rt_item_id
5220 AND itemtlp.language = extitemtlp.language
5221 AND price.rt_item_id = upg.rt_item_id (+)
5222 AND price.supplier_site_id = upg.supplier_site_id (+)
5223 AND price.currency = upg.currency (+)
5224 AND price.contract_id = upg.price_contract_id (+)
5225 AND ( -- Last update changes in items / price tables
5226 (itemb.last_update_date > g_bulk_last_run_date
5227 OR itemtlp.last_update_date > g_bulk_last_run_date
5228 OR extitemtlp.last_update_date > g_bulk_last_run_date
5229 OR price.last_update_date > g_bulk_last_run_date)
5230 OR -- The items that errored out in the previous run
5231 (upg.po_header_id is null
5232 OR upg.po_line_id is null))
5233 ) doc
5234 GROUP BY doc.org_id, doc.supplier_id, doc.supplier_site_id,
5235 doc.currency, doc.gbpa_cpa_reference,
5236 doc.language,
5237 doc.po_interface_header_id, doc.po_header_id,
5238 doc.created_language, doc.upg_cpa_reference
5239 ORDER BY doc.org_id, doc.supplier_id, doc.supplier_site_id,
5240 doc.currency, doc.gbpa_cpa_reference,
5241 doc.po_interface_header_id, count DESC, doc.language;
5242
5243 ----- Start of declaring columns selected in the cursor -----
5244
5245 l_org_id_tbl DBMS_SQL.NUMBER_TABLE;
5246 l_supplier_id_tbl DBMS_SQL.NUMBER_TABLE;
5247 l_supplier_site_id_tbl DBMS_SQL.NUMBER_TABLE;
5248 l_currency_tbl DBMS_SQL.VARCHAR2_TABLE;
5249 l_gbpa_cpa_reference_tbl DBMS_SQL.NUMBER_TABLE;
5250 l_language_tbl DBMS_SQL.VARCHAR2_TABLE;
5251 l_po_interface_header_id_tbl DBMS_SQL.NUMBER_TABLE;
5252 l_po_header_id_tbl DBMS_SQL.NUMBER_TABLE;
5253 l_upg_created_language_tbl DBMS_SQL.VARCHAR2_TABLE;
5254 l_upg_cpa_reference_tbl DBMS_SQL.NUMBER_TABLE;
5255 l_count_tbl DBMS_SQL.NUMBER_TABLE;
5256
5257 ------ End of declaring columns selected in the cursor ------
5258
5259 l_api_name CONSTANT VARCHAR2(30) := 'checkUpdateInGBPAForDelta';
5260 l_err_loc PLS_INTEGER;
5261 l_interface_header_id NUMBER;
5262 l_start_date DATE;
5263 l_end_date DATE;
5264 l_log_string VARCHAR2(2000);
5265 BEGIN
5266 l_err_loc := 100;
5267 l_start_date := sysdate;
5268
5269 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5270 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5271 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5272 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
5273 END IF;
5274 -- Perform the contract auto sourcing for delta
5275 contractAutoSourcing;
5276
5277 l_err_loc := 110;
5278 OPEN checkUpdateInGBPAForDeltaCsr;
5279
5280 l_err_loc := 120;
5281 --Not expecting a huge number of GBPA header's that will be returned from the cursor.
5282 --Considering the fact that we are grouping by on supplier_id, org_id, supplier_site_id, currency and language
5283 FETCH checkUpdateInGBPAForDeltaCsr BULK COLLECT INTO
5284 l_org_id_tbl, l_supplier_id_tbl, l_supplier_site_id_tbl, l_currency_tbl,
5285 l_gbpa_cpa_reference_tbl, l_language_tbl,
5286 l_po_interface_header_id_tbl, l_po_header_id_tbl, l_upg_created_language_tbl,
5287 l_upg_cpa_reference_tbl, l_count_tbl;
5288
5289
5290 l_err_loc := 130;
5291 CLOSE checkUpdateInGBPAForDeltaCsr;
5292
5293 l_err_loc := 140;
5294 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5295 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5296 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5297 'Total no: of distinct GBPA headers attributes found:' || l_org_id_tbl.COUNT);
5298 END IF;
5299
5300 l_err_loc := 150;
5301 FOR i in 1..l_org_id_tbl.COUNT LOOP
5302 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5303 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
5304 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5305 ' --> Values fetched from the cursor; '||
5306 'l_org_id_tbl:' || l_org_id_tbl(i) ||
5307 ', l_supplier_id_tbl:' || l_supplier_id_tbl(i) ||
5308 ', l_supplier_site_id_tbl:' || l_supplier_site_id_tbl(i) ||
5309 ', l_currency_tbl:' || l_currency_tbl(i) ||
5310 ', l_gbpa_cpa_reference_tbl:' || l_gbpa_cpa_reference_tbl(i) ||
5311 ', l_language_tbl:' || l_language_tbl(i) ||
5312 ', l_supplier_id_tbl:' || l_supplier_id_tbl(i) ||
5313 ', l_po_interface_header_id_tbl:' || l_po_interface_header_id_tbl(i) ||
5314 ', l_po_header_id_tbl:' || l_po_header_id_tbl(i) ||
5315 ', l_upg_created_language_tbl:' ||l_upg_created_language_tbl(i) ||
5316 ', l_upg_cpa_reference_tbl:' || l_upg_cpa_reference_tbl(i) ||
5317 ', l_count_tbl:' || l_count_tbl(i) );
5318 END IF;
5319
5320 l_err_loc := 160;
5321 g_current_gbpa_hdr_rec.org_id := l_org_id_tbl(i);
5322 g_current_gbpa_hdr_rec.vendor_id := l_supplier_id_tbl(i);
5323 g_current_gbpa_hdr_rec.vendor_site_id := l_supplier_site_id_tbl(i);
5324 g_current_gbpa_hdr_rec.currency_code := l_currency_tbl(i);
5325 g_current_gbpa_hdr_rec.language := l_language_tbl(i);
5326 g_current_gbpa_hdr_rec.cpa_reference := l_gbpa_cpa_reference_tbl(i);
5327 g_current_gbpa_hdr_rec.interface_header_id := l_po_interface_header_id_tbl(i);
5328 g_current_gbpa_hdr_rec.po_header_id := l_po_header_id_tbl(i);
5329 g_current_gbpa_hdr_rec.upg_created_language := l_upg_created_language_tbl(i);
5330 g_current_gbpa_hdr_rec.upg_cpa_reference := l_upg_cpa_reference_tbl(i);
5331
5332 l_err_loc := 170;
5333 processGBPALinesForDelta;
5334 END LOOP; --FOR LOOP of l_org_id_tbl
5335
5336 l_err_loc := 180;
5337 l_end_date := sysdate;
5338 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5339 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5340 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5341 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date) ||
5342 '; Total no: of GBPA headers created:' || g_GBPA_hdr_count ||
5343 ', Total no: of bulkload items processed:' || g_total_bulkld_row_count);
5344 END IF;
5345 EXCEPTION
5346 WHEN OTHERS THEN
5347 ICX_CAT_UTIL_PVT.logUnexpectedException(
5348 G_PKG_NAME, l_api_name,
5349 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
5350 raise;
5351 END checkUpdateInGBPAForDelta;
5352
5353 PROCEDURE checkDeleteInGBPAForDelta
5354 IS
5355 -- Reason for joining back to po_headers_all is:
5356 -- pomigratecatalog code is dependant on the org_id being
5357 -- populated in po_headers_interface for its processing
5358 -- Reason for outer join with po_headers_all, because there may be items in
5359 -- catalog that was never migrated due to errors, so they will have po_header_id as null
5360 CURSOR getDeletedItemPricesInCatlgCsr IS
5361 SELECT rt_item_id, po_interface_header_id, po_interface_line_id,
5362 upg.po_header_id, po_line_id, ph.org_id
5363 FROM icx_cat_r12_upgrade upg, po_headers_all ph
5364 WHERE NOT EXISTS (SELECT 'x'
5365 FROM icx_cat_items_b itemsB, icx_cat_item_prices prices
5366 WHERE itemsB.rt_item_id = prices.rt_item_id
5367 AND upg.rt_item_id = prices.rt_item_id
5368 AND upg.supplier_site_id = prices.supplier_site_id
5369 AND upg.currency = prices.currency
5370 AND upg.price_contract_id = prices.contract_id)
5371 /* NOT NEEDED IF WE UPDATE the prices table with contract_id = -2 for bulkload items.
5372 (upg.contract_id IS NULL OR
5373 prices.contract_id IS NULL OR
5374 upg.contract_id = prices.contract_id) */
5375 AND upg.po_header_id = ph.po_header_id (+)
5376 -- Order by is done for inserting only one header into po_interface_headers
5377 -- for all the lines to be deleted in a particular header.
5378 ORDER BY upg.po_header_id;
5379
5380 ----- Start of declaring columns selected in the cursor -----
5381
5382 l_rt_item_id_tbl DBMS_SQL.NUMBER_TABLE;
5383 l_po_interface_header_id_tbl DBMS_SQL.NUMBER_TABLE;
5384 l_po_interface_line_id_tbl DBMS_SQL.NUMBER_TABLE;
5385 l_po_header_id_tbl DBMS_SQL.NUMBER_TABLE;
5386 l_po_line_id_tbl DBMS_SQL.NUMBER_TABLE;
5387 l_org_id_tbl DBMS_SQL.NUMBER_TABLE;
5388
5389 ------ End of declaring columns selected in the cursor ------
5390
5391 l_api_name CONSTANT VARCHAR2(30) := 'checkDeleteInGBPAForDelta';
5392 l_err_loc PLS_INTEGER;
5393 l_err_string VARCHAR2(4000);
5394 l_batch_count PLS_INTEGER;
5395 l_item_row_count PLS_INTEGER;
5396 l_prev_po_header_id NUMBER;
5397 l_interface_header_id NUMBER;
5398 l_interface_line_id NUMBER;
5399 l_start_date DATE;
5400 l_end_date DATE;
5401 l_log_string VARCHAR2(2000);
5402 BEGIN
5403 l_err_loc := 100;
5404 l_start_date := sysdate;
5405
5406 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5407 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5408 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5409 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
5410 END IF;
5411 l_batch_count := 0;
5412 l_item_row_count := 0;
5413 --Assign the previous po_header_id to some dummy values
5414 l_prev_po_header_id := -1212;
5415
5416 l_err_loc := 110;
5417 OPEN getDeletedItemPricesInCatlgCsr;
5418
5419 LOOP
5420 l_err_loc := 120;
5421 l_rt_item_id_tbl.DELETE;
5422 l_po_interface_header_id_tbl.DELETE;
5423 l_po_interface_line_id_tbl.DELETE;
5424 l_po_header_id_tbl.DELETE;
5425 l_po_line_id_tbl.DELETE;
5426 l_org_id_tbl.DELETE;
5427
5428 BEGIN
5429 l_err_loc := 130;
5430 FETCH getDeletedItemPricesInCatlgCsr BULK COLLECT INTO
5431 l_rt_item_id_tbl, l_po_interface_header_id_tbl,
5432 l_po_interface_line_id_tbl, l_po_header_id_tbl,
5433 l_po_line_id_tbl, l_org_id_tbl
5434 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
5435
5436 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5437 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5438 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5439 'Total no: of records fetced from the cursor:' || l_rt_item_id_tbl.COUNT);
5440 END IF;
5441
5442 l_err_loc := 160;
5443 EXIT WHEN l_rt_item_id_tbl.COUNT = 0;
5444
5445 l_err_loc := 170;
5446 l_batch_count := l_batch_count + 1;
5447
5448 l_err_loc := 190;
5449 l_item_row_count := l_item_row_count + l_rt_item_id_tbl.COUNT;
5450
5451 l_err_loc := 200;
5452 FOR i in 1..l_rt_item_id_tbl.COUNT LOOP
5453 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5454 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
5455 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5456 ' --> Values fetched from the cursor; '||
5457 'l_rt_item_id_tbl:' || l_rt_item_id_tbl(i) ||
5458 ', l_po_interface_header_id_tbl:' || l_po_interface_header_id_tbl(i) ||
5459 ', l_po_interface_line_id_tbl:' || l_po_interface_line_id_tbl(i) ||
5460 ', l_po_header_id_tbl:' || l_po_header_id_tbl(i) ||
5461 ', l_po_line_id_tbl:' || l_po_line_id_tbl(i) ||
5462 ', l_org_id_tbl:' || l_org_id_tbl(i) );
5463 END IF;
5464
5465 IF (l_po_line_id_tbl(i) IS NOT NULL) THEN
5466 --Only if the line was created as a po_line, need to Insert a row
5467 --in po_lines_interface with DELETE action
5468 --And also delete the row from icx_cat_r12_upgrade.
5469 IF (l_prev_po_header_id <> l_po_header_id_tbl(i)) THEN
5470 --po_header_id has changed, so get the next interfaceHeaderId
5471 --and populate a line in po_headers_interface
5472 l_interface_header_id := getNextInterfaceHdrIdFromSeq;
5473
5474 l_err_loc := 210;
5475 g_po_hdrs_int_rec.interface_header_id := l_interface_header_id;
5476 g_po_hdrs_int_rec.action := 'UPDATE';
5477 g_po_hdrs_int_rec.document_type_code := 'BLANKET';
5478 g_po_hdrs_int_rec.budget_account_segment1 := null;
5479 g_po_hdrs_int_rec.po_header_id := l_po_header_id_tbl(i);
5480 g_po_hdrs_int_rec.approval_status := 'IN PROCESS';
5481 g_po_hdrs_int_rec.org_id := l_org_id_tbl(i);
5482 --The rest of the values can be inserted as null in po_headers_interface
5483 --i.e. we are not touching the values that are alreay present in po_headers_all
5484 g_po_hdrs_int_rec.vendor_id := null;
5485 g_po_hdrs_int_rec.vendor_site_id := null;
5486 g_po_hdrs_int_rec.currency_code := null;
5487 g_po_hdrs_int_rec.cpa_reference := null;
5488 g_po_hdrs_int_rec.created_language := null;
5489 g_po_hdrs_int_rec.comments := null;
5490
5491 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5492 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
5493 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5494 ' --> inserting into headers interface' ||
5495 ', g_po_hdrs_int_rec.po_header_id: ' || g_po_hdrs_int_rec.po_header_id ||
5496 ', l_interface_header_id: ' || l_interface_header_id);
5497 END IF;
5498 insertPOHeadersInterface;
5499 END IF;
5500
5501 --Get the next interfaceLineId to be used in po_lines_interface
5502 l_interface_line_id := getNextInterfaceLineIdFromSeq;
5503 l_err_loc := 220;
5504 --Put the current values into g_po_line_attrval_int_rec for po_lines_interface
5505 g_po_line_attrval_int_rec.interface_header_id := l_interface_header_id;
5506 g_po_line_attrval_int_rec.interface_line_id := l_interface_line_id;
5507 g_po_line_attrval_int_rec.action := 'DELETE';
5508 g_po_line_attrval_int_rec.po_line_id := l_po_line_id_tbl(i);
5509 g_po_line_attrval_int_rec.po_header_id := l_po_header_id_tbl(i);
5510 --Put the rest as null
5511 g_po_line_attrval_int_rec.unit_price := null;
5512 g_po_line_attrval_int_rec.uom_code := null;
5513 g_po_line_attrval_int_rec.negotiated_by_preparer_flag := null;
5514 g_po_line_attrval_int_rec.ip_category_id := null;
5515 g_po_line_attrval_int_rec.category_id := null;
5516 g_po_line_attrval_int_rec.category_name := null;
5517 g_po_line_attrval_int_rec.vendor_product_num := null;
5518 g_po_line_attrval_int_rec.supplier_part_auxid := null;
5519 g_po_line_attrval_int_rec.item_description := null;
5520 g_po_line_attrval_int_rec.catalog_name := null;
5521
5522 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5523 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
5524 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5525 ' --> inserting into lines interface' ||
5526 ', g_po_line_attrval_int_rec.po_header_id: ' || g_po_line_attrval_int_rec.po_header_id ||
5527 ', g_po_line_attrval_int_rec.po_line_id: ' || g_po_line_attrval_int_rec.po_line_id ||
5528 ', l_interface_header_id: ' || l_interface_header_id ||
5529 ', l_interface_line_id: ' || l_interface_line_id);
5530 END IF;
5531 insertPOLinesInterface;
5532 END IF;
5533
5534 l_err_loc := 230;
5535 g_r12_upg_rec.rt_item_id := l_rt_item_id_tbl(i);
5536 g_r12_upg_rec.po_interface_header_id := l_po_interface_header_id_tbl(i);
5537 g_r12_upg_rec.po_interface_line_id := l_po_interface_line_id_tbl(i);
5538 g_r12_upg_rec.po_header_id := l_po_header_id_tbl(i);
5539 g_r12_upg_rec.po_line_id := l_po_line_id_tbl(i);
5540
5541 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5542 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
5543 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5544 ' --> deleting from r12 upgrade' ||
5545 ', l_rt_item_id_tbl: ' || l_rt_item_id_tbl(i) );
5546 END IF;
5547 deleteR12Upgrade;
5548
5549 l_err_loc := 240;
5550 l_prev_po_header_id := l_po_header_id_tbl(i);
5551
5552 l_err_loc := 300;
5553 populatePOInterfaceTables('INLOOP');
5554 END LOOP; --FOR LOOP of l_rt_item_id_tbl
5555
5556 l_err_loc := 310;
5557 EXIT WHEN l_rt_item_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
5558 EXCEPTION
5559 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
5560 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
5561 || '-' || l_err_loc
5562 || ', Total processeded batches:' || l_batch_count
5563 || ', Cursor will be reopened;';
5564 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
5565 l_err_loc := 330;
5566 IF (getDeletedItemPricesInCatlgCsr%ISOPEN) THEN
5567 CLOSE getDeletedItemPricesInCatlgCsr;
5568 OPEN getDeletedItemPricesInCatlgCsr;
5569 END IF;
5570 END;
5571 END LOOP; --CURSOR LOOP
5572
5573 l_err_loc := 350;
5574 populatePOInterfaceTables('OUTLOOP');
5575
5576 IF (getDeletedItemPricesInCatlgCsr%ISOPEN) THEN
5577 CLOSE getDeletedItemPricesInCatlgCsr;
5578 END IF;
5579
5580 l_err_loc := 360;
5581 l_end_date := sysdate;
5582 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5583 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5584 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5585 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date) ||
5586 ', Total no: of batches processed:' ||l_batch_count ||
5587 ', Total no: of bulkloaded items processed:' ||l_item_row_count);
5588 END IF;
5589
5590 EXCEPTION
5591 WHEN OTHERS THEN
5592 ICX_CAT_UTIL_PVT.logUnexpectedException(
5593 G_PKG_NAME, l_api_name,
5594 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
5595 raise;
5596 END checkDeleteInGBPAForDelta;
5597
5598 PROCEDURE syncPOIntHdrIdInR12UpgTbl
5599 IS
5600 CURSOR syncPOIntHdrIdInR12UpgTblCsr IS
5601 SELECT doc.po_header_id, COUNT(*)
5602 FROM (SELECT po_interface_header_id, po_header_id
5603 FROM icx_cat_r12_upgrade
5604 WHERE po_header_id IS NOT NULL
5605 GROUP BY po_interface_header_id, po_header_id) doc
5606 GROUP BY po_header_id
5607 HAVING COUNT(*) > 1;
5608
5609 CURSOR syncRowsInR12UpgTblCsr IS
5610 SELECT rowid
5611 FROM icx_cat_r12_upgrade
5612 WHERE po_header_id IS NULL
5613 AND po_interface_header_id IS NOT NULL;
5614
5615 ----- Start of declaring columns selected in the cursor -----
5616
5617 l_po_header_id_tbl DBMS_SQL.NUMBER_TABLE;
5618 l_count_tbl DBMS_SQL.NUMBER_TABLE;
5619 l_rowid_tbl DBMS_SQL.UROWID_TABLE;
5620
5621 ------ End of declaring columns selected in the cursor ------
5622
5623 l_api_name CONSTANT VARCHAR2(30) := 'syncPOIntHdrIdInR12UpgTbl';
5624 l_err_loc PLS_INTEGER;
5625 l_batch_count PLS_INTEGER;
5626 l_item_row_count PLS_INTEGER;
5627 l_start_date DATE;
5628 l_end_date DATE;
5629 l_upo_hdr_id_tbl DBMS_SQL.NUMBER_TABLE;
5630 l_upo_int_hdr_id_tbl DBMS_SQL.NUMBER_TABLE;
5631 l_upd_index PLS_INTEGER;
5632 l_err_string VARCHAR2(4000);
5633
5634 BEGIN
5635 l_err_loc := 100;
5636 l_start_date := sysdate;
5637
5638 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5639 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5640 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5641 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
5642 END IF;
5643
5644 l_err_loc := 200;
5645 OPEN syncPOIntHdrIdInR12UpgTblCsr;
5646
5647 l_err_loc := 300;
5648 FETCH syncPOIntHdrIdInR12UpgTblCsr BULK COLLECT INTO
5649 l_po_header_id_tbl, l_count_tbl;
5650
5651 l_err_loc := 400;
5652 CLOSE syncPOIntHdrIdInR12UpgTblCsr;
5653
5654 l_err_loc := 500;
5655 FOR i in 1..l_po_header_id_tbl.COUNT LOOP
5656 l_upd_index := l_upo_hdr_id_tbl.COUNT + 1;
5657 l_err_loc := 600;
5658 l_upo_int_hdr_id_tbl(l_upd_index) := getNextInterfaceHdrIdFromSeq;
5659 l_upo_hdr_id_tbl(l_upd_index) := l_po_header_id_tbl(i);
5660
5661 l_err_loc := 700;
5662 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5663 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5664 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5665 ' --> Values fetched from the cursor; '||
5666 'l_po_header_id_tbl:' || l_po_header_id_tbl(i) ||
5667 ', l_count_tbl:' || l_count_tbl(i) ||
5668 ', new_interface_header_id:' || l_upo_int_hdr_id_tbl(l_upd_index) );
5669 END IF;
5670 END LOOP; --FOR LOOP of l_po_header_id_tbl
5671
5672 l_err_loc := 800;
5673 FORALL i IN 1..l_upo_hdr_id_tbl.COUNT
5674 UPDATE icx_cat_r12_upgrade
5675 SET po_interface_header_id = l_upo_int_hdr_id_tbl(i)
5676 WHERE po_header_id = l_upo_hdr_id_tbl(i);
5677
5678 l_err_loc := 900;
5679 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5680 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5681 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5682 'Number of rows updated in r12 upgrade with new interface_header_id ' || SQL%ROWCOUNT);
5683 END IF;
5684
5685 l_err_loc := 1000;
5686
5687 -- Set po_interface_header_id and created_language
5688 -- to null for all the rows which doesn't have a po_header_id
5689 l_batch_count := 0;
5690 l_item_row_count := 0;
5691
5692 OPEN syncRowsInR12UpgTblCsr;
5693
5694 LOOP
5695 l_err_loc := 1100;
5696 l_rowid_tbl.DELETE;
5697
5698 BEGIN
5699 l_err_loc := 1200;
5700 FETCH syncRowsInR12UpgTblCsr BULK COLLECT INTO
5701 l_rowid_tbl
5702 LIMIT ICX_CAT_UTIL_PVT.g_batch_size;
5703
5704 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5705 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5706 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5707 'Total no: of rows fetched from the cursor:' || l_rowid_tbl.COUNT);
5708 END IF;
5709
5710 l_err_loc := 1300;
5711 EXIT WHEN l_rowid_tbl.COUNT = 0;
5712
5713 l_err_loc := 1400;
5714 l_batch_count := l_batch_count + 1;
5715
5716 l_err_loc := 1500;
5717 l_item_row_count := l_item_row_count + l_rowid_tbl.COUNT;
5718
5719 l_err_loc := 1600;
5720 FORALL i IN 1..l_rowid_tbl.COUNT
5721 UPDATE icx_cat_r12_upgrade
5722 SET po_interface_header_id = NULL,
5723 created_language = NULL
5724 WHERE rowid = l_rowid_tbl(i);
5725
5726 l_err_loc := 1700;
5727 IF (l_rowid_tbl.COUNT > 0) THEN
5728 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5729 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
5730 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5731 'No: of rows updated in icx_cat_r12_upgrade:' ||SQL%ROWCOUNT);
5732 END IF;
5733 END IF;
5734
5735 l_err_loc := 1800;
5736 COMMIT;
5737
5738 EXIT WHEN l_rowid_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
5739 EXCEPTION
5740 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
5741 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
5742 || '-' || l_err_loc
5743 || ', Total processed batches:' || l_batch_count
5744 || ', Cursor will be reopened.';
5745 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
5746 l_err_loc := 1900;
5747 IF (syncRowsInR12UpgTblCsr%ISOPEN) THEN
5748 CLOSE syncRowsInR12UpgTblCsr;
5749 END IF;
5750 OPEN syncRowsInR12UpgTblCsr;
5751 END;
5752 END LOOP; --CURSOR LOOP
5753
5754 l_err_loc := 2000;
5755 IF (syncRowsInR12UpgTblCsr%ISOPEN) THEN
5756 CLOSE syncRowsInR12UpgTblCsr;
5757 END IF;
5758
5759 l_err_loc := 2100;
5760 l_end_date := sysdate;
5761 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5762 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5763 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5764 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date) ||
5765 ', Total no: of batches processed:' ||l_batch_count ||
5766 ', Total no: of bulkloaded items processed:' ||l_item_row_count);
5767 END IF;
5768
5769 EXCEPTION
5770 WHEN OTHERS THEN
5771 ICX_CAT_UTIL_PVT.logUnexpectedException(
5772 G_PKG_NAME, l_api_name,
5773 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
5774 raise;
5775 END syncPOIntHdrIdInR12UpgTbl;
5776
5777 PROCEDURE syncGBPAsForDeltaInBlkldItems
5778 IS
5779 l_api_name CONSTANT VARCHAR2(30) := 'syncGBPAsForDeltaInBlkldItems';
5780 l_err_loc PLS_INTEGER;
5781 BEGIN
5782 l_err_loc := 100;
5783
5784 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5785 ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, 'Start...');
5786 END IF;
5787 /*
5788 Possible changes after pre-upgrade and before another run of pre-upgrade/upgrade
5789 1. Check for items added i.e. rt_item_id not in icx_cat_r12_upgrade
5790 2. Check for price added i.e. price_rowid not in icx_cat_r12_upgrade
5791 3. Check for item updated/translation added
5792 Note: Steps 1, 2 and 3 will be done together using the following approach:
5793 a) Outer join with icx_cat_r12_upgrade
5794 b) Check for last_update_date > g_bulk_last_run_date in icx_cat_items_b, icx_cat_items_tlp,
5795 icx_cat_ext_items_tlp and icx_cat_item_prices
5796 4. Check for items deleted i.e. rt_item_id exists in icx_cat_r12_upgrade but not in icx_cat_items_b
5797 5. Check for price deleted i.e. price_rowid exists in icx_cat_r12_upgrade but not in icx_cat_items_b
5798 6. Check for any pricing hdr attribute (i.e. supplier_site_id, currency, contract_id) update after running pre-upgrade.
5799 Note: Steps 4, 5 and 6 will be done together using the following approach:
5800 a) Get all the records from icx_cat_r12_upgrade that don't exist in icx_cat_items_b and icx_cat_item_prices
5801 based on rt_item_id, supplier_site_id, currency, contract_id
5802 7. Check for items that have errors i.e. the ones that were not migrated into po tables due to validation errors,
5803 These will have po_interface_header_id and po_interface_line_id populated but will have null po_header_id and po_line_id
5804 Assumptions: Translations cannot be deleted.
5805 */
5806 -- First we will sync up all the po_interface_header_ids
5807 -- in icx_cat_r12_upgrade which belongs to the same po_header_id but exists with
5808 -- different po_interface_header_id in icx_cat_r12_upgrade
5809 -- Reason being, lines belonging to the same po_header where processed at two different upgrade delta jobs.
5810 syncPOIntHdrIdInR12UpgTbl;
5811
5812 -- call the delete
5813 checkDeleteInGBPAForDelta; --Checks for Steps 4, 5 and 6.
5814 checkUpdateInGBPAForDelta; --Checks for Steps 1, 2, 3 and 7.
5815
5816 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5817 ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name, ' done ;' );
5818 END IF;
5819 EXCEPTION
5820 WHEN OTHERS THEN
5821 ICX_CAT_UTIL_PVT.logUnexpectedException(
5822 G_PKG_NAME, l_api_name,
5823 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
5824 raise;
5825 END syncGBPAsForDeltaInBlkldItems;
5826
5827 PROCEDURE migrateBulkloadItems
5828 IS
5829 CURSOR cleanUpContractIdsCsr(p_rt_item_id NUMBER) IS
5830 SELECT rowid, rt_item_id
5831 FROM icx_cat_item_prices
5832 WHERE rt_item_id >= p_rt_item_id
5833 AND price_type in ('BULKLOAD', 'CONTRACT')
5834 AND contract_id IS NULL;
5835
5836 l_api_name CONSTANT VARCHAR2(30) := 'migrateBulkloadItems';
5837 l_err_loc PLS_INTEGER;
5838 l_rowid_tbl DBMS_SQL.UROWID_TABLE;
5839 l_rt_item_id_tbl DBMS_SQL.NUMBER_TABLE;
5840 l_batch_count PLS_INTEGER;
5841 l_start_rt_item_id NUMBER;
5842 l_err_string VARCHAR2(4000);
5843 l_icx_schema_name VARCHAR2(30) := NULL;
5844 BEGIN
5845 l_err_loc := 100;
5846 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5847 ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, 'Start...');
5848 END IF;
5849
5850 -- cleanup the contract_id for bulkload items
5851 l_err_loc := 110;
5852 OPEN cleanUpContractIdsCsr(0);
5853 LOOP
5854 l_err_loc := 120;
5855 l_rowid_tbl.DELETE;
5856 l_rt_item_id_tbl.DELETE;
5857
5858 BEGIN
5859 l_err_loc := 130;
5860 FETCH cleanUpContractIdsCsr BULK COLLECT INTO
5861 l_rowid_tbl, l_rt_item_id_tbl
5862 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
5863
5864 l_err_loc := 140;
5865 EXIT WHEN l_rt_item_id_tbl.COUNT = 0;
5866
5867 l_err_loc := 150;
5868 l_batch_count := l_batch_count + 1;
5869
5870 l_err_loc := 160;
5871 --Save the last rt_item_id processed,
5872 --so that re-open of cursor will start from the saved rt_item_id.
5873 l_start_rt_item_id := l_rt_item_id_tbl(l_rt_item_id_tbl.COUNT);
5874
5875 l_err_loc := 180;
5876 FORALL i IN 1..l_rowid_tbl.COUNT
5877 UPDATE icx_cat_item_prices
5878 SET contract_id = -2
5879 WHERE rowid = l_rowid_tbl(i);
5880
5881 l_err_loc := 185;
5882 IF (l_rowid_tbl.COUNT > 0) THEN
5883 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5884 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
5885 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5886 'No: of rows updated in icx_cat_item_prices:' ||SQL%ROWCOUNT);
5887 END IF;
5888 END IF;
5889
5890 l_err_loc := 190;
5891 COMMIT;
5892
5893 l_err_loc := 200;
5894 EXIT WHEN l_rt_item_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
5895 EXCEPTION
5896 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
5897 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
5898 || '-' || l_err_loc
5899 || ', Total processeded batches:' || l_batch_count
5900 || ', Cursor will be reopened with rt_item_id:' || l_start_rt_item_id;
5901 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
5902 l_err_loc := 210;
5903 IF (cleanUpContractIdsCsr%ISOPEN) THEN
5904 CLOSE cleanUpContractIdsCsr;
5905 OPEN cleanUpContractIdsCsr(l_start_rt_item_id);
5906 END IF;
5907 END;
5908 END LOOP; --CURSOR LOOP
5909
5910 l_err_loc := 220;
5911 IF (cleanUpContractIdsCsr%ISOPEN) THEN
5912 CLOSE cleanUpContractIdsCsr;
5913 END IF;
5914
5915 g_GBPA_hdr_count := 0;
5916 g_total_bulkld_row_count := 0;
5917
5918 IF g_bulk_last_run_date IS NULL THEN
5919 l_err_loc := 230;
5920 -- Delete all the rows in icx_cat_r12_upgrade, because pre-upgrade was never run
5921 -- or never ran successfully. But icx_cat_r12_upgrade could have data from the
5922 -- previous run of data exception jobs.
5923 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5924 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5925 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5926 'g_bulk_last_run_date:' || g_bulk_last_run_date ||
5927 '; about to truncate icx_cat_r12_upgrade...');
5928 END IF;
5929
5930 l_err_loc := 240;
5931 l_icx_schema_name := ICX_CAT_UTIL_PVT.getIcxSchemaName;
5932
5933 l_err_loc := 250;
5934 EXECUTE IMMEDIATE
5935 'TRUNCATE TABLE '|| l_icx_schema_name ||'.icx_cat_r12_upgrade';
5936
5937 l_err_loc := 260;
5938 createGBPAsForBlkldItems; --First time
5939 ELSE
5940 l_err_loc := 270;
5941 syncGBPAsForDeltaInBlkldItems; --Pre-upgrade is already run
5942 END IF;
5943 EXCEPTION
5944 WHEN OTHERS THEN
5945 ICX_CAT_UTIL_PVT.logUnexpectedException(
5946 G_PKG_NAME, l_api_name,
5947 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
5948 raise;
5949 END migrateBulkloadItems;
5950
5951 -- End of bulk load items upgrade --
5952
5953 -- No need of this in the code to be source controlled.
5954 PROCEDURE callPOMigrateCatalog
5955 IS
5956 l_api_name CONSTANT VARCHAR2(30) := 'callPOMigrateCatalog';
5957 l_err_loc PLS_INTEGER;
5958 l_return_status VARCHAR2(20);
5959 l_msg_count NUMBER;
5960 l_msg_data VARCHAR2(4000);
5961 l_start_date DATE;
5962 l_end_date DATE;
5963 l_log_string VARCHAR2(2000);
5964 BEGIN
5965 l_err_loc := 100;
5966 ICX_CAT_UTIL_PVT.g_job_pdoi_update_date := NULL;
5967 l_start_date := sysdate;
5968
5969 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5970 l_log_string := 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ||
5971 ', g_current_program:' || ICX_CAT_UTIL_PVT.g_current_program ||
5972 ', g_data_exception_program:' || ICX_CAT_UTIL_PVT.g_data_exception_program;
5973 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5974 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5975 l_log_string);
5976 END IF;
5977
5978 -- Call the PDOI API.
5979 IF (ICX_CAT_UTIL_PVT.g_current_program = ICX_CAT_UTIL_PVT.g_data_exception_program) THEN
5980 l_err_loc := 200;
5981 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
5982 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
5983 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
5984 'Calling migrate catalog with FND_API.G_TRUE:' || FND_API.G_TRUE);
5985 END IF;
5986 -- Call it with 'FND_API.G_TRUE' for validate only and no commit done to transaction tables
5987 PO_R12_CAT_UPG_GRP.migrate_catalog
5988 ( 1.0 , -- P_API_VERSION
5989 FND_API.G_TRUE , -- P_COMMIT
5990 FND_API.G_FALSE , -- P_INIT_MSG_LIST
5991 FND_API.G_VALID_LEVEL_FULL , -- P_VALIDATION_LEVEL
5992 1 , -- P_LOG_LEVEL
5993 g_PDOI_batch_id , -- P_BATCH_ID
5994 ICX_CAT_UTIL_PVT.g_batch_size , -- P_BATCH_SIZE
5995 FND_API.G_TRUE , -- P_VALIDATE_ONLY_MODE
5996 l_return_status , -- X_RETURN_STATUS
5997 l_msg_count , -- X_MSG_COUNT
5998 l_msg_data -- X_MSG_DATA
5999 );
6000
6001 -- Remove all the rows that are created in icx_cat_r12_upgrade table in the current job.
6002 ELSE
6003 l_err_loc := 300;
6004 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6005 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6006 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6007 'Calling migrate catalog with FND_API.G_FALSE:' || FND_API.G_FALSE);
6008 END IF;
6009 -- Call it with 'FND_API.G_FALSE' for commit into transaction tables
6010 PO_R12_CAT_UPG_GRP.migrate_catalog
6011 ( 1.0 , -- P_API_VERSION
6012 FND_API.G_TRUE , -- P_COMMIT
6013 FND_API.G_FALSE , -- P_INIT_MSG_LIST
6014 FND_API.G_VALID_LEVEL_FULL , -- P_VALIDATION_LEVEL
6015 1 , -- P_LOG_LEVEL
6016 g_PDOI_batch_id , -- P_BATCH_ID
6017 ICX_CAT_UTIL_PVT.g_batch_size , -- P_BATCH_SIZE
6018 FND_API.G_FALSE , -- P_VALIDATE_ONLY_MODE
6019 l_return_status , -- X_RETURN_STATUS
6020 l_msg_count , -- X_MSG_COUNT
6021 l_msg_data -- X_MSG_DATA
6022 );
6023 END IF;
6024
6025 l_err_loc := 400;
6026 l_end_date := sysdate;
6027 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6028 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6029 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6030 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
6031 END IF;
6032
6033 l_err_loc := 500;
6034 ICX_CAT_UTIL_PVT.g_job_pdoi_complete_date := SYSDATE;
6035 EXCEPTION
6036 WHEN OTHERS THEN
6037 ICX_CAT_UTIL_PVT.logUnexpectedException(
6038 G_PKG_NAME, l_api_name,
6039 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
6040 ICX_CAT_UTIL_PVT.g_job_pdoi_complete_date := NULL;
6041 RAISE;
6042 END callPOMigrateCatalog;
6043
6044 PROCEDURE callICXProcessDataExcptnRpt
6045 IS
6046 l_api_name CONSTANT VARCHAR2(30) := 'callICXProcessDataExcptnRpt';
6047 l_err_loc PLS_INTEGER;
6048 l_start_date DATE;
6049 l_end_date DATE;
6050 l_log_string VARCHAR2(2000);
6051 BEGIN
6052 l_err_loc := 100;
6053 l_start_date := sysdate;
6054 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6055 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6056 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6057 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
6058 END IF;
6059
6060 l_err_loc := 200;
6061 -- Call the ICX API to process the data exception report for the
6062 -- lines rejected during poMigrateCatalog with errors.
6063 ICX_CAT_R12_DATA_EXCEP_RPT_PVT.process_data_exceptions_report(g_PDOI_batch_id);
6064
6065 l_err_loc := 300;
6066 l_end_date := sysdate;
6067 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6068 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6069 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6070 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
6071 END IF;
6072 EXCEPTION
6073 WHEN OTHERS THEN
6074 ICX_CAT_UTIL_PVT.logUnexpectedException(
6075 G_PKG_NAME, l_api_name,
6076 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
6077 ICX_CAT_UTIL_PVT.g_job_current_status := ICX_CAT_UTIL_PVT.g_job_failed_status;
6078 ICX_CAT_UTIL_PVT.g_job_complete_date := NULL;
6079 END callICXProcessDataExcptnRpt;
6080
6081 PROCEDURE updatePOHeaderId
6082 ( p_interface_header_id IN DBMS_SQL.NUMBER_TABLE
6083 )
6084 IS
6085 l_api_name CONSTANT VARCHAR2(30) := 'updatePOHeaderId';
6086 l_err_loc PLS_INTEGER;
6087 l_row_count PLS_INTEGER;
6088 BEGIN
6089 l_err_loc := 100;
6090 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6091 ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, 'Start...');
6092 END IF;
6093
6094 FOR i IN 1..p_interface_header_id.COUNT LOOP
6095 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6096 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
6097 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6098 'p_interface_header_id('||i||'):' || p_interface_header_id(i));
6099 END IF;
6100 END LOOP;
6101
6102 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6103 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6104 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6105 'Count of p_interface_header_id:' || p_interface_header_id.COUNT);
6106 END IF;
6107
6108 l_err_loc := 200;
6109 FORALL i IN 1..p_interface_header_id.COUNT
6110 UPDATE icx_cat_r12_upgrade upg
6111 SET (po_header_id, created_language) =
6112 (SELECT po_header_id, created_language
6113 FROM po_headers_interface phi
6114 WHERE phi.interface_header_id = upg.po_interface_header_id)
6115 WHERE upg.po_interface_header_id = p_interface_header_id(i);
6116
6117 l_err_loc := 300;
6118 l_row_count := SQL%ROWCOUNT;
6119
6120 l_err_loc := 350;
6121 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6122 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6123 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6124 'No: of header rows updated in icx_cat_r12_upgrade table:' || l_row_count ||
6125 ', g_job_pdoi_update_date:' || ICX_CAT_UTIL_PVT.g_job_pdoi_update_date);
6126 END IF;
6127
6128 l_err_loc := 400;
6129 IF (l_row_count > 0 AND
6130 ICX_CAT_UTIL_PVT.g_job_pdoi_update_date IS NULL)
6131 THEN
6132 ICX_CAT_UTIL_PVT.g_job_pdoi_update_date := sysdate;
6133 -- Update the pdoi_update_date in the jobs table.
6134 updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_paused_status);
6135 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6136 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
6137 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6138 ', g_job_pdoi_update_date set to:' || ICX_CAT_UTIL_PVT.g_job_pdoi_update_date);
6139 END IF;
6140 END IF;
6141
6142 l_err_loc := 500;
6143 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6144 ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name, ' done ;' );
6145 END IF;
6146 EXCEPTION
6147 WHEN OTHERS THEN
6148 ICX_CAT_UTIL_PVT.logUnexpectedException(
6149 G_PKG_NAME, l_api_name,
6150 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
6151 RAISE;
6152 END updatePOHeaderId;
6153
6154 PROCEDURE updatePOLineId
6155 ( p_interface_line_id IN DBMS_SQL.NUMBER_TABLE
6156 )
6157 IS
6158 l_api_name CONSTANT VARCHAR2(30) := 'updatePOLineId';
6159 l_err_loc PLS_INTEGER;
6160 l_row_count PLS_INTEGER;
6161 BEGIN
6162 l_err_loc := 100;
6163 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6164 ICX_CAT_UTIL_PVT.logProcBegin(g_pkg_name, l_api_name, 'Start...');
6165 END IF;
6166
6167 FOR i IN 1..p_interface_line_id.COUNT LOOP
6168 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6169 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
6170 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6171 'p_interface_line_id('||i||'):' || p_interface_line_id(i));
6172 END IF;
6173 END LOOP;
6174
6175 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6176 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6177 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6178 'Count of p_interface_line_id:' || p_interface_line_id.COUNT);
6179 END IF;
6180
6181 l_err_loc := 200;
6182 FORALL i IN 1..p_interface_line_id.COUNT
6183 UPDATE icx_cat_r12_upgrade upg
6184 SET po_line_id =
6185 (SELECT po_line_id
6186 FROM po_lines_interface pli
6187 WHERE pli.interface_line_id = upg.po_interface_line_id)
6188 WHERE upg.po_interface_line_id = p_interface_line_id(i);
6189
6190 l_err_loc := 300;
6191 l_row_count := SQL%ROWCOUNT;
6192
6193 l_err_loc := 350;
6194 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6195 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6196 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6197 'No: of line rows updated in icx_cat_r12_upgrade table:' || l_row_count ||
6198 ', g_job_pdoi_update_date:' || ICX_CAT_UTIL_PVT.g_job_pdoi_update_date);
6199 END IF;
6200
6201 l_err_loc := 400;
6202 -- This should never be run, because the updatePoHeaderid is always called
6203 -- by the pdoi first, which should have already updated a value for
6204 -- ICX_CAT_UTIL_PVT.g_job_pdoi_update_date
6205 IF (l_row_count > 0 AND
6206 ICX_CAT_UTIL_PVT.g_job_pdoi_update_date IS NULL)
6207 THEN
6208 ICX_CAT_UTIL_PVT.g_job_pdoi_update_date := sysdate;
6209 -- Update the pdoi_update_date in the jobs table.
6210 updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_paused_status);
6211 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6212 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6213 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6214 ', g_job_pdoi_update_date set to:' || ICX_CAT_UTIL_PVT.g_job_pdoi_update_date);
6215 END IF;
6216 END IF;
6217
6218 l_err_loc := 500;
6219 IF (FND_LOG.LEVEL_PROCEDURE >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6220 ICX_CAT_UTIL_PVT.logProcEnd(g_pkg_name, l_api_name, ' done ;' );
6221 END IF;
6222 EXCEPTION
6223 WHEN OTHERS THEN
6224 ICX_CAT_UTIL_PVT.logUnexpectedException(
6225 G_PKG_NAME, l_api_name,
6226 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
6227 RAISE;
6228 END updatePOLineId;
6229
6230 -- Call the purgeInvalidBlanketLines to make sure we dont have any invalid documents
6231 -- in the r12 intermedia tables
6232 PROCEDURE callPurgeInvalidBlanketLines
6233 IS
6234 l_api_name CONSTANT VARCHAR2(30) := 'callPurgeInvalidBlanketLines';
6235 l_err_loc PLS_INTEGER;
6236 BEGIN
6237 l_err_loc := 100;
6238 ICX_CAT_POPULATE_ITEM_PVT.purgeInvalidBlanketLines;
6239 EXCEPTION
6240 WHEN OTHERS THEN
6241 ICX_CAT_UTIL_PVT.logUnexpectedException(
6242 G_PKG_NAME, l_api_name,
6243 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
6244 ICX_CAT_UTIL_PVT.g_job_current_status := ICX_CAT_UTIL_PVT.g_job_failed_status;
6245 ICX_CAT_UTIL_PVT.g_job_complete_date := NULL;
6246 END callPurgeInvalidBlanketLines;
6247
6248 PROCEDURE upgradeFavoriteListHdrs
6249 IS
6250 l_api_name CONSTANT VARCHAR2(30) := 'upgradeFavoriteListHdrs';
6251 l_err_loc PLS_INTEGER;
6252 l_start_date DATE;
6253 l_end_date DATE;
6254 l_continue BOOLEAN;
6255 l_row_count PLS_INTEGER;
6256 BEGIN
6257 l_err_loc := 100;
6258 l_start_date := sysdate;
6259 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6260 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6261 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6262 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
6263 END IF;
6264
6265 l_err_loc := 150;
6266 INSERT INTO icx_cat_fav_list_headers
6267 (
6268 employee_id, favorite_list_id, favorite_list_name,
6269 last_update_date, last_updated_by, last_update_login,
6270 creation_date, created_by,
6271 description, inactive_date, attribute_category,
6272 attribute1, attribute2, attribute3, attribute4, attribute5,
6273 attribute6, attribute7, attribute8, attribute9, attribute10,
6274 attribute11, attribute12, attribute13, attribute14, attribute15,
6275 primary_flag
6276 )
6277 SELECT
6278 employee_id, favorite_list_id, favorite_list_name,
6279 last_update_date, last_updated_by, last_update_login,
6280 NVL(creation_date, last_update_date), NVL(created_by, last_updated_by),
6281 description, inactive_date, attribute_category,
6282 attribute1, attribute2, attribute3, attribute4, attribute5,
6283 attribute6, attribute7, attribute8, attribute9, attribute10,
6284 attribute11, attribute12, attribute13, attribute14, attribute15,
6285 primary_flag
6286 FROM por_favorite_list_headers old_fav_hdrs
6287 WHERE NOT EXISTS (SELECT NULL
6288 FROM icx_cat_fav_list_headers new_fav_hdrs
6289 WHERE new_fav_hdrs.employee_id = old_fav_hdrs.employee_id
6290 AND new_fav_hdrs.favorite_list_id = old_fav_hdrs.favorite_list_id);
6291
6292 l_err_loc := 200;
6293 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6294 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6295 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6296 'No: of rows inserted into icx_cat_fav_list_headers during upgrade:' || SQL%ROWCOUNT);
6297 END IF;
6298
6299 l_err_loc := 250;
6300 COMMIT;
6301
6302 l_err_loc := 300;
6303 -- Update the primary_flag in icx_cat_fav_list_headers
6304 l_continue := TRUE;
6305 WHILE l_continue LOOP
6306 l_err_loc := 400;
6307 UPDATE icx_cat_fav_list_headers favout
6308 SET primary_flag = 'Y'
6309 WHERE primary_flag is null
6310 AND favorite_list_name = 'POR_FAVORITE_LIST'
6311 AND NOT EXISTS (SELECT 'x' FROM icx_cat_fav_list_headers favin
6312 WHERE favin.employee_id = favout.employee_id
6313 AND favin.primary_flag = 'Y')
6314 AND ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size;
6315
6316 l_err_loc := 500;
6317 l_row_count := SQL%ROWCOUNT;
6318 IF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size OR
6319 l_row_count = 0)
6320 THEN
6321 l_continue := FALSE;
6322 END IF;
6323
6324 l_err_loc := 550;
6325 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6326 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
6327 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6328 'No: of rows updated in icx_cat_fav_list_headers for primary_flag:' || l_row_count);
6329 END IF;
6330
6331 l_err_loc := 600;
6332 COMMIT;
6333 END LOOP;
6334
6335 l_err_loc := 700;
6336 l_end_date := sysdate;
6337 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6338 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6339 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6340 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
6341 END IF;
6342 EXCEPTION
6343 WHEN OTHERS THEN
6344 ICX_CAT_UTIL_PVT.logUnexpectedException(
6345 G_PKG_NAME, l_api_name,
6346 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
6347 ICX_CAT_UTIL_PVT.g_job_current_status := ICX_CAT_UTIL_PVT.g_job_failed_status;
6348 ICX_CAT_UTIL_PVT.g_job_complete_date := NULL;
6349 END upgradeFavoriteListHdrs;
6350
6351 PROCEDURE upgradeFavoriteListLines
6352 IS
6353 -- Update the source_doc_line_id in por_favorite_list_lines
6354 -- for items that were bulkloaded in prior releases.
6355 CURSOR updSrcDocIdsInOldFavLinesCsr IS
6356 SELECT fav.rowid, upg.po_line_id
6357 FROM por_favorite_list_lines fav,
6358 icx_cat_item_prices price,
6359 icx_cat_r12_upgrade upg
6360 WHERE fav.rt_item_id IS NOT NULL
6361 AND fav.price_list_id IS NOT NULL
6362 AND fav.source_doc_line_id IS NULL
6363 AND fav.rt_item_id = price.rt_item_id
6364 AND fav.price_list_id = price.price_list_id
6365 AND fav.suggested_vendor_site_id = price.supplier_site_id
6366 AND price.rt_item_id = upg.rt_item_id
6367 AND price.supplier_site_id = upg.supplier_site_id
6368 AND price.currency = upg.currency
6369 AND price.contract_id = upg.price_contract_id
6370 AND upg.po_line_id IS NOT NULL;
6371
6372 -- Update ItemType in por_favorite_list_lines
6373 CURSOR updItemTypeInOldFavLinesCsr IS
6374 SELECT favorite_list_line_id, source_doc_line_id, template_name,
6375 template_line_num, item_id, asl_id, rt_item_id
6376 FROM por_favorite_list_lines
6377 WHERE duplicate_in_r12 IS NULL
6378 AND item_type IS NULL
6379 OR (item_type = 'CATALOG'
6380 AND (source_doc_line_id IS NULL
6381 OR template_name IS NULL
6382 OR item_id IS NULL
6383 OR asl_id IS NULL));
6384
6385 -- Since ASL is no longer supported in iProcurement in R12
6386 -- Update the two asl records with the same inventory_item_id
6387 -- or an asl and an inventory_item_id existing in the same
6388 -- favorite list as duplicate.
6389 CURSOR checkForDuplicatesCsr IS
6390 SELECT fav.favorite_list_id, fav.item_id, fav.favorite_list_line_id
6391 FROM
6392 ( SELECT favorite_list_id, item_id, duplicate_in_r12, COUNT(*)
6393 FROM
6394 ( SELECT favorite_list_id, item_id, duplicate_in_r12
6395 FROM por_favorite_list_lines fav_out
6396 WHERE fav_out.item_type = 'CATALOG'
6397 AND asl_id <> -2
6398 UNION ALL
6399 SELECT favorite_list_id, item_id, duplicate_in_r12
6400 FROM por_favorite_list_lines fav_out
6401 WHERE item_type = 'CATALOG'
6402 AND asl_id = -2 AND source_doc_line_id = -2 AND template_name = '-2'
6403 AND EXISTS (SELECT 'x' FROM por_favorite_list_lines fav_in
6404 WHERE asl_id <> -2 AND item_type = 'CATALOG'
6405 AND fav_in.item_id = fav_out.item_id
6406 AND fav_in.favorite_list_id = fav_out.favorite_list_id)
6407 )
6408 GROUP BY favorite_list_id, item_id, duplicate_in_r12
6409 HAVING COUNT(*) > 1
6410 ) dupe, por_favorite_list_lines fav
6411 WHERE fav.favorite_list_id = dupe.favorite_list_id
6412 AND fav.item_id = dupe.item_id
6413 ORDER BY fav.favorite_list_id, fav.item_id;
6414
6415 -- Includes catalog items
6416 CURSOR catalogItemUpgradeCsr IS
6417 SELECT favorite_list_id, favorite_list_line_id,
6418 fav.source_doc_line_id, fav.template_name,
6419 fav.template_line_num, fav.item_id,
6420 items.source_type, items.language, items.org_id
6421 FROM por_favorite_list_lines fav, icx_cat_items_ctx_hdrs_tlp items
6422 WHERE fav.item_type = 'CATALOG'
6423 AND fav.duplicate_in_r12 IS NULL
6424 AND fav.source_doc_line_id = items.po_line_id
6425 AND fav.template_name = items.req_template_name
6426 AND fav.template_line_num = items.req_template_line_num
6427 AND fav.item_id = items.inventory_item_id
6428 AND NOT EXISTS ( SELECT NULL
6429 FROM icx_cat_fav_list_lines_tlp new_fav
6430 WHERE new_fav.favorite_list_id = fav.favorite_list_id
6431 AND new_fav.favorite_list_line_id = fav.favorite_list_line_id)
6432 ORDER BY favorite_list_id, favorite_list_line_id, fav.source_doc_line_id,
6433 fav.template_name, fav.template_line_num, fav.item_id,
6434 items.source_type;
6435
6436 -- Includes non-catalog and external (punchout/transparent punchout items
6437 CURSOR otherItemUpgradeCsr (p_profile_option_id NUMBER) IS
6438 SELECT fav_hdrs.favorite_list_id, fav_hdrs.employee_id, users.user_id,
6439 prf_vals.profile_option_value, COUNT(*)
6440 FROM por_favorite_list_headers fav_hdrs, fnd_user users,
6441 fnd_profile_option_values prf_vals, por_favorite_list_lines fav_lines
6442 WHERE fav_hdrs.favorite_list_id = fav_lines.favorite_list_id
6443 AND fav_lines.item_type <> 'CATALOG'
6444 AND fav_hdrs.employee_id = users.employee_id (+)
6445 AND users.user_id = prf_vals.level_value (+)
6446 AND prf_vals.profile_option_id (+) = p_profile_option_id
6447 AND prf_vals.level_id (+) = 10004
6448 AND NOT EXISTS ( SELECT NULL
6449 FROM icx_cat_fav_list_lines_tlp new_fav
6450 WHERE new_fav.favorite_list_id = fav_lines.favorite_list_id
6451 AND new_fav.favorite_list_line_id = fav_lines.favorite_list_line_id )
6452 GROUP BY fav_hdrs.favorite_list_id, fav_hdrs.employee_id, users.user_id,
6453 prf_vals.profile_option_value
6454 ORDER BY fav_hdrs.favorite_list_id, fav_hdrs.employee_id, users.user_id;
6455
6456 CURSOR getOrgIdsAtRespAndAppLevelCsr (p_user_id NUMBER,
6457 p_profile_option_id NUMBER) IS
6458 SELECT DISTINCT NVL(resp_profile.profile_option_value,
6459 NVL(app_profile.profile_option_value, -2)) org_id
6460 FROM fnd_responsibility resp,
6461 fnd_profile_option_values resp_profile,
6462 fnd_profile_option_values app_profile,
6463 fnd_user_resp_groups_all user_resp
6464 WHERE user_resp.user_id = p_user_id
6465 AND user_resp.responsibility_application_id IN (177, 178, 201, 396, 426)
6466 AND user_resp.responsibility_id = resp.responsibility_id
6467 AND user_resp.responsibility_application_id = resp.application_id
6468 AND app_profile.profile_option_id(+) = p_profile_option_id
6469 AND app_profile.level_id(+) = 10002
6470 AND app_profile.level_value(+) = resp.application_id
6471 AND resp_profile.profile_option_id(+) = p_profile_option_id
6472 AND resp_profile.level_id(+) = 10003
6473 AND resp_profile.level_value(+) = resp.responsibility_id
6474 ORDER BY 1;
6475
6476 CURSOR getOtherFavLinesForHdrCsr (p_favorite_list_id NUMBER) IS
6477 SELECT favorite_list_line_id
6478 FROM por_favorite_list_lines fav_lines
6479 WHERE fav_lines.favorite_list_id = p_favorite_list_id
6480 AND fav_lines.item_type <> 'CATALOG';
6481
6482 ----- Start of declaring columns selected in the cursor -----
6483
6484 l_rowid_tbl DBMS_SQL.UROWID_TABLE;
6485 l_favorite_list_id_tbl DBMS_SQL.NUMBER_TABLE;
6486 l_favorite_list_line_id_tbl DBMS_SQL.NUMBER_TABLE;
6487 l_po_line_id_tbl DBMS_SQL.NUMBER_TABLE;
6488 l_req_template_name_tbl DBMS_SQL.VARCHAR2_TABLE;
6489 l_req_template_line_num_tbl DBMS_SQL.NUMBER_TABLE;
6490 l_inventory_item_id_tbl DBMS_SQL.NUMBER_TABLE;
6491 l_asl_id_tbl DBMS_SQL.NUMBER_TABLE;
6492 l_rt_item_id_tbl DBMS_SQL.NUMBER_TABLE;
6493 l_language_tbl DBMS_SQL.VARCHAR2_TABLE;
6494 l_employee_id_tbl DBMS_SQL.NUMBER_TABLE;
6495 l_user_id_tbl DBMS_SQL.NUMBER_TABLE;
6496 l_profile_option_value_tbl DBMS_SQL.VARCHAR2_TABLE;
6497 l_count_tbl DBMS_SQL.NUMBER_TABLE;
6498 l_org_id_tbl DBMS_SQL.NUMBER_TABLE;
6499 l_source_type_tbl DBMS_SQL.VARCHAR2_TABLE;
6500 l_item_type_tbl DBMS_SQL.VARCHAR2_TABLE;
6501 l_dupe_fav_list_line_id_tbl DBMS_SQL.NUMBER_TABLE;
6502
6503 ------ End of declaring columns selected in the cursor ------
6504
6505 l_api_name CONSTANT VARCHAR2(30) := 'upgradeFavoriteListLines';
6506 l_err_loc PLS_INTEGER;
6507 l_start_date DATE;
6508 l_end_date DATE;
6509 l_err_string VARCHAR2(4000);
6510 l_continue BOOLEAN;
6511 l_row_count PLS_INTEGER;
6512 l_batch_count PLS_INTEGER;
6513 l_prev_favorite_list_id NUMBER := -1;
6514 l_prev_favorite_list_line_id NUMBER := -1;
6515 l_prev_rt_item_id NUMBER := -1;
6516 l_prev_po_line_id NUMBER := -1;
6517 l_prev_req_template_name icx_cat_items_ctx_hdrs_tlp.req_template_name%TYPE := '-1';
6518 l_prev_req_template_line_num NUMBER := -1;
6519 l_prev_inventory_item_id NUMBER := -1;
6520 l_prev_source_type icx_cat_items_ctx_hdrs_tlp.source_type%TYPE := '-1';
6521 l_dupe_fav_list_index PLS_INTEGER := 0;
6522 l_fav_list_lines_index PLS_INTEGER := 0;
6523 l_org_id_index PLS_INTEGER := 0;
6524 l_profile_option_id NUMBER;
6525 l_org_id_profile_value_exist VARCHAR2(1) := 'N';
6526 l_org_already_exists VARCHAR2(1) := 'N';
6527 l_site_level_prf_opt_val fnd_profile_option_values.profile_option_value%TYPE;
6528 l_is_site_prf_val_in_org_tbl VARCHAR2(1) := 'N';
6529
6530 BEGIN
6531 l_err_loc := 100;
6532 l_start_date := sysdate;
6533 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6534 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6535 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6536 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
6537 END IF;
6538
6539 l_err_loc := 150;
6540 -- Update the source_doc_line_id in por_favorite_list_lines
6541 -- for items that were bulkloaded in prior releases.
6542 l_batch_count := 0;
6543 OPEN updSrcDocIdsInOldFavLinesCsr;
6544
6545 LOOP
6546 l_err_loc := 200;
6547 l_rowid_tbl.DELETE;
6548 l_po_line_id_tbl.DELETE;
6549
6550 BEGIN
6551 l_err_loc := 250;
6552 FETCH updSrcDocIdsInOldFavLinesCsr BULK COLLECT INTO
6553 l_rowid_tbl, l_po_line_id_tbl
6554 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
6555
6556 l_err_loc := 300;
6557 EXIT WHEN l_rowid_tbl.COUNT = 0;
6558
6559 l_batch_count := l_batch_count + 1;
6560
6561 l_err_loc := 350;
6562 FORALL i in 1..l_rowid_tbl.COUNT
6563 UPDATE por_favorite_list_lines
6564 SET source_doc_line_id = l_po_line_id_tbl(i)
6565 WHERE rowid = l_rowid_tbl(i);
6566
6567 l_err_loc := 400;
6568 IF (l_rowid_tbl.COUNT > 0) THEN
6569 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6570 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
6571 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6572 'No: of rows updated in por_favorite_list_lines for bulk loaded items:' ||SQL%ROWCOUNT);
6573 END IF;
6574 END IF;
6575
6576 l_err_loc := 450;
6577 COMMIT;
6578
6579 l_err_loc := 500;
6580 EXIT WHEN l_rowid_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
6581 EXCEPTION
6582 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
6583 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
6584 || '-' || l_err_loc
6585 || ', Total processeded batches:' || l_batch_count;
6586 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
6587 l_err_loc := 550;
6588 CLOSE updSrcDocIdsInOldFavLinesCsr;
6589 OPEN updSrcDocIdsInOldFavLinesCsr;
6590 END;
6591 END LOOP; -- CURSOR LOOP updSrcDocIdsInOldFavLinesCsr
6592
6593 l_err_loc := 580;
6594 IF (updSrcDocIdsInOldFavLinesCsr%ISOPEN) THEN
6595 CLOSE updSrcDocIdsInOldFavLinesCsr;
6596 END IF;
6597
6598 l_err_loc := 600;
6599 -- Update ItemType in por_favorite_list_lines
6600 l_batch_count := 0;
6601 OPEN updItemTypeInOldFavLinesCsr;
6602
6603 LOOP
6604 l_err_loc := 700;
6605 l_favorite_list_line_id_tbl.DELETE;
6606 l_po_line_id_tbl.DELETE;
6607 l_req_template_name_tbl.DELETE;
6608 l_req_template_line_num_tbl.DELETE;
6609 l_inventory_item_id_tbl.DELETE;
6610 l_asl_id_tbl.DELETE;
6611 l_rt_item_id_tbl.DELETE;
6612 l_item_type_tbl.DELETE;
6613
6614 BEGIN
6615 l_err_loc := 800;
6616 FETCH updItemTypeInOldFavLinesCsr BULK COLLECT INTO
6617 l_favorite_list_line_id_tbl, l_po_line_id_tbl,
6618 l_req_template_name_tbl, l_req_template_line_num_tbl,
6619 l_inventory_item_id_tbl, l_asl_id_tbl, l_rt_item_id_tbl
6620 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
6621
6622 l_err_loc := 900;
6623 EXIT WHEN l_favorite_list_line_id_tbl.COUNT = 0;
6624
6625 l_batch_count := l_batch_count + 1;
6626
6627 l_err_loc := 1000;
6628 FOR i in 1..l_favorite_list_line_id_tbl.COUNT LOOP
6629 IF (l_rt_item_id_tbl(i) IS NULL AND
6630 l_po_line_id_tbl(i) IS NULL AND
6631 l_req_template_name_tbl(i) IS NULL AND
6632 l_inventory_item_id_tbl(i) IS NULL AND
6633 l_asl_id_tbl(i) IS NULL)
6634 THEN
6635 l_item_type_tbl(i) := 'NONCATALOG';
6636 ELSE
6637 l_err_loc := 1100;
6638 l_item_type_tbl(i) := 'CATALOG';
6639 l_po_line_id_tbl(i) := NVL(l_po_line_id_tbl(i), -2);
6640 l_req_template_name_tbl(i) := NVL(l_req_template_name_tbl(i), '-2');
6641 l_req_template_line_num_tbl(i) := NVL(l_req_template_line_num_tbl(i), -2);
6642 l_inventory_item_id_tbl(i) := NVL(l_inventory_item_id_tbl(i), -2);
6643 l_asl_id_tbl(i) := NVL(l_asl_id_tbl(i), -2);
6644 END IF;
6645 END LOOP;
6646
6647 l_err_loc := 1200;
6648 FORALL i in 1..l_favorite_list_line_id_tbl.COUNT
6649 UPDATE por_favorite_list_lines
6650 SET item_type = l_item_type_tbl(i),
6651 source_doc_line_id = l_po_line_id_tbl(i),
6652 template_name = l_req_template_name_tbl(i),
6653 template_line_num = l_req_template_line_num_tbl(i),
6654 item_id = l_inventory_item_id_tbl(i),
6655 asl_id = l_asl_id_tbl(i)
6656 WHERE favorite_list_line_id = l_favorite_list_line_id_tbl(i);
6657
6658 l_err_loc := 1300;
6659 IF (l_favorite_list_line_id_tbl.COUNT > 0) THEN
6660 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6661 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
6662 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6663 'No: of rows updated in por_favorite_list_lines for item_type:' ||SQL%ROWCOUNT);
6664 END IF;
6665 END IF;
6666
6667 l_err_loc := 1400;
6668 COMMIT;
6669
6670 l_err_loc := 1500;
6671 EXIT WHEN l_favorite_list_line_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
6672 EXCEPTION
6673 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
6674 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
6675 || '-' || l_err_loc
6676 || ', Total processeded batches:' || l_batch_count;
6677 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
6678 l_err_loc := 1600;
6679 CLOSE updItemTypeInOldFavLinesCsr;
6680 OPEN updItemTypeInOldFavLinesCsr;
6681 END;
6682 END LOOP; -- CURSOR LOOP updItemTypeInOldFavLinesCsr
6683
6684 l_err_loc := 1700;
6685 IF (updItemTypeInOldFavLinesCsr%ISOPEN) THEN
6686 CLOSE updItemTypeInOldFavLinesCsr;
6687 END IF;
6688
6689 l_err_loc := 1710;
6690 l_favorite_list_line_id_tbl.DELETE;
6691 l_po_line_id_tbl.DELETE;
6692 l_req_template_name_tbl.DELETE;
6693 l_req_template_line_num_tbl.DELETE;
6694 l_inventory_item_id_tbl.DELETE;
6695 l_asl_id_tbl.DELETE;
6696 l_rt_item_id_tbl.DELETE;
6697 l_item_type_tbl.DELETE;
6698
6699 l_err_loc := 1800;
6700 l_prev_favorite_list_id := -1;
6701 l_prev_inventory_item_id := -1;
6702
6703 -- Since ASL is no longer supported in iProcurement in R12
6704 -- Update the two asl records with the same inventory_item_id
6705 -- or an asl and an inventory_item_id existing in the same
6706 -- favorite list as duplicate.d
6707 l_batch_count := 0;
6708 l_err_loc := 1900;
6709 OPEN checkForDuplicatesCsr;
6710
6711 LOOP
6712 l_err_loc := 2000;
6713 l_favorite_list_id_tbl.DELETE;
6714 l_inventory_item_id_tbl.DELETE;
6715 l_favorite_list_line_id_tbl.DELETE;
6716
6717 BEGIN
6718 l_err_loc := 2100;
6719 FETCH checkForDuplicatesCsr BULK COLLECT INTO
6720 l_favorite_list_id_tbl,
6721 l_inventory_item_id_tbl,
6722 l_favorite_list_line_id_tbl
6723 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
6724
6725 l_err_loc := 2200;
6726 EXIT WHEN l_favorite_list_line_id_tbl.COUNT = 0;
6727
6728 l_batch_count := l_batch_count + 1;
6729
6730 l_err_loc := 2300;
6731 FOR i in 1..l_favorite_list_line_id_tbl.COUNT LOOP
6732 IF (l_prev_favorite_list_id = l_favorite_list_id_tbl(i) AND
6733 l_prev_inventory_item_id = l_inventory_item_id_tbl(i) )
6734 THEN
6735 l_err_loc := 2400;
6736 -- Two lines exist with the same inventory_item_id,
6737 -- So mark this one as duplicate
6738 l_dupe_fav_list_index := l_dupe_fav_list_line_id_tbl.COUNT + 1;
6739 l_dupe_fav_list_line_id_tbl(l_dupe_fav_list_index) := l_favorite_list_line_id_tbl(i);
6740
6741 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6742 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6743 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6744 'fav list catalog lines marked as duplicate;' ||
6745 ', l_dupe_fav_list_line_id_tbl :' || l_dupe_fav_list_line_id_tbl(l_dupe_fav_list_index));
6746 END IF;
6747 END IF;
6748
6749 l_err_loc := 2500;
6750 l_prev_favorite_list_id := l_favorite_list_id_tbl(i);
6751 l_prev_inventory_item_id := l_inventory_item_id_tbl(i);
6752 END LOOP;
6753
6754 l_err_loc := 2600;
6755 FORALL i in 1..l_dupe_fav_list_line_id_tbl.COUNT
6756 UPDATE por_favorite_list_lines
6757 SET duplicate_in_r12 = 'Y'
6758 WHERE favorite_list_line_id = l_dupe_fav_list_line_id_tbl(i);
6759
6760 l_err_loc := 2700;
6761 IF (l_favorite_list_line_id_tbl.COUNT > 0) THEN
6762 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6763 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
6764 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6765 'No: of rows updated in por_favorite_list_lines for duplicates:' ||SQL%ROWCOUNT);
6766 END IF;
6767 END IF;
6768
6769 l_err_loc := 2800;
6770 l_dupe_fav_list_line_id_tbl.DELETE;
6771
6772 l_err_loc := 2900;
6773 COMMIT;
6774
6775 l_err_loc := 3000;
6776 EXIT WHEN l_favorite_list_line_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
6777 EXCEPTION
6778 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
6779 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
6780 || '-' || l_err_loc
6781 || ', Total processeded batches:' || l_batch_count;
6782 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
6783 l_err_loc := 3100;
6784 CLOSE checkForDuplicatesCsr;
6785 OPEN checkForDuplicatesCsr;
6786 END;
6787 END LOOP; -- CURSOR LOOP checkForDuplicatesCsr
6788
6789 l_err_loc := 3200;
6790 IF (checkForDuplicatesCsr%ISOPEN) THEN
6791 CLOSE checkForDuplicatesCsr;
6792 END IF;
6793
6794 l_err_loc := 3210;
6795 l_favorite_list_id_tbl.DELETE;
6796 l_inventory_item_id_tbl.DELETE;
6797 l_favorite_list_line_id_tbl.DELETE;
6798
6799 l_err_loc := 3300;
6800 l_prev_favorite_list_id := -1;
6801 l_prev_favorite_list_line_id := -1;
6802 l_prev_po_line_id := -1;
6803 l_prev_req_template_name := '-1';
6804 l_prev_req_template_line_num := -1;
6805 l_prev_inventory_item_id := -1;
6806 l_prev_source_type := '-1';
6807
6808 -- Update the catalog items in favorite list lines
6809 l_batch_count := 0;
6810 l_err_loc := 3400;
6811 OPEN catalogItemUpgradeCsr;
6812
6813 LOOP
6814 l_err_loc := 3500;
6815 l_favorite_list_id_tbl.DELETE;
6816 l_favorite_list_line_id_tbl.DELETE;
6817 l_po_line_id_tbl.DELETE;
6818 l_req_template_name_tbl.DELETE;
6819 l_req_template_line_num_tbl.DELETE;
6820 l_inventory_item_id_tbl.DELETE;
6821 l_source_type_tbl.DELETE;
6822 l_language_tbl.DELETE;
6823 l_org_id_tbl.DELETE;
6824
6825 BEGIN
6826 l_err_loc := 3600;
6827 FETCH catalogItemUpgradeCsr BULK COLLECT INTO
6828 l_favorite_list_id_tbl, l_favorite_list_line_id_tbl,
6829 l_po_line_id_tbl, l_req_template_name_tbl,
6830 l_req_template_line_num_tbl, l_inventory_item_id_tbl,
6831 l_source_type_tbl, l_language_tbl, l_org_id_tbl
6832 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
6833
6834 l_err_loc := 3700;
6835 EXIT WHEN l_favorite_list_id_tbl.COUNT = 0;
6836
6837 l_batch_count := l_batch_count + 1;
6838
6839 l_err_loc := 3800;
6840 FOR i IN 1..l_favorite_list_id_tbl.COUNT LOOP
6841
6842 l_err_loc := 3900;
6843 g_total_row_count := g_total_row_count + 1;
6844 l_fav_list_lines_index := gIFLCFavoriteListIdTbl.COUNT + 1;
6845 gIFLCFavoriteListIdTbl(l_fav_list_lines_index) := l_favorite_list_id_tbl(i);
6846 gIFLCOldFavoriteListLineIdTbl(l_fav_list_lines_index) := l_favorite_list_line_id_tbl(i);
6847 gIFLCSourceTypeTbl(l_fav_list_lines_index) := l_source_type_tbl(i);
6848 gIFLCOrgIdTbl(l_fav_list_lines_index) := l_org_id_tbl(i);
6849 gIFLCLanguageTbl(l_fav_list_lines_index) := l_language_tbl(i);
6850
6851 IF (l_prev_favorite_list_id = l_favorite_list_id_tbl(i) AND
6852 l_prev_favorite_list_line_id = l_favorite_list_line_id_tbl(i) AND
6853 l_prev_po_line_id = l_po_line_id_tbl(i) AND
6854 l_prev_req_template_name = l_req_template_name_tbl(i) AND
6855 l_prev_req_template_line_num = l_req_template_line_num_tbl(i) AND
6856 l_prev_inventory_item_id = l_inventory_item_id_tbl(i) AND
6857 l_prev_source_type = l_source_type_tbl(i) )
6858 THEN
6859 l_err_loc := 4000;
6860 -- Either language or org_id has changed, so get a new favorite_list_line_id
6861 gIFLCNewFavoriteListLineIdTbl(l_fav_list_lines_index) := getNextFavListLineIdFromSeq;
6862 ELSE
6863 l_err_loc := 4100;
6864 gIFLCNewFavoriteListLineIdTbl(l_fav_list_lines_index) := l_favorite_list_line_id_tbl(i);
6865 END IF;
6866
6867 l_err_loc := 4200;
6868 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6869 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
6870 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6871 'fav list catalog lines upgrade values at fav_lines_index :' || l_fav_list_lines_index ||
6872 ', gIFLCFavoriteListIdTbl :' || gIFLCFavoriteListIdTbl(l_fav_list_lines_index) ||
6873 ', gIFLCOldFavoriteListLineIdTbl :' || gIFLCOldFavoriteListLineIdTbl(l_fav_list_lines_index) ||
6874 ', gIFLCSourceTypeTbl :' || gIFLCSourceTypeTbl(l_fav_list_lines_index) ||
6875 ', gIFLCOrgIdTbl :' || gIFLCOrgIdTbl(l_fav_list_lines_index) ||
6876 ', gIFLCNewFavoriteListLineIdTbl :' || gIFLCNewFavoriteListLineIdTbl(l_fav_list_lines_index) ||
6877 ', gIFLCLanguageTbl :' || gIFLCLanguageTbl(l_fav_list_lines_index) );
6878 END IF;
6879
6880 l_err_loc := 4300;
6881 l_prev_favorite_list_id := l_favorite_list_id_tbl(i);
6882 l_prev_favorite_list_line_id := l_favorite_list_line_id_tbl(i);
6883 l_prev_po_line_id := l_po_line_id_tbl(i);
6884 l_prev_req_template_name := l_req_template_name_tbl(i);
6885 l_prev_req_template_line_num := l_req_template_line_num_tbl(i);
6886 l_prev_inventory_item_id := l_inventory_item_id_tbl(i);
6887 l_prev_source_type := l_source_type_tbl(i);
6888
6889 l_err_loc := 4400;
6890 populatePOInterfaceTables('INLOOP');
6891 END LOOP; -- FOR LOOP of l_favorite_list_id_tbl
6892
6893 l_err_loc := 4500;
6894 EXIT WHEN l_favorite_list_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
6895 EXCEPTION
6896 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
6897 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
6898 || '-' || l_err_loc
6899 || ', Total processeded batches:' || l_batch_count;
6900 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
6901 l_err_loc := 4600;
6902 CLOSE catalogItemUpgradeCsr;
6903 OPEN catalogItemUpgradeCsr;
6904 END;
6905 END LOOP; -- CURSOR LOOP catalogItemUpgradeCsr
6906
6907 l_err_loc := 4700;
6908 populatePOInterfaceTables('OUTLOOP');
6909
6910 l_err_loc := 4800;
6911 IF (catalogItemUpgradeCsr%ISOPEN) THEN
6912 CLOSE catalogItemUpgradeCsr;
6913 END IF;
6914
6915 l_err_loc := 4810;
6916 l_favorite_list_id_tbl.DELETE;
6917 l_favorite_list_line_id_tbl.DELETE;
6918 l_po_line_id_tbl.DELETE;
6919 l_req_template_name_tbl.DELETE;
6920 l_req_template_line_num_tbl.DELETE;
6921 l_inventory_item_id_tbl.DELETE;
6922 l_source_type_tbl.DELETE;
6923 l_language_tbl.DELETE;
6924 l_org_id_tbl.DELETE;
6925
6926 l_err_loc := 4900;
6927 l_language_tbl.DELETE;
6928
6929 -- Get the installed and base languages
6930 l_err_loc := 5000;
6931 SELECT language_code
6932 BULK COLLECT INTO l_language_tbl
6933 FROM fnd_languages
6934 WHERE installed_flag IN ('B', 'I')
6935 ORDER BY installed_flag;
6936
6937 l_err_loc := 5100;
6938 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6939 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6940 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6941 'l_language_tbl.COUNT:' || l_language_tbl.COUNT);
6942 END IF;
6943
6944 l_err_loc := 5200;
6945 SELECT profile_option_id
6946 INTO l_profile_option_id
6947 FROM fnd_profile_options
6948 WHERE profile_option_name = 'ORG_ID';
6949
6950 l_err_loc := 5300;
6951 l_prev_favorite_list_id := -1;
6952
6953 l_batch_count := 0;
6954 -- Includes non-catalog and external (punchout/transparent punchout items
6955 l_err_loc := 5400;
6956 OPEN otherItemUpgradeCsr(l_profile_option_id);
6957
6958 LOOP
6959 l_err_loc := 5500;
6960 l_favorite_list_id_tbl.DELETE;
6961 l_employee_id_tbl.DELETE;
6962 l_user_id_tbl.DELETE;
6963 l_profile_option_value_tbl.DELETE;
6964 l_count_tbl.DELETE;
6965
6966 BEGIN
6967 l_err_loc := 5600;
6968 FETCH otherItemUpgradeCsr BULK COLLECT INTO
6969 l_favorite_list_id_tbl, l_employee_id_tbl,
6970 l_user_id_tbl, l_profile_option_value_tbl,
6971 l_count_tbl
6972 LIMIT ICX_CAT_UTIL_PVT.g_batch_size ;
6973
6974 l_err_loc := 5700;
6975 EXIT WHEN l_favorite_list_id_tbl.COUNT = 0;
6976
6977 l_batch_count := l_batch_count + 1;
6978
6979 l_err_loc := 5800;
6980 FOR i IN 1..l_favorite_list_id_tbl.COUNT LOOP
6981 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6982 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
6983 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
6984 'Processing the favorite_list_id:' || l_favorite_list_id_tbl(i));
6985 END IF;
6986
6987 l_err_loc := 5900;
6988 IF (l_prev_favorite_list_id <> l_favorite_list_id_tbl(i)) THEN
6989 l_is_site_prf_val_in_org_tbl := 'N';
6990 END IF;
6991
6992 l_err_loc := 6000;
6993 IF ( l_prev_favorite_list_id <> -1 AND
6994 l_prev_favorite_list_id <> l_favorite_list_id_tbl(i) AND
6995 l_org_id_tbl.COUNT > 0 )
6996 THEN
6997 l_err_loc := 6100;
6998 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
6999 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7000 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7001 'Forming the gIFLO tables for favorite_list_id:' || l_prev_favorite_list_id ||
7002 '; l_org_id_tbl.COUNT:' || l_org_id_tbl.COUNT);
7003 END IF;
7004
7005 l_err_loc := 6200;
7006 OPEN getOtherFavLinesForHdrCsr(l_prev_favorite_list_id);
7007
7008 l_err_loc := 6300;
7009 FETCH getOtherFavLinesForHdrCsr BULK COLLECT INTO
7010 l_favorite_list_line_id_tbl;
7011
7012 l_err_loc := 6400;
7013 CLOSE getOtherFavLinesForHdrCsr;
7014
7015 l_err_loc := 6500;
7016 FOR j IN 1..l_favorite_list_line_id_tbl.COUNT LOOP
7017 l_err_loc := 6600;
7018 FOR k IN 1..l_org_id_tbl.COUNT LOOP
7019 l_err_loc := 6700;
7020 FOR l IN 1..l_language_tbl.COUNT LOOP
7021 l_err_loc := 6800;
7022 g_total_row_count := g_total_row_count + 1;
7023 l_fav_list_lines_index := gIFLOFavoriteListIdTbl.COUNT + 1;
7024 gIFLOFavoriteListIdTbl(l_fav_list_lines_index) := l_prev_favorite_list_id;
7025 gIFLOOldFavoriteListLineIdTbl(l_fav_list_lines_index) := l_favorite_list_line_id_tbl(j);
7026 IF (k=1 AND l=1) THEN
7027 l_err_loc := 6900;
7028 gIFLONewFavoriteListLineIdTbl(l_fav_list_lines_index) := l_favorite_list_line_id_tbl(j);
7029 ELSE
7030 l_err_loc := 7000;
7031 gIFLONewFavoriteListLineIdTbl(l_fav_list_lines_index) := getNextFavListLineIdFromSeq;
7032 END IF;
7033 l_err_loc := 7100;
7034 gIFLOOrgIdTbl(l_fav_list_lines_index) := l_org_id_tbl(k);
7035 gIFLOLanguageTbl(l_fav_list_lines_index) := l_language_tbl(l);
7036 END LOOP;
7037 END LOOP;
7038 END LOOP;
7039
7040 l_err_loc := 7200;
7041 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7042 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7043 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7044 'Formed the gIFLO tables for favorite_list_id:' || l_prev_favorite_list_id ||
7045 '; count of favorite_lines in the hdr:' || l_count_tbl(i) ||
7046 ', gIFLOFavoriteListIdTbl.COUNT:' || gIFLOFavoriteListIdTbl.COUNT);
7047 END IF;
7048
7049 l_err_loc := 7300;
7050 l_org_id_tbl.DELETE;
7051 l_org_already_exists := 'N';
7052 END IF;
7053
7054 l_err_loc := 7400;
7055 IF (l_user_id_tbl(i) IS NOT NULL) THEN
7056 IF (l_profile_option_value_tbl(i) IS NOT NULL) THEN
7057 l_err_loc := 7500;
7058 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7059 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7060 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7061 'User level profile option:ORG_ID value:' || l_profile_option_value_tbl(i));
7062 END IF;
7063 l_err_loc := 7600;
7064 l_org_already_exists := ICX_CAT_UTIL_PVT.checkValueExistsInTable(l_org_id_tbl, l_profile_option_value_tbl(i));
7065 IF ( l_org_already_exists = 'N' ) THEN
7066 l_err_loc := 7700;
7067 l_org_id_index := l_org_id_tbl.COUNT + 1;
7068 l_org_id_tbl(l_org_id_index) := l_profile_option_value_tbl(i);
7069 l_err_loc := 7800;
7070 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7071 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
7072 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7073 'Added to the l_org_id_tbl for, l_user_id_tbl:' || l_user_id_tbl(i) ||
7074 ', l_org_id_tbl.COUNT:' || l_org_id_tbl.COUNT ||
7075 ', l_org_id_tbl:' || l_org_id_tbl(l_org_id_index));
7076 END IF;
7077 END IF; -- IF ( l_org_already_exists = 'N' ) THEN
7078 ELSE
7079 l_err_loc := 7900;
7080 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7081 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7082 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7083 'User level profile option:ORG_ID value:' || l_profile_option_value_tbl(i) ||
7084 ', About to get the Resp level profile option:ORG_ID values');
7085 END IF;
7086 l_err_loc := 8000;
7087 l_org_id_profile_value_exist := 'N';
7088
7089 l_err_loc := 8100;
7090 -- Get the profile option value at the responsibility/application for the user
7091 FOR l_prf_option_val IN getOrgIdsAtRespAndAppLevelCsr(l_user_id_tbl(i), l_profile_option_id) LOOP
7092 l_err_loc := 8200;
7093 l_org_id_profile_value_exist := 'Y';
7094 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7095 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7096 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7097 'Resp level profile option:ORG_ID value:' || l_prf_option_val.org_id);
7098 END IF;
7099 l_err_loc := 8300;
7100 IF (l_prf_option_val.org_id <> '-2') THEN
7101 l_org_already_exists := ICX_CAT_UTIL_PVT.checkValueExistsInTable(l_org_id_tbl, l_prf_option_val.org_id);
7102 ELSE
7103 l_err_loc := 8400;
7104 -- l_prf_option_val.org_id = -2
7105 -- The profile option: ORG_ID is not set at responsibility and application level,
7106 -- So get the profile option value at site level.
7107 -- Start from here ...
7108 IF ( l_site_level_prf_opt_val IS NULL ) THEN
7109 l_err_loc := 8500;
7110 SELECT profile_option_value
7111 INTO l_site_level_prf_opt_val
7112 FROM fnd_profile_option_values
7113 WHERE profile_option_id = l_profile_option_id
7114 AND level_id = 10001;
7115
7116 l_err_loc := 8600;
7117 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7118 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7119 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7120 'Site level profile option:ORG_ID value:' || l_site_level_prf_opt_val );
7121 END IF;
7122 END IF;
7123 l_err_loc := 8700;
7124 IF (l_is_site_prf_val_in_org_tbl = 'N') THEN
7125 l_err_loc := 8800;
7126 l_org_already_exists := ICX_CAT_UTIL_PVT.checkValueExistsInTable(l_org_id_tbl, l_site_level_prf_opt_val);
7127 l_is_site_prf_val_in_org_tbl := 'Y';
7128 ELSE
7129 l_err_loc := 8900;
7130 l_org_already_exists := 'Y';
7131 END IF;
7132 END IF; -- IF (l_prf_option_val.org_id <> '-2') THEN
7133
7134 IF ( l_org_already_exists = 'N' ) THEN
7135 l_err_loc := 9000;
7136 l_org_id_index := l_org_id_tbl.COUNT + 1;
7137 IF (l_prf_option_val.org_id <> '-2') THEN
7138 l_err_loc := 9100;
7139 l_org_id_tbl(l_org_id_index) := l_prf_option_val.org_id;
7140 ELSE
7141 l_err_loc := 9200;
7142 l_org_id_tbl(l_org_id_index) := l_site_level_prf_opt_val;
7143 END IF;
7144
7145 l_err_loc := 9300;
7146 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7147 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
7148 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7149 'Added to the l_org_id_tbl for, l_user_id_tbl:' || l_user_id_tbl(i) ||
7150 ', l_org_id_tbl.COUNT:' || l_org_id_tbl.COUNT ||
7151 ', l_org_id_tbl:' || l_org_id_tbl(l_org_id_index));
7152 END IF;
7153 END IF; -- IF ( l_org_already_exists = 'N' ) THEN
7154 END LOOP; -- l_prf_option_val IN getOrgIdsAtRespAndAppLevelCsr
7155
7156 l_err_loc := 9400;
7157 IF (l_org_id_profile_value_exist = 'N') THEN
7158 -- Log the favorite list header info.
7159 -- This header will be probably removed if there are no lines in this one
7160 l_err_loc := 9500;
7161 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7162 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7163 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7164 'ALERT: The user attached to the favorite list header does not have' ||
7165 ' profile option:ORG_ID value set at user level and responsibility level of' ||
7166 ' those resps belong to the following applications: 177, 178, 201, 396, 426;' ||
7167 ' Details: l_favorite_list_id_tbl:' || l_favorite_list_id_tbl(i) ||
7168 ', l_employee_id_tbl:' || l_employee_id_tbl(i) ||
7169 ', l_user_id_tbl:' || l_user_id_tbl(i) ||
7170 ', l_profile_option_value_tbl:' || l_profile_option_value_tbl(i) ||
7171 ', l_count_tbl:' || l_count_tbl(i) ||
7172 ', l_org_id_profile_value_exist:' || l_org_id_profile_value_exist);
7173 END IF;
7174 END IF;
7175 END IF; -- IF (l_profile_option_value_tbl(i) IS NOT NULL) THEN
7176 ELSE -- IF (l_user_id_tbl(i) IS NOT NULL) THEN
7177 l_err_loc := 9600;
7178 -- Log the favorite list header info.
7179 -- This header will be probably removed if there are no lines in this one
7180 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7181 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7182 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7183 'ALERT: The employee attached to the favorite list header does not have a user;' ||
7184 ' Details: l_favorite_list_id_tbl:' || l_favorite_list_id_tbl(i) ||
7185 ', l_employee_id_tbl:' || l_employee_id_tbl(i) ||
7186 ', l_user_id_tbl:' || l_user_id_tbl(i) ||
7187 ', l_profile_option_value_tbl:' || l_profile_option_value_tbl(i) ||
7188 ', l_count_tbl:' || l_count_tbl(i));
7189 END IF;
7190 END IF; -- IF (l_user_id_tbl(i) IS NOT NULL) THEN
7191
7192 l_err_loc := 9700;
7193 IF (i = l_favorite_list_id_tbl.COUNT AND
7194 l_org_id_tbl.COUNT > 0)
7195 THEN
7196 l_err_loc := 9800;
7197 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7198 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7199 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7200 'Forming the gIFLO tables for favorite_list_id:' || l_favorite_list_id_tbl(i) ||
7201 '; l_org_id_tbl.COUNT:' || l_org_id_tbl.COUNT);
7202 END IF;
7203
7204 l_err_loc := 9900;
7205 OPEN getOtherFavLinesForHdrCsr(l_favorite_list_id_tbl(i));
7206
7207 l_err_loc := 10000;
7208 FETCH getOtherFavLinesForHdrCsr BULK COLLECT INTO
7209 l_favorite_list_line_id_tbl;
7210
7211 l_err_loc := 10100;
7212 CLOSE getOtherFavLinesForHdrCsr;
7213
7214 l_err_loc := 10200;
7215 FOR j IN 1..l_favorite_list_line_id_tbl.COUNT LOOP
7216 l_err_loc := 10300;
7217 FOR k IN 1..l_org_id_tbl.COUNT LOOP
7218 l_err_loc := 10400;
7219 FOR l IN 1..l_language_tbl.COUNT LOOP
7220 l_err_loc := 10500;
7221 g_total_row_count := g_total_row_count + 1;
7222 l_fav_list_lines_index := gIFLOFavoriteListIdTbl.COUNT + 1;
7223 gIFLOFavoriteListIdTbl(l_fav_list_lines_index) := l_favorite_list_id_tbl(i);
7224 gIFLOOldFavoriteListLineIdTbl(l_fav_list_lines_index) := l_favorite_list_line_id_tbl(j);
7225 IF (k=1 AND l=1) THEN
7226 l_err_loc := 10600;
7227 gIFLONewFavoriteListLineIdTbl(l_fav_list_lines_index) := l_favorite_list_line_id_tbl(j);
7228 ELSE
7229 l_err_loc := 10700;
7230 gIFLONewFavoriteListLineIdTbl(l_fav_list_lines_index) := getNextFavListLineIdFromSeq;
7231 END IF;
7232 l_err_loc := 10800;
7233 gIFLOOrgIdTbl(l_fav_list_lines_index) := l_org_id_tbl(k);
7234 gIFLOLanguageTbl(l_fav_list_lines_index) := l_language_tbl(l);
7235 END LOOP;
7236 END LOOP;
7237 END LOOP;
7238
7239 l_err_loc := 10900;
7240 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7241 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7242 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7243 'Formed the gIFLO tables for favorite_list_id:' || l_favorite_list_id_tbl(i) ||
7244 '; count of favorite_lines in the hdr:' || l_count_tbl(i) ||
7245 ', gIFLOFavoriteListIdTbl.COUNT:' || gIFLOFavoriteListIdTbl.COUNT);
7246 END IF;
7247
7248 l_err_loc := 11000;
7249 l_org_id_tbl.DELETE;
7250 l_org_already_exists := 'N';
7251 END IF;
7252
7253 l_err_loc := 11100;
7254 l_prev_favorite_list_id := l_favorite_list_id_tbl(i);
7255
7256 l_err_loc := 11200;
7257 populatePOInterfaceTables('INLOOP');
7258 END LOOP; -- FOR i IN 1..l_favorite_list_id_tbl.COUNT LOOP
7259
7260 l_err_loc := 11300;
7261 EXIT WHEN l_favorite_list_id_tbl.COUNT < ICX_CAT_UTIL_PVT.g_batch_size;
7262 EXCEPTION
7263 WHEN ICX_CAT_UTIL_PVT.g_snap_shot_too_old THEN
7264 l_err_string := ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name)
7265 || '-' || l_err_loc
7266 || ', Total processeded batches:' || l_batch_count;
7267 ICX_CAT_UTIL_PVT.logAndCommitSnapShotTooOld(g_pkg_name, l_api_name, l_err_string);
7268 l_err_loc := 11400;
7269 CLOSE otherItemUpgradeCsr;
7270 OPEN otherItemUpgradeCsr(l_profile_option_id);
7271 END;
7272 END LOOP; -- CURSOR LOOP otherItemUpgradeCsr
7273
7274 l_err_loc := 11500;
7275 FOR j IN 1..gIFLOFavoriteListIdTbl.COUNT LOOP
7276 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7277 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
7278 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7279 'fav list other lines upgrade values at j :' || j ||
7280 ', gIFLOFavoriteListIdTbl :' || gIFLOFavoriteListIdTbl(j) ||
7281 ', gIFLOOldFavoriteListLineIdTbl :' || gIFLOOldFavoriteListLineIdTbl(j) ||
7282 ', gIFLONewFavoriteListLineIdTbl :' || gIFLONewFavoriteListLineIdTbl(j) ||
7283 ', gIFLOOrgIdTbl :' || gIFLOOrgIdTbl(j) ||
7284 ', gIFLOLanguageTbl :' || gIFLOLanguageTbl(j) );
7285 END IF;
7286 END LOOP;
7287
7288 l_err_loc := 11600;
7289 populatePOInterfaceTables('OUTLOOP');
7290
7291 l_err_loc := 11700;
7292 IF (otherItemUpgradeCsr%ISOPEN) THEN
7293 CLOSE otherItemUpgradeCsr;
7294 END IF;
7295
7296 l_err_loc := 11710;
7297 l_favorite_list_id_tbl.DELETE;
7298 l_employee_id_tbl.DELETE;
7299 l_user_id_tbl.DELETE;
7300 l_profile_option_value_tbl.DELETE;
7301 l_count_tbl.DELETE;
7302
7303 l_err_loc := 11800;
7304 -- Clean up the favorite_list_headers for which there is no lines.
7305 l_continue := TRUE;
7306 WHILE l_continue LOOP
7307 l_err_loc := 11900;
7308 l_favorite_list_id_tbl.DELETE;
7309 l_employee_id_tbl.DELETE;
7310
7311 l_err_loc := 12000;
7312 DELETE FROM icx_cat_fav_list_headers hdrs
7313 WHERE NOT EXISTS ( SELECT 'x' FROM icx_cat_fav_list_lines_tlp lines
7314 WHERE lines.favorite_list_id = hdrs.favorite_list_id)
7315 AND ROWNUM <= ICX_CAT_UTIL_PVT.g_batch_size
7316 RETURNING favorite_list_id, employee_id
7317 BULK COLLECT INTO l_favorite_list_id_tbl, l_employee_id_tbl;
7318
7319 l_err_loc := 12100;
7320 l_row_count := SQL%ROWCOUNT;
7321
7322 l_err_loc := 12200;
7323 IF (l_row_count < ICX_CAT_UTIL_PVT.g_batch_size OR
7324 l_row_count = 0)
7325 THEN
7326 l_continue := FALSE;
7327 END IF;
7328
7329 l_err_loc := 390;
7330 IF (l_favorite_list_id_tbl.COUNT > 0) THEN
7331 IF (FND_LOG.LEVEL_STATEMENT >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7332 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
7333 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7334 'No: of rows deleted from icx_cat_fav_list_headers for which there are no lines:' || l_row_count);
7335 FOR i IN 1..l_favorite_list_id_tbl.COUNT LOOP
7336 FND_LOG.string(FND_LOG.LEVEL_STATEMENT,
7337 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7338 'l_favorite_list_id_tbl(i):' || l_favorite_list_id_tbl(i) ||
7339 ', l_employee_id_tbl(i):' || l_employee_id_tbl(i));
7340 END LOOP;
7341 END IF;
7342 END IF;
7343
7344 l_err_loc := 12300;
7345 COMMIT;
7346 END LOOP;
7347
7348 l_err_loc := 12500;
7349 l_end_date := sysdate;
7350 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7351 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7352 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7353 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
7354 END IF;
7355
7356 EXCEPTION
7357 WHEN OTHERS THEN
7358 ICX_CAT_UTIL_PVT.logUnexpectedException(
7359 G_PKG_NAME, l_api_name,
7360 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
7361 ICX_CAT_UTIL_PVT.g_job_current_status := ICX_CAT_UTIL_PVT.g_job_failed_status;
7362 ICX_CAT_UTIL_PVT.g_job_complete_date := NULL;
7363 END upgradeFavoriteListLines;
7364
7365 PROCEDURE createCtxDomainIndex
7366 IS
7367 l_api_name CONSTANT VARCHAR2(30) := 'createCtxDomainIndex';
7368 l_err_loc PLS_INTEGER;
7369 l_icx_schema_name VARCHAR2(30) := NULL;
7370 l_status VARCHAR2(8);
7371 l_domidx_status VARCHAR2(12);
7372 l_domidx_opstatus VARCHAR2(6);
7373 l_index_exists NUMBER;
7374 l_start_date DATE;
7375 l_end_date DATE;
7376 BEGIN
7377 l_err_loc := 100;
7378 l_start_date := sysdate;
7379 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7380 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7381 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7382 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
7383 END IF;
7384
7385 l_err_loc := 200;
7386 l_icx_schema_name := ICX_CAT_UTIL_PVT.getIcxSchemaName;
7387
7388 l_err_loc := 300;
7389 BEGIN
7390 SELECT 0, status, domidx_status, domidx_opstatus
7391 INTO l_index_exists, l_status, l_domidx_status, l_domidx_opstatus
7392 FROM all_indexes
7393 WHERE index_name = 'ICX_CAT_ITEMSCTXDESC_HDRS'
7394 AND owner = l_icx_schema_name;
7395 EXCEPTION
7396 WHEN NO_DATA_FOUND THEN
7397 l_index_exists := -1;
7398 END;
7399
7400 l_err_loc := 400;
7401 IF (l_index_exists = 0 AND
7402 (l_status <> 'VALID' OR
7403 l_domidx_status <> 'VALID' OR
7404 l_domidx_opstatus <> 'VALID'))
7405 THEN
7406 l_err_loc := 500;
7407 -- Call the drop index first
7408 ICX_CAT_INTERMEDIA_INDEX_PVT.drop_index;
7409
7410 l_err_loc := 600;
7411 ICX_CAT_INTERMEDIA_INDEX_PVT.create_index;
7412
7413 l_err_loc := 700;
7414 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7415 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7416 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7417 'Drop and Create indexes called ');
7418 END IF;
7419 ELSIF (l_index_exists = -1) THEN
7420 l_err_loc := 800;
7421 ICX_CAT_INTERMEDIA_INDEX_PVT.create_index;
7422
7423 l_err_loc := 900;
7424 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7425 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7426 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7427 'Create index called ');
7428 END IF;
7429 END IF;
7430
7431 l_err_loc := 1000;
7432 l_end_date := sysdate;
7433 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7434 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7435 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7436 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
7437 END IF;
7438
7439 l_err_loc := 1100;
7440 EXCEPTION
7441 WHEN OTHERS THEN
7442 ICX_CAT_UTIL_PVT.logUnexpectedException(
7443 G_PKG_NAME, l_api_name,
7444 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
7445 ICX_CAT_UTIL_PVT.g_job_current_status := ICX_CAT_UTIL_PVT.g_job_failed_status;
7446 ICX_CAT_UTIL_PVT.g_job_complete_date := NULL;
7447 RAISE_APPLICATION_ERROR (-20000,
7448 'Exception at ' || G_PKG_NAME ||'.' || l_api_name ||
7449 '(' || l_err_loc || '), ' || SQLERRM);
7450 END createCtxDomainIndex;
7451
7452 PROCEDURE callICXFinalSteps
7453 IS
7454 l_api_name CONSTANT VARCHAR2(30) := 'callICXFinalSteps';
7455 l_err_loc PLS_INTEGER;
7456 l_upgrade_job_number PLS_INTEGER;
7457 l_start_date DATE;
7458 l_end_date DATE;
7459 BEGIN
7460 l_err_loc := 100;
7461 l_start_date := sysdate;
7462
7463 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7464 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7465 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7466 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
7467 END IF;
7468
7469 l_err_loc := 200;
7470 --Initialize the ICX_CAT_UTIL_PVT.g_COMMIT to true.
7471 --Deciding factor whether to commit or not in ICX_CAT_UTIL_PVT
7472 ICX_CAT_UTIL_PVT.setCommitParameter(FND_API.G_TRUE);
7473
7474 l_err_loc := 300;
7475 -- Set batch_size/commit_size into ICX_CAT_UTIL_PVT.g_batch_size
7476 ICX_CAT_UTIL_PVT.setBatchSize;
7477
7478 l_err_loc := 400;
7479 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7480 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7481 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7482 ', AUDSID:' || g_audsid);
7483 END IF;
7484
7485 l_err_loc := 500;
7486 l_upgrade_job_number := ICX_CAT_UTIL_PVT.getR12UpgradeJobNumber;
7487
7488 l_err_loc := 600;
7489 -- Set the userId etc..
7490 -- gUserId is used in created_by which should be -12 to identify the rows created by r12 upgrade
7491 ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id := ICX_CAT_UTIL_PVT.g_upgrade_user;
7492 ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id := ICX_CAT_UTIL_PVT.getNextSequenceForWhoColumns;
7493 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id := l_upgrade_job_number;
7494 ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id := l_upgrade_job_number;
7495 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id := l_upgrade_job_number;
7496 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id := l_upgrade_job_number;
7497 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id := l_upgrade_job_number;
7498
7499 l_err_loc := 700;
7500 ICX_CAT_UTIL_PVT.g_job_type := ICX_CAT_UTIL_PVT.g_icx_final_upg_program;
7501 ICX_CAT_UTIL_PVT.g_job_number := l_upgrade_job_number;
7502
7503 l_err_loc := 800;
7504 createR12UpgradeJob(g_audsid, null);
7505
7506 l_err_loc := 900;
7507 -- Set the base language
7508 ICX_CAT_UTIL_PVT.setBaseLanguage;
7509
7510 l_err_loc := 1000;
7511 callPurgeInvalidBlanketLines;
7512
7513 l_err_loc := 1200;
7514 upgradeFavoriteListHdrs;
7515
7516 l_err_loc := 1300;
7517 upgradeFavoriteListLines;
7518
7519 l_err_loc := 1400;
7520 createCtxDomainIndex;
7521
7522 l_err_loc := 1500;
7523 IF (ICX_CAT_UTIL_PVT.g_job_current_status IS NULL) THEN
7524 ICX_CAT_UTIL_PVT.g_job_current_status := ICX_CAT_UTIL_PVT.g_job_complete_status;
7525 ICX_CAT_UTIL_PVT.g_job_complete_date := sysdate;
7526 END IF;
7527
7528 l_err_loc := 1600;
7529 updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_current_status);
7530
7531 l_err_loc := 1700;
7532 l_end_date := sysdate;
7533 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7534 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7535 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7536 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
7537 END IF;
7538 EXCEPTION
7539 WHEN OTHERS THEN
7540 ICX_CAT_UTIL_PVT.logUnexpectedException(
7541 G_PKG_NAME, l_api_name,
7542 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
7543 ICX_CAT_UTIL_PVT.g_job_current_status := ICX_CAT_UTIL_PVT.g_job_failed_status;
7544 ICX_CAT_UTIL_PVT.g_job_complete_date := NULL;
7545 updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_failed_status);
7546 RAISE_APPLICATION_ERROR (-20000,
7547 'Exception at ' || G_PKG_NAME ||'.' || l_api_name ||
7548 '(' || l_err_loc || '), ' || SQLERRM);
7549 END callICXFinalSteps;
7550
7551 -- Appends a number 1, 2, etc to p_key. to find a distinct descriptor key,
7552 -- Returns a key value that is not present as a descriptor key
7553 FUNCTION getDistinctDescKeyFromCAT
7554 ( p_key IN VARCHAR2
7555 )
7556 RETURN VARCHAR2 IS
7557 l_suffix PLS_INTEGER := 1;
7558 l_newKey VARCHAR2(250);
7559 l_temp PLS_INTEGER;
7560 BEGIN
7561 LOOP
7562 l_newKey := p_key || l_suffix;
7563 l_suffix := l_suffix + 1;
7564 BEGIN
7565 SELECT 1
7566 INTO l_temp
7567 FROM icx_cat_descriptors_tl
7568 WHERE UPPER(key) = l_newKey;
7569 EXCEPTION
7570 WHEN NO_DATA_FOUND THEN
7571 --The current l_newKey is distinct, return it
7572 return l_newKey;
7573 END;
7574 END LOOP;
7575 END getDistinctDescKeyFromCAT;
7576
7577 PROCEDURE runAttributeUpgrade
7578 IS
7579 -- Cursor to check if the new descriptors added in R12 already
7580 -- existed on the customer instance with the same key
7581 -- New descriptors added in R12:
7582 -- SOURCE
7583 -- SHOPPING_CATEGORY
7584 -- PURCHASING_CATEGORY
7585 -- ITEM_REVISION
7586 CURSOR checkIcxCatDescriptorsTlCsr IS
7587 SELECT rt_descriptor_id, UPPER(key)
7588 FROM icx_cat_descriptors_tl
7589 WHERE UPPER(key) IN ('SOURCE',
7590 'SHOPPING_CATEGORY',
7591 'PURCHASING_CATEGORY',
7592 'ITEM_REVISION')
7593 AND language = source_lang
7594 AND rt_descriptor_id > 100;
7595
7596 -- Cursor to check the searchable for some of the descritpors that can never be made
7597 -- searchable in R12.
7598 CURSOR checkSrchbleForSpecAttrsCsr IS
7599 SELECT attribute_id, key
7600 FROM icx_cat_attributes_tl
7601 WHERE key IN ('PURCHASING_CATEGORY',
7602 'THUMBNAIL_IMAGE',
7603 'SUPPLIER_SITE',
7604 'PICTURE',
7605 'UOM',
7606 'PRICE',
7607 'CURRENCY',
7608 'FUNCTIONAL_PRICE',
7609 'FUNCTIONAL_CURRENCY',
7610 'ATTACHMENT_URL',
7611 'SUPPLIER_URL',
7612 'MANUFACTURER_URL')
7613 AND searchable = 1
7614 AND rt_category_id = 0
7615 AND language = ICX_CAT_UTIL_PVT.g_base_language;
7616
7617 ----- Start of declaring columns selected in the cursor -----
7618 l_rt_descriptor_id_tbl DBMS_SQL.NUMBER_TABLE;
7619 l_attribute_id_tbl DBMS_SQL.NUMBER_TABLE;
7620 l_key_tbl DBMS_SQL.VARCHAR2_TABLE;
7621 ------ End of declaring columns selected in the cursor ------
7622
7623 -- variables for update
7624 l_upd_index PLS_INTEGER;
7625 l_upd_rt_descriptor_id_tbl DBMS_SQL.NUMBER_TABLE;
7626 l_upd_key_tbl DBMS_SQL.VARCHAR2_TABLE;
7627 l_new_key VARCHAR2(250);
7628
7629 l_api_name CONSTANT VARCHAR2(30) := 'runAttributeUpgrade';
7630 l_err_loc PLS_INTEGER;
7631 l_is_attr_already_upgraded NUMBER;
7632 BEGIN
7633 l_err_loc := 100;
7634 BEGIN
7635 SELECT 1
7636 INTO l_is_attr_already_upgraded
7637 FROM dual
7638 WHERE EXISTS (SELECT 'attribute records'
7639 FROM icx_cat_attributes_tl
7640 WHERE attribute_id > 100);
7641 EXCEPTION
7642 WHEN NO_DATA_FOUND THEN
7643 l_is_attr_already_upgraded := -1;
7644 END;
7645
7646 l_err_loc := 200;
7647 OPEN checkIcxCatDescriptorsTlCsr;
7648
7649 l_err_loc := 1100;
7650 l_rt_descriptor_id_tbl.DELETE;
7651 l_key_tbl.DELETE;
7652 FETCH checkIcxCatDescriptorsTlCsr BULK COLLECT INTO l_rt_descriptor_id_tbl, l_key_tbl;
7653
7654 l_err_loc := 1200;
7655 CLOSE checkIcxCatDescriptorsTlCsr;
7656
7657 l_err_loc := 1300;
7658 FOR i IN 1..l_rt_descriptor_id_tbl.COUNT LOOP
7659 l_new_key := NULL;
7660 l_err_loc := 1400;
7661 l_new_key := getDistinctDescKeyFromCAT(l_key_tbl(i));
7662 IF (l_new_key IS NOT NULL) THEN
7663 l_err_loc := 1500;
7664 l_upd_index := l_upd_rt_descriptor_id_tbl.COUNT + 1;
7665 l_upd_rt_descriptor_id_tbl(l_upd_index) := l_rt_descriptor_id_tbl(i);
7666 l_upd_key_tbl(l_upd_index) := l_new_key;
7667 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7668 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7669 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7670 'changing descriptor key from:' || l_key_tbl(i) ||
7671 ', to :' || l_new_key || ' in icx_cat_descriptors_tl for rt_descriptor_id :' ||
7672 l_rt_descriptor_id_tbl(i));
7673 END IF;
7674 END IF;
7675 END LOOP;
7676
7677 l_err_loc := 1600;
7678 FORALL i IN 1..l_upd_rt_descriptor_id_tbl.COUNT
7679 UPDATE icx_cat_descriptors_tl
7680 SET key = l_upd_key_tbl(i)
7681 WHERE rt_descriptor_id = l_upd_rt_descriptor_id_tbl(i);
7682
7683 l_err_loc := 1700;
7684 COMMIT;
7685
7686 INSERT INTO icx_cat_attributes_tl
7687 (
7688 attribute_id, language, source_lang,
7689 attribute_name, description, rt_category_id, type,
7690 sequence, key,
7691 searchable, search_results_visible, item_detail_visible,
7692 created_by, creation_date,
7693 last_updated_by, last_update_login, last_update_date,
7694 request_id, program_application_id, program_id,
7695 rebuild_flag, section_tag,
7696 stored_in_table, stored_in_column
7697 )
7698 (
7699 SELECT
7700 des1.rt_descriptor_id, des1.language, des1.source_lang,
7701 des1.descriptor_name, des1.description, des1.rt_category_id, des1.type,
7702 des1.sequence, des1.key,
7703 des1.searchable, des1.search_results_visible, des1.item_detail_visible,
7704 des1.created_by, des1.creation_date,
7705 des1.last_updated_by, des1.last_update_login, des1.last_update_date,
7706 des1.batch_job_num, des1.program_application_id, des1.program_id,
7707 des1.rebuild_flag, des1.section_tag,
7708 DECODE(des1.type, 2, 'PO_ATTRIBUTE_VALUES_TLP', 'PO_ATTRIBUTE_VALUES'),
7709 des1.stored_in_column
7710 FROM
7711 icx_cat_descriptors_tl des1
7712 WHERE des1.rt_descriptor_id > 100
7713 AND NOT EXISTS (SELECT NULL FROM icx_cat_attributes_tl des2
7714 WHERE des1.rt_descriptor_id = des2.attribute_id
7715 AND des1.language = des2.language)
7716 );
7717
7718 l_err_loc := 300;
7719 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7720 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7721 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7722 'No: of rows inserted into icx_cat_attributes_tl during upgrade:' || SQL%ROWCOUNT);
7723 END IF;
7724
7725 IF (l_is_attr_already_upgraded = -1) THEN
7726 l_err_loc := 400;
7727 OPEN checkSrchbleForSpecAttrsCsr;
7728
7729 l_err_loc := 500;
7730 l_attribute_id_tbl.DELETE;
7731 l_key_tbl.DELETE;
7732 FETCH checkSrchbleForSpecAttrsCsr BULK COLLECT INTO l_attribute_id_tbl, l_key_tbl;
7733
7734 l_err_loc := 600;
7735 CLOSE checkSrchbleForSpecAttrsCsr;
7736
7737 l_err_loc := 700;
7738 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7739 FOR i IN 1..l_attribute_id_tbl.COUNT LOOP
7740 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7741 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7742 ' Attribute key:' || l_key_tbl(i) || ', will be made non-searchable');
7743 END LOOP;
7744 END IF;
7745
7746 l_err_loc := 800;
7747 FORALL i IN 1..l_attribute_id_tbl.COUNT
7748 UPDATE icx_cat_attributes_tl
7749 SET searchable = 0
7750 WHERE attribute_id = l_attribute_id_tbl(i);
7751
7752 l_err_loc := 850;
7753 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7754 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7755 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7756 'No: of rows updated with searchable=0 in icx_cat_attributes_tl during upgrade:' || SQL%ROWCOUNT);
7757 END IF;
7758 END IF;
7759
7760 l_err_loc := 900;
7761 COMMIT;
7762
7763 l_err_loc := 1000;
7764 EXCEPTION
7765 WHEN OTHERS THEN
7766 ICX_CAT_UTIL_PVT.logUnexpectedException(
7767 G_PKG_NAME, l_api_name,
7768 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
7769 END runAttributeUpgrade;
7770
7771 PROCEDURE initializeGlobalVariables
7772 ( p_current_program IN VARCHAR2
7773 )
7774 IS
7775 l_api_name CONSTANT VARCHAR2(30) := 'initializeGlobalVariables';
7776 l_err_loc PLS_INTEGER;
7777 l_upgrade_job_number PLS_INTEGER;
7778 BEGIN
7779 l_err_loc := 100;
7780 --Initialize the ICX_CAT_UTIL_PVT.g_COMMIT to true.
7781 --Deciding factor whether to commit or not in ICX_CAT_UTIL_PVT
7782 ICX_CAT_UTIL_PVT.setCommitParameter(FND_API.G_TRUE);
7783
7784 l_err_loc := 200;
7785 -- Set batch_size/commit_size into ICX_CAT_UTIL_PVT.g_batch_size
7786 ICX_CAT_UTIL_PVT.setBatchSize;
7787
7788 l_err_loc := 300;
7789 -- Get the next batch_id for PDOI
7790 -- Get it from the po_headers_interface
7791 -- Cannot use the API PO_PDOI_UTL.get_next_batch_id because
7792 -- this is not available in 11.5.9 and 11.5.10
7793 SELECT NVL(MAX(batch_id), 0) + 1
7794 INTO g_PDOI_batch_id
7795 FROM po_headers_interface;
7796
7797 l_err_loc := 400;
7798 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7799 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7800 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7801 'PDOI Batch Id:' || g_PDOI_batch_id ||
7802 ', p_current_program:' || p_current_program ||
7803 ', AUDSID:' || g_audsid);
7804 END IF;
7805
7806 l_err_loc := 500;
7807 -- Deciding factor to whether call callPOMigrateCatalog in validate_only_mode or not.
7808 ICX_CAT_UTIL_PVT.g_current_program := p_current_program;
7809
7810 l_err_loc := 600;
7811 -- Set the userId etc..
7812 -- gUserId is used in created_by which should be -12 to identify the rows created by r12 upgrade
7813 ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id := ICX_CAT_UTIL_PVT.g_upgrade_user;
7814 ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id := ICX_CAT_UTIL_PVT.getNextSequenceForWhoColumns;
7815
7816 l_err_loc := 700;
7817 IF (p_current_program = ICX_CAT_UTIL_PVT.g_upgrade_program) THEN
7818 -- R12 upgrade call
7819 l_upgrade_job_number := ICX_CAT_UTIL_PVT.getR12UpgradeJobNumber;
7820
7821 l_err_loc := 900;
7822 ICX_CAT_UTIL_PVT.g_job_type := ICX_CAT_UTIL_PVT.g_upgrade_program;
7823 ICX_CAT_UTIL_PVT.g_job_number := l_upgrade_job_number;
7824
7825 l_err_loc := 1000;
7826 -- Set the who columns also
7827 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id := l_upgrade_job_number;
7828 ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id := l_upgrade_job_number;
7829 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id := l_upgrade_job_number;
7830 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id := l_upgrade_job_number;
7831 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id := l_upgrade_job_number;
7832
7833 l_err_loc := 1100;
7834 createR12UpgradeJob(g_audsid, g_pdoi_batch_id);
7835 ELSE
7836 l_err_loc := 1200;
7837 -- Pre-upgrade / Data-exceptions call.
7838 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id := fnd_global.login_id;
7839 ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id := fnd_global.conc_request_id;
7840 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id := fnd_global.prog_appl_id;
7841 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id := fnd_global.conc_program_id;
7842 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id := fnd_global.conc_login_id;
7843
7844 l_err_loc := 1300;
7845 IF (p_current_program = ICX_CAT_UTIL_PVT.g_pre_upgrade_program) THEN
7846 ICX_CAT_UTIL_PVT.g_job_type := ICX_CAT_UTIL_PVT.g_pre_upgrade_program;
7847 ICX_CAT_UTIL_PVT.g_job_number := fnd_global.conc_request_id;
7848 ELSIF (p_current_program = ICX_CAT_UTIL_PVT.g_data_exception_program) THEN
7849 l_err_loc := 1400;
7850 ICX_CAT_UTIL_PVT.g_job_type := ICX_CAT_UTIL_PVT.g_data_exception_program;
7851 ICX_CAT_UTIL_PVT.g_job_number := fnd_global.conc_request_id;
7852 END IF;
7853 END IF;
7854
7855 l_err_loc := 1500;
7856 -- Get the last pre-upgrade completed dates
7857 SELECT NVL(MAX(PREUPG_PDOI_COMPLETE_DATE), NULL) extract_last_run_date,
7858 NVL(MAX(preupg_pdoi_update_date), NULL) bulk_last_run_date,
7859 NVL(MAX(preupg_bpa_complete_date), NULL) bpa_last_run_date,
7860 NVL(MAX(preupg_quote_complete_date), NULL) quote_last_run_date,
7861 NVL(MAX(preupg_reqtmplt_complete_date), NULL) reqtmplt_last_run_date,
7862 NVL(MAX(preupg_mi_complete_date), NULL) mi_last_run_date
7863 INTO g_extract_last_run_date,
7864 g_bulk_last_run_date,
7865 g_bpa_last_run_date,
7866 g_quote_last_run_date,
7867 g_reqtmplt_last_run_date,
7868 g_mi_last_run_date
7869 FROM icx_cat_r12_upgrade_jobs
7870 -- Check within jobs that are not data exception
7871 -- OR child data exception process ( which will be submitted from pre-upgrade program)
7872 WHERE job_type NOT IN (ICX_CAT_UTIL_PVT.g_data_exception_program,
7873 ICX_CAT_UTIL_PVT.g_child_data_excptn_program);
7874
7875 l_err_loc := 1700;
7876 -- Update the current job to running status
7877 updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_running_status);
7878
7879 l_err_loc := 1800;
7880 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7881 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7882 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7883 'Upgrade last successful completion dates:' ||
7884 ', g_extract_last_run_date: ' || g_extract_last_run_date ||
7885 ', g_bulk_last_run_date: ' || g_bulk_last_run_date ||
7886 ', g_bpa_last_run_date: ' || g_bpa_last_run_date ||
7887 ', g_quote_last_run_date: ' || g_quote_last_run_date ||
7888 ', g_reqtmplt_last_run_date: ' || g_reqtmplt_last_run_date ||
7889 ', g_mi_last_run_date: ' || g_mi_last_run_date );
7890 END IF;
7891
7892 l_err_loc := 1900;
7893 -- Set the base language
7894 ICX_CAT_UTIL_PVT.setBaseLanguage;
7895
7896 l_err_loc := 2000;
7897 EXCEPTION
7898 WHEN OTHERS THEN
7899 ICX_CAT_UTIL_PVT.logUnexpectedException(
7900 G_PKG_NAME, l_api_name,
7901 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
7902 raise;
7903 END initializeGlobalVariables;
7904
7905 PROCEDURE commonAPICallsFromUpgAndPreUpg
7906 IS
7907 l_api_name CONSTANT VARCHAR2(30) := 'commonAPICallsFromUpgAndPreUpg';
7908 l_err_loc PLS_INTEGER;
7909 BEGIN
7910 l_err_loc := 100;
7911 runAttributeUpgrade;
7912
7913 l_err_loc := 300;
7914 moveExtItemsBaseAndLocalAttr;
7915
7916 l_err_loc := 400;
7917 migrateBulkloadItems;
7918
7919 l_err_loc := 500;
7920 -- Call the PDOI API.
7921 callPOMigrateCatalog;
7922
7923 l_err_loc := 600;
7924 EXCEPTION
7925 WHEN OTHERS THEN
7926 ICX_CAT_UTIL_PVT.logUnexpectedException(
7927 G_PKG_NAME, l_api_name,
7928 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
7929 RAISE;
7930 END commonAPICallsFromUpgAndPreUpg;
7931
7932 PROCEDURE submitDataExceptionsRequest
7933 ( is_sub_request IN BOOLEAN ,
7934 p_data_exception_job OUT NOCOPY NUMBER
7935 )
7936 IS
7937 l_api_name CONSTANT VARCHAR2(30) := 'submitDataExceptionsRequest';
7938 l_err_loc PLS_INTEGER;
7939 l_start_date DATE;
7940 l_end_date DATE;
7941 l_log_string VARCHAR2(2000);
7942 l_counter PLS_INTEGER;
7943 BEGIN
7944 l_err_loc := 100;
7945 l_start_date := sysdate;
7946
7947 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7948 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7949 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7950 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
7951 END IF;
7952
7953 l_err_loc := 150;
7954 l_counter := 0;
7955 WHILE (TRUE) LOOP
7956 l_counter := l_counter + 1;
7957 l_err_loc := 200;
7958 p_data_exception_job := fnd_request.submit_request
7959 (
7960 'ICX', -- application
7961 'ICXCUCDER', -- program
7962 -- ICX_CAT_R12_UPGRADE_PVT.runDataExcptnRptChildProcess;
7963 null, -- description
7964 NULL, -- start_time
7965 is_sub_request, -- sub_request (TRUE from pre-upgrade, FALSE from upgrade)
7966 ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id, -- p_parent_int_req_id
7967 ICX_CAT_UTIL_PVT.g_batch_size, -- p_batch_size
7968 FND_API.G_TRUE, -- p_commit
7969 g_PDOI_batch_id -- p_pdoi_batch_id
7970 );
7971 IF (p_data_exception_job > 0) THEN
7972 l_err_loc := 300;
7973 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7974 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7975 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7976 ', Child 1, Data Exceptions job submitted; request_id :' ||
7977 p_data_exception_job);
7978 END IF;
7979 EXIT;
7980 ELSIF (l_counter > 3) THEN
7981 l_err_loc := 400;
7982 p_data_exception_job := 0;
7983 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7984 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
7985 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
7986 ', Child 1, Data Exceptions job not submitted; So submitting' ||
7987 ' it as a serial process. About to call callICXProcessDataExcptnRpt');
7988 END IF;
7989 l_err_loc := 450;
7990 callICXProcessDataExcptnRpt;
7991 EXIT;
7992 END IF;
7993 END LOOP;
7994
7995 l_err_loc := 500;
7996 l_end_date := sysdate;
7997
7998 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
7999 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
8000 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
8001 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
8002 END IF;
8003
8004 l_err_loc := 600;
8005 EXCEPTION
8006 WHEN OTHERS THEN
8007 ICX_CAT_UTIL_PVT.logUnexpectedException(
8008 G_PKG_NAME, l_api_name,
8009 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
8010 END submitDataExceptionsRequest;
8011
8012 PROCEDURE upgradeDefaultSortProfiles
8013 IS
8014 l_api_name CONSTANT VARCHAR2(30) := 'upgradeDefaultSortProfiles';
8015 l_relevance_profile_value VARCHAR2(1) := 'N';
8016 l_application_id NUMBER;
8017 l_profile_option_id NUMBER;
8018 l_err_loc PLS_INTEGER;
8019 BEGIN
8020 l_err_loc := 100;
8021 BEGIN
8022 SELECT fpov.profile_option_value
8023 INTO l_relevance_profile_value
8024 FROM fnd_profile_options fpo, fnd_profile_option_values fpov
8025 WHERE fpo.profile_option_name = 'POR_SORT_BY_RELEVANCE'
8026 AND fpo.profile_option_id = fpov.profile_option_id
8027 AND fpov.level_id = 10001;
8028
8029 l_err_loc := 200;
8030 EXCEPTION
8031 WHEN no_data_found THEN
8032 -- no row is found, that means the relevance profile value is not set
8033 null;
8034
8035 END;
8036
8037 l_err_loc := 250;
8038 -- insert rows to fnd_profile_option_values only if the relevance profile value is 'Y'
8039 IF (l_relevance_profile_value = 'Y') THEN
8040 l_err_loc := 300;
8041 SELECT application_id, profile_option_id
8042 INTO l_application_id, l_profile_option_id
8043 FROM fnd_profile_options
8044 WHERE profile_option_name = 'POR_DEFAULT_SHOPPING_SORT';
8045
8046 l_err_loc := 350;
8047 -- insert only if row doesn't exist
8048 INSERT INTO fnd_profile_option_values
8049 (application_id, profile_option_id, level_id, level_value, last_update_date,
8050 last_updated_by, creation_date, created_by, last_update_login, profile_option_value)
8051 SELECT l_application_id, l_profile_option_id, 10001, 0, sysdate, fnd_global.user_id,
8052 sysdate, fnd_global.user_id, fnd_global.login_id, 'Relevance'
8053 FROM dual
8054 WHERE NOT EXISTS (SELECT 1
8055 FROM fnd_profile_option_values
8056 WHERE application_id = l_application_id
8057 AND profile_option_id = l_profile_option_id
8058 AND level_id = 10001
8059 AND level_value = 0);
8060
8061 l_err_loc := 400;
8062 SELECT application_id, profile_option_id
8063 INTO l_application_id, l_profile_option_id
8064 FROM fnd_profile_options
8065 WHERE profile_option_name = 'POR_DEFAULT_SHOPPING_SORT_ORDER';
8066
8067 l_err_loc := 450;
8068 -- insert only if row doesn't exist
8069 INSERT INTO fnd_profile_option_values
8070 (application_id, profile_option_id, level_id, level_value, last_update_date,
8071 last_updated_by, creation_date, created_by, last_update_login, profile_option_value)
8072 SELECT l_application_id, l_profile_option_id, 10001, 0, sysdate, fnd_global.user_id,
8073 sysdate, fnd_global.user_id, fnd_global.login_id, 'DESC'
8074 FROM dual
8075 WHERE NOT EXISTS (SELECT 1
8076 FROM fnd_profile_option_values
8077 WHERE application_id = l_application_id
8078 AND profile_option_id = l_profile_option_id
8079 AND level_id = 10001
8080 AND level_value = 0);
8081
8082 l_err_loc := 500;
8083 END IF;
8084
8085 l_err_loc := 550;
8086 COMMIT;
8087
8088 l_err_loc := 600;
8089 EXCEPTION
8090 WHEN OTHERS THEN
8091 ROLLBACK;
8092 ICX_CAT_UTIL_PVT.logUnexpectedException(
8093 G_PKG_NAME, l_api_name,
8094 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
8095 RAISE_APPLICATION_ERROR (-20000,
8096 'Exception at ' || G_PKG_NAME ||'.' || l_api_name ||
8097 '(' || l_err_loc || '), ' || SQLERRM);
8098 END upgradeDefaultSortProfiles;
8099
8100 PROCEDURE runR12Upgrade
8101 ( x_errbuf OUT NOCOPY VARCHAR2 ,
8102 x_retcode OUT NOCOPY NUMBER
8103 )
8104 IS
8105 l_api_name CONSTANT VARCHAR2(30) := 'runR12Upgrade';
8106 l_err_loc PLS_INTEGER;
8107 l_data_exception_job NUMBER;
8108 l_start_date DATE;
8109 l_end_date DATE;
8110 l_log_string VARCHAR2(2000);
8111 BEGIN
8112 l_err_loc := 100;
8113 x_retcode := 0;
8114 x_errbuf := '';
8115
8116 l_err_loc := 200;
8117 l_start_date := sysdate;
8118
8119 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
8120 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
8121 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
8122 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') );
8123 END IF;
8124
8125 l_err_loc := 300;
8126 initializeGlobalVariables(ICX_CAT_UTIL_PVT.g_upgrade_program);
8127
8128 l_err_loc := 400;
8129 commonAPICallsFromUpgAndPreUpg;
8130
8131 l_err_loc := 500;
8132 -- During upgrade running through adpatch, we are just submitting a concurrent program
8133 -- for data exceptions. This job will be picked up when the system comes back up.
8134 -- During patching, before submitting the job,
8135 -- set the fnd_conc_maintain.apps_initialize_for_mgr
8136 fnd_conc_maintain.apps_initialize_for_mgr;
8137
8138 l_err_loc := 600;
8139 submitDataExceptionsRequest(FALSE, l_data_exception_job);
8140
8141 l_err_loc := 1200;
8142 IF (ICX_CAT_UTIL_PVT.g_job_current_status IS NULL) THEN
8143 ICX_CAT_UTIL_PVT.g_job_current_status := ICX_CAT_UTIL_PVT.g_job_complete_status;
8144 ICX_CAT_UTIL_PVT.g_job_complete_date := sysdate;
8145 END IF;
8146
8147 l_err_loc := 1300;
8148 updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_current_status);
8149
8150 l_err_loc := 1400;
8151 l_end_date := sysdate;
8152 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
8153 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
8154 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
8155 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
8156 END IF;
8157
8158 l_err_loc := 1500;
8159 EXCEPTION
8160 WHEN OTHERS THEN
8161 ICX_CAT_UTIL_PVT.logUnexpectedException(
8162 G_PKG_NAME, l_api_name,
8163 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
8164 ROLLBACK;
8165 ICX_CAT_UTIL_PVT.g_job_complete_date := NULL;
8166 updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_failed_status);
8167 x_retcode := 2;
8168 x_errbuf := 'Exception at ' ||
8169 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name) ||
8170 '(l_err_loc:' || l_err_loc || '), ' || SQLERRM;
8171 raise;
8172 END runR12Upgrade;
8173
8174 PROCEDURE runDataExcptnRptChildProcess
8175 ( x_errbuf OUT NOCOPY VARCHAR2 ,
8176 x_retcode OUT NOCOPY NUMBER ,
8177 p_parent_int_req_id IN NUMBER ,
8178 p_batch_size IN NUMBER ,
8179 p_commit IN VARCHAR2 ,
8180 p_pdoi_batch_id IN NUMBER
8181 )
8182 IS
8183 l_api_name CONSTANT VARCHAR2(30) := 'runDataExcptnRptChildProcess';
8184 l_err_loc PLS_INTEGER;
8185 l_start_date DATE;
8186 l_end_date DATE;
8187 l_log_string VARCHAR2(2000);
8188 l_audsid NUMBER := USERENV('SESSIONID');
8189 BEGIN
8190 l_err_loc := 100;
8191 l_start_date := sysdate;
8192 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
8193 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
8194 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
8195 'Started at:' || TO_CHAR(l_start_date, 'DD-MON-YYYY HH24:MI:SS') ||
8196 ', audsid:' || l_audsid ||
8197 'Parameters: p_parent_int_req_id:' || p_parent_int_req_id ||
8198 ' p_batch_size:' || p_batch_size ||
8199 ' p_commit:' || p_commit ||
8200 ' p_pdoi_batch_id:' || p_pdoi_batch_id);
8201 END IF;
8202
8203 l_err_loc := 200;
8204 ICX_CAT_UTIL_PVT.g_batch_size := p_batch_size;
8205
8206 l_err_loc := 300;
8207 ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id := ICX_CAT_UTIL_PVT.g_upgrade_user;
8208 ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id := p_parent_int_req_id;
8209 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id := fnd_global.login_id;
8210 ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id := fnd_global.conc_request_id;
8211 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id := fnd_global.prog_appl_id;
8212 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id := fnd_global.conc_program_id;
8213 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id := fnd_global.conc_login_id;
8214
8215 l_err_loc := 400;
8216 -- Set the global commit parameter
8217 ICX_CAT_UTIL_PVT.setCommitParameter(p_commit);
8218
8219 l_err_loc := 500;
8220 ICX_CAT_UTIL_PVT.g_job_type := ICX_CAT_UTIL_PVT.g_child_data_excptn_program;
8221 ICX_CAT_UTIL_PVT.g_job_number := ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id;
8222
8223 l_err_loc := 600;
8224 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
8225 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
8226 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
8227 ' g_job_type:' || ICX_CAT_UTIL_PVT.g_job_type ||
8228 ' g_job_number:' || ICX_CAT_UTIL_PVT.g_job_number);
8229 END IF;
8230
8231 l_err_loc := 700;
8232 createR12UpgradeJob(l_audsid, p_pdoi_batch_id);
8233
8234 -- Call the ICX API to process the data exception report for the
8235 -- lines rejected during poMigrateCatalog with errors.
8236 l_err_loc := 800;
8237 ICX_CAT_R12_DATA_EXCEP_RPT_PVT.process_data_exceptions_report(p_pdoi_batch_id);
8238
8239 l_err_loc := 900;
8240 ICX_CAT_UTIL_PVT.g_job_complete_date := SYSDATE;
8241 ICX_CAT_R12_UPGRADE_PVT.updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_complete_status);
8242
8243 l_err_loc := 1000;
8244 x_retcode := 0;
8245 x_errbuf := l_api_name ||' done';
8246
8247 l_err_loc := 1100;
8248 l_end_date := sysdate;
8249 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
8250 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
8251 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
8252 ' done in:' || ICX_CAT_UTIL_PVT.getTimeStats(l_start_date, l_end_date));
8253 END IF;
8254 EXCEPTION
8255 WHEN OTHERS THEN
8256 ICX_CAT_UTIL_PVT.logUnexpectedException(
8257 G_PKG_NAME, l_api_name,
8258 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
8259 ROLLBACK;
8260 ICX_CAT_UTIL_PVT.g_job_complete_date := NULL;
8261 updateR12UpgradeJob(ICX_CAT_UTIL_PVT.g_job_failed_status);
8262 x_retcode := 2;
8263 x_errbuf := 'Exception at ' ||
8264 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name) ||
8265 '(l_err_loc:' || l_err_loc || '), ' || SQLERRM;
8266 END runDataExcptnRptChildProcess;
8267
8268 PROCEDURE createR12UpgradeJob
8269 ( p_audsid IN NUMBER ,
8270 p_pdoi_batch_id IN NUMBER DEFAULT NULL
8271 )
8272 IS
8273 l_api_name CONSTANT VARCHAR2(30) := 'createR12UpgradeJob';
8274 l_err_loc PLS_INTEGER;
8275 BEGIN
8276 l_err_loc := 100;
8277 INSERT INTO icx_cat_r12_upgrade_jobs
8278 (job_type, job_number, status, run_date, audsid, pdoi_batch_id,
8279 last_update_login, last_updated_by, last_update_date,
8280 created_by, creation_date, internal_request_id, request_id,
8281 program_application_id, program_id, program_login_id)
8282 SELECT ICX_CAT_UTIL_PVT.g_job_type, ICX_CAT_UTIL_PVT.g_job_number,
8283 ICX_CAT_UTIL_PVT.g_job_running_status, sysdate, p_audsid, p_pdoi_batch_id,
8284 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
8285 ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id, sysdate,
8286 ICX_CAT_UTIL_PVT.g_who_columns_rec.user_id, sysdate,
8287 ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
8288 ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
8289 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
8290 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
8291 ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
8292 FROM DUAL
8293 WHERE NOT EXISTS (SELECT 'x' FROM icx_cat_r12_upgrade_jobs
8294 WHERE job_type = ICX_CAT_UTIL_PVT.g_job_type
8295 AND job_number = ICX_CAT_UTIL_PVT.g_job_number );
8296
8297 l_err_loc := 200;
8298 COMMIT;
8299
8300 l_err_loc := 300;
8301 EXCEPTION
8302 WHEN OTHERS THEN
8303 ICX_CAT_UTIL_PVT.logUnexpectedException(
8304 G_PKG_NAME, l_api_name,
8305 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
8306 raise;
8307 END createR12UpgradeJob;
8308
8309 PROCEDURE updateR12UpgradeJob
8310 ( p_job_status IN VARCHAR2 ,
8311 p_audsid2 IN NUMBER DEFAULT NULL
8312 )
8313 IS
8314 l_api_name CONSTANT VARCHAR2(30) := 'updateR12UpgradeJob';
8315 l_err_loc PLS_INTEGER;
8316 l_row_count PLS_INTEGER;
8317 BEGIN
8318 l_err_loc := 100;
8319 IF ( p_job_status = ICX_CAT_UTIL_PVT.g_job_running_status) THEN
8320 UPDATE icx_cat_r12_upgrade_jobs
8321 SET status = p_job_status,
8322 audsid = g_audsid,
8323 pdoi_batch_id = g_PDOI_batch_id,
8324 last_update_login = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
8325 last_updated_by = ICX_CAT_UTIL_PVT.g_who_columns_rec.login_id,
8326 last_update_date = sysdate,
8327 internal_request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.internal_request_id,
8328 request_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.request_id,
8329 program_application_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_application_id,
8330 program_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_id,
8331 program_login_id = ICX_CAT_UTIL_PVT.g_who_columns_rec.program_login_id
8332 WHERE job_type = ICX_CAT_UTIL_PVT.g_job_type
8333 AND job_number = ICX_CAT_UTIL_PVT.g_job_number;
8334 ELSIF ( p_job_status = ICX_CAT_UTIL_PVT.g_job_paused_status) THEN
8335 -- i.e. paused status, when run as parent
8336 -- we need to update the pdoi_update_date and pdoi_complete_date
8337 -- because when the parent is re-started, it is re-started in a
8338 -- new session and these global varaibles are lost
8339 l_err_loc := 200;
8340 UPDATE icx_cat_r12_upgrade_jobs
8341 SET preupg_pdoi_update_date = ICX_CAT_UTIL_PVT.g_job_pdoi_update_date,
8342 preupg_pdoi_complete_date = ICX_CAT_UTIL_PVT.g_job_pdoi_complete_date
8343 WHERE job_type = ICX_CAT_UTIL_PVT.g_job_type
8344 AND job_number = ICX_CAT_UTIL_PVT.g_job_number;
8345 ELSE
8346 -- i.e. completed / failed status
8347 l_err_loc := 300;
8348 UPDATE icx_cat_r12_upgrade_jobs
8349 SET status = p_job_status,
8350 audsid2 = p_audsid2,
8351 preupg_complete_date = ICX_CAT_UTIL_PVT.g_job_complete_date,
8352 preupg_pdoi_update_date = NVL(ICX_CAT_UTIL_PVT.g_job_pdoi_update_date, preupg_pdoi_update_date),
8353 preupg_pdoi_complete_date = NVL(ICX_CAT_UTIL_PVT.g_job_pdoi_complete_date, preupg_pdoi_complete_date),
8354 preupg_bpa_complete_date = ICX_CAT_UTIL_PVT.g_job_bpa_complete_date,
8355 preupg_quote_complete_date = ICX_CAT_UTIL_PVT.g_job_quote_complete_date,
8356 preupg_reqtmplt_complete_date = ICX_CAT_UTIL_PVT.g_job_reqtmplt_complete_date,
8357 preupg_mi_complete_date = ICX_CAT_UTIL_PVT.g_job_mi_complete_date
8358 WHERE job_type = ICX_CAT_UTIL_PVT.g_job_type
8359 AND job_number = ICX_CAT_UTIL_PVT.g_job_number;
8360 END IF;
8361
8362 l_err_loc := 400;
8363 l_row_count := SQL%ROWCOUNT;
8364
8365 l_err_loc := 500;
8366 IF (FND_LOG.LEVEL_UNEXPECTED >= FND_LOG.G_CURRENT_RUNTIME_LEVEL) THEN
8367 FND_LOG.string(FND_LOG.LEVEL_UNEXPECTED,
8368 ICX_CAT_UTIL_PVT.getModuleNameForDebug(g_pkg_name, l_api_name),
8369 '; No: of rows updated in icx_cat_r12_upgrade_jobs:' || l_row_count);
8370 END IF;
8371
8372 l_err_loc := 600;
8373 COMMIT;
8374 EXCEPTION
8375 WHEN OTHERS THEN
8376 ICX_CAT_UTIL_PVT.logUnexpectedException(
8377 G_PKG_NAME, l_api_name,
8378 ' --> l_err_loc:' ||l_err_loc ||' '|| SQLERRM);
8379 END updateR12UpgradeJob;
8380
8381 END ICX_CAT_R12_UPGRADE_PVT;