[Home] [Help]
PACKAGE BODY: APPS.EGO_ODI_PUB
Source
1 package body ego_odi_pub as
2 /* $Header: EGOODIXB.pls 120.59.12020000.2 2013/04/09 01:25:29 trudave ship $ */
3
4 /*==========================================================================+
5 | Copyright (c) 1993 Oracle Corporation Belmont, California, USA |
6 | All rights reserved. |
7 +===========================================================================+
8 | |
9 | File Name : EGOODIXB.pls |
10 | DESCRIPTION : This file is a packaged procedure for the PLM exploders. |
11 | |
12 | |
13 +==========================================================================*/
14
15
16
17 function Validate_Item(p_session_id IN NUMBER,
18 p_odi_session_id IN NUMBER,
19 p_index in number,
20 p_inv_id in VARCHAR2,
21 p_org_id in NUMBER,
22 p_segment1 in varchar2 DEFAULT NULL,
23 p_segment2 in varchar2 DEFAULT NULL,
24 p_segment3 in varchar2 DEFAULT NULL,
25 p_segment4 in varchar2 DEFAULT NULL,
26 p_segment5 in varchar2 DEFAULT NULL,
27 p_segment6 in varchar2 DEFAULT NULL,
28 p_segment7 in varchar2 DEFAULT NULL,
29 p_segment8 in varchar2 DEFAULT NULL,
30 p_segment9 in varchar2 DEFAULT NULL,
31 p_segment10 in varchar2 DEFAULT NULL,
32 p_segment11 in varchar2 DEFAULT NULL,
33 p_segment12 in varchar2 DEFAULT NULL,
34 p_segment13 in varchar2 DEFAULT NULL,
35 p_segment14 in varchar2 DEFAULT NULL,
36 p_segment15 in varchar2 DEFAULT NULL,
37 p_segment16 in varchar2 DEFAULT NULL,
38 p_segment17 in varchar2 DEFAULT NULL,
39 p_segment18 in varchar2 DEFAULT NULL,
40 p_segment19 in varchar2 DEFAULT NULL,
41 p_segment20 in varchar2 DEFAULT NULL,
42 x_inv_item_id OUT NOCOPY number
43 ) RETURN BOOLEAN
44 is
45
46 l_inv_item_id NUMBER;
47 l_segment1 VARCHAR2(40);
48 l_segment2 VARCHAR2(40);
49 l_segment3 VARCHAR2(40);
50 l_segment4 VARCHAR2(40);
51 l_segment5 VARCHAR2(40);
52 l_segment6 VARCHAR2(40);
53 l_segment7 VARCHAR2(40);
54 l_segment8 VARCHAR2(40);
55 l_segment9 VARCHAR2(40);
56 l_segment10 VARCHAR2(40);
57 l_segment11 VARCHAR2(40);
58 l_segment12 VARCHAR2(40);
59 l_segment13 VARCHAR2(40);
60 l_segment14 VARCHAR2(40);
61 l_segment15 VARCHAR2(40);
62 l_segment16 VARCHAR2(40);
63 l_segment17 VARCHAR2(40);
64 l_segment18 VARCHAR2(40);
65 l_segment19 VARCHAR2(40);
66 l_segment20 VARCHAR2(40);
67
68 BEGIN
69
70 IF p_org_id IS NULL THEN
71 RETURN FALSE;
72 END IF;
73
74 IF p_inv_id IS NULL and p_segment1 IS NULL THEN
75 RETURN FALSE;
76 END IF;
77
78 IF p_inv_id ='?' and p_segment1 ='?' THEN
79 RETURN FALSE;
80 END IF;
81
82 IF p_inv_id = '?' THEN
83 l_inv_item_id := NULL;
84 ELSE
85 l_inv_item_id := p_inv_id;
86 END IF;
87
88
89 l_segment1 := p_segment1;
90 l_segment2 := p_segment2;
91 l_segment3 := p_segment3;
92 l_segment4 := p_segment4;
93 l_segment5 := p_segment5;
94 l_segment6 := p_segment6;
95 l_segment7 := p_segment7;
96 l_segment8 := p_segment8;
97 l_segment9 := p_segment9;
98 l_segment10 := p_segment10;
99 l_segment11 := p_segment11;
100 l_segment12 := p_segment12;
101 l_segment13 := p_segment13;
102 l_segment14 := p_segment14;
103 l_segment15 := p_segment15;
104 l_segment16 := p_segment16;
105 l_segment17 := p_segment17;
106 l_segment18 := p_segment18;
107 l_segment19 := p_segment19;
108 l_segment20 := p_segment20;
109
110 IF l_segment1 = '?' THEN l_segment1 := NULL; END IF;
111 IF l_segment2 = '?' THEN l_segment2 := NULL; END IF;
112 IF l_segment3 = '?' THEN l_segment3 := NULL; END IF;
113 IF l_segment4 = '?' THEN l_segment4 := NULL; END IF;
114 IF l_segment5 = '?' THEN l_segment5 := NULL; END IF;
115 IF l_segment6 = '?' THEN l_segment6 := NULL; END IF;
116 IF l_segment7 = '?' THEN l_segment7 := NULL; END IF;
117 IF l_segment8 = '?' THEN l_segment8 := NULL; END IF;
118 IF l_segment9 = '?' THEN l_segment9 := NULL; END IF;
119 IF l_segment10 = '?' THEN l_segment10 := NULL; END IF;
120 IF l_segment11 = '?' THEN l_segment11 := NULL; END IF;
121 IF l_segment12 = '?' THEN l_segment12 := NULL; END IF;
122 IF l_segment13 = '?' THEN l_segment13 := NULL; END IF;
123 IF l_segment14 = '?' THEN l_segment14 := NULL; END IF;
124 IF l_segment15 = '?' THEN l_segment15 := NULL; END IF;
125 IF l_segment16 = '?' THEN l_segment16 := NULL; END IF;
126 IF l_segment17 = '?' THEN l_segment17 := NULL; END IF;
127 IF l_segment18 = '?' THEN l_segment18 := NULL; END IF;
128 IF l_segment19 = '?' THEN l_segment19 := NULL; END IF;
129 IF l_segment20 = '?' THEN l_segment20 := NULL; END IF;
130
131 --dbms_output.put_line( ' Inside Validate_Item ');
132 IF (l_inv_item_id IS NOT NULL) THEN
133
134 select inventory_item_id
135 INTO x_inv_item_id
136 from mtl_system_items_kfv
137 WHERE organization_id = p_org_id
138 AND inventory_item_id = to_number(l_inv_item_id);
139
140 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
141 p_odi_session_id => p_odi_session_id,
142 p_input_id => p_index,
143 p_param_name => 'InventoryItemId',
144 p_param_value => l_inv_item_id );
145
146 ELSE
147
148 --dbms_output.put_line('for segments ');
149 select inventory_item_id
150 INTO x_inv_item_id
151 from mtl_system_items_kfv
152 WHERE organization_id = p_org_id
153 AND Nvl(segment1, 0) = Nvl(l_segment1, 0)
154 AND Nvl(segment2, 0) = Nvl(l_segment2, 0)
155 AND Nvl(segment3, 0) = Nvl(l_segment3, 0)
156 AND Nvl(segment4, 0) = Nvl(l_segment4, 0)
157 AND Nvl(segment5, 0) = Nvl(l_segment5, 0)
158 AND Nvl(segment6, 0) = Nvl(l_segment6, 0)
159 AND Nvl(segment7, 0) = Nvl(l_segment7, 0)
160 AND Nvl(segment8, 0) = Nvl(l_segment8, 0)
161 AND Nvl(segment9, 0) = Nvl(l_segment9, 0)
162 AND Nvl(segment10, 0) = Nvl(l_segment10, 0)
163 AND Nvl(segment11, 0) = Nvl(l_segment11, 0)
164 AND Nvl(segment12, 0) = Nvl(l_segment12, 0)
165 AND Nvl(segment13, 0) = Nvl(l_segment13, 0)
166 AND Nvl(segment14, 0) = Nvl(l_segment14, 0)
167 AND Nvl(segment15, 0) = Nvl(l_segment15, 0)
168 AND Nvl(segment16, 0) = Nvl(l_segment16, 0)
169 AND Nvl(segment17, 0) = Nvl(l_segment17, 0)
170 AND Nvl(segment18, 0) = Nvl(l_segment18, 0)
171 AND Nvl(segment19, 0) = Nvl(l_segment19, 0)
172 AND Nvl(segment20, 0) = Nvl(l_segment20, 0);
173
174 EGO_ITEM_WS_PVT.POPULATE_SEGMENTS(p_session_id ,
175 p_odi_session_id ,
176 p_segment1 ,
177 p_segment2 ,
178 p_segment3 ,
179 p_segment4 ,
180 p_segment5 ,
181 p_segment6 ,
182 p_segment7 ,
183 p_segment8 ,
184 p_segment9 ,
185 p_segment10 ,
186 p_segment11 ,
187 p_segment12 ,
188 p_segment13 ,
189 p_segment14 ,
190 p_segment15 ,
191 p_segment16 ,
192 p_segment17 ,
193 p_segment18 ,
194 p_segment19 ,
195 p_segment20 ,
196 p_index );
197
198 END IF;
199
200 RETURN TRUE;
201
202 EXCEPTION
203 WHEN No_Data_Found THEN
204 --dbms_output.put_line(' Error : Invalid Item ');
205 --raise_application_error(-20101, 'Invalid Organization Id or Organization Name');
206
207 IF (l_inv_item_id IS NOT NULL) THEN
208
209 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
210 p_odi_session_id => p_odi_session_id,
211 p_input_id => p_index,
212 p_err_code => 'EGO_INVALID_ITEM_ID',
213 p_err_message => 'Invalid Inventory Item Id');
214
215 ELSE
216
217 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
218 p_odi_session_id => p_odi_session_id,
219 p_input_id => p_index,
220 p_err_code => 'EGO_INVALID_ITEM_NAME',
221 p_err_message => 'Invalid Inventory Item Name');
222 END IF;
223
224 RETURN FALSE;
225 -- error OUT NOCOPY
226 WHEN OTHERS THEN
227 --dbms_output.put_line(' Error : '|| SQLERRM);
228 RETURN FALSE;
229
230 END Validate_Item;
231
232
233
234 function Validate_Organization(p_session_id IN NUMBER,
235 p_odi_session_id IN NUMBER,
236 p_index in number,
237 p_org_id in VARCHAR2 DEFAULT NULL,
238 p_org_code IN VARCHAR2 DEFAULT NULL,
239 x_organization_id OUT NOCOPY number
240 ) RETURN BOOLEAN
241 is
242
243 l_org_id NUMBER;
244
245 BEGIN
246 --dbms_output.put_line('Inside Validate_organization');
247
248 IF p_org_id IS NULL and p_org_code IS NULL THEN
249 RETURN FALSE;
250 END IF;
251
252 IF p_org_id = '?' and p_org_code = '?' THEN
253 RETURN FALSE;
254 END IF;
255
256 IF p_org_id = '?' THEN
257 l_org_id := NULL;
258 ELSE
259 l_org_id := to_number(p_org_id);
260 END IF;
261
262 IF (l_org_id IS NOT NULL) THEN
263
264 --dbms_output.put_line(' with org id :'||p_org_id );
265 select organization_id
266 INTO x_organization_id
267 from mtl_parameters
268 WHERE organization_id = to_number(l_org_id);
269
270 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
271 p_odi_session_id => p_odi_session_id,
272 p_input_id => p_index,
273 p_param_name => 'OrganizationId',
274 p_param_value => l_org_id);
275
276 ELSE
277
278 --dbms_output.put_line(' with org code p_org_code: '|| p_org_code);
279 select organization_id
280 INTO x_organization_id
281 from mtl_parameters
282 WHERE organization_code = p_org_code;
283
284 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
285 p_odi_session_id => p_odi_session_id,
286 p_input_id => p_index,
287 p_param_name => 'OrganizationCode',
288 p_param_value => p_org_code );
289
290
291 END IF;
292
293 RETURN TRUE;
294
295 EXCEPTION
296 WHEN No_Data_Found THEN
297 --dbms_output.put_line(' Error : Invalid Organization Details ');
298 --raise_application_error(-20101, 'Invalid Organization Id');
299 IF (l_org_id IS NOT NULL) THEN
300
301 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
302 p_odi_session_id => p_odi_session_id,
303 p_input_id => p_index,
304 p_err_code => 'EGO_INVALID_ORG_ID',
305 p_err_message => 'Invalid Organization Id');
306 ELSE
307
308 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
309 p_odi_session_id => p_odi_session_id,
310 p_input_id => p_index,
311 p_err_code => 'EGO_INVALID_ORG_CODE',
312 p_err_message => 'Invalid Organization Code');
313
314 END IF;
315
316 RETURN FALSE;
317 -- error OUT NOCOPY
318 WHEN OTHERS THEN
319 --dbms_output.put_line(' Error : '|| SQLERRM);
320 RETURN FALSE;
321
322 END Validate_Organization;
323
324
325 /*
326 Validates the provided attribute group id or name and returns TRUE if they are
327 valid. If the id is provided, the name is derived and returned in x_ag_name.
328 To validate the attribute group name, the attribute p_ag_id must be null.
329 */
330 function Validate_Attribute_Group(p_session_id NUMBER,
331 p_odi_session_id IN NUMBER,
332 p_ag_id in VARCHAR2,
333 p_ag_name IN VARCHAR2,
334 x_ag_name OUT NOCOPY VARCHAR2
335 ) RETURN BOOLEAN
336 is
337
338 l_index NUMBER;
339 l_ag_id VARCHAR2(150);
340 l_ag_name VARCHAR2(150);
341
342 BEGIN
343
344 l_ag_id := p_ag_id;
345 l_ag_name := p_ag_name;
346
347 IF p_ag_id = '?' THEN
348 l_ag_id := NULL;
349 END IF;
350
351 IF p_ag_name = '?' THEN
352 l_ag_name := NULL;
353 END IF;
354
355 IF l_ag_id IS NULL AND l_ag_name IS NULL THEN
356 RETURN FALSE;
357 END IF;
358
359 --dbms_output.put_line('Inside Validate_organization');
360 IF (l_ag_id IS NOT NULL) THEN
361
362 --dbms_output.put_line(' with ag id :'||p_ag_id );
363 SELECT ATTR_GROUP_NAME
364 into x_ag_name
365 FROM ego_attr_groups_v
366 WHERE ATTR_GROUP_ID = to_number(l_ag_id);
367
368 ELSE
369
370 --dbms_output.put_line(' with org code p_org_code: '|| p_org_code);
371 SELECT ATTR_GROUP_NAME
372 INTO x_ag_name
373 FROM ego_attr_groups_v
374 WHERE ATTR_GROUP_NAME = l_ag_name;
375
376 END IF;
377
378 RETURN TRUE;
379
380 EXCEPTION
381 WHEN No_Data_Found THEN
382
383 --dbms_output.put_line(' Error : Invalid Organization Details ');
384
385 SELECT Nvl(Max(INPUT_ID),0) + 1 into l_index
386 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
387 WHERE session_id = p_session_id;
388
389 IF (l_ag_id IS NOT NULL) THEN
390
391 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
392 p_odi_session_id => p_odi_session_id,
393 p_input_id => l_index,
394 p_param_name => 'AttributeGroupId',
395 p_param_value => l_ag_id
396 );
397
398 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
399 p_odi_session_id => p_odi_session_id,
400 p_input_id => l_index,
401 p_err_code => 'EGO_INVALID_AG_ID',
402 p_err_message => 'Invalid Attribute Group Id');
403
404 ELSE
405
406 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
407 p_odi_session_id => p_odi_session_id,
408 p_input_id => l_index,
409 p_param_name => 'AttributeGroupName',
410 p_param_value => l_ag_name
411 );
412
413 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
414 p_odi_session_id => p_odi_session_id,
415 p_input_id => l_index,
416 p_err_code => 'EGO_INVALID_AG_NAME',
417 p_err_message => 'Invalid Attribute Group Name');
418
419 END IF;
420
421 RETURN FALSE;
422 -- error OUT NOCOPY
423 WHEN OTHERS THEN
424 --dbms_output.put_line(' Error : '|| SQLERRM);
425 /*INSERT INTO emt_temp (Session_id, message)
426 values (p_session_id, 'Handling exception at Config_UDA: ' );
427 */
428 RETURN FALSE;
429
430 END Validate_Attribute_Group;
431
432
433 --validates if the provided structure name exists
434 --for primary structures, the name passes should be 'Primary'. After
435 --execution, the name 'Primary' will be converted to NULL so the bom
436 --explosion code can correctly retrieve the primary BOM
437 function Validate_Structure_Name(p_session_id IN NUMBER,
438 p_odi_session_id IN NUMBER,
439 p_str_name IN OUT NOCOPY VARCHAR2,
440 p_org_id IN NUMBER) RETURN BOOLEAN
441 is
442
443 l_tmp_str_name VARCHAR2(100);
444 l_error_str_name VARCHAR2(100);
445 p_index NUMBER;
446
447 BEGIN
448
449 /*INSERT INTO emt_temp (Session_id, message)
450 values (4293, 'new inside l_str_name:' || p_str_name);
451 */
452
453 l_tmp_str_name := p_str_name;
454 l_error_str_name := p_str_name;
455
456 IF l_tmp_str_name IS NULL THEN
457 RETURN FALSE;
458 END IF;
459
460 IF upper(l_tmp_str_name) = 'PRIMARY' OR l_tmp_str_name = '?' THEN
461 p_str_name := NULL;
462 l_tmp_str_name := p_str_name;
463 RETURN TRUE;
464 END IF;
465
466
467 select ALTERNATE_DESIGNATOR_CODE
468 into p_str_name
469 from bom_alternate_designators
470 WHERE organization_id = p_org_id
471 AND ALTERNATE_DESIGNATOR_CODE = l_tmp_str_name;
472
473 RETURN TRUE;
474
475 EXCEPTION
476 WHEN No_Data_Found THEN
477
478 --dbms_output.put_line(' Error : Invalid Revision Details ');
479
480 SELECT Nvl(Max(INPUT_ID),0) + 1 into p_index
481 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
482 WHERE session_id = p_session_id;
483
484 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
485 p_odi_session_id => p_odi_session_id,
486 p_input_id => p_index,
487 p_param_name => 'StructureName',
488 p_param_value => l_error_str_name
489 );
490
491 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
492 p_odi_session_id => p_odi_session_id,
493 p_input_id => p_index,
494 p_err_code => 'EGO_INVALID_STRUCTURE',
495 p_err_message => 'Invalid Structure Name and Org Combination');
496
497 RETURN FALSE;
498 -- error OUT NOCOPY
499 WHEN OTHERS THEN
500 --dbms_output.put_line(' Error : '|| SQLERRM);
501 RETURN FALSE;
502
503 END Validate_Structure_Name;
504
505
506 --validates if the provided structure name exists for a given item.
507 function Validate_Item_Structure_Name(p_session_id IN NUMBER,
508 p_odi_session_id IN NUMBER,
509 p_str_name IN VARCHAR2,
510 p_item_id IN NUMBER,
511 p_org_id IN NUMBER,
512 p_input_index IN NUMBER) RETURN BOOLEAN
513 is
514
515 l_tmp_str_name VARCHAR2(100);
516 l_error_str_name VARCHAR2(100);
517 --p_index NUMBER;
518
519 BEGIN
520
521 /*INSERT INTO emt_temp (Session_id, message)
522 values (4293, 'new inside l_str_name:' || p_str_name);
523 */
524
525 l_tmp_str_name := p_str_name;
526 l_error_str_name := p_str_name;
527
528 IF l_tmp_str_name IS NULL THEN
529 RETURN FALSE;
530 END IF;
531
532 IF upper(l_tmp_str_name) = 'PRIMARY' OR l_tmp_str_name = '?' THEN
533 l_tmp_str_name := NULL;
534 END IF;
535
536 IF l_tmp_str_name IS NOT NULL THEN
537
538 select alternate_bom_designator
539 into l_tmp_str_name
540 from bom_structures_b
541 where assembly_item_id = p_item_id
542 and organization_id = p_org_id
543 and alternate_bom_designator = l_tmp_str_name;
544
545 ELSE
546
547 select alternate_bom_designator
548 into l_tmp_str_name
549 from bom_structures_b
550 where assembly_item_id = p_item_id
551 and organization_id = p_org_id
552 and alternate_bom_designator IS NULL;
553
554 END IF;
555
556 RETURN TRUE;
557
558 EXCEPTION
559 WHEN No_Data_Found THEN
560
561 --dbms_output.put_line(' Error : Invalid Revision Details ');
562
563 /*SELECT Nvl(Max(INPUT_ID),0) + 1 into p_index
564 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
565 WHERE session_id = p_session_id;*/
566
567 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
568 p_odi_session_id => p_odi_session_id,
569 p_input_id => p_input_index,
570 p_param_name => 'StructureName',
571 p_param_value => l_error_str_name
572 );
573
574 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
575 p_odi_session_id => p_odi_session_id,
576 p_input_id => p_input_index,
577 p_err_code => 'EGO_INVALID_STRUCTURE',
578 p_err_message => 'Invalid Structure Name for a given Item');
579
580 RETURN FALSE;
581 -- error OUT NOCOPY
582 WHEN OTHERS THEN
583 --dbms_output.put_line(' Error : '|| SQLERRM);
584 RETURN FALSE;
585
586 END Validate_Item_Structure_Name;
587
588
589
590 --validates if the provided security group name exists
591 function Validate_Security_Group(p_session_id IN NUMBER,
592 p_odi_session_id IN NUMBER,
593 p_sec_grp_name IN VARCHAR2,
594 x_sec_grp_id OUT NOCOPY NUMBER) RETURN BOOLEAN
595 is
596
597 l_index NUMBER;
598
599 BEGIN
600
601 IF p_sec_grp_name IS NULL OR p_sec_grp_name = '?' THEN
602 x_sec_grp_id := NULL;
603 RETURN FALSE;
604 END IF;
605
606 --retrieving security group id from security group name
607 select security_group_id
608 into x_sec_grp_id
609 from FND_SECURITY_GROUPS
610 where security_group_key = p_sec_grp_name;
611
612 RETURN TRUE;
613
614 EXCEPTION
615 WHEN No_Data_Found THEN
616 --dbms_output.put_line(' Error : Invalid Revision Details ');
617
618 SELECT Nvl(Max(INPUT_ID),0) + 1 into l_index
619 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
620 WHERE session_id = p_session_id;
621
622 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
623 p_odi_session_id => p_odi_session_id,
624 p_input_id => l_index,
625 p_param_name => 'SecurityGroup',
626 p_param_value => p_sec_grp_name
627 );
628
629 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
630 p_odi_session_id => p_odi_session_id,
631 p_input_id => l_index,
632 p_err_code => 'EGO_INVALID_SECURITY_GROUP',
633 p_err_message => 'Invalid Security Group');
634
635 RETURN FALSE;
636 -- error OUT NOCOPY
637 WHEN OTHERS THEN
638 --dbms_output.put_line(' Error : '|| SQLERRM);
639 RETURN FALSE;
640
641 END Validate_Security_Group;
642
643
644 --validates if the provided responsibility application name exists
645 function Validate_Resp_Appl_Name(p_session_id IN NUMBER,
646 p_odi_session_id IN NUMBER,
647 p_resp_appl_name IN VARCHAR2,
648 x_resp_appl_id OUT NOCOPY NUMBER) RETURN BOOLEAN
649 is
650
651 l_index NUMBER;
652
653 BEGIN
654
655 IF p_resp_appl_name IS NULL OR p_resp_appl_name = '?' THEN
656 x_resp_appl_id := NULL;
657 RETURN FALSE;
658 END IF;
659
660 --retrieving application id from application name
661 select application_id
662 into x_resp_appl_id
663 from FND_APPLICATION
664 where application_short_name = p_resp_appl_name;
665
666 RETURN TRUE;
667
668 EXCEPTION
669 WHEN No_Data_Found THEN
670 --dbms_output.put_line(' Error : Invalid Revision Details ');
671
672 SELECT Nvl(Max(INPUT_ID),0) + 1 into l_index
673 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
674 WHERE session_id = p_session_id;
675
676 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
677 p_odi_session_id => p_odi_session_id,
678 p_input_id => l_index,
679 p_param_name => 'ResponsibilityApplicationName',
680 p_param_value => p_resp_appl_name
681 );
682
683 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
684 p_odi_session_id => p_odi_session_id,
685 p_input_id => l_index,
686 p_err_code => 'EGO_INVALID_RESP_APPL_NAME',
687 p_err_message => 'Invalid Responsibility Application Name');
688
689 RETURN FALSE;
690 -- error OUT NOCOPY
691 WHEN OTHERS THEN
692 --dbms_output.put_line(' Error : '|| SQLERRM);
693 RETURN FALSE;
694
695 END Validate_Resp_Appl_Name;
696
697
698 --validates if the provided responsibility name exists
699 function Validate_Resp_Name(p_session_id IN NUMBER,
700 p_odi_session_id IN NUMBER,
701 p_resp_name IN VARCHAR2,
702 x_resp_id OUT NOCOPY NUMBER) RETURN BOOLEAN
703 is
704
705 l_index NUMBER;
706
707 BEGIN
708
709 IF p_resp_name IS NULL OR p_resp_name = '?' THEN
710 x_resp_id := NULL;
711 RETURN FALSE;
712 END IF;
713
714 --retrieving responsibility id from responsibility name
715 Select responsibility_id
716 into x_resp_id
717 from FND_RESPONSIBILITY
718 where responsibility_key = p_resp_name;
719
720 RETURN TRUE;
721
722 EXCEPTION
723 WHEN No_Data_Found THEN
724 --dbms_output.put_line(' Error : Invalid Revision Details ');
725
726 SELECT Nvl(Max(INPUT_ID),0) + 1 into l_index
727 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
728 WHERE session_id = p_session_id;
729
730 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
731 p_odi_session_id => p_odi_session_id,
732 p_input_id => l_index,
733 p_param_name => 'ResponsibilityName',
734 p_param_value => p_resp_name
735 );
736
737 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
738 p_odi_session_id => p_odi_session_id,
739 p_input_id => l_index,
740 p_err_code => 'EGO_INVALID_RESP_NAME',
741 p_err_message => 'Invalid Responsibility Name');
742
743 RETURN FALSE;
744 -- error OUT NOCOPY
745 WHEN OTHERS THEN
746 --dbms_output.put_line(' Error : '|| SQLERRM);
747 RETURN FALSE;
748
749 END Validate_Resp_Name;
750
751
752 function Validate_Language_Info(p_session_id IN NUMBER,
753 p_odi_session_id IN NUMBER,
754 p_language_code IN OUT NOCOPY VARCHAR2,
755 p_language_name VARCHAR2 DEFAULT NULL) RETURN BOOLEAN
756 is
757
758 l_temp VARCHAR(100);
759 l_index NUMBER;
760
761 BEGIN
762
763 --dbms_output.put_line('Inside Validate_Language_Info');
764 IF p_language_code IS NULL AND p_language_name IS NULL THEN
765 RETURN FALSE;
766 END IF;
767
768 IF p_language_code ='?' AND p_language_name ='?' THEN
769 RETURN FALSE;
770 END IF;
771
772
773 l_temp := p_language_code;
774
775 IF l_temp = '?' THEN
776 l_temp:= NULL;
777 END IF;
778
779 IF l_temp IS NOT NULL THEN
780 select language_code
781 into p_language_code
782 from fnd_languages where language_code = l_temp;
783 ELSE
784 select language_code
785 into p_language_code
786 from fnd_languages where nls_language = upper(p_language_name);
787 END IF;
788
789 RETURN TRUE;
790
791 EXCEPTION
792 WHEN No_Data_Found THEN
793 --dbms_output.put_line(' Error : Invalid Language Code ');
794
795 SELECT Nvl(Max(INPUT_ID),0) + 1 into l_index
796 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
797 WHERE session_id = p_session_id;
798
799
800 IF l_temp IS NOT NULL THEN
801
802 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
803 p_odi_session_id => p_odi_session_id,
804 p_input_id => l_index,
805 p_param_name => 'LanguageCode',
806 p_param_value => l_temp
807 );
808
809 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
810 p_odi_session_id => p_odi_session_id,
811 p_input_id => l_index,
812 p_err_code => 'EGO_INVALID_LANGUAGE_CODE',
813 p_err_message => 'Invalid Language Code');
814
815 ELSE
816
817 EGO_ODI_PUB.Populate_Input_Identifier(p_session_id => p_session_id,
818 p_odi_session_id => p_odi_session_id,
819 p_input_id => l_index,
820 p_param_name => 'LanguageName',
821 p_param_value => p_language_name
822 );
823
824 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
825 p_odi_session_id => p_odi_session_id,
826 p_input_id => l_index,
827 p_err_code => 'EGO_INVALID_LANGUAGE_NAME',
828 p_err_message => 'Invalid Language Name');
829
830
831 END IF;
832
833 RETURN FALSE;
834 -- error OUT NOCOPY
835 WHEN OTHERS THEN
836 --dbms_output.put_line(' Error : '|| SQLERRM);
837 RETURN FALSE;
838
839 END Validate_Language_Info;
840
841
842 --Inserts the list of parameters contained in raw XML pointed by XPATH
843 --expression into table EGO_PUB_WS_CONFIG
844 PROCEDURE Insert_ODI_Parameter_List(p_session_id IN NUMBER,
845 p_xml_node_xpath VARCHAR2,
846 p_parameter_name VARCHAR2,
847 p_web_service_name VARCHAR2 DEFAULT NULL)
848 IS
849
850 l_node_name VARCHAR2(100);
851 l_pos NUMBER;
852
853 --
854 -- Query to retrieve the list of values for a given xml node of type list
855 --
856 --Cursor to recover list of node values
857 CURSOR c_xml_node_value_list(p_session_id NUMBER,
858 xml_node_path VARCHAR2,
859 xml_node_name VARCHAR2)
860 IS
861 select extractValue(val, xml_node_name) value
862 from
863 (select value(tags) val
864 from EGO_PUB_WS_PARAMS i,
865 table(XMLSequence(
866 extract(i.xmlcontent, xml_node_path))) tags
867 where session_id = p_session_id);
868
869
870 BEGIN
871
872 l_pos := instr(p_xml_node_xpath, '/', -1);
873 --Dbms_Output.put_line('p_search_str: ' || p_search_str);
874 --Dbms_Output.put_line('xml_node_name pos: ' || l_pos);
875 l_node_name := substr(p_xml_node_xpath, l_pos+1, length(p_xml_node_xpath) - l_pos);
876 --Dbms_Output.put_line('xml_node_name: ' || l_node_name);
877
878 --looping throgh all values and insert them in table
879 FOR r in c_xml_node_value_list(p_session_id,
880 p_xml_node_xpath,
881 l_node_name) LOOP
882
883 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
884 odi_session_id,
885 Parameter_Name,
886 Data_Type,
887 Char_value,
888 creation_date,
889 created_by,
890 web_service_name)
891 VALUES (p_session_id,
892 p_session_id,
893 p_parameter_name,
894 2,
895 r.value,
896 sysdate,
897 0,
898 p_web_service_name);
899
900 END LOOP;
901
902
903 END Insert_ODI_Parameter_List;
904
905
906
907 --Function that returns the specified ODI input parameter from table
908 --EGO_PUB_WS_PARAMS using the session_id.
909 --INPUT:
910 --p_session_id: unique identifier of input XML stored in table EGO_PUB_WS_PARAMS
911 --p_search_str: x_path expression pointing to parameter to be recovered
912 -- (e.g. '/structureQueryParameters/PublishEntities/StructureRevision')
913 --OUTPUT:
914 --parameter value in VARCHAR or NULL if parameter specified does not exist
915 FUNCTION Get_ODI_Input_Parameter(p_session_id IN NUMBER, p_search_str IN VARCHAR2) RETURN VARCHAR2 IS
916
917 x_value VARCHAR2(100);
918
919 BEGIN
920
921
922
923 select extractValue(xmlcontent, p_search_str)
924 into x_value
925 from EGO_PUB_WS_PARAMS
926 where session_id = p_session_id;
927
928 --check for parameter value not available condition generated by
929 --some web services when parameter value is not specified.
930 IF x_value = '?' THEN
931 x_value := NULL;
932 END IF;
933
934 RETURN x_value;
935
936 END Get_ODI_Input_Parameter;
937
938
939
940 --Function that returns the specified ODI input parameters from table
941 --EGO_PUB_WS_PARAMS using the session_id as a comma separated list.
942 --INPUT:
943 --p_session_id: unique identifier of input XML stored in table EGO_PUB_WS_PARAMS
944 --p_search_str: x_path expression pointing to parameter to be recovered. The parameter
945 -- to be recovered (xml node) must be of type list
946 -- (e.g. '/structureQueryParameters/ListOfLanguageInformation/LanguageCode')
947 /*
948 FUNCTION Get_ODI_Input_Parameter_list(p_session_id IN NUMBER, p_search_str IN VARCHAR2)
949 RETURN VARCHAR2 IS
950
951 x_value VARCHAR2(4000);
952 l_node_name VARCHAR2(100);
953 l_pos NUMBER;
954
955 --
956 -- Query to retrieve the list of values for a given xml node of type list
957 --
958 --Cursor to recover list of node values
959 CURSOR c_xml_node_value_list(p_session_id NUMBER,
960 xml_node_path VARCHAR2,
961 xml_node_name VARCHAR2)
962 IS
963 select extractValue(val, xml_node_name) value
964 from
965 (select value(tags) val
966 from EGO_PUB_WS_PARAMS i,
967 table(XMLSequence(
968 extract(i.xmlcontent, xml_node_path))) tags
969 where session_id = p_session_id);
970
971 BEGIN
972
973 --x_value := '';
974
975 l_pos := instr(p_search_str, '/', -1);
976 --Dbms_Output.put_line('p_search_str: ' || p_search_str);
977 --Dbms_Output.put_line('xml_node_name pos: ' || l_pos);
978 l_node_name := substr(p_search_str, l_pos+1, length(p_search_str) - l_pos);
979 --Dbms_Output.put_line('xml_node_name: ' || l_node_name);
980
981 --looping throgh all values to create comma separated list
982 FOR r in c_xml_node_value_list(p_session_id,
983 p_search_str,
984 l_node_name) LOOP
985
986 IF x_value IS NULL THEN
987 x_value := r.value;
988 ELSE
989 x_value := x_value || ',' || r.value;
990 END IF;
991
992 END LOOP;
993
994 RETURN x_value;
995
996 END Get_ODI_Input_Parameter_list;
997 */
998
999
1000
1001 --initializes the FND security context depending on the invokation mode.
1002 --Depending on the invokation mode (e.g. BATCH, LIST, and HMDM), the
1003 --credentials for initializing the security must be found in different places.
1004 PROCEDURE Init_Security_Structure(p_session_id IN NUMBER,
1005 p_odi_session_id IN NUMBER)
1006 IS
1007
1008 l_mode VARCHAR2(100);
1009 l_application_id NUMBER;
1010 l_responsibility_id NUMBER;
1011 l_user_id NUMBER;
1012 l_security_group_id NUMBER;
1013 l_batch_id NUMBER;
1014 l_user_name VARCHAR2(100);
1015 l_responsibility_name VARCHAR2(100);
1016 l_responsibility_appl_name VARCHAR2(100);
1017 l_security_group_name VARCHAR2(100);
1018 l_is_valid BOOLEAN;
1019
1020
1021 BEGIN
1022
1023 --retrieving invokation mode
1024 select char_value
1025 into l_mode
1026 from EGO_PUB_WS_CONFIG
1027 where parameter_name = 'MODE'
1028 and web_service_name = 'GET_ITEM_STRUCTURE'
1029 and session_id = p_session_id;
1030
1031
1032
1033 --if mode is batch, get security related information from publication
1034 --framework using batch_id. The FND_SECURITY is enabled using the
1035 --login credentials of the person who created the batch
1036 --IF l_mode = 'BATCH' THEN
1037
1038 /*--retrieving batchId from input XML
1039 select to_number(extractValue(xmlcontent, '/structureQueryParameters/BatchStructureQueryParameters/BatchId'))
1040 into l_batch_id
1041 from EGO_PUB_WS_PARAMS
1042 where session_id = p_session_id;
1043
1044 --retrieving user_id and responsibility
1045 select created_by, responsibility_id
1046 into l_user_id,l_responsibility_id
1047 from EGO_PUB_BAT_HDR_B
1048 where batch_id = l_batch_id;
1049
1050 --retrieving responsibility_id
1051 Select application_id
1052 into l_application_id
1053 from FND_RESPONSIBILITY
1054 where responsibility_id = l_responsibility_id;
1055 */
1056
1057
1058 --END IF;
1059
1060 --If mode is LIST or BATCH, we initialize the FND security using the
1061 --credentials provided by the party calling the web service.
1062 --IF l_mode = 'LIST' OR l_mode = 'HMDM' THEN
1063
1064 --raise_application_error(-20000, 'security information unavailable for LIST mode');
1065
1066 --reading fnd user name
1067 select char_value
1068 into l_user_name
1069 from EGO_PUB_WS_CONFIG
1070 where session_id = p_session_id
1071 and web_service_name = 'GET_ITEM_STRUCTURE'
1072 and parameter_name = 'FND_USER_NAME';
1073
1074 --retrieving user id from user name
1075 select user_id
1076 into l_user_id
1077 from fnd_user
1078 where user_name = l_user_name;
1079
1080 --reading responsibility name
1081 select char_value
1082 into l_responsibility_name
1083 from EGO_PUB_WS_CONFIG
1084 where session_id = p_session_id
1085 and web_service_name = 'GET_ITEM_STRUCTURE'
1086 and parameter_name = 'RESPONSIBILITY_NAME';
1087
1088 --validating responsibility name
1089 l_is_valid := Validate_Resp_Name(p_session_id => p_session_id,
1090 p_odi_session_id => p_odi_session_id,
1091 p_resp_name => l_responsibility_name,
1092 x_resp_id => l_responsibility_id);
1093 --IF l_is_valid = FALSE THEN
1094 --TODO: Handle properly
1095 -- raise_application_error(-20000, 'Invalid Responsibility Name');
1096 --END IF;
1097
1098 --reading responsibility application name
1099 select char_value
1100 into l_responsibility_appl_name
1101 from EGO_PUB_WS_CONFIG
1102 where session_id = p_session_id
1103 and web_service_name = 'GET_ITEM_STRUCTURE'
1104 and parameter_name = 'RESPONSIBILITY_APPL_NAME';
1105
1106 --validating responsibility application name
1107 l_is_valid := Validate_Resp_Appl_Name(p_session_id => p_session_id,
1108 p_odi_session_id => p_odi_session_id,
1109 p_resp_appl_name => l_responsibility_appl_name,
1110 x_resp_appl_id => l_application_id);
1111 --IF l_is_valid = FALSE THEN
1112 --TODO: Handle properly
1113 -- raise_application_error(-20000, 'Invalid Responsibility Application Name');
1114 --END IF;
1115
1116 --reading security group name
1117 select char_value
1118 into l_security_group_name
1119 from EGO_PUB_WS_CONFIG
1120 where session_id = p_session_id
1121 and web_service_name = 'GET_ITEM_STRUCTURE'
1122 and parameter_name = 'SECURITY_GROUP_NAME';
1123
1124 --validating security group
1125 l_is_valid := Validate_Security_Group(p_session_id => p_session_id,
1126 p_odi_session_id => p_odi_session_id,
1127 p_sec_grp_name => l_security_group_name,
1128 x_sec_grp_id => l_security_group_id);
1129 --IF l_is_valid = FALSE THEN
1130 --TODO: Raise error if provided security group is not valid
1131 --NULL;
1132 --raise_application_error(-20000, 'security information unavailable for LIST mode');
1133 --END IF;
1134
1135
1136
1137 -- END IF;
1138
1139 --remove, debugging purposes only
1140 /*INSERT INTO emt_temp (Session_id, message)
1141 values (p_session_id, 'FND_SEC Userid: ' || l_user_id);
1142 --remove, debugging purposes only
1143 INSERT INTO emt_temp (Session_id, message)
1144 values (p_session_id, 'FND_SEC respid: ' || l_responsibility_id);
1145 --remove, debugging purposes only
1146 INSERT INTO emt_temp (Session_id, message)
1147 values (p_session_id, 'FND_SEC appid: ' || l_application_id);
1148 */
1149
1150
1151 --Initializing security context
1152 FND_GLOBAL.APPS_INITIALIZE(
1153 USER_ID=>l_user_id,
1154 RESP_ID=>l_responsibility_id,
1155 RESP_APPL_ID=>l_application_id
1156 );
1157
1158 --FND_GLOBAL.Apps_Initialize(user_id => 1006535, resp_id => 24089, resp_appl_id => 431);
1159 --Dbms_Output.put_line('FND_GLOBAL.User_Id: ' || FND_GLOBAL.User_Id);
1160 --Dbms_Output.put_line('FND_GLOBAL.Login_Id: ' || FND_GLOBAL.Login_Id);
1161
1162 END Init_Security_Structure;
1163
1164
1165 --Checks the specified security priviledge on items stored in table BOM_ODI_WS_ENTITIES.
1166 --If an item (row) is found not to have the privilege, the PUBLISH_FLAG columns is set to 'N'
1167 --so the end-item data is not published by ODI interfaces.
1168 PROCEDURE check_end_item_security(p_session_id IN NUMBER,
1169 p_odi_session_id IN NUMBER,
1170 p_priv_check IN VARCHAR2,
1171 p_for_exploded_items IN VARCHAR2,
1172 x_return_status OUT NOCOPY VARCHAR2
1173 )
1174 IS
1175
1176 l_sec_predicate VARCHAR2(32767);
1177 l_dynamic_update_sql VARCHAR2(32767);
1178 l_dynamic_sql VARCHAR2(32767);
1179 l_item_id NUMBER;
1180 l_org_id NUMBER;
1181 l_rev_id NUMBER;
1182
1183 l_mode VARCHAR2(10);
1184 l_batch_id NUMBER;
1185 l_batch_ent_obj_id NUMBER;
1186 l_user_name VARCHAR2(100);
1187 l_structure_name VARCHAR2(100);
1188 p_index number;
1189 l_seq_number NUMBER;
1190
1191
1192 TYPE DYNAMIC_CUR IS REF CURSOR;
1193 v_dynamic_cursor DYNAMIC_CUR;
1194
1195 BEGIN
1196
1197 --dbms_output.put_line(' Starting of check_security ');
1198
1199 --delete, for debugging only
1200 /*INSERT INTO emt_temp (Session_id, message)
1201 values (p_session_id, ' Starting of Check_security ');*/
1202
1203
1204 --obtaining security predicate based on FND_SECURITY initialization
1205 --dbms_output.put_line(' calling EGO_DATA_SECURITY.get_security_predicat ');
1206 EGO_DATA_SECURITY.get_security_predicate
1207 (p_api_version => 1.0
1208 ,p_function => p_priv_check
1209 ,p_object_name => 'EGO_ITEM'
1210 ,p_user_name => 'HZ_PARTY:'||TO_CHAR(FND_GLOBAL.PARTY_ID)
1211 ,p_statement_type => 'EXISTS'
1212 ,p_pk1_alias => 'i.ITEM_ID'
1213 ,p_pk2_alias => 'i.ITEM_ORG_ID'
1214 ,p_pk3_alias => NULL
1215 ,p_pk4_alias => NULL
1216 ,p_pk5_alias => NULL
1217 ,x_predicate => l_sec_predicate
1218 ,x_return_status => x_return_status );
1219
1220 --dbms_output.put_line( ' Before If T, F : x_return_status - '|| x_return_status);
1221
1222 --remove
1223 /*INSERT INTO emt_temp (Session_id, message)
1224 values (p_session_id, ' x_return_status: ' || x_return_status);
1225 INSERT INTO emt_temp (Session_id, message)
1226 values (p_session_id, ' l_sec_predicate: ' || l_sec_predicate);
1227
1228 */
1229
1230 IF x_return_status IN ('T','F') THEN
1231
1232 IF l_sec_predicate IS NOT NULL THEN
1233
1234 BEGIN
1235
1236 --selecting all end-items that do not have the publish privilege from table
1237 --BOM_ODI_WS_ENTITIES
1238 l_dynamic_sql := ' select ITEM_ID, ITEM_ORG_ID, ITEM_REV, SEQUENCE_NUMBER ' ||
1239 ' from BOM_ODI_WS_ENTITIES i ' ||
1240 ' where i.session_id = :1 ' ||
1241 ' AND NOT ' || l_sec_predicate;
1242
1243 --remove
1244 /*INSERT INTO emt_temp (Session_id, message)
1245 values (p_session_id, ' l_dynamic_sql: ' || l_dynamic_sql);
1246 */
1247 --Looping throught all items with no publish privilege to generate the error
1248 --messages
1249 OPEN v_dynamic_cursor FOR l_dynamic_sql
1250 USING p_session_id;
1251 LOOP
1252
1253 FETCH v_dynamic_cursor INTO l_item_id , l_org_id, l_rev_id, l_seq_number;
1254 EXIT WHEN v_dynamic_cursor%NOTFOUND;
1255
1256 --dbms_output.put_line(' In the loop Insering ... ');
1257 --dbms_output.put_line(' No Publiush priv for l_item_id :' || l_item_id);
1258
1259 --remove
1260 /*INSERT INTO emt_temp (Session_id, message)
1261 values (p_session_id, ' No publish privilege for item: ' || l_item_id);*/
1262
1263
1264 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
1265 p_odi_session_id => p_odi_session_id,
1266 p_input_id => l_seq_number,
1267 p_err_code => 'EGO_NO_PUBLISH_PRIV',
1268 p_err_message => 'User does not have the publish privilege for item');
1269
1270 END LOOP;
1271
1272 CLOSE v_dynamic_cursor;
1273 x_return_status := 'S';
1274 --dbms_output.put_line(' Doing Commit ');
1275 --COMMIT;
1276
1277 EXCEPTION
1278 WHEN OTHERS THEN
1279 --dbms_output.put_line('When others of check security Error :'|| SQLERRM);
1280 ROLLBACK;
1281 x_return_status := 'E';
1282 RAISE;
1283
1284 IF (v_dynamic_cursor%ISOPEN) THEN
1285 CLOSE v_dynamic_cursor;
1286 END IF;
1287 END; -- end of BEGIN
1288
1289
1290 --Now that the error messages have been generated,
1291 --set the flag PUBLISH_FLAG to 'N' in table table BOM_ODI_WS_ENTITIES
1292 --for end-items with no publish privilege to prevent their publication.
1293 /*l_dynamic_update_sql := ' delete from BOM_ODI_WS_ENTITIES i ' ||
1294 ' where i.session_id = :1 ' ||
1295 ' AND NOT ' || l_sec_predicate;*/
1296
1297 l_dynamic_update_sql := ' update BOM_ODI_WS_ENTITIES i ' ||
1298 ' set PUBLISH_FLAG = ''N'' ' ||
1299 ' where i.session_id = :1 ' ||
1300 ' AND nvl(i.PUBLISH_FLAG, ''Y'') = ''Y'' ' ||
1301 ' AND NOT ' || l_sec_predicate;
1302
1303
1304 --dbms_output.put_line(' Executing the l_dynamic_update_sql');
1305 EXECUTE IMMEDIATE l_dynamic_update_sql
1306 USING IN p_session_id;
1307
1308 ELSE
1309 x_return_status := 'S';
1310 END IF; -- end of l_sec_predicate IS NOT NULL
1311
1312 END IF;
1313
1314 END check_end_item_security;
1315
1316
1317 /*
1318 PROCEDURE generate_component_error(p_session_id IN NUMBER)
1319 IS
1320 BEGIN
1321
1322 --selecting end-item for a given component based on group_id
1323 --
1324 -- For exploded items give error message wrt to its structure.
1325 -- So, the following query retreives the end-items for the component
1326 FOR i IN (SELECT item_id, item_org_id, item_rev FROM BOM_ODI_WS_ENTITIES
1327 where group_id = l_group_id and session_id = p_session_id)
1328
1329 --(SELECT pk1_value, pk2_value, pk3_value FROM EGO_ODI_WS_ENTITIES ent1
1330 -- WHERE session_id = p_session_id and
1331 -- SEQUENCE_NUMBER IN (
1332 -- SELECT PK4_VALUE
1333 -- FROM EGO_ODI_WS_ENTITIES ent2
1334 -- WHERE PK1_VALUE = l_item_id
1335 -- AND PK2_VALUE = l_org_id
1336 -- AND ent1.session_id = ent2.session_id
1337 -- ))
1338 LOOP
1339
1340 --dbms_output.put_line('User did not have the privilege '||p_priv_check ||', on the the item '|| l_item_id);
1341
1342 --dbms_output.put_line('User did not have the privilege '||p_priv_check ||', for few components of the item '||i.item_id);
1343
1344 --retrieving invokation mode
1345 select char_value
1346 into l_mode
1347 from EGO_PUB_WS_CONFIG
1348 where parameter_name = 'MODE'
1349 and session_id = p_session_id;
1350
1351 IF (l_mode = 'BATCH') THEN
1352
1353 --retrieving batchId from input XML
1354 select to_number(extractValue(xmlcontent, '/structureQueryParameters/BatchStructureQueryParameters/BatchId'))
1355 into l_batch_id
1356 from EGO_PUB_WS_PARAMS
1357 where session_id = p_session_id;
1358
1359 --retrieving batch_id
1360 --select Numeric_Value
1361 --into l_batch_id
1362 --from EGO_PUB_WS_CONFIG
1363 --where parameter_name = 'BATCH_ID'
1364 --and session_id = p_session_id;
1365
1366 --selecting entity_object_id with respect to
1367 --publication framework tables to report the error
1368 SELECT BATCH_ENTITY_OBJECT_ID
1369 INTO l_batch_ent_obj_id
1370 FROM Ego_Pub_Bat_Ent_Objs_v
1371 WHERE batch_id = l_batch_id
1372 AND PK1_VALUE = i.item_id
1373 AND PK2_VALUE = i.item_org_id
1374 AND PK3_VALUE = i.item_rev;
1375
1376 SELECT party_name INTO l_user_name
1377 FROM EGO_USER_V WHERE USER_ID = FND_GLOBAL.USER_ID;
1378
1379 SELECT CHAR_VALUE INTO l_structure_name FROM EGO_PUB_BAT_PARAMS_B
1380 WHERE type_id=l_batch_id AND Upper(parameter_name) ='STRUCTURE_NAME';
1381
1382 UPDATE EGO_PUB_BAT_STATUS_B
1383 SET STATUS_CODE = 'F' , MESSAGE = 'User ' || l_user_name ||' does not have the publilsh privilege on few components of the structure ' ||
1384 l_structure_name || ' for this Item.'
1385 WHERE batch_id = l_batch_id AND BATCH_ENTITY_OBJECT_ID = l_batch_ent_obj_id;
1386
1387 ELSE
1388
1389 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
1390 p_odi_session_id => p_odi_session_id,
1391 p_input_id => l_seq_number,
1392 p_err_code => 'EGO_NO_PUBLISH_PRIV',
1393 p_err_message => 'User does not have the publilsh privilege on few components of the structure for the item');
1394
1395 END IF;
1396
1397 END LOOP;
1398
1399 END generate_component_error;
1400 */
1401
1402 --OLD PROCEDURE ANALYZING COMPONENTS IN BATCH MODE
1403 --Checks the specified security priviledge on all components stored in table BOM_EXPLOSIONS_ALL
1404 --pointed by session_id in table BOM_ODI_WS_REVISIONS after all bom explosions have been executed
1405 --for all end-items with valid publish privilege in table BOM_ODI_WS_ENTITIES.
1406 --If an item (row) is found not to have the privilege, it is deleted from the table.
1407 /*PROCEDURE check_component_security(p_session_id IN NUMBER,
1408 p_odi_session_id IN NUMBER,
1409 p_priv_check IN VARCHAR2,
1410 --p_group_id IN NUMBER,
1411 x_return_status OUT NOCOPY VARCHAR2
1412 )
1413 IS
1414
1415 l_sec_predicate VARCHAR2(32767);
1416 l_dynamic_update_sql VARCHAR2(32767);
1417 l_dynamic_sql VARCHAR2(32767);
1418 l_item_id NUMBER;
1419 l_org_id NUMBER;
1420 l_rowid ROWID;
1421
1422 l_mode VARCHAR2(10);
1423 l_batch_id NUMBER;
1424 l_batch_ent_obj_id NUMBER;
1425 l_user_name VARCHAR2(100);
1426 l_structure_name VARCHAR2(100);
1427 p_index number;
1428 l_seq_number NUMBER;
1429 l_group_id NUMBER;
1430
1431 TYPE DYNAMIC_CUR IS REF CURSOR;
1432 v_dynamic_cursor DYNAMIC_CUR;
1433
1434 BEGIN
1435
1436 --dbms_output.put_line(' Starting of check_component_security ');
1437
1438 --delete, for debugging only
1439 INSERT INTO emt_temp (Session_id, message)
1440 values (p_session_id, ' Starting of Check_security ');
1441
1442
1443 --obtaining security predicate based on FND_SECURITY initialization
1444 --dbms_output.put_line(' calling EGO_DATA_SECURITY.get_security_predicat ');
1445 EGO_DATA_SECURITY.get_security_predicate
1446 (p_api_version => 1.0
1447 ,p_function => p_priv_check
1448 ,p_object_name => 'EGO_ITEM'
1449 ,p_user_name => 'HZ_PARTY:'||TO_CHAR(FND_GLOBAL.PARTY_ID)
1450 ,p_statement_type => 'EXISTS'
1451 ,p_pk1_alias => 'e.COMPONENT_ITEM_ID'
1452 ,p_pk2_alias => 'e.ORGANIZATION_ID'
1453 ,p_pk3_alias => NULL
1454 ,p_pk4_alias => NULL
1455 ,p_pk5_alias => NULL
1456 ,x_predicate => l_sec_predicate
1457 ,x_return_status => x_return_status );
1458
1459 --dbms_output.put_line( ' Before If T, F : x_return_status - '|| x_return_status);
1460
1461 --remove
1462 INSERT INTO emt_temp (Session_id, message)
1463 values (p_session_id, ' x_return_status: ' || x_return_status);
1464 INSERT INTO emt_temp (Session_id, message)
1465 values (p_session_id, ' l_sec_predicate: ' || l_sec_predicate);
1466
1467
1468
1469 IF x_return_status IN ('T','F') THEN
1470
1471 IF l_sec_predicate IS NOT NULL THEN
1472
1473 BEGIN
1474
1475 --selecting all components that do not have the publish privilege from table
1476 --BOM_EXPLOSIONS_ALL and joining with table BOM_ODI_WS_REVISIONS to update PUBLISH_FLAG
1477 l_dynamic_sql := ' select i.row_id, e.COMPONENT_ITEM_ID, e.ORGANIZATION_ID, i.sequence_number, e.group_id ' ||
1478 ' from bom_explosions_all e, bom_odi_ws_revisions i ' ||
1479 ' where i.session_id = :1 ' ||
1480 'and e.rowid = i.row_id' ||
1481 ' AND NOT ' || l_sec_predicate;
1482
1483 --for debugging purposes only
1484 INSERT INTO emt_temp (Session_id, message)
1485 values (p_session_id, ' Inside check_component_privilege: ');
1486 INSERT INTO emt_temp (Session_id, message)
1487 values (p_session_id, ' l_dynamic_sql: ' || l_dynamic_sql);
1488
1489
1490
1491 --Looping throught all components with no publish privilege to generate the error
1492 --messages
1493 OPEN v_dynamic_cursor FOR l_dynamic_sql
1494 USING p_session_id;
1495 LOOP
1496
1497 FETCH v_dynamic_cursor INTO l_rowid, l_item_id , l_org_id, l_seq_number, l_group_id;
1498 EXIT WHEN v_dynamic_cursor%NOTFOUND;
1499
1500 --dbms_output.put_line(' In the loop Insering ... ');
1501
1502 --for debugging purposes only
1503 INSERT INTO emt_temp (Session_id, message)
1504 values (p_session_id, ' Looping to generate error info: ');
1505 INSERT INTO emt_temp (Session_id, message)
1506 values (p_session_id, ' l_rowid: ' || l_rowid);
1507 INSERT INTO emt_temp (Session_id, message)
1508 values (p_session_id, ' l_item_id: ' || l_item_id);
1509 INSERT INTO emt_temp (Session_id, message)
1510 values (p_session_id, ' l_org_id: ' || l_org_id);
1511
1512 --TODO: Replace this code with a proper error generation mechanim
1513 --for components
1514 IF TRUE THEN
1515
1516 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
1517 p_odi_session_id => p_odi_session_id,
1518 p_input_id => l_seq_number,
1519 p_err_code => 'EGO_NO_PUBLISH_PRIV',
1520 p_err_message => 'User does not have the publilsh privilege on few components of the structure for the item');
1521
1522 ELSE
1523 NULL;
1524 --generate_component_error(p_session_id IN NUMBER)
1525 END IF;
1526 --TODO: end
1527
1528
1529 --Now that the error messages have been generated,
1530 --set the flag PUBLISH_FLAG to 'N' in table table bom_odi_ws_revisions
1531 --for ecomponents with no publish privilege to prevent their publication.
1532 l_dynamic_update_sql := ' update BOM_ODI_WS_REVISIONS s ' ||
1533 ' set PUBLISH_FLAG = ''N'' ' ||
1534 ' where s.session_id = :1 ' ||
1535 ' AND nvl(s.PUBLISH_FLAG, ''Y'') = ''Y'' ' ||
1536 ' AND s.row_id =:2';
1537
1538 INSERT INTO emt_temp (Session_id, message)
1539 values (p_session_id, ' l_dynamic_update_sql: ' || l_dynamic_update_sql);
1540
1541 --dbms_output.put_line(' Executing the l_dynamic_update_sql');
1542 EXECUTE IMMEDIATE l_dynamic_update_sql
1543 USING IN p_session_id, l_rowid;
1544
1545 END LOOP;
1546
1547 CLOSE v_dynamic_cursor;
1548 x_return_status := 'S';
1549 --dbms_output.put_line(' Doing Commit ');
1550 --COMMIT;
1551
1552 EXCEPTION
1553 WHEN OTHERS THEN
1554 --dbms_output.put_line('When others of check security Error :'|| SQLERRM);
1555 --ROLLBACK;
1556 x_return_status := 'E';
1557 RAISE;
1558
1559 IF (v_dynamic_cursor%ISOPEN) THEN
1560 CLOSE v_dynamic_cursor;
1561 END IF;
1562 END; -- end of BEGIN
1563
1564 ELSE
1565 x_return_status := 'S';
1566 END IF; -- end of l_sec_predicate IS NOT NULL
1567
1568 END IF;
1569
1570 END check_component_security;*/
1571
1572
1573 --Checks the specified security priviledge on all components stored in table BOM_EXPLOSIONS_ALL
1574 --pointed by session_id in table BOM_ODI_WS_REVISIONS after all bom explosions have been executed
1575 --for all end-items with valid publish privilege in table BOM_ODI_WS_ENTITIES.
1576 --If an item (row) is found not to have the privilege, it is deleted from the table.
1577 PROCEDURE check_component_security(p_session_id IN NUMBER,
1578 p_odi_session_id IN NUMBER,
1579 p_priv_check IN VARCHAR2,
1580 p_group_id IN NUMBER,
1581 p_input_identifier IN NUMBER,
1582 p_inv_item_id IN NUMBER,
1583 p_org_id IN NUMBER,
1584 p_rev_id IN NUMBER,
1585 x_return_status OUT NOCOPY VARCHAR2
1586 )
1587 IS
1588
1589 l_sec_predicate VARCHAR2(32767);
1590 l_dynamic_sql VARCHAR2(32767);
1591 l_dynamic_update_sql VARCHAR2(32767);
1592
1593 l_mode VARCHAR2(10);
1594 l_batch_id NUMBER;
1595 l_batch_ent_obj_id NUMBER;
1596 l_user_name VARCHAR2(100);
1597 l_structure_name VARCHAR2(100);
1598 p_index number;
1599 l_group_id NUMBER;
1600 l_count NUMBER;
1601
1602
1603 BEGIN
1604
1605 --dbms_output.put_line(' Starting of check_component_security ');
1606
1607 --delete, for debugging only
1608 /*INSERT INTO emt_temp (Session_id, message)
1609 values (p_session_id, ' Starting of Check_Component_security ');
1610 */
1611 --obtaining security predicate based on FND_SECURITY initialization
1612 --dbms_output.put_line(' calling EGO_DATA_SECURITY.get_security_predicate ');
1613 EGO_DATA_SECURITY.get_security_predicate
1614 (p_api_version => 1.0
1615 ,p_function => p_priv_check
1616 ,p_object_name => 'EGO_ITEM'
1617 ,p_user_name => 'HZ_PARTY:'||TO_CHAR(FND_GLOBAL.PARTY_ID)
1618 ,p_statement_type => 'EXISTS'
1619 ,p_pk1_alias => 'e.COMPONENT_ITEM_ID'
1620 ,p_pk2_alias => 'e.ORGANIZATION_ID'
1621 ,p_pk3_alias => NULL
1622 ,p_pk4_alias => NULL
1623 ,p_pk5_alias => NULL
1624 ,x_predicate => l_sec_predicate
1625 ,x_return_status => x_return_status );
1626
1627 --dbms_output.put_line( ' Before If T, F : x_return_status - '|| x_return_status);
1628
1629 --remove
1630 /*INSERT INTO emt_temp (Session_id, message)
1631 values (p_session_id, ' x_return_status: ' || x_return_status);
1632 INSERT INTO emt_temp (Session_id, message)
1633 values (p_session_id, ' l_sec_predicate: ' || l_sec_predicate);
1634 */
1635
1636
1637 IF x_return_status IN ('T','F') THEN
1638
1639 IF l_sec_predicate IS NOT NULL THEN
1640
1641 BEGIN
1642
1643 --selecting all components that do not have the publish privilege from table
1644 --BOM_EXPLOSIONS_ALL
1645 /*l_dynamic_sql := ' select e.COMPONENT_ITEM_ID, e.ORGANIZATION_ID, e.group_id ' ||
1646 ' from bom_explosions_all e ' ||
1647 ' where e.group_id = :1 ' ||
1648 ' AND NOT ' || l_sec_predicate;*/
1649
1650 l_dynamic_sql := ' select count(*) ' ||
1651 ' from bom_explosions_all e ' ||
1652 ' where e.group_id = :1 ' ||
1653 ' AND NOT ' || l_sec_predicate;
1654
1655
1656 --dbms_output.put_line(' Executing the l_dynamic_sql');
1657 EXECUTE IMMEDIATE l_dynamic_sql
1658 INTO l_count
1659 USING IN p_group_id;
1660
1661 --if the count is different from zero, it means at least one component does not have
1662 --the publish privilege.
1663 IF l_count > 0 THEN
1664
1665 --dbms_output.PUT_LINE('At least one component has no publish privilege: ');
1666
1667 /*INSERT INTO emt_temp (Session_id, message)
1668 values (p_session_id, 'components without publish privilege: ' || l_count);
1669 */
1670 EGO_ODI_PUB.Log_Error(p_session_id => p_session_id,
1671 p_odi_session_id => p_odi_session_id,
1672 p_input_id => p_input_identifier,
1673 p_err_code => 'EGO_NO_PUBLISH_PRIV',
1674 p_err_message => 'User does not have the publilsh privilege on few components of the structure for the item');
1675
1676 --UPDATE END-ITEM WITH PUBLISH_FLAG = 'N' TO PREVENT ITS PUBLICATION
1677 l_dynamic_update_sql := ' update BOM_ODI_WS_ENTITIES i ' ||
1678 ' set PUBLISH_FLAG = ''N'' ' ||
1679 ' where i.session_id = :1 ' ||
1680 ' and i.odi_session_id = :2 ' ||
1681 ' and i.item_id = :3 ' ||
1682 ' and i.item_org_id = :4 ' ||
1683 ' and i.item_rev = :5 ' ||
1684 ' AND nvl(i.PUBLISH_FLAG, ''Y'') = ''Y'' ';
1685
1686 --dbms_output.put_line(' Executing the l_dynamic_update_sql');
1687 EXECUTE IMMEDIATE l_dynamic_update_sql
1688 USING IN p_session_id, p_odi_session_id, p_inv_item_id, p_org_id, p_rev_id;
1689
1690
1691 END IF;
1692
1693 --for debugging purposes only
1694 /*INSERT INTO emt_temp (Session_id, message)
1695 values (p_session_id, ' Inside check_component_privilege: ');
1696 INSERT INTO emt_temp (Session_id, message)
1697 values (p_session_id, ' l_dynamic_sql: ' || l_dynamic_sql);
1698 */
1699 x_return_status := 'S';
1700 --dbms_output.put_line(' Doing Commit ');
1701 --COMMIT;
1702
1703 EXCEPTION
1704 WHEN OTHERS THEN
1705 --dbms_output.put_line('When others of check security Error :'|| SQLERRM);
1706 x_return_status := 'E';
1707 RAISE;
1708
1709 END; -- end of BEGIN
1710
1711 ELSE
1712 x_return_status := 'S';
1713 END IF; -- end of l_sec_predicate IS NOT NULL
1714
1715 END IF;
1716
1717 END check_component_security;
1718
1719
1720 --returns the mode in which the getItemStructure web service is being
1721 --invoked. The function returns a string describing the invokation
1722 --mode as follows:
1723 --
1724 -- 'HMDM' - The web service is being invoked by H-MDM compatible code
1725 -- 'BATCH' - The web service is being invoked by PIM for TELCO publication
1726 -- code triggered by publication framework GUI
1727 -- 'LIST' - The web service is being invoked by PIM for TELCO publication
1728 -- code and the parameters are passed as list of items
1729 -- 'NONE' - If none of the above modes were found in the payload
1730 FUNCTION Invocation_Mode_Structure(p_session_id IN NUMBER) RETURN VARCHAR2 IS
1731
1732 x_mode VARCHAR2(10) := 'NONE';
1733 l_tmp_val VARCHAR2(100);
1734 l_exists NUMBER;
1735 l_exists1 NUMBER;
1736
1737 BEGIN
1738
1739 --FIRST CHECK FOR SUBROUTINE MODE
1740 select count(*)
1741 into l_exists
1742 from EGO_PUB_WS_CONFIG
1743 where session_id = p_session_id
1744 and web_service_name = 'GET_ITEM_STRUCTURE'
1745 and parameter_name = 'MODE'
1746 and char_value = 'SUBROUTINE';
1747
1748 IF l_exists=1 THEN
1749 RETURN 'SUBROUTINE';
1750 END IF;
1751
1752
1753 --START BATCH MODE CHECK
1754 --if batch_id is populated, we are in 'BATCH' mode
1755 select existsNode(xmlcontent, '/structureQueryParameters/BatchStructureQueryParameters/BatchId')
1756 into l_exists
1757 from EGO_PUB_WS_PARAMS
1758 where session_id = p_session_id;
1759
1760 IF l_exists=1 THEN
1761
1762 select extractValue(xmlcontent, '/structureQueryParameters/BatchStructureQueryParameters/BatchId')
1763 into l_tmp_val
1764 from EGO_PUB_WS_PARAMS
1765 where session_id = p_session_id;
1766
1767 IF l_tmp_val <> '?' THEN
1768 RETURN 'BATCH';
1769 END IF;
1770
1771 END IF;
1772
1773
1774 --START HMDM MODE CHECK
1775 --if organization Id or organization name were populated, we are in 'HMDM' mode
1776 select existsNode(xmlcontent, '/structureQueryParameters/OrganizationId')
1777 into l_exists
1778 from EGO_PUB_WS_PARAMS
1779 where session_id = p_session_id;
1780
1781 select existsNode(xmlcontent, '/structureQueryParameters/OrganizationCode')
1782 into l_exists1
1783 from EGO_PUB_WS_PARAMS
1784 where session_id = p_session_id;
1785
1786
1787 IF l_exists=1 OR l_exists1=1 THEN
1788
1789 select extractValue(xmlcontent, '/structureQueryParameters/OrganizationId')
1790 into l_tmp_val
1791 from EGO_PUB_WS_PARAMS
1792 where session_id = p_session_id;
1793
1794 IF l_tmp_val <> '?' THEN
1795 RETURN 'HMDM';
1796 END IF;
1797
1798 select extractValue(xmlcontent, '/structureQueryParameters/OrganizationCode')
1799 into l_tmp_val
1800 from EGO_PUB_WS_PARAMS
1801 where session_id = p_session_id;
1802
1803 IF l_tmp_val <> '?' THEN
1804 RETURN 'HMDM';
1805 END IF;
1806
1807 END IF;
1808
1809
1810 --START LIST MODE CHECK
1811 --if node ListOfItemStructureQueryParams occurs more than once,
1812 --we are in 'LIST' MODE
1813 select count(*)
1814 into l_exists
1815 from EGO_PUB_WS_PARAMS
1816 where session_id = p_session_id
1817 and existsNode(xmlcontent, '/structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/OrganizationId')=1;
1818
1819 select count(*)
1820 into l_exists1
1821 from EGO_PUB_WS_PARAMS
1822 where session_id = p_session_id
1823 and existsNode(xmlcontent, '/structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/OrganizationCode')=1;
1824
1825
1826 --TODO: Change this to a check using the same XPATH expression as statement above
1827 --if there is one occurrence, check structurename node for meaningful value
1828 IF l_exists>=1 OR l_exists1>=1 THEN
1829
1830 /*select extractValue(xmlcontent, '/structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/OrganizationId')
1831 into l_tmp_val
1832 from EGO_PUB_WS_PARAMS
1833 where session_id = p_session_id;
1834
1835 IF l_tmp_val <> '?' THEN
1836 RETURN 'LIST';
1837
1838 END IF;*/
1839 RETURN 'LIST';
1840
1841 END IF;
1842
1843 --If mode could not be determined, error out
1844 --IF x_mode = 'NONE' THEN
1845 raise_application_error(-20000, 'Invokation mode (e.g. BATCH, LIST or HMDM) could not be determined ');
1846 --END IF;
1847
1848 RETURN x_mode;
1849
1850 END Invocation_Mode_Structure;
1851
1852
1853
1854 --Inserts language options in EGO_PUB_WS_CONFIG table
1855 PROCEDURE Config_Languages(p_session_id IN NUMBER,
1856 p_odi_session_id IN NUMBER,
1857 p_lang_search_str IN VARCHAR2,
1858 p_web_service_name VARCHAR2 DEFAULT NULL)
1859 IS
1860
1861 l_lang_code_tab dbms_sql.varchar2_table;
1862 l_lang_name_tab dbms_sql.varchar2_table;
1863
1864 l_langcode_xpath VARCHAR2(200):=p_lang_search_str||'/LanguageCode';
1865 l_langname_xpath VARCHAR2(200):=p_lang_search_str||'/LanguageName';
1866 l_codes_provided VARCHAR(3):='Y';
1867 l_count NUMBER;
1868 l_is_valid BOOLEAN;
1869 l_valid_count NUMBER := 0;
1870 l_temp_code VARCHAR(200);
1871 l_temp_name VARCHAR(200);
1872
1873 BEGIN
1874
1875 --extracting language Codes
1876 SELECT extractValue(lang_code, '/LanguageCode')
1877 BULK COLLECT INTO l_lang_code_tab
1878 FROM (SELECT Value(langcode) lang_code
1879 FROM EGO_PUB_WS_PARAMS i,
1880 TABLE(XMLSequence(
1881 extract(i.xmlcontent, l_langcode_xpath) )) langcode
1882 WHERE session_id=p_session_id
1883 );
1884
1885 --extracting language names
1886 SELECT extractValue(lang_code, '/LanguageName')
1887 BULK COLLECT INTO l_lang_name_tab
1888 FROM (SELECT Value(langcode) lang_code
1889 FROM EGO_PUB_WS_PARAMS i,
1890 TABLE(XMLSequence(
1891 extract(i.xmlcontent, l_langname_xpath) )) langcode
1892 WHERE session_id=p_session_id
1893 );
1894
1895
1896 l_count := l_lang_code_tab.Count;
1897 IF l_count < l_lang_name_tab.Count THEN
1898 l_count := l_lang_name_tab.Count;
1899 END IF;
1900
1901 --check if all language codes provided are different from null
1902 IF l_count > 0 THEN
1903
1904 FOR i IN 1..l_count
1905 LOOP
1906
1907 IF l_lang_code_tab.Count >= i THEN
1908 l_temp_code := l_lang_code_tab(i);
1909 ELSE
1910 l_temp_code := NULL;
1911 END IF;
1912 IF l_lang_name_tab.Count >= i THEN
1913 l_temp_name := l_lang_name_tab(i);
1914 ELSE
1915 l_temp_name := NULL;
1916 END IF;
1917
1918 /*INSERT INTO emt_temp (Session_id, message)
1919 values (p_session_id, ' l_temp_code: ' || l_temp_code);
1920 INSERT INTO emt_temp (Session_id, message)
1921 values (p_session_id, ' l_lang_name_tab(i): ' || l_lang_name_tab(i));
1922 INSERT INTO emt_temp (Session_id, message)
1923 values (p_session_id, ' l_temp_name: ' || l_temp_name);
1924 */
1925
1926 --validating language code or language name
1927 l_is_valid := Validate_Language_Info(p_session_id => p_session_id,
1928 p_odi_session_id => p_odi_session_id,
1929 p_language_code => l_temp_code,
1930 p_language_name => l_temp_name);
1931
1932 IF l_is_valid = TRUE THEN
1933 l_valid_count := l_valid_count + 1;
1934 l_lang_code_tab(i) := l_temp_code;
1935 ELSE
1936 l_lang_code_tab(i) := NULL;
1937 --TODO: Generate warning message for non-valid language code/name
1938 --in l_temp_code or l_temp_name
1939 END IF;
1940
1941 END LOOP;
1942
1943 --if no valid language codes or names were found, assume none were passed
1944 IF l_valid_count = 0 THEN
1945 l_codes_provided := 'N';
1946 END IF;
1947
1948 ELSE
1949
1950 l_codes_provided := 'N';
1951
1952 END IF;
1953
1954 --Insert record into config table for parameter language
1955 --IF l_lang_code_tab.Count> 0 THEN
1956 IF l_codes_provided = 'Y' THEN
1957
1958 FOR i IN 1..l_count
1959 LOOP
1960
1961 IF l_lang_code_tab(i) IS NOT NULL THEN
1962 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,
1963 odi_session_id,
1964 Parameter_Name,
1965 Data_Type,
1966 Date_Value,
1967 Char_value,
1968 Numeric_Value,
1969 creation_date,
1970 created_by,
1971 web_service_name)
1972 VALUES (p_session_id,
1973 p_odi_session_id,
1974 'LANGUAGE_CODE',
1975 2,
1976 NULL,
1977 l_lang_code_tab(i),
1978 NULL,
1979 SYSDATE,
1980 G_CURRENT_USER_ID,
1981 p_web_service_name);
1982 END IF;
1983 END LOOP;
1984
1985 ELSE
1986
1987 FOR i IN (SELECT language_code FROM FND_LANGUAGES WHERE INSTALLED_FLAG IN ('I','B') ) LOOP
1988 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,
1989 odi_session_id,
1990 Parameter_Name,
1991 Data_Type,
1992 Date_Value,
1993 Char_value,
1994 Numeric_Value,
1995 creation_date,
1996 created_by,
1997 web_service_name)
1998 VALUES (p_session_id,
1999 p_odi_session_id,
2000 'LANGUAGE_CODE',
2001 2,
2002 NULL,
2003 i.language_code,
2004 NULL,
2005 SYSDATE,
2006 G_CURRENT_USER_ID,
2007 p_web_service_name);
2008 END LOOP;
2009
2010 END IF;
2011
2012
2013 END Config_Languages;
2014
2015
2016 --Inserts language options in EGO_PUB_WS_CONFIG table
2017 PROCEDURE Config_UDAs(p_session_id IN NUMBER,
2018 p_odi_session_id IN NUMBER,
2019 p_parameter_name IN VARCHAR2,
2020 p_uda_search_str IN VARCHAR2,
2021 p_ag_id_node_tag IN VARCHAR2,
2022 p_ag_name_node_tag IN VARCHAR2,
2023 p_web_service_name VARCHAR2 DEFAULT NULL)
2024 IS
2025
2026 x_ag_name VARCHAR2(100);
2027 l_valid_ag BOOLEAN;
2028
2029 l_uda_attr_id_tab dbms_sql.varchar2_table;
2030 l_uda_attr_name_tab dbms_sql.varchar2_table;
2031 l_uda_id_xpath VARCHAR2(1000):=p_uda_search_str || '/' || p_ag_id_node_tag;
2032 l_uda_name_xpath VARCHAR2(1000):=p_uda_search_str || '/' || p_ag_name_node_tag;
2033
2034
2035 BEGIN
2036
2037
2038 --Dbms_Output.put_line('Processing UDA Configurations');
2039 --remove, debugging purposes only
2040 /*INSERT INTO emt_temp (Session_id, message)
2041 values (p_session_id, 'Entering Config_UDAs ' || p_parameter_name);
2042 */
2043
2044 --reading list of attribute group ids
2045 SELECT extractValue(uda_ag, p_ag_id_node_tag)
2046 BULK COLLECT INTO l_uda_attr_id_tab
2047 FROM (SELECT Value(udaag) uda_ag
2048 FROM EGO_PUB_WS_PARAMS i,
2049 TABLE(XMLSequence(
2050 extract(i.xmlcontent, l_uda_id_xpath) )) udaag
2051 WHERE session_id=p_session_id
2052 );
2053
2054 --reading list of attribute group names
2055 SELECT extractValue(uda_ag, p_ag_name_node_tag)
2056 BULK COLLECT INTO l_uda_attr_name_tab
2057 FROM (SELECT Value(udaag) uda_ag
2058 FROM EGO_PUB_WS_PARAMS i,
2059 TABLE(XMLSequence(
2060 extract(i.xmlcontent, l_uda_name_xpath) )) udaag
2061 WHERE session_id=p_session_id
2062 );
2063
2064 --Dbms_Output.put_line('Before If of UDA Configurations :'||l_uda_attr_id_tab.Count );
2065 --Dbms_Output.put_line('Before If of UDA Configurations :'||l_uda_attr_name_tab.Count );
2066
2067 --If attribute ids where provided, generate names
2068 --and generate the names
2069 IF l_uda_attr_id_tab.Count > 0 THEN
2070
2071
2072
2073 --for all attribute Ids read
2074 FOR i IN 1..l_uda_attr_id_tab.Count
2075 LOOP
2076
2077 /*INSERT INTO emt_temp (Session_id, message)
2078 values (p_session_id, 'Inside attr_id loop l_uda_attr_id_tab(i) : ' || l_uda_attr_id_tab(i));
2079 */
2080
2081
2082
2083 --TODO: Validate attribute ID and obtain name
2084 l_valid_ag := Validate_Attribute_Group(p_session_id,
2085 p_odi_session_id,
2086 l_uda_attr_id_tab(i),
2087 NULL,
2088 x_ag_name);
2089
2090 --debugging statement remove
2091 /*INSERT INTO emt_temp (Session_id, message)
2092 values (p_session_id, 'x_ag_name: ' || x_ag_name);
2093
2094 IF l_valid_ag = TRUE THEN
2095 INSERT INTO emt_temp (Session_id, message)
2096 values (p_session_id, 'validation TRUE');
2097
2098 ELSE
2099 INSERT INTO emt_temp (Session_id, message)
2100 values (p_session_id, 'validation FALSE');
2101
2102 END IF;*/
2103
2104
2105 IF l_valid_ag = TRUE THEN
2106
2107 --Dbms_Output.put_line('Inserting');
2108 --insert attribute name in configuration table
2109 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2110 odi_session_id,
2111 Parameter_Name,
2112 Data_Type,
2113 Date_Value,
2114 Char_value,
2115 Numeric_Value,
2116 creation_date,
2117 created_by,
2118 web_service_name)
2119 VALUES (p_session_id,
2120 p_odi_session_id,
2121 p_parameter_name,
2122 2,
2123 NULL,
2124 x_ag_name,
2125 NULL,SYSDATE,
2126 G_CURRENT_USER_ID,
2127 p_web_service_name);
2128 ELSE
2129 --TODO: Generate warning here
2130 --raise_application_error(-20101, 'Warning: Invalid Attribute Group');
2131 NULL;
2132 END IF;
2133
2134 END LOOP;
2135
2136 END IF;
2137
2138
2139 --If attribute names were provided and no IDs
2140 --validate names and insert into configuration table
2141 IF l_uda_attr_name_tab.Count > 0 THEN
2142
2143 --Dbms_Output.put_line('In the loop ');
2144
2145 --for all attribute names read
2146 FOR i IN 1..l_uda_attr_name_tab.Count
2147 LOOP
2148
2149 --TODO: Validate attribute name
2150 l_valid_ag := Validate_Attribute_Group(p_session_id,
2151 p_odi_session_id,
2152 NULL,
2153 l_uda_attr_name_tab(i),
2154 x_ag_name);
2155
2156 /*INSERT INTO emt_temp (Session_id, message)
2157 values (p_session_id, 'Inside attr_name loop l_uda_attr_name_tab(i) : ' || l_uda_attr_name_tab(i));
2158 */
2159
2160 --delete debugging
2161 /*IF l_valid_ag = TRUE THEN
2162 INSERT INTO emt_temp (Session_id, message)
2163 values (p_session_id, 'validation TRUE');
2164
2165 ELSE
2166 INSERT INTO emt_temp (Session_id, message)
2167 values (p_session_id, 'validation FALSE');
2168
2169 END IF;*/
2170
2171 IF l_valid_ag = TRUE THEN
2172
2173 --Dbms_Output.put_line('Inserting');
2174 --insert attribute name in configuration table
2175 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2176 odi_session_id,
2177 Parameter_Name,
2178 Data_Type,
2179 Date_Value,
2180 Char_value,
2181 Numeric_Value,
2182 creation_date,
2183 created_by,
2184 web_service_name)
2185 VALUES (p_session_id,
2186 p_odi_session_id,
2187 p_parameter_name,
2188 2,
2189 NULL,
2190 l_uda_attr_name_tab(i),
2191 NULL,SYSDATE,
2192 G_CURRENT_USER_ID,
2193 p_web_service_name);
2194 ELSE
2195 --TODO: Generate warning here
2196 NULL;
2197 END IF;
2198
2199 END LOOP;
2200
2201 END IF;
2202
2203
2204 EXCEPTION
2205 WHEN OTHERS THEN
2206 NULL;
2207 /* INSERT INTO emt_temp (Session_id, message)
2208 values (p_session_id, 'Handling exception at Config_UDA: ' || SQLERRM);
2209
2210 */
2211 --TODO: Handle errors here
2212 --Dbms_Output.put_line('Create_Config_Param Exception:- '||SQLERRM||' Code :- '||SQLCODE);
2213
2214 END Config_UDAs;
2215
2216
2217
2218
2219 --creates all configurability parameters and stores them in table
2220 --EGO_PUB_WS_CONFIG
2221 PROCEDURE Create_Params_Structure(p_session_id IN NUMBER,
2222 p_odi_session_id IN NUMBER)
2223 IS
2224
2225 l_mode VARCHAR2(10) :='BATCH';
2226 l_exists NUMBER;
2227 l_fnd_user_name VARCHAR2(100);
2228 l_responsibility_name VARCHAR2(100);
2229 l_responsibility_appl_name VARCHAR2(100);
2230 l_security_group_name VARCHAR2(100);
2231 l_retpayload VARCHAR2(10) :='Y';
2232 l_batch_id NUMBER;
2233 l_user_id NUMBER;
2234 l_responsibility_id NUMBER;
2235 l_application_id NUMBER;
2236
2237 l_config_option VARCHAR2(100);
2238 l_xml_node_xpath VARCHAR2(1000);
2239 l_parameter_name VARCHAR2(100);
2240
2241 --array to store XML path expressions to retrieve single-value params
2242 TYPE xpath_expr_array_type IS VARRAY(15) OF VARCHAR2(1000);
2243 l_xpath_expr_array xpath_expr_array_type;
2244
2245 --array to store single_value parameter names
2246 TYPE parameter_name_array_type IS VARRAY(15) OF VARCHAR2(1000);
2247 l_parameter_name_array parameter_name_array_type;
2248
2249
2250 BEGIN
2251
2252 --determine invokation mode for getItemStructure web service
2253 --and insert in parametes table
2254 l_mode := Invocation_Mode_Structure(p_session_id);
2255
2256 --if mode is SUBROUTINE, all parameters in table EGO_PUB_WS_CONFIG
2257 --have already been created by invoking ODI Scenario, so quit
2258 --procedure
2259 IF l_mode = 'SUBROUTINE' THEN
2260 RETURN;
2261 END IF;
2262
2263 --debugging statement remove
2264 /*INSERT INTO emt_temp (Session_id, message)
2265 values (p_session_id, 'invokation mode:' || l_mode);
2266 */
2267
2268 --inserting invokation mode as config parameter
2269 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2270 odi_session_id,
2271 Parameter_Name,
2272 Data_Type,
2273 Char_value,
2274 creation_date,
2275 created_by,
2276 web_service_name)
2277 VALUES (p_session_id,
2278 p_odi_session_id,
2279 'MODE',
2280 2,
2281 l_mode,
2282 sysdate,
2283 0,
2284 'GET_ITEM_STRUCTURE');
2285
2286
2287 /*TODO: See if this is required for chunking to work
2288 IF (l_retpayload='Y')
2289 THEN
2290 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
2291 VALUES (p_session_id,p_session_id,'return_payload',2,NULL,'TRUE',NULL,SYSDATE,G_CURRENT_USER_ID);
2292 ELSE
2293 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
2294 VALUES (p_session_id,p_session_id,'return_payload',2,NULL,'FALSE',NULL,SYSDATE,G_CURRENT_USER_ID);
2295 END IF;
2296 --End Chunking
2297 */
2298
2299
2300
2301 --
2302 --STEP ONE: RETRIEVE ALL SINGLE-VALUE CONFIGURATION PARAMETERS
2303 -- AND STORE THEM IN TABLE EGO_PUB_WS_CONFIG
2304 --
2305
2306 --initialize arrays of parameter names
2307 l_parameter_name_array := parameter_name_array_type('PUBLISH_REVISIONS',
2308 'PUBLISH_STRUCT_AGS',
2309 'PUBLISH_COMPONENTS',
2310 'PUBLISH_COMP_REF',
2311 'PUBLISH_COMP_SUBS',
2312 'PUBLISH_COMP_AGS',
2313 'LEVELS_TO_EXPLODE',
2314 'EXPLODE_OPTION',
2315 'EXPLODE_STD_BOM',
2316 'RETURN_PAYLOAD',
2317 'PUBLISH_COMP_OVR_AGS',
2318 'PUBLISH_COMP_EXCLUSIONS',
2319 'PUBLISH_VS_EXCLUSIONS'
2320 );
2321
2322 CASE
2323
2324 WHEN l_mode = 'BATCH' THEN
2325
2326 l_xpath_expr_array := xpath_expr_array_type('/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/StructureRevision',
2327 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/StructureHeaderAttributeGroups',
2328 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/StructureComponents',
2329 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/PublishStructureComponents/StructureReferenceDesignators',
2330 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/PublishStructureComponents/StructureSubstituteComponents',
2331 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/PublishStructureComponents/ComponentAttributeGroups',
2332 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/BomExploderParameters/LevelsToExplode',
2333 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/BomExploderParameters/ExplodeOption',
2334 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/BomExploderParameters/ExplodeStandard',
2335 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/ReturnPayload',
2336 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/PublishStructureComponents/ComponentUDAOverrides',
2337 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/PublishStructureComponents/ComponentExclusions',
2338 '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/PublishStructureComponents/ValueSetExclusions'
2339
2340 );
2341
2342
2343 WHEN l_mode = 'HMDM' THEN
2344
2345 l_xpath_expr_array := xpath_expr_array_type('/structureQueryParameters/PublishEntities/StructureRevision',
2346 '/structureQueryParameters/PublishEntities/StructureHeaderAttributeGroups',
2347 '/structureQueryParameters/PublishEntities/StructureComponents',
2348 '/structureQueryParameters/PublishEntities/PublishStructureComponents/StructureReferenceDesignators',
2349 '/structureQueryParameters/PublishEntities/PublishStructureComponents/StructureSubstituteComponents',
2350 '/structureQueryParameters/PublishEntities/PublishStructureComponents/ComponentAttributeGroups',
2351 '/structureQueryParameters/BomExploderParameters/LevelsToExplode',
2352 '/structureQueryParameters/BomExploderParameters/ExplodeOption',
2353 '/structureQueryParameters/BomExploderParameters/ExplodeStandard',
2354 '/structureQueryParameters/PublishEntities/ReturnPayload',
2355 '/structureQueryParameters/PublishEntities/PublishStructureComponents/ComponentUDAOverrides',
2356 '/structureQueryParameters/PublishEntities/PublishStructureComponents/ComponentExclusions',
2357 '/structureQueryParameters/PublishEntities/PublishStructureComponents/ValueSetExclusions'
2358 );
2359
2360
2361 WHEN l_mode = 'LIST' THEN
2362
2363 l_xpath_expr_array := xpath_expr_array_type('/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/StructureRevision',
2364 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/StructureHeaderAttributeGroups',
2365 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/StructureComponents',
2366 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/PublishStructureComponents/StructureReferenceDesignators',
2367 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/PublishStructureComponents/StructureSubstituteComponents',
2368 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/PublishStructureComponents/ComponentAttributeGroups',
2369 '/structureQueryParameters/ParametersForListOfItems/Configurability/BomExploderParameters/LevelsToExplode',
2370 '/structureQueryParameters/ParametersForListOfItems/Configurability/BomExploderParameters/ExplodeOption',
2371 '/structureQueryParameters/ParametersForListOfItems/Configurability/BomExploderParameters/ExplodeStandard',
2372 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/ReturnPayload',
2373 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/PublishStructureComponents/ComponentUDAOverrides',
2374 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/PublishStructureComponents/ComponentExclusions',
2375 '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/PublishStructureComponents/ValueSetExclusions'
2376
2377 );
2378
2379 --if no mode has been identified, error out
2380 ELSE
2381 raise_application_error(-20101, 'Invokation mode (e.g. BATCH, LIST, or HMDM) could not be determined');
2382
2383
2384 END CASE;
2385
2386
2387 --retrieve all single-value parameters of interest from XML
2388 --and store them in table EGO_PUB_WS_CONFIG
2389 FOR position IN 1..l_parameter_name_array.COUNT
2390 LOOP
2391
2392 l_config_option := upper(EGO_ODI_PUB.Get_ODI_Input_Parameter(p_session_id, l_xpath_expr_array(position)));
2393
2394 --if parameter is not provided, assume a default value of 'Y' (Yes)
2395 IF l_config_option IS NULL OR l_config_option = '?' THEN
2396
2397 CASE
2398 WHEN l_parameter_name_array(position) = 'LEVELS_TO_EXPLODE' THEN
2399 --Temporary workaround for bug 8768551. This line must
2400 --be changed to l_config_option := '60' once bug is fixed
2401 l_config_option := '60';
2402 WHEN l_parameter_name_array(position) = 'EXPLODE_OPTION' THEN
2403 l_config_option := '2';
2404 WHEN l_parameter_name_array(position) = 'EXPLODE_STD_BOM' THEN
2405 l_config_option := 'N';
2406 ELSE
2407 l_config_option := 'Y';
2408 END CASE;
2409
2410
2411 END IF;
2412
2413 IF l_config_option IS NOT NULL AND l_config_option <> '?' THEN
2414
2415 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2416 odi_session_id,
2417 Parameter_Name,
2418 Data_Type,
2419 Char_value,
2420 creation_date,
2421 created_by,
2422 web_service_name)
2423 VALUES (p_session_id,
2424 p_odi_session_id,
2425 l_parameter_name_array(position),
2426 2,
2427 l_config_option,
2428 sysdate,
2429 0,
2430 'GET_ITEM_STRUCTURE');
2431
2432 END IF;
2433
2434 END LOOP;
2435
2436
2437
2438 --RETRIEVING FND_USER_NAME, RESPONSIBILITY_NAME, RESPONSIBILITY_APPL_NAME, and
2439 --SECURITY_GROUP_NAME depending on input mode
2440
2441 --if mode is LIST or H-MDM, get authentication information from
2442 --user calling the web service. This info is stored in table
2443 --EGO_PUB_WS_PARAMS and can be recovered with the session_id
2444 IF l_mode <> 'BATCH' THEN
2445
2446 --retrieving and storing FND_USER_NAME
2447 select fnd_user_name
2448 into l_fnd_user_name
2449 from EGO_PUB_WS_PARAMS
2450 where session_id = p_session_id;
2451
2452 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2453 odi_session_id,
2454 Parameter_Name,
2455 Data_Type,
2456 Char_value,
2457 creation_date,
2458 created_by,
2459 web_service_name)
2460 VALUES (p_session_id,
2461 p_odi_session_id,
2462 'FND_USER_NAME',
2463 2,
2464 l_fnd_user_name,
2465 sysdate,
2466 0,
2467 'GET_ITEM_STRUCTURE');
2468
2469 --retrieving and storing RESPONSIBILITY_NAME
2470 select responsibility_name
2471 into l_responsibility_name
2472 from EGO_PUB_WS_PARAMS
2473 where session_id = p_session_id;
2474
2475 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2476 odi_session_id,
2477 Parameter_Name,
2478 Data_Type,
2479 Char_value,
2480 creation_date,
2481 created_by,
2482 web_service_name)
2483 VALUES (p_session_id,
2484 p_odi_session_id,
2485 'RESPONSIBILITY_NAME',
2486 2,
2487 l_responsibility_name,
2488 sysdate,
2489 0,
2490 'GET_ITEM_STRUCTURE');
2491
2492
2493 --retrieving and storing RESPONSIBILITY_APPL_NAME
2494 select responsibility_appl_name
2495 into l_responsibility_appl_name
2496 from EGO_PUB_WS_PARAMS
2497 where session_id = p_session_id;
2498
2499 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2500 odi_session_id,
2501 Parameter_Name,
2502 Data_Type,
2503 Char_value,
2504 creation_date,
2505 created_by,
2506 web_service_name)
2507 VALUES (p_session_id,
2508 p_odi_session_id,
2509 'RESPONSIBILITY_APPL_NAME',
2510 2,
2511 l_responsibility_appl_name,
2512 sysdate,
2513 0,
2514 'GET_ITEM_STRUCTURE');
2515
2516
2517 --retrieving and storing SECURITY_GROUP_NAME
2518 select security_group_name
2519 into l_security_group_name
2520 from EGO_PUB_WS_PARAMS
2521 where session_id = p_session_id;
2522
2523 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2524 odi_session_id,
2525 Parameter_Name,
2526 Data_Type,
2527 Char_value,
2528 creation_date,
2529 created_by,
2530 web_service_name)
2531 VALUES (p_session_id,
2532 p_odi_session_id,
2533 'SECURITY_GROUP_NAME',
2534 2,
2535 l_security_group_name,
2536 sysdate,
2537 0,
2538 'GET_ITEM_STRUCTURE');
2539
2540 --IF MODE IS BATCH, retrieve authentication data from Publication Framework tables
2541 --This means the authentication information used corresponds to user who created the
2542 --publication batch throught the publication UI.
2543 ELSE
2544
2545
2546 --retrieving batchId from input XML
2547 select to_number(extractValue(xmlcontent, '/structureQueryParameters/BatchStructureQueryParameters/BatchId'))
2548 into l_batch_id
2549 from EGO_PUB_WS_PARAMS
2550 where session_id = p_session_id;
2551
2552 --retrieving user_id and responsibility
2553 select created_by, responsibility_id
2554 into l_user_id, l_responsibility_id
2555 from EGO_PUB_BAT_HDR_B
2556 where batch_id = l_batch_id;
2557
2558 --retrieving user name
2559 select USER_NAME
2560 into l_fnd_user_name
2561 from fnd_user
2562 where user_id = l_user_id;
2563
2564 --inserting user name
2565 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2566 odi_session_id,
2567 Parameter_Name,
2568 Data_Type,
2569 Char_value,
2570 creation_date,
2571 created_by,
2572 web_service_name)
2573 VALUES (p_session_id,
2574 p_odi_session_id,
2575 'FND_USER_NAME',
2576 2,
2577 l_fnd_user_name,
2578 sysdate,
2579 0,
2580 'GET_ITEM_STRUCTURE');
2581
2582 --retrieving responsibility name
2583 select responsibility_key
2584 into l_responsibility_name
2585 from FND_RESPONSIBILITY
2586 where responsibility_id = l_responsibility_id;
2587
2588 --inserting responsibility name
2589 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2590 odi_session_id,
2591 Parameter_Name,
2592 Data_Type,
2593 Char_value,
2594 creation_date,
2595 created_by,
2596 web_service_name)
2597 VALUES (p_session_id,
2598 p_odi_session_id,
2599 'RESPONSIBILITY_NAME',
2600 2,
2601 l_responsibility_name,
2602 sysdate,
2603 0,
2604 'GET_ITEM_STRUCTURE');
2605
2606 --retrieving application_id
2607 Select application_id
2608 into l_application_id
2609 from FND_RESPONSIBILITY
2610 where responsibility_id = l_responsibility_id;
2611
2612 --retrieving responsibility_appl_name
2613 select APPLICATION_SHORT_NAME
2614 into l_responsibility_appl_name
2615 from FND_APPLICATION
2616 where application_id = l_application_id;
2617
2618 --inserting responsibility_appl_name
2619 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2620 odi_session_id,
2621 Parameter_Name,
2622 Data_Type,
2623 Char_value,
2624 creation_date,
2625 created_by,
2626 web_service_name)
2627 VALUES (p_session_id,
2628 p_odi_session_id,
2629 'RESPONSIBILITY_APPL_NAME',
2630 2,
2631 l_responsibility_appl_name,
2632 sysdate,
2633 0,
2634 'GET_ITEM_STRUCTURE');
2635
2636 --inserting security_group_name as NULL
2637 l_security_group_name := NULL;
2638 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
2639 odi_session_id,
2640 Parameter_Name,
2641 Data_Type,
2642 Char_value,
2643 creation_date,
2644 created_by,
2645 web_service_name)
2646 VALUES (p_session_id,
2647 p_odi_session_id,
2648 'SECURITY_GROUP_NAME',
2649 2,
2650 l_security_group_name,
2651 sysdate,
2652 0,
2653 'GET_ITEM_STRUCTURE');
2654 END IF;
2655
2656
2657
2658 --In batch mode, parameter LEVELS_TO_EXPLODE provided un publication UI
2659 --overrides parameter passed during invokation of web service
2660 --thus, the parameter is updated with the value from publication fwk tables
2661 IF l_mode = 'BATCH' THEN
2662
2663 --retrieving batch_id
2664 select to_number(extractValue(xmlcontent, '/structureQueryParameters/BatchStructureQueryParameters/BatchId'))
2665 into l_batch_id
2666 from EGO_PUB_WS_PARAMS
2667 where session_id = p_session_id;
2668
2669 --retrieving levels_to_explode
2670 select to_char(numeric_value)
2671 into l_config_option
2672 from Ego_Pub_Bat_Params_B
2673 where type_id = l_batch_id
2674 and parameter_name = 'LEVELS_TO_EXPLODE';
2675
2676 --updating value of config parameter
2677 UPDATE EGO_PUB_WS_CONFIG
2678 SET Char_value = l_config_option
2679 where Parameter_Name = 'LEVELS_TO_EXPLODE'
2680 and web_service_name = 'GET_ITEM_STRUCTURE'
2681 and session_id = p_session_id
2682 and odi_session_id = p_odi_session_id;
2683
2684 --retrieving EXPLODE_STD_BOM
2685 select char_value
2686 into l_config_option
2687 from Ego_Pub_Bat_Params_B
2688 where type_id = l_batch_id
2689 and parameter_name = 'EXPLODE_STD_BOM';
2690
2691 --updating value of config parameter
2692 UPDATE EGO_PUB_WS_CONFIG
2693 SET Char_value = l_config_option
2694 where Parameter_Name = 'EXPLODE_STD_BOM'
2695 and web_service_name = 'GET_ITEM_STRUCTURE'
2696 and session_id = p_session_id
2697 and odi_session_id = p_odi_session_id;
2698 -- Start bug 12932318 (FP of bug 12908261)
2699 -- Read parameter EXPLODE_OPTION if present.
2700 -- otherwise, defaulting to 2 or CURRENT explosion type.
2701
2702 --Check if parameter EXPLODE_OPTION exists
2703 select to_char(count(*))
2704 into l_config_option
2705 from Ego_Pub_Bat_Params_B
2706 where type_id = l_batch_id
2707 and parameter_name = 'EXPLODE_OPTION';
2708
2709 IF l_config_option = '0' THEN
2710 --forcing explosion type to be CURRENT (2)
2711 l_config_option := '2';
2712 UPDATE EGO_PUB_WS_CONFIG
2713 SET Char_value = l_config_option
2714 where Parameter_Name = 'EXPLODE_OPTION'
2715 and web_service_name = 'GET_ITEM_STRUCTURE'
2716 and session_id = p_session_id
2717 and odi_session_id = p_odi_session_id;
2718 ELSE
2719 --retrieving EXPLODE_OPTION
2720 select to_char(NUMERIC_VALUE) --Bug 12984722(FP of bug 12984605) : Read from NUMERIC_VALUE instead of CHAR_VALUE
2721 into l_config_option
2722 from Ego_Pub_Bat_Params_B
2723 where type_id = l_batch_id
2724 and parameter_name = 'EXPLODE_OPTION';
2725
2726 --updating EXPLOSION_OPTION
2727 UPDATE EGO_PUB_WS_CONFIG
2728 SET Char_value = l_config_option
2729 where Parameter_Name = 'EXPLODE_OPTION'
2730 and web_service_name = 'GET_ITEM_STRUCTURE'
2731 and session_id = p_session_id
2732 and odi_session_id = p_odi_session_id;
2733
2734 END IF;
2735
2736 -- End bug 12932318 (FP of bug 12908261)
2737
2738
2739 END IF;
2740
2741 --
2742 --STEP TWO: RETRIEVE ALL MULTI-VALUE CONFIGURATION PARAMETERS
2743 -- AND STORE THEM IN TABLE EGO_PUB_WS_CONFIG
2744 --
2745
2746
2747 --RETRIEVING LIST OF LANGUAGES
2748 l_parameter_name := 'LANGUAGE_CODE';
2749
2750 CASE
2751 WHEN l_mode = 'BATCH' THEN
2752 l_xml_node_xpath := '/structureQueryParameters/BatchStructureQueryParameters/Configurability/ListOfLanguageInformation';
2753 WHEN l_mode = 'HMDM' THEN
2754 l_xml_node_xpath := '/structureQueryParameters/ListOfLanguageInformation';
2755 WHEN l_mode = 'LIST' THEN
2756 l_xml_node_xpath := '/structureQueryParameters/ParametersForListOfItems/Configurability/ListOfLanguageInformation';
2757 END CASE;
2758
2759 --Inserts language options in Config table
2760 Config_Languages(p_session_id,
2761 p_odi_session_id,
2762 l_xml_node_xpath,
2763 'GET_ITEM_STRUCTURE');
2764
2765
2766 --RETRIEVING LIST OF STRUCTURE HEADER ATTRIBUTE GROUPS TO PUBLISH
2767 CASE
2768 WHEN l_mode = 'BATCH' THEN
2769 --l_xml_node_xpath := '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/ListOfPublishStructureHeaderAttributeGroups/PublishStructureHeaderAttributeGroup';
2770 l_xml_node_xpath := '//PublishStructureHeaderAttributeGroup';
2771 WHEN l_mode = 'HMDM' THEN
2772 --l_xml_node_xpath := '/structureQueryParameters/PublishEntities/ListOfPublishStructureHeaderAttributeGroups/PublishStructureHeaderAttributeGroup';
2773 l_xml_node_xpath := '//PublishStructureHeaderAttributeGroup';
2774 WHEN l_mode = 'LIST' THEN
2775 --l_xml_node_xpath := '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/ListOfPublishStructureHeaderAttributeGroups/PublishStructureHeaderAttributeGroup';
2776 l_xml_node_xpath := '//PublishStructureHeaderAttributeGroup';
2777 END CASE;
2778
2779
2780 --Insert configurability options for Structure Header Attribute Groups
2781 Config_UDAs(p_session_id,
2782 p_odi_session_id,
2783 'HEADER_AG_NAME',
2784 l_xml_node_xpath,
2785 'AttributegroupId',
2786 'AttributeGroupName',
2787 'GET_ITEM_STRUCTURE');
2788
2789
2790 --RETRIEVING LIST OF COMPONENT ATTRIBUTE GROUPS TO PUBLISH
2791 CASE
2792 WHEN l_mode = 'BATCH' THEN
2793 --l_xml_node_xpath := '/structureQueryParameters/BatchStructureQueryParameters/Configurability/PublishEntities/PublishStructureComponents/ListOfPublishComponentAttributeGroups/PublishComponentAttributeGroup';
2794 l_xml_node_xpath := '//PublishComponentAttributeGroup';
2795 WHEN l_mode = 'HMDM' THEN
2796 --l_xml_node_xpath := '/structureQueryParameters/PublishEntities/PublishStructureComponents/ListOfPublishComponentAttributeGroups/PublishComponentAttributeGroup';
2797 l_xml_node_xpath := '//PublishComponentAttributeGroup';
2798 WHEN l_mode = 'LIST' THEN
2799 --l_xml_node_xpath := '/structureQueryParameters/ParametersForListOfItems/Configurability/PublishEntities/PublishStructureComponents/ListOfPublishComponentAttributeGroups/PublishComponentAttributeGroup';
2800 l_xml_node_xpath := '//PublishComponentAttributeGroup';
2801 END CASE;
2802
2803
2804 --Insert configurability options for Structure Header Attribute Groups
2805 Config_UDAs(p_session_id,
2806 p_odi_session_id,
2807 'COMP_AG_NAME',
2808 l_xml_node_xpath,
2809 'AttributegroupId',
2810 'AttributeGroupName',
2811 'GET_ITEM_STRUCTURE');
2812
2813
2814 END Create_Params_Structure;
2815
2816
2817
2818
2819 --procedure that populates ODI input table BOM_ODI_WS_ENTITIES for
2820 --getItemStructure web service depending on the web service invocation mode
2821 --('BATCH','HMDM','LIST'). The input data is obtained from the following
2822 --sources depending on the invocation mode:
2823 --MODE='BATCH': input data obtained from Publication Framework tables
2824 --MODE='HMDM' : input data is obtained from XML sent by invoking client in request
2825 --MODE='LIST' : input data is obtained from XML sent by invoking client in request
2826 PROCEDURE Create_Entities_Structure(p_session_id IN NUMBER,
2827 p_odi_session_id IN NUMBER)
2828 IS
2829
2830 l_mode VARCHAR(100);
2831 l_structure_name VARCHAR2(150);
2832 l_explosion_date DATE;
2833 l_explosion_date_rev DATE; -- Bug 12932318 (Fp of bug 12908261)
2834 l_batch_id NUMBER;
2835 l_item_id NUMBER;
2836 l_org_id NUMBER;
2837 l_rev_id NUMBER;
2838 x_item_id NUMBER;
2839 x_org_id NUMBER;
2840 l_comma_separated_str VARCHAR2(2000);
2841 l_temp_varchar VARCHAR2(150);
2842 l_temp2_varchar VARCHAR2(150);
2843 l_temp3_varchar VARCHAR2(150);
2844 l_segment1 VARCHAR2(40);
2845 l_segment2 VARCHAR2(40);
2846 l_segment3 VARCHAR2(40);
2847 l_segment4 VARCHAR2(40);
2848 l_segment5 VARCHAR2(40);
2849 l_segment6 VARCHAR2(40);
2850 l_segment7 VARCHAR2(40);
2851 l_segment8 VARCHAR2(40);
2852 l_segment9 VARCHAR2(40);
2853 l_segment10 VARCHAR2(40);
2854 l_segment11 VARCHAR2(40);
2855 l_segment12 VARCHAR2(40);
2856 l_segment13 VARCHAR2(40);
2857 l_segment14 VARCHAR2(40);
2858 l_segment15 VARCHAR2(40);
2859 l_segment16 VARCHAR2(40);
2860 l_segment17 VARCHAR2(40);
2861 l_segment18 VARCHAR2(40);
2862 l_segment19 VARCHAR2(40);
2863 l_segment20 VARCHAR2(40);
2864 l_validate_structure BOOLEAN := TRUE; --tells if structure name has to be validated
2865 l_validate_org_id BOOLEAN := TRUE; --tells if organization name has to be validated
2866 l_is_item_id_valid BOOLEAN := TRUE; --tells if organization name has to be validated
2867 l_is_valid BOOLEAN := TRUE;
2868
2869 --tables for LIST mode
2870 l_item_id_tab dbms_sql.varchar2_table;
2871 l_org_id_tab dbms_sql.varchar2_table;
2872 l_rev_id_tab dbms_sql.varchar2_table;
2873 l_root_node_id_tab dbms_sql.varchar2_table;
2874 l_item_segment1_tab dbms_sql.varchar2_table;
2875 l_item_segment2_tab dbms_sql.varchar2_table;
2876 l_item_segment3_tab dbms_sql.varchar2_table;
2877 l_item_segment4_tab dbms_sql.varchar2_table;
2878 l_item_segment5_tab dbms_sql.varchar2_table;
2879 l_item_segment6_tab dbms_sql.varchar2_table;
2880 l_item_segment7_tab dbms_sql.varchar2_table;
2881 l_item_segment8_tab dbms_sql.varchar2_table;
2882 l_item_segment9_tab dbms_sql.varchar2_table;
2883 l_item_segment10_tab dbms_sql.varchar2_table;
2884 l_item_segment11_tab dbms_sql.varchar2_table;
2885 l_item_segment12_tab dbms_sql.varchar2_table;
2886 l_item_segment13_tab dbms_sql.varchar2_table;
2887 l_item_segment14_tab dbms_sql.varchar2_table;
2888 l_item_segment15_tab dbms_sql.varchar2_table;
2889 l_item_segment16_tab dbms_sql.varchar2_table;
2890 l_item_segment17_tab dbms_sql.varchar2_table;
2891 l_item_segment18_tab dbms_sql.varchar2_table;
2892 l_item_segment19_tab dbms_sql.varchar2_table;
2893 l_item_segment20_tab dbms_sql.varchar2_table;
2894 l_org_name_tab dbms_sql.varchar2_table;
2895 l_rev_name_tab dbms_sql.varchar2_table;
2896 l_structure_name_tab dbms_sql.varchar2_table;
2897 l_explosion_date_tab dbms_sql.varchar2_table;
2898 l_count NUMBER;
2899 l_item_index NUMBER;
2900
2901 --variables to read comma separated string
2902 --l_list1 VARCHAR2(50) := 'A,B,C,D,E,F,G,H,I,J';
2903 l_tablen BINARY_INTEGER;
2904 l_tab DBMS_UTILITY.uncl_array;
2905
2906 --Cursor to retrieve list of end-items from Publication Framework
2907 CURSOR c_fwk_end_items(p_batch_id NUMBER) IS
2908 SELECT pk1_value,
2909 pk2_value,
2910 pk3_value
2911 FROM EGO_PUB_BAT_ENT_OBJS_V
2912 WHERE batch_id = p_batch_id AND user_entered = 'Y';
2913
2914 --Cursor to retrieve list of end-items for SUBROUTINE mode
2915 CURSOR c_subroutine_end_items(p_session_id NUMBER) IS
2916 SELECT CHAR_VALUE
2917 from EGO_PUB_WS_CONFIG
2918 where session_id = p_session_id
2919 and web_service_name = 'GET_ITEM_STRUCTURE'
2920 and parameter_name = 'ITEM_INFORMATION';
2921
2922
2923 BEGIN
2924
2925 --identify getItemStructure web service invocation mode
2926 select char_value
2927 into l_mode
2928 from EGO_PUB_WS_CONFIG
2929 where session_id = p_session_id
2930 and web_service_name = 'GET_ITEM_STRUCTURE'
2931 and parameter_name = 'MODE';
2932
2933 --populate odi input table depending on mode from different data sources
2934 CASE
2935
2936 --if mode is SUBROUTINE, get item information from EGO_PUB_WS_CONFIG table
2937 WHEN l_mode = 'SUBROUTINE' THEN
2938
2939 /*extract list of inventory item ids */
2940 SELECT to_number(char_value)
2941 BULK COLLECT INTO l_item_id_tab
2942 from EGO_PUB_WS_CONFIG
2943 where session_id = p_session_id
2944 and web_service_name = 'GET_ITEM_STRUCTURE'
2945 and parameter_name like 'INVENTORY_ITEM_ID_%'
2946 order by parameter_name;
2947
2948 /*extract list of organization ids */
2949 SELECT to_number(char_value)
2950 BULK COLLECT INTO l_org_id_tab
2951 from EGO_PUB_WS_CONFIG
2952 where session_id = p_session_id
2953 and web_service_name = 'GET_ITEM_STRUCTURE'
2954 and parameter_name like 'ORGANIZATION_ID_%'
2955 order by parameter_name;
2956
2957 /*extract list of revision ids */
2958 SELECT to_number(char_value)
2959 BULK COLLECT INTO l_rev_id_tab
2960 from EGO_PUB_WS_CONFIG
2961 where session_id = p_session_id
2962 and web_service_name = 'GET_ITEM_STRUCTURE'
2963 and parameter_name like 'REVISION_ID_%'
2964 order by parameter_name;
2965
2966 /*extract list of structure names */
2967 SELECT char_value
2968 BULK COLLECT INTO l_structure_name_tab
2969 from EGO_PUB_WS_CONFIG
2970 where session_id = p_session_id
2971 and web_service_name = 'GET_ITEM_STRUCTURE'
2972 and parameter_name like 'STRUCTURE_NAME_%'
2973 order by parameter_name;
2974
2975 /*extract list of root node ids */
2976 SELECT to_number(char_value)
2977 BULK COLLECT INTO l_root_node_id_tab
2978 from EGO_PUB_WS_CONFIG
2979 where session_id = p_session_id
2980 and web_service_name = 'GET_ITEM_STRUCTURE'
2981 and parameter_name like 'ROOT_NODE_ID_%'
2982 order by parameter_name;
2983
2984
2985
2986 --setting explosion date to the current date
2987 l_explosion_date := sysdate;
2988
2989
2990 --computing number of items in list from organization id
2991 l_count := l_org_id_tab.Count;
2992
2993
2994 --inserting from XML into data into ODI structure input table
2995 FOR i IN 1..l_count LOOP
2996
2997 --START VALIDATIONS-----------------------
2998
2999 --validate organization id and/or name
3000 l_temp_varchar := l_org_id_tab(i);
3001 l_temp2_varchar := NULL;
3002 l_is_valid := Validate_Organization(p_session_id => p_session_id,
3003 p_odi_session_id => p_odi_session_id,
3004 p_index => i,
3005 p_org_id => l_temp_varchar,
3006 p_org_code => l_temp2_varchar,
3007 x_organization_id => l_org_id);
3008 --IF l_is_valid = FALSE THEN
3009 --TODO: Generate warning only and skip loop
3010 -- raise_application_error(-20104, 'Invalid Organization Id or Organization Name');
3011 --END IF;
3012
3013
3014 --validate item id
3015 l_temp_varchar := l_item_id_tab(i);
3016 l_is_valid := Validate_Item(p_session_id => p_session_id,
3017 p_odi_session_id => p_odi_session_id,
3018 p_index => i,
3019 p_inv_id => l_temp_varchar,
3020 p_org_id => l_org_id,
3021 x_inv_item_id => l_item_id);
3022 --IF l_is_valid = FALSE THEN
3023 --TODO: Generate warning only and skip loop
3024 --raise_application_error(-20104, 'Invalid Item Id or Name ' || l_segment1);
3025 --END IF;
3026
3027
3028 --validating revision information
3029 l_rev_id := to_number(l_rev_id_tab(i));
3030 l_temp2_varchar := NULL;
3031 l_is_valid := EGO_ITEM_WS_PVT.validate_revision_details(p_session_id => p_session_id,
3032 p_odi_session_id => p_odi_session_id,
3033 p_index => i,
3034 p_inv_id => l_item_id,
3035 p_org_id => l_org_id,
3036 p_rev_id => l_rev_id,
3037 p_revision => l_temp2_varchar,
3038 p_rev_date => l_explosion_date,
3039 p_revision_id => l_rev_id, --out var
3040 p_revision_date => l_explosion_date --out var
3041 );
3042 --IF l_is_valid = FALSE THEN
3043 --TODO: Generate warning only
3044 -- raise_application_error(-20104, 'Invalid Revision ID or Revision Label');
3045 --END IF;
3046
3047 --validating structure name
3048 l_structure_name := l_structure_name_tab(i);
3049 l_is_valid := Validate_Structure_Name(p_session_id => p_session_id,
3050 p_odi_session_id => p_odi_session_id,
3051 p_str_name => l_structure_name,
3052 p_org_id => l_org_id);
3053
3054
3055 --Validate if structure name provided for the batch exists for the current end-item
3056 l_is_valid := Validate_Item_Structure_Name(p_session_id => p_session_id,
3057 p_odi_session_id => p_odi_session_id,
3058 p_str_name => l_structure_name,
3059 p_item_id => l_item_id,
3060 p_org_id => l_org_id,
3061 p_input_index => i);
3062
3063 --IF l_is_valid = FALSE THEN
3064 --TODO: Generate warning only and skip loop
3065 -- raise_application_error(-20104, 'Invalid Structure Name');
3066 --END IF;
3067
3068 --END VALIDATIONS-----------------------
3069
3070
3071 INSERT
3072 INTO BOM_ODI_WS_ENTITIES(
3073 session_id,
3074 odi_session_id,
3075 ITEM_ID,
3076 ITEM_ORG_ID,
3077 ITEM_REV,
3078 structure_name,
3079 EXPLOSION_DATE,
3080 PUBLISH_FLAG,
3081 SEQUENCE_NUMBER,
3082 CREATION_DATE,
3083 CREATED_BY,
3084 ROOT_NODE_ID)
3085 VALUES(
3086 p_session_id,
3087 p_odi_session_id,
3088 l_item_id,
3089 l_org_id,
3090 l_rev_id,
3091 l_structure_name,
3092 l_explosion_date,
3093 'Y',
3094 i,
3095 sysdate,
3096 0,
3097 l_root_node_id_tab(i));
3098
3099 END LOOP;
3100
3101
3102 --if mode is batch, get information from publication framework using batch_id
3103 WHEN l_mode = 'BATCH' THEN
3104
3105 --retrieving batchId from input XML
3106 select to_number(extractValue(xmlcontent, '/structureQueryParameters/BatchStructureQueryParameters/BatchId'))
3107 into l_batch_id
3108 from EGO_PUB_WS_PARAMS
3109 where session_id = p_session_id;
3110
3111 --retrieving structure name from publication framework params table
3112 select char_value
3113 into l_structure_name
3114 from EGO_PUB_PARAMETERS_V
3115 where type_id = l_batch_id and parameter_name = 'STRUCTURE_NAME';
3116
3117
3118 --retrieving explosion date from publication framework params table
3119 select date_value
3120 into l_explosion_date
3121 from EGO_PUB_PARAMETERS_V
3122 where type_id = l_batch_id and parameter_name = 'EXPLOSION_DATE';
3123
3124
3125 --retrieving all end-items batch from publication framework entity tables
3126 --and inserting data into ODI structure input table
3127 l_item_index :=0;
3128 FOR r in c_fwk_end_items(l_batch_id) LOOP
3129
3130 l_item_index := l_item_index + 1;
3131
3132 --retrieving item_id, org_id, and rev_id from publication
3133 --framework tables
3134 l_item_id := r.pk1_value;
3135 l_org_id := r.pk2_value;
3136 l_rev_id := r.pk3_value;
3137
3138 --Validate organization id only once since it is the same for all
3139 --items in batch. If not valid, error out
3140 IF l_validate_org_id = TRUE THEN
3141
3142 l_is_valid := Validate_Organization(p_session_id => p_session_id,
3143 p_odi_session_id => p_odi_session_id,
3144 p_index => l_item_index,
3145 p_org_id => l_org_id,
3146 x_organization_id => l_org_id);
3147 --IF l_is_valid = FALSE THEN
3148 -- raise_application_error(-20104, 'Invalid Organization Id');
3149 --END IF;
3150 l_validate_org_id :=FALSE;
3151 END IF;
3152
3153 --Validate if structure name exists in the system for the given organization.
3154 --This validation must only happen once since it is the same for all
3155 --items in batch.
3156 IF l_validate_structure = TRUE THEN
3157
3158 /*INSERT INTO emt_temp (Session_id, message)
3159 values (p_session_id, 'new in l_str_name:' || l_structure_name);*/
3160
3161
3162 l_is_valid := Validate_Structure_Name(p_session_id => p_session_id,
3163 p_odi_session_id => p_odi_session_id,
3164 p_str_name => l_structure_name,
3165 p_org_id => l_org_id);
3166
3167
3168 /*INSERT INTO emt_temp (Session_id, message)
3169 values (p_session_id, 'new out l_str_name:' || l_structure_name);
3170 */
3171
3172 --NULL;
3173 /*
3174 IF l_is_valid = FALSE THEN
3175 IF l_structure_name IS NULL THEN
3176 --TODO: exit the loop without publishing any structure and
3177 --generate warning instead of error
3178 raise_application_error(-20104, 'Structure Name NOT provided');
3179 ELSE
3180 raise_application_error(-20104, 'Invalid Structure Name');
3181 END IF;
3182
3183 END IF;
3184 */
3185 l_validate_structure :=FALSE;
3186 END IF;
3187
3188
3189 --validate item id for current end-item.
3190 l_is_valid := Validate_Item(p_session_id => p_session_id,
3191 p_odi_session_id => p_odi_session_id,
3192 p_index => l_item_index,
3193 p_inv_id => l_item_id,
3194 p_org_id => l_org_id,
3195 x_inv_item_id => l_item_id);
3196 --IF l_is_valid = FALSE THEN
3197 -- NULL;
3198 --TODO: Generate warning here and skip this item
3199 --raise_application_error(-20104, 'Invalid Item Id');
3200 --END IF;
3201
3202 --Validate if structure name provided for the batch exists for the current end-item
3203 l_is_valid := Validate_Item_Structure_Name(p_session_id => p_session_id,
3204 p_odi_session_id => p_odi_session_id,
3205 p_str_name => l_structure_name,
3206 p_item_id => l_item_id,
3207 p_org_id => l_org_id,
3208 p_input_index => l_item_index);
3209
3210
3211 l_is_valid := EGO_ITEM_WS_PVT.validate_revision_details(p_session_id => p_session_id,
3212 p_odi_session_id => p_odi_session_id,
3213 p_index => l_item_index,
3214 p_inv_id => l_item_id,
3215 p_org_id => l_org_id,
3216 p_rev_id => l_rev_id,
3217 p_revision => null,
3218 p_rev_date => l_explosion_date,
3219 p_revision_id => l_rev_id, --out var
3220 p_revision_date => l_explosion_date_rev -- Bug 12932318 (FP of bug 12908261)
3221 );
3222 --IF l_is_valid = FALSE THEN
3223 -- raise_application_error(-20104, 'Invalid Revision ID or Revision Label');
3224 --END IF;
3225
3226 --if item is valid, insert to input table, otherwise generate warning
3227 IF l_is_item_id_valid = TRUE THEN
3228
3229 INSERT
3230 INTO BOM_ODI_WS_ENTITIES(
3231 session_id,
3232 odi_session_id,
3233 ITEM_ID,
3234 ITEM_ORG_ID,
3235 ITEM_REV,
3236 structure_name,
3237 EXPLOSION_DATE,
3238 PUBLISH_FLAG,
3239 SEQUENCE_NUMBER,
3240 CREATION_DATE,
3241 CREATED_BY,
3242 ROOT_NODE_ID)
3243 VALUES(
3244 p_session_id,
3245 p_odi_session_id,
3246 l_item_id,
3247 l_org_id,
3248 l_rev_id,
3249 l_structure_name,
3250 l_explosion_date,
3251 'Y',
3252 l_item_index,
3253 sysdate,
3254 0,
3255 -1);
3256
3257 --ELSE
3258 --TODO: Generate warning here
3259 --raise_application_error(-20101, ' Warning: Invalid Item Id');
3260 END IF;
3261
3262
3263 END LOOP;
3264
3265
3266 WHEN l_mode = 'HMDM' THEN
3267
3268
3269 --retrieving organization_id from input XML
3270 l_temp_varchar := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/OrganizationId');
3271 l_temp2_varchar := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/OrganizationCode');
3272 --validate organization id or name
3273 l_is_valid := Validate_Organization(p_session_id => p_session_id,
3274 p_odi_session_id => p_odi_session_id,
3275 p_index => 1,
3276 p_org_id => l_temp_varchar,
3277 p_org_code => l_temp2_varchar,
3278 x_organization_id => l_org_id);
3279 --IF l_is_valid = FALSE THEN
3280 -- raise_application_error(-20104, 'Invalid Organization Id or Name');
3281 --END IF;
3282
3283
3284 --retrieving inventory_item_id from input XML
3285 l_temp_varchar := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemId');
3286 l_segment1 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment1');
3287 l_segment2 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment2');
3288 l_segment3 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment3');
3289 l_segment4 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment4');
3290 l_segment5 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment5');
3291 l_segment6 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment6');
3292 l_segment7 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment7');
3293 l_segment8 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment8');
3294 l_segment9 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment9');
3295 l_segment10 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment10');
3296 l_segment11 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment11');
3297 l_segment12 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment12');
3298 l_segment13 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment13');
3299 l_segment14 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment14');
3300 l_segment15 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment15');
3301 l_segment16 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment16');
3302 l_segment17 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment17');
3303 l_segment18 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment18');
3304 l_segment19 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment19');
3305 l_segment20 := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/InventoryItemName/Segment20');
3306 --validate item id or name
3307 l_is_valid := Validate_Item(p_session_id => p_session_id,
3308 p_odi_session_id => p_odi_session_id,
3309 p_index => 1,
3310 p_inv_id => l_temp_varchar,
3311 p_org_id => l_org_id,
3312 p_segment1 => l_segment1,
3313 p_segment2 => l_segment2,
3314 p_segment3 => l_segment3,
3315 p_segment4 => l_segment4,
3316 p_segment5 => l_segment5,
3317 p_segment6 => l_segment6,
3318 p_segment7 => l_segment7,
3319 p_segment8 => l_segment8,
3320 p_segment9 => l_segment9,
3321 p_segment10 => l_segment10,
3322 p_segment11 => l_segment11,
3323 p_segment12 => l_segment12,
3324 p_segment13 => l_segment13,
3325 p_segment14 => l_segment14,
3326 p_segment15 => l_segment15,
3327 p_segment16 => l_segment16,
3328 p_segment17 => l_segment17,
3329 p_segment18 => l_segment18,
3330 p_segment19 => l_segment19,
3331 p_segment20 => l_segment20,
3332 x_inv_item_id => l_item_id);
3333 --IF l_is_valid = FALSE THEN
3334 -- raise_application_error(-20104, 'Invalid Item Id or Name');
3335 --END IF;
3336
3337 --retrieving revision_id, revision, and explosion date from input XML
3338 l_rev_id := to_number(Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/RevisionId'));
3339 l_temp2_varchar := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/Revision');
3340 --NOTE: Errors might arise from the conversion between varchar2 and date if the user provided date
3341 --format and the db format do not match. Watch out for this condition.
3342 l_explosion_date := to_date(Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/RevisionDate'));
3343 --validating revision information
3344 /*l_is_valid := Validate_Revision_Info(p_rev_id => l_temp_varchar,
3345 p_revision => l_temp2_varchar,
3346 p_inv_id => l_item_id,
3347 p_org_id => l_org_id,
3348 x_revision_id => l_rev_id);
3349 */
3350 l_is_valid := EGO_ITEM_WS_PVT.validate_revision_details(p_session_id => p_session_id,
3351 p_odi_session_id => p_odi_session_id,
3352 p_index => 1,
3353 p_inv_id => l_item_id,
3354 p_org_id => l_org_id,
3355 p_rev_id => l_rev_id,
3356 p_revision => l_temp2_varchar,
3357 p_rev_date => l_explosion_date,
3358 p_revision_id => l_rev_id, --out var
3359 p_revision_date => l_explosion_date --out var
3360 );
3361
3362
3363 --IF l_is_valid = FALSE THEN
3364 -- raise_application_error(-20104, 'Invalid Revision ID or Revision Label');
3365 --END IF;
3366
3367
3368 --retrieving structure_name from input XML
3369 l_structure_name := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/StructureName');
3370 l_is_valid := Validate_Structure_Name(p_session_id => p_session_id,
3371 p_odi_session_id => p_odi_session_id,
3372 p_str_name => l_structure_name,
3373 p_org_id => l_org_id);
3374
3375 --IF l_is_valid = FALSE THEN
3376 -- raise_application_error(-20104, 'Invalid Structure Name');
3377 --END IF;
3378
3379 --Validate if structure name provided for the batch exists for the current end-item
3380 l_is_valid := Validate_Item_Structure_Name(p_session_id => p_session_id,
3381 p_odi_session_id => p_odi_session_id,
3382 p_str_name => l_structure_name,
3383 p_item_id => l_item_id,
3384 p_org_id => l_org_id,
3385 p_input_index => 1);
3386
3387 --retrieving explosion_date/revision_date from input XML
3388 /*l_temp_varchar := Get_ODI_Input_Parameter(p_session_id, '/structureQueryParameters/RevisionDate');
3389 --validating revision date is valid date
3390 l_is_valid := Validate_revision_date(l_temp_varchar,
3391 l_item_id ,
3392 l_org_id,
3393 l_explosion_date);
3394 IF l_is_valid = FALSE THEN
3395 raise_application_error(-20104, 'Invalid Revision Date');
3396 END IF;*/
3397
3398 INSERT
3399 INTO BOM_ODI_WS_ENTITIES(
3400 session_id,
3401 odi_session_id,
3402 ITEM_ID,
3403 ITEM_ORG_ID,
3404 ITEM_REV,
3405 structure_name,
3406 EXPLOSION_DATE,
3407 PUBLISH_FLAG,
3408 SEQUENCE_NUMBER,
3409 CREATION_DATE,
3410 CREATED_BY,
3411 ROOT_NODE_ID)
3412 VALUES(
3413 p_session_id,
3414 p_odi_session_id,
3415 l_item_id,
3416 l_org_id,
3417 l_rev_id,
3418 l_structure_name,
3419 l_explosion_date,
3420 'Y',
3421 1,
3422 sysdate,
3423 0,
3424 -1);
3425
3426
3427 WHEN l_mode = 'LIST' THEN
3428
3429
3430 /*extract list of inventory item ids */
3431 SELECT extractValue(lang_code, '/InventoryItemId')
3432 BULK COLLECT INTO l_item_id_tab
3433 FROM (SELECT Value(langcode) lang_code
3434 FROM EGO_PUB_WS_PARAMS i,
3435 TABLE(XMLSequence(
3436 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemId') )) langcode
3437 WHERE session_id=p_session_id
3438 );
3439
3440 /*extract list of inventory item segment1 */
3441 SELECT extractValue(lang_code, '/Segment1')
3442 BULK COLLECT INTO l_item_segment1_tab
3443 FROM (SELECT Value(langcode) lang_code
3444 FROM EGO_PUB_WS_PARAMS i,
3445 TABLE(XMLSequence(
3446 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment1') )) langcode
3447 WHERE session_id=p_session_id
3448 );
3449
3450 /*extract list of inventory item segment2 */
3451 SELECT extractValue(lang_code, '/Segment2')
3452 BULK COLLECT INTO l_item_segment2_tab
3453 FROM (SELECT Value(langcode) lang_code
3454 FROM EGO_PUB_WS_PARAMS i,
3455 TABLE(XMLSequence(
3456 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment2') )) langcode
3457 WHERE session_id=p_session_id
3458 );
3459
3460 /*extract list of inventory item segment3 */
3461 SELECT extractValue(lang_code, '/Segment3')
3462 BULK COLLECT INTO l_item_segment3_tab
3463 FROM (SELECT Value(langcode) lang_code
3464 FROM EGO_PUB_WS_PARAMS i,
3465 TABLE(XMLSequence(
3466 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment3') )) langcode
3467 WHERE session_id=p_session_id
3468 );
3469
3470 /*extract list of inventory item segment4 */
3471 SELECT extractValue(lang_code, '/Segment4')
3472 BULK COLLECT INTO l_item_segment4_tab
3473 FROM (SELECT Value(langcode) lang_code
3474 FROM EGO_PUB_WS_PARAMS i,
3475 TABLE(XMLSequence(
3476 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment4') )) langcode
3477 WHERE session_id=p_session_id
3478 );
3479
3480 /*extract list of inventory item segment5 */
3481 SELECT extractValue(lang_code, '/Segment5')
3482 BULK COLLECT INTO l_item_segment5_tab
3483 FROM (SELECT Value(langcode) lang_code
3484 FROM EGO_PUB_WS_PARAMS i,
3485 TABLE(XMLSequence(
3486 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment5') )) langcode
3487 WHERE session_id=p_session_id
3488 );
3489
3490 /*extract list of inventory item segment6 */
3491 SELECT extractValue(lang_code, '/Segment6')
3492 BULK COLLECT INTO l_item_segment6_tab
3493 FROM (SELECT Value(langcode) lang_code
3494 FROM EGO_PUB_WS_PARAMS i,
3495 TABLE(XMLSequence(
3496 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment6') )) langcode
3497 WHERE session_id=p_session_id
3498 );
3499
3500 /*extract list of inventory item segment7 */
3501 SELECT extractValue(lang_code, '/Segment7')
3502 BULK COLLECT INTO l_item_segment7_tab
3503 FROM (SELECT Value(langcode) lang_code
3504 FROM EGO_PUB_WS_PARAMS i,
3505 TABLE(XMLSequence(
3506 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment7') )) langcode
3507 WHERE session_id=p_session_id
3508 );
3509
3510 /*extract list of inventory item segment8 */
3511 SELECT extractValue(lang_code, '/Segment8')
3512 BULK COLLECT INTO l_item_segment8_tab
3513 FROM (SELECT Value(langcode) lang_code
3514 FROM EGO_PUB_WS_PARAMS i,
3515 TABLE(XMLSequence(
3516 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment8') )) langcode
3517 WHERE session_id=p_session_id
3518 );
3519
3520 /*extract list of inventory item segment9 */
3521 SELECT extractValue(lang_code, '/Segment9')
3522 BULK COLLECT INTO l_item_segment9_tab
3523 FROM (SELECT Value(langcode) lang_code
3524 FROM EGO_PUB_WS_PARAMS i,
3525 TABLE(XMLSequence(
3526 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment9') )) langcode
3527 WHERE session_id=p_session_id
3528 );
3529
3530 /*extract list of inventory item segment10 */
3531 SELECT extractValue(lang_code, '/Segment10')
3532 BULK COLLECT INTO l_item_segment10_tab
3533 FROM (SELECT Value(langcode) lang_code
3534 FROM EGO_PUB_WS_PARAMS i,
3535 TABLE(XMLSequence(
3536 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment10') )) langcode
3537 WHERE session_id=p_session_id
3538 );
3539
3540 /*extract list of inventory item segment11 */
3541 SELECT extractValue(lang_code, '/Segment11')
3542 BULK COLLECT INTO l_item_segment11_tab
3543 FROM (SELECT Value(langcode) lang_code
3544 FROM EGO_PUB_WS_PARAMS i,
3545 TABLE(XMLSequence(
3546 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment11') )) langcode
3547 WHERE session_id=p_session_id
3548 );
3549
3550 /*extract list of inventory item segment12 */
3551 SELECT extractValue(lang_code, '/Segment12')
3552 BULK COLLECT INTO l_item_segment12_tab
3553 FROM (SELECT Value(langcode) lang_code
3554 FROM EGO_PUB_WS_PARAMS i,
3555 TABLE(XMLSequence(
3556 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment12') )) langcode
3557 WHERE session_id=p_session_id
3558 );
3559
3560 /*extract list of inventory item segment13 */
3561 SELECT extractValue(lang_code, '/Segment13')
3562 BULK COLLECT INTO l_item_segment13_tab
3563 FROM (SELECT Value(langcode) lang_code
3564 FROM EGO_PUB_WS_PARAMS i,
3565 TABLE(XMLSequence(
3566 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment13') )) langcode
3567 WHERE session_id=p_session_id
3568 );
3569
3570 /*extract list of inventory item segment14 */
3571 SELECT extractValue(lang_code, '/Segment14')
3572 BULK COLLECT INTO l_item_segment14_tab
3573 FROM (SELECT Value(langcode) lang_code
3574 FROM EGO_PUB_WS_PARAMS i,
3575 TABLE(XMLSequence(
3576 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment14') )) langcode
3577 WHERE session_id=p_session_id
3578 );
3579
3580 /*extract list of inventory item segment15 */
3581 SELECT extractValue(lang_code, '/Segment15')
3582 BULK COLLECT INTO l_item_segment15_tab
3583 FROM (SELECT Value(langcode) lang_code
3584 FROM EGO_PUB_WS_PARAMS i,
3585 TABLE(XMLSequence(
3586 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment15') )) langcode
3587 WHERE session_id=p_session_id
3588 );
3589
3590 /*extract list of inventory item segment16 */
3591 SELECT extractValue(lang_code, '/Segment16')
3592 BULK COLLECT INTO l_item_segment16_tab
3593 FROM (SELECT Value(langcode) lang_code
3594 FROM EGO_PUB_WS_PARAMS i,
3595 TABLE(XMLSequence(
3596 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment16') )) langcode
3597 WHERE session_id=p_session_id
3598 );
3599
3600 /*extract list of inventory item segment17 */
3601 SELECT extractValue(lang_code, '/Segment17')
3602 BULK COLLECT INTO l_item_segment17_tab
3603 FROM (SELECT Value(langcode) lang_code
3604 FROM EGO_PUB_WS_PARAMS i,
3605 TABLE(XMLSequence(
3606 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment17') )) langcode
3607 WHERE session_id=p_session_id
3608 );
3609
3610 /*extract list of inventory item segment18 */
3611 SELECT extractValue(lang_code, '/Segment18')
3612 BULK COLLECT INTO l_item_segment18_tab
3613 FROM (SELECT Value(langcode) lang_code
3614 FROM EGO_PUB_WS_PARAMS i,
3615 TABLE(XMLSequence(
3616 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment18') )) langcode
3617 WHERE session_id=p_session_id
3618 );
3619
3620 /*extract list of inventory item segment19 */
3621 SELECT extractValue(lang_code, '/Segment19')
3622 BULK COLLECT INTO l_item_segment19_tab
3623 FROM (SELECT Value(langcode) lang_code
3624 FROM EGO_PUB_WS_PARAMS i,
3625 TABLE(XMLSequence(
3626 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment19') )) langcode
3627 WHERE session_id=p_session_id
3628 );
3629
3630 /*extract list of inventory item segment20 */
3631 SELECT extractValue(lang_code, '/Segment20')
3632 BULK COLLECT INTO l_item_segment20_tab
3633 FROM (SELECT Value(langcode) lang_code
3634 FROM EGO_PUB_WS_PARAMS i,
3635 TABLE(XMLSequence(
3636 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/InventoryItemName/Segment20') )) langcode
3637 WHERE session_id=p_session_id
3638 );
3639
3640
3641 /*extract list of organization ids */
3642 SELECT extractValue(lang_code, '/OrganizationId')
3643 BULK COLLECT INTO l_org_id_tab
3644 FROM (SELECT Value(langcode) lang_code
3645 FROM EGO_PUB_WS_PARAMS i,
3646 TABLE(XMLSequence(
3647 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/OrganizationId') )) langcode
3648 WHERE session_id=p_session_id
3649 );
3650
3651 /*extract list of organization codes */
3652 SELECT extractValue(lang_code, '/OrganizationCode')
3653 BULK COLLECT INTO l_org_name_tab
3654 FROM (SELECT Value(langcode) lang_code
3655 FROM EGO_PUB_WS_PARAMS i,
3656 TABLE(XMLSequence(
3657 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/OrganizationCode') )) langcode
3658 WHERE session_id=p_session_id
3659 );
3660
3661
3662 /*extract list of revision ids */
3663 SELECT extractValue(lang_code, '/RevisionId')
3664 BULK COLLECT INTO l_rev_id_tab
3665 FROM (SELECT Value(langcode) lang_code
3666 FROM EGO_PUB_WS_PARAMS i,
3667 TABLE(XMLSequence(
3668 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/RevisionId') )) langcode
3669 WHERE session_id=p_session_id
3670 );
3671
3672 /*extract list of revision codes */
3673 SELECT extractValue(lang_code, '/Revision')
3674 BULK COLLECT INTO l_rev_name_tab
3675 FROM (SELECT Value(langcode) lang_code
3676 FROM EGO_PUB_WS_PARAMS i,
3677 TABLE(XMLSequence(
3678 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/Revision') )) langcode
3679 WHERE session_id=p_session_id
3680 );
3681
3682
3683 /*extract list of revision dates or explosion dates */
3684 --IMPORTANT NOTE: explosion_date might casue issues during the conversion
3685 --between varchar2 and date type as the format for the date stored in database might be
3686 --different from the format provided by the user. perhaps specify format in to_char()?
3687 SELECT extractValue(lang_code, '/RevisionDate')
3688 BULK COLLECT INTO l_explosion_date_tab
3689 FROM (SELECT Value(langcode) lang_code
3690 FROM EGO_PUB_WS_PARAMS i,
3691 TABLE(XMLSequence(
3692 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/RevisionDate') )) langcode
3693 WHERE session_id=p_session_id
3694 );
3695
3696
3697 /*extract list of structure names */
3698 SELECT extractValue(lang_code, '/StructureName')
3699 BULK COLLECT INTO l_structure_name_tab
3700 FROM (SELECT Value(langcode) lang_code
3701 FROM EGO_PUB_WS_PARAMS i,
3702 TABLE(XMLSequence(
3703 extract(i.xmlcontent, 'structureQueryParameters/ParametersForListOfItems/ListOfItemStructureQueryParams/StructureName') )) langcode
3704 WHERE session_id=p_session_id
3705 );
3706
3707
3708 --computing number of items in list from organization id or name since
3709 --one of them must be populated
3710 l_count := l_org_id_tab.Count;
3711 IF l_org_name_tab.Count > l_count THEN
3712 l_count := l_org_name_tab.Count;
3713 END IF;
3714
3715 --inserting from XML into data into ODI structure input table
3716 FOR i IN 1..l_count LOOP
3717
3718 --START VALIDATIONS-----------------------
3719
3720 --validate organization id and/or name
3721 IF l_org_id_tab.Count >= i THEN
3722 l_temp_varchar := l_org_id_tab(i);
3723 ELSE
3724 l_temp_varchar := NULL;
3725 END IF;
3726 IF l_org_name_tab.Count >= i THEN
3727 l_temp2_varchar := l_org_name_tab(i);
3728 ELSE
3729 l_temp2_varchar := NULL;
3730 END IF;
3731 l_is_valid := Validate_Organization(p_session_id => p_session_id,
3732 p_odi_session_id => p_odi_session_id,
3733 p_index => i,
3734 p_org_id => l_temp_varchar,
3735 p_org_code => l_temp2_varchar,
3736 x_organization_id => l_org_id);
3737 --IF l_is_valid = FALSE THEN
3738 --TODO: Generate warning only and skip loop
3739 -- raise_application_error(-20104, 'Invalid Organization Id or Organization Name');
3740 --END IF;
3741
3742
3743 --validate item id and/or name
3744 IF l_item_id_tab.Count >= i THEN
3745 l_temp_varchar := l_item_id_tab(i);
3746 ELSE
3747 l_temp_varchar := NULL;
3748 END IF;
3749 IF l_item_segment1_tab.Count >= i THEN
3750 l_segment1 := l_item_segment1_tab(i);
3751 ELSE
3752 l_segment1 := NULL;
3753 END IF;
3754 IF l_item_segment2_tab.Count >= i THEN
3755 l_segment2 := l_item_segment2_tab(i);
3756 ELSE
3757 l_segment2 := NULL;
3758 END IF;
3759 IF l_item_segment3_tab.Count >= i THEN
3760 l_segment3 := l_item_segment3_tab(i);
3761 ELSE
3762 l_segment3 := NULL;
3763 END IF;
3764 IF l_item_segment4_tab.Count >= i THEN
3765 l_segment4 := l_item_segment4_tab(i);
3766 ELSE
3767 l_segment4 := NULL;
3768 END IF;
3769 IF l_item_segment5_tab.Count >= i THEN
3770 l_segment5 := l_item_segment5_tab(i);
3771 ELSE
3772 l_segment5 := NULL;
3773 END IF;
3774 IF l_item_segment6_tab.Count >= i THEN
3775 l_segment6 := l_item_segment6_tab(i);
3776 ELSE
3777 l_segment6 := NULL;
3778 END IF;
3779 IF l_item_segment7_tab.Count >= i THEN
3780 l_segment7 := l_item_segment7_tab(i);
3781 ELSE
3782 l_segment7 := NULL;
3783 END IF;
3784 IF l_item_segment8_tab.Count >= i THEN
3785 l_segment8 := l_item_segment8_tab(i);
3786 ELSE
3787 l_segment8 := NULL;
3788 END IF;
3789 IF l_item_segment9_tab.Count >= i THEN
3790 l_segment9 := l_item_segment9_tab(i);
3791 ELSE
3792 l_segment9 := NULL;
3793 END IF;
3794 IF l_item_segment10_tab.Count >= i THEN
3795 l_segment10 := l_item_segment10_tab(i);
3796 ELSE
3797 l_segment10 := NULL;
3798 END IF;
3799 IF l_item_segment11_tab.Count >= i THEN
3800 l_segment11 := l_item_segment11_tab(i);
3801 ELSE
3802 l_segment11 := NULL;
3803 END IF;
3804 IF l_item_segment12_tab.Count >= i THEN
3805 l_segment12 := l_item_segment12_tab(i);
3806 ELSE
3807 l_segment12 := NULL;
3808 END IF;
3809 IF l_item_segment13_tab.Count >= i THEN
3810 l_segment13 := l_item_segment13_tab(i);
3811 ELSE
3812 l_segment13 := NULL;
3813 END IF;
3814 IF l_item_segment14_tab.Count >= i THEN
3815 l_segment14 := l_item_segment14_tab(i);
3816 ELSE
3817 l_segment14 := NULL;
3818 END IF;
3819 IF l_item_segment15_tab.Count >= i THEN
3820 l_segment15 := l_item_segment15_tab(i);
3821 ELSE
3822 l_segment15 := NULL;
3823 END IF;
3824 IF l_item_segment16_tab.Count >= i THEN
3825 l_segment16 := l_item_segment16_tab(i);
3826 ELSE
3827 l_segment16 := NULL;
3828 END IF;
3829 IF l_item_segment17_tab.Count >= i THEN
3830 l_segment17 := l_item_segment17_tab(i);
3831 ELSE
3832 l_segment17 := NULL;
3833 END IF;
3834 IF l_item_segment18_tab.Count >= i THEN
3835 l_segment18 := l_item_segment18_tab(i);
3836 ELSE
3837 l_segment18 := NULL;
3838 END IF;
3839 IF l_item_segment19_tab.Count >= i THEN
3840 l_segment19 := l_item_segment19_tab(i);
3841 ELSE
3842 l_segment19 := NULL;
3843 END IF;
3844 IF l_item_segment20_tab.Count >= i THEN
3845 l_segment20 := l_item_segment20_tab(i);
3846 ELSE
3847 l_segment20 := NULL;
3848 END IF;
3849
3850 l_is_valid := Validate_Item(p_session_id => p_session_id,
3851 p_odi_session_id => p_odi_session_id,
3852 p_index => i,
3853 p_inv_id => l_temp_varchar,
3854 p_org_id => l_org_id,
3855 p_segment1 => l_segment1,
3856 p_segment2 => l_segment2,
3857 p_segment3 => l_segment3,
3858 p_segment4 => l_segment4,
3859 p_segment5 => l_segment5,
3860 p_segment6 => l_segment6,
3861 p_segment7 => l_segment7,
3862 p_segment8 => l_segment8,
3863 p_segment9 => l_segment9,
3864 p_segment10 => l_segment10,
3865 p_segment11 => l_segment11,
3866 p_segment12 => l_segment12,
3867 p_segment13 => l_segment13,
3868 p_segment14 => l_segment14,
3869 p_segment15 => l_segment15,
3870 p_segment16 => l_segment16,
3871 p_segment17 => l_segment17,
3872 p_segment18 => l_segment18,
3873 p_segment19 => l_segment19,
3874 p_segment20 => l_segment20,
3875 x_inv_item_id => l_item_id);
3876 --IF l_is_valid = FALSE THEN
3877 --TODO: Generate warning only and skip loop
3878 --raise_application_error(-20104, 'Invalid Item Id or Name ' || l_segment1);
3879 --END IF;
3880
3881 --validating revision information
3882 IF l_rev_id_tab.Count >= i THEN
3883 l_rev_id := to_number(l_rev_id_tab(i));
3884 ELSE
3885 l_rev_id := NULL;
3886 END IF;
3887 IF l_rev_name_tab.Count >= i THEN
3888 l_temp2_varchar := l_rev_name_tab(i);
3889 ELSE
3890 l_temp2_varchar := NULL;
3891 END IF;
3892 IF l_explosion_date_tab.Count >= i THEN
3893 --NOTE: watch for conversion between varchar2 and date.
3894 --there might be differences bewteen DB format and user provided
3895 --format
3896 l_explosion_date := to_date(l_explosion_date_tab(i));
3897 ELSE
3898 l_explosion_date := NULL;
3899 END IF;
3900
3901 /*l_is_valid := Validate_Revision_Info(p_rev_id => l_temp_varchar,
3902 p_revision => l_temp2_varchar,
3903 p_inv_id => l_item_id,
3904 p_org_id => l_org_id,
3905 x_revision_id => l_rev_id);
3906
3907 */
3908 l_is_valid := EGO_ITEM_WS_PVT.validate_revision_details(p_session_id => p_session_id,
3909 p_odi_session_id => p_odi_session_id,
3910 p_index => i,
3911 p_inv_id => l_item_id,
3912 p_org_id => l_org_id,
3913 p_rev_id => l_rev_id,
3914 p_revision => l_temp2_varchar,
3915 p_rev_date => l_explosion_date,
3916 p_revision_id => l_rev_id, --out var
3917 p_revision_date => l_explosion_date --out var
3918 );
3919
3920 --IF l_is_valid = FALSE THEN
3921 --TODO: Generate warning only
3922 -- raise_application_error(-20104, 'Invalid Revision ID or Revision Label');
3923 --END IF;
3924
3925
3926 --validating structure name
3927 l_structure_name := l_structure_name_tab(i);
3928 l_is_valid := Validate_Structure_Name(p_session_id => p_session_id,
3929 p_odi_session_id => p_odi_session_id,
3930 p_str_name => l_structure_name,
3931 p_org_id => l_org_id);
3932
3933
3934 --Validate if structure name provided for the batch exists for the current end-item
3935 l_is_valid := Validate_Item_Structure_Name(p_session_id => p_session_id,
3936 p_odi_session_id => p_odi_session_id,
3937 p_str_name => l_structure_name,
3938 p_item_id => l_item_id,
3939 p_org_id => l_org_id,
3940 p_input_index => i);
3941
3942 --IF l_is_valid = FALSE THEN
3943 --TODO: Generate warning only and skip loop
3944 -- raise_application_error(-20104, 'Invalid Structure Name');
3945 --END IF;
3946
3947 --validating revision date is valid date
3948 /*l_is_valid := Validate_revision_date( l_explosion_date_tab(i),
3949 l_item_id,
3950 l_org_id,
3951 l_explosion_date);
3952 IF l_is_valid = FALSE THEN
3953 --TODO: Generate warning only and skip loop
3954 raise_application_error(-20104, 'Invalid Revision Date');
3955 END IF;*/
3956
3957 --END VALIDATIONS-----------------------
3958
3959
3960 INSERT
3961 INTO BOM_ODI_WS_ENTITIES(
3962 session_id,
3963 odi_session_id,
3964 ITEM_ID,
3965 ITEM_ORG_ID,
3966 ITEM_REV,
3967 structure_name,
3968 EXPLOSION_DATE,
3969 PUBLISH_FLAG,
3970 SEQUENCE_NUMBER,
3971 CREATION_DATE,
3972 CREATED_BY,
3973 ROOT_NODE_ID)
3974 VALUES(
3975 p_session_id,
3976 p_odi_session_id,
3977 l_item_id,
3978 l_org_id,
3979 l_rev_id,
3980 l_structure_name,
3981 l_explosion_date,
3982 'Y',
3983 i,
3984 sysdate,
3985 0,
3986 -1);
3987
3988 END LOOP;
3989
3990 END CASE;
3991
3992 END Create_Entities_Structure;
3993
3994
3995
3996 --Given a component code in the form of a string contained the concatenated
3997 --inventory_item_id values, this procedure converts the inventory_item_ids
3998 --into inventory_item_names and formats the output in the following manner:
3999 --<ComponentCode>
4000 -- <ItemReference>
4001 -- <Name>A</Name>
4002 -- <Sequence>1</Sequence>
4003 -- </ItemReference>
4004 -- <ItemReference>
4005 -- <Name>B</Name>
4006 -- <Sequence>2</Sequence>
4007 -- </ItemReference>
4008 --</ComponentCode>
4009 FUNCTION Decode_Component_Code(component_code IN VARCHAR2) RETURN CLOB
4010 IS
4011
4012 --str VARCHAR2(1000); commented for bug fix 8858296
4013 str CLOB; --added for bug fix 8858296
4014 item_name VARCHAR2(4000);
4015 l_bom_item_type NUMBER;
4016 l_icc_name VARCHAR2(4000);
4017 item_id VARCHAR2(100);
4018 item_count NUMBER;
4019 --start_index NUMBER;
4020 end_index NUMBER;
4021 l_component_code VARCHAR2(4000);
4022
4023 BEGIN
4024 item_count := length(component_code)/20;
4025 --str := 'Count3: ' || item_count || ' ';
4026 str := to_clob('<ComponentPath>'); --added to_clob for bug fix 8858296
4027 l_component_code := component_code;
4028
4029 for i in 1..item_count
4030 loop
4031 --retrieving inventory_item_id from component_code string
4032 item_id := ltrim(substr(l_component_code,0,20),'0I');
4033 l_component_code := substr(l_component_code,21);
4034
4035 --converting inventory_item_id to inventory_item_name and related info
4036 select msi.concatenated_segments,
4037 msi.bom_item_type,
4038 icc.concatenated_segments
4039 into item_name, l_bom_item_type, l_icc_name
4040 from MTL_SYSTEM_ITEMS_kfv msi,
4041 MTL_ITEM_CATALOG_GROUPS_kfv icc
4042 where
4043 inventory_item_id = item_id
4044 and msi.item_catalog_group_id =icc.item_catalog_group_id(+)
4045 and rownum = 1; -- Bug 12932318 (FP of bug 12908261)
4046
4047 --formatting as XML
4048 --added to_clob for bug fix 8858296
4049 str := str || to_clob('<ItemReference><Name>' || item_name || '</Name><Sequence>' || i || '</Sequence>' || '<BomItemType>' || l_bom_item_type || '</BomItemType><CatalogCategoryName>' || l_icc_name || '</CatalogCategoryName></ItemReference>');
4050
4051 end loop;
4052
4053 str := str || to_clob('</ComponentPath>');
4054
4055 RETURN str;
4056 END;
4057
4058
4059 /*
4060 If the user provides only the Revision and does NOT provide Explosion Date then, system would
4061 calculate the explosion date based on the selected Item Revision. The explosion date would be
4062 End Effective Date (for Past Revision), Sys Date (for Current Revision) and Start Effective Date
4063 (for Future Revision). If the user provies both Revision and Explosion Date then, system would
4064 check if the selected Item Revision is effective on the given Explosion Date. If it is not
4065 effective on the given explosion date, system would select the Item Revision effective on the
4066 given explosion date. In other words, Explosion Date would take precedence over Item Revision.
4067 Also, as discussed please ensure that the Item Web Service will honour the Fixed Revision
4068 Floating Revision functionality for the components.
4069 */
4070 /*FUNCTION Compute_Revision_Date(p_rev_date IN DATE,
4071 p_revision_id NUMBER,
4072 p_revision_label VARCHAR2,
4073 p_inventory_item_id IN NUMBER,
4074 p_organization_id IN NUMBER)
4075 RETURN DATE
4076 IS
4077
4078 l_revision_id NUMBER;
4079 l_revision_label VARCHAR2(100);
4080 l_rev_date DATE;
4081 l_effective_date DATE;
4082 l_rev_end_date DATE;
4083
4084
4085 --cursor to retrieve revision label
4086 CURSOR c_get_revision_label(p_inv_item_id NUMBER,
4087 p_org_id NUMBER,
4088 p_rev_id NUMBER) IS
4089 select revision_id,
4090 revision,
4091 inventory_item_id,
4092 organization_id,
4093 effectivity_date,
4094 (select nvl( min(b.effectivity_date)-(1/86400),to_date('9999/12/31 00:00:00','yyyy/mm/dd hh24:mi:ss')) end_date from mtl_item_revisions_b b
4095 where b.inventory_item_id = a.inventory_item_id and
4096 b.organization_id = a.organization_id and
4097 b.effectivity_date > a.effectivity_date) end_date,
4098 implementation_date
4099 from mtl_item_revisions_b a
4100 where a.organization_id = p_org_id
4101 and inventory_item_id = p_inventory_item_id
4102 and revision_id = p_rev_id;
4103
4104
4105 --cursor to retrieve revision identifier
4106 CURSOR c_get_revision_id(p_inv_item_id NUMBER,
4107 p_org_id NUMBER,
4108 p_rev_label VARCHAR) IS
4109 select revision_id,
4110 revision,
4111 inventory_item_id,
4112 organization_id,
4113 effectivity_date,
4114 (select nvl( min(b.effectivity_date)-(1/86400),to_date('9999/12/31 00:00:00','yyyy/mm/dd hh24:mi:ss')) end_date from mtl_item_revisions_b b
4115 where b.inventory_item_id = a.inventory_item_id and
4116 b.organization_id = a.organization_id and
4117 b.effectivity_date > a.effectivity_date) end_date,
4118 implementation_date
4119 from mtl_item_revisions_b a
4120 where a.organization_id = p_org_id
4121 and inventory_item_id = p_inventory_item_id
4122 and revision = p_rev_label;
4123
4124 BEGIN
4125
4126 l_rev_date := p_rev_date;
4127 l_revision_id := p_revision_id;
4128 l_revision_label := p_revision_label;
4129
4130
4131 --if user provided either revision id or code/label
4132 IF l_revision_id IS NOT NULL OR l_revision_label IS NOT NULL THEN
4133
4134 --first, derive both, revision id and revision label/code
4135 --from available parameter
4136 IF l_revision_id IS NOT NULL THEN
4137
4138 FOR r in c_get_revision_label(p_inventory_item_id,
4139 p_organization_id,
4140 l_revision_id) LOOP
4141 l_revision_label := r.revision;
4142 l_effective_date := r.effectivity_date;
4143 l_rev_end_date := r.end_date;
4144 END LOOP;
4145
4146 ELSE
4147 FOR r in c_get_revision_id(p_inventory_item_id,
4148 p_organization_id,
4149 l_revision_label) LOOP
4150 l_revision_id := r.revision_id;
4151 l_effective_date := r.effectivity_date;
4152 l_rev_end_date := r.end_date;
4153 END LOOP;
4154 END IF;
4155
4156 --debugging statement remove
4157 --INSERT INTO emt_temp (Session_id, message)
4158 -- values (-1, 'l_revision_label:' || l_revision_label);
4159 --INSERT INTO emt_temp (Session_id, message)
4160 -- values (-1, 'l_revision_id:' || l_revision_id);
4161 --INSERT INTO emt_temp (Session_id, message)
4162 -- values (-1, 'l_effective_date:' || l_effective_date);
4163 --INSERT INTO emt_temp (Session_id, message)
4164 -- values (-1, 'l_rev_end_date:' || l_rev_end_date);
4165 --
4166
4167 --once we have both, revision ID and revision label
4168 IF l_revision_id IS NOT NULL and l_revision_label IS NOT NULL THEN
4169
4170 --if revision date was not provided, assume effectivity
4171 --date as explosion date
4172 IF l_rev_date IS NULL THEN
4173 l_rev_date := l_effective_date;
4174 ELSE
4175 --if revision date was provided, validate
4176 IF l_rev_date > l_effective_date THEN
4177
4178 IF l_rev_date < l_rev_end_date THEN
4179 --rev date is ok, use only revision date
4180 --and not revision id
4181 l_revision_id := NULL;
4182 ELSE
4183 --revision date is greater than end date,
4184 --force it to be effectivity date
4185 l_rev_date := l_effective_date;
4186 END IF;
4187
4188 ELSE
4189 --if revision date is before the effectivity date
4190 --force it to be equal to effectivity date
4191 l_rev_date := l_effective_date;
4192 END IF;
4193
4194
4195
4196 END IF;
4197
4198 ELSE
4199
4200 --if either revision id or revision code/label are null,
4201 --then error out
4202 IF l_revision_id IS NOT NULL THEN
4203 raise_application_error(-20104, 'Invalid Revision Id');
4204 ELSE
4205 raise_application_error(-20100, 'Invalid Revision Code/Label');
4206 END IF;
4207
4208 END IF;
4209
4210
4211 --if user did not provide revision id or code/label
4212 --ELSE for IF p_revision_id IS NOT NULL OR p_rev_label IS NOT NULL THEN
4213 ELSE
4214
4215 --if user provided explosion_date, validate it
4216 IF l_rev_date IS NOT NULL THEN
4217
4218
4219 --revision date has already been validated, maybe next
4220 --validation is not required?
4221 NULL;
4222 --validate revision_date
4223 --Validate_revision_date(p_rev_date => to_char(l_rev_date),
4224 -- p_inventory_item_id => p_inventory_item_id,
4225 -- p_organization_id => p_organization_id,
4226 -- x_rev_date => l_rev_date);
4227
4228 --if user did not provide explosion_date, revision id or revision code,
4229 --assume explosion date is today's date
4230 ELSE
4231 l_rev_date := sysdate;
4232
4233 END IF;
4234
4235 END IF;
4236
4237
4238 if ((revisionId != null) || (revision != null)) {
4239 RevisionVVOImpl revVO = getRevisionVVO();
4240 //Date[] rev_date = null;
4241 whereClause =
4242 "(organization_id = :1) and (inventory_item_id = :2)";
4243
4244 if (revisionId != null) {
4245 whereClause = whereClause + " and revision_id = :3 ";
4246 //" (organization_id = :1) and (inventory_item_id = :2) and (revision_id = :3)";
4247 revVO.setWhereClause(whereClause.toString());
4248 revVO.setWhereClauseParam(0, organizationId);
4249 revVO.setWhereClauseParam(1, inventoryItemId);
4250 revVO.setWhereClauseParam(2, revisionId);
4251 } else {
4252 if (revision != null) {
4253 whereClause = whereClause + " and revision = :3 ";
4254 revVO.setWhereClause(whereClause.toString());
4255 revVO.setWhereClauseParam(0, organizationId);
4256 revVO.setWhereClauseParam(1, inventoryItemId);
4257 revVO.setWhereClauseParam(2, revision);
4258 }
4259 }
4260 revVO.executeQuery();
4261 RevisionVVORowImpl revVORow = (RevisionVVORowImpl)revVO.first();
4262 if (revVORow != null) {
4263 if (revisionId == null)
4264 revisionId = revVORow.getRevisionId();
4265
4266 if (revision == null)
4267 revision = revVORow.getRevision();
4268
4269 Date effectiveDate = revVORow.getEffectivityDate();
4270 Date revisionEndDate = revVORow.getEndDate();
4271
4272 if (revisionDate == null) {
4273 revisionDate = effectiveDate;
4274 }
4275 else {
4276 if ((revisionDate.compareTo(effectiveDate) == 1)) {
4277 if (revisionDate.compareTo(revisionEndDate) != -1) {
4278 revisionDate = effectiveDate;
4279 } else {
4280 revisionId = null;
4281 }
4282 } else {
4283 revisionDate = effectiveDate;
4284 }
4285 }
4286
4287 } else {
4288 if (revisionId != null) {
4289 throw new OAException("EGO", "EGO_ITEM_SVC_INCORRECT_REV_ID");
4290 } else {
4291 throw new OAException("EGO", "EGO_ITEM_SVC_INCORRECT_REV");
4292 }
4293 }
4294
4295 }
4296
4297 //End of if(revisionId != null || revisionLabel != null)
4298 else {
4299 if (revisionDate != null) {
4300 //Perform validations on revision date and throw error if not valid.
4301 validateRevisionDate(organizationId, inventoryItemId, revisionDate);
4302 } else {
4303 revisionDate = txn.getCurrentUserDate();
4304 }
4305 }
4306
4307 if (txn.isLoggingEnabled(OAFwkConstants.STATEMENT)) {
4308 txn.writeDiagnostics(this, "Validated revision",
4309 OAFwkConstants.STATEMENT);
4310 txn.writeDiagnostics(this, "revisionId " + revisionId,
4311 OAFwkConstants.STATEMENT);
4312 txn.writeDiagnostics(this, "revision " + revisionId,
4313 OAFwkConstants.STATEMENT);
4314 txn.writeDiagnostics(this, "revisionDate " + revisionId,
4315 OAFwkConstants.STATEMENT);
4316
4317 }
4318
4319
4320
4321 RETURN l_rev_date;
4322
4323 END Compute_Revision_Date;*/
4324
4325
4326 /*
4327 PROCEDURE Check_Publish_Privilege(p_session_id IN NUMBER)
4328 IS
4329
4330 l_sec_predicate VARCHAR2(32767);
4331 l_dynamic_update_sql VARCHAR2(32767);
4332 l_dynamic_sql VARCHAR2(32767);
4333 l_item_id NUMBER;
4334 l_org_id NUMBER;
4335 l_rev_id NUMBER;
4336 p_priv_check VARCHAR2(100);
4337 x_return_status VARCHAR2(100);
4338
4339 BEGIN
4340
4341 --debugging statement remove
4342 -- INSERT INTO emt_temp (Session_id, message)
4343 -- values (p_session_id, 'Entering Check_Publish_Privilege ');
4344
4345
4346 p_priv_check := 'EGO_PUBLISH_ITEM';
4347
4348 --dbms_output.put_line(' calling EGO_DATA_SECURITY.get_security_predicat ');
4349 EGO_DATA_SECURITY.get_security_predicate
4350 (p_api_version => 1.0
4351 ,p_function => p_priv_check -- 'EGO_VIEW_ITEM'
4352 ,p_object_name => 'EGO_ITEM'
4353 ,p_user_name => 'HZ_PARTY:'||TO_CHAR(FND_GLOBAL.PARTY_ID) --FND_GLOBAL.PARTY_ID --'HZ_PARTY:'||TO_CHAR(G_PARTY_ID)
4354 ,p_statement_type => 'EXISTS'
4355 ,p_pk1_alias => 'i.pk1_value'
4356 ,p_pk2_alias => 'i.pk2_value'
4357 ,p_pk3_alias => NULL
4358 ,p_pk4_alias => NULL
4359 ,p_pk5_alias => NULL
4360 ,x_predicate => l_sec_predicate
4361 ,x_return_status => x_return_status );
4362
4363
4364 --INSERT INTO emt_temp (Session_id, message)
4365 -- values (p_session_id, 'x_return_status: ' || x_return_status);
4366
4367 --INSERT INTO emt_temp (Session_id, message)
4368 -- values (p_session_id, 'p_user_name: ' || 'HZ_PARTY:'||TO_CHAR(FND_GLOBAL.PARTY_ID));
4369
4370 --debugging statement remove
4371 -- INSERT INTO emt_temp (Session_id, message)
4372 -- values (p_session_id, 'l_sec_predicate: ' || l_sec_predicate);
4373
4374
4375 IF x_return_status IN ('T','F') THEN
4376
4377 IF l_sec_predicate IS NOT NULL THEN
4378
4379 l_dynamic_sql := ' select pk1_value, pk2_value, pk3_value ' ||
4380 ' from EGO_ODI_WS_ENTITIES i ' ||
4381 ' where i.session_id = :1 ' ||
4382 ' AND nvl(i.REF1_VALUE, ''Y'') = ''Y'' ' ||
4383 ' AND NOT ' || l_sec_predicate;
4384
4385 --debugging statement remove
4386 -- INSERT INTO emt_temp (Session_id, message)
4387 -- values (p_session_id, 'sql: ' || l_dynamic_sql);
4388
4389 END IF;
4390
4391 END IF;
4392
4393
4394 END Check_Publish_Privilege;
4395 */
4396
4397
4398 /*This procedure is in charge of exploding the second level of an ICC structure.
4399 In concrete, this procedure performe the following actions:
4400 1. Finds all the first level components of the ICC-Structure that have been
4401 previously retrieved by the EGO_GETICCSTRUCTURE ODI Package
4402 2. loops through the first level components and identifies which ones
4403 are of type OPTION_CLASS
4404 3. ODI_SESSION_ID un table EGO_PUB_WS_CONFIG (that contains parameters to
4405 execute ODI scenario as subroutine) is set to -1 to avoid conflicts
4406 with ODI main scenario invoking ODI scenario as subroutine while
4407 reading input parameters.
4408 */
4409 PROCEDURE Explode_ICC_Structure(p_session_id IN NUMBER,
4410 p_odi_session_id IN NUMBER)
4411 IS
4412
4413 l_mode VARCHAR(100);
4414 l_application_id NUMBER;
4415 l_responsibility_id NUMBER;
4416 l_user_id NUMBER;
4417 l_batch_id NUMBER;
4418 l_batch_size NUMBER :=0;
4419
4420 --for security
4421 l_fnd_user_name VARCHAR2(100);
4422 l_responsibility_name VARCHAR2(100);
4423 l_responsibility_appl_name VARCHAR2(100);
4424 l_security_group_name VARCHAR2(100);
4425
4426 l_session_id NUMBER := p_session_id;
4427 l_inventory_item_id NUMBER;
4428 l_organization_id NUMBER;
4429 l_revision_id NUMBER;
4430 l_structure_name VARCHAR2(100) := 'Flow';
4431
4432 --component revisions information
4433 l_comp_rev VARCHAR2(100);
4434 l_comp_rev_id NUMBER;
4435 l_comp_rev_label VARCHAR2(100);
4436 l_comp_parent_rev VARCHAR2(100);
4437 l_comp_rev_high_date DATE;
4438
4439 --x_rev_date DATE;
4440 --x_rev_id NUMBER;
4441 l_valid BOOLEAN;
4442
4443
4444 --bom explosion configurability
4445 l_levels_to_explode NUMBER;
4446 l_explode_option NUMBER;
4447 l_explode_standard VARCHAR2(10);
4448 l_ordered_by NUMBER :=1;
4449
4450 x_err_msg VARCHAR2(1000);
4451 x_error_code NUMBER;
4452 x_group_id NUMBER :=654;
4453 x_return_status VARCHAR2(1);
4454
4455 --l_item_information VARCHAR2(1000);
4456
4457 --array to store single_value parameter names
4458 TYPE parameter_name_array_type IS VARRAY(15) OF VARCHAR2(1000);
4459 l_parameter_name_array parameter_name_array_type;
4460
4461 --array to store single_value parameter names
4462 TYPE parameter_value_array_type IS VARRAY(15) OF VARCHAR2(1000);
4463 l_parameter_value_array parameter_value_array_type;
4464
4465
4466 --cursor to retrieve the all 1st level components generated by executing
4467 --the EGO_GETICCSTRUCTURE ODI Package
4468 cursor c_first_level_components(p_session_id NUMBER, p_odi_session_id NUMBER) is
4469 select parent_sequence_id,
4470 pk1_value,
4471 ref1_value, /*BOM_ITEM_TYPE*/
4472 ref2_value, /*INVENTORY_ITEM_ID*/
4473 ref3_value, /*ORGANIZATION_ID*/
4474 ref4_value, /*REVISION_ID*/
4475 ref5_value, /*STRUCTURE_TYPE*/
4476 ref6_value /*STRUCTURE_NAME*/
4477 from EGO_PUB_WS_FLAT_RECS
4478 where session_id = p_session_id
4479 and odi_session_id = p_odi_session_id
4480 and entity_type = 'ICCSH_COMP';
4481
4482
4483 BEGIN
4484
4485
4486 --looping through all the components found for the end-item during the
4487 --bom explosion procedure to record their current revision and revision_id
4488 for comp_rec in c_first_level_components(p_session_id, p_odi_session_id)
4489 loop
4490
4491 --If Component is of type OPTION_CLASS (BOM_ITEM_TYPE=2), then
4492 -- execute getItemStructure web service for current item
4493 IF comp_rec.ref1_value = '2' THEN
4494
4495 l_batch_size := l_batch_size + 1;
4496
4497 --Generating concatenated string containing information for which the structure will be published
4498 --FORMAT: INVENTORY_ITEM_ID, ORGANIZATION_ID, REVISION_ID, STRUCTURE_TYPE, STRUCTURE_NAME
4499 --l_item_information := comp_rec.ref2_value || ',' || comp_rec.ref3_value || ',' || comp_rec.ref4_value || ',' || comp_rec.ref5_value || ',' || comp_rec.ref6_value;
4500
4501 --INSERT NEW PARAMETER INVENTORY_ITEM_ID IN EGO_PUB_WS_CONFIG
4502 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4503 odi_session_id,
4504 Parameter_Name,
4505 Data_Type,
4506 Char_value,
4507 creation_date,
4508 created_by,
4509 web_service_name)
4510 VALUES (p_session_id,
4511 -1,
4512 'INVENTORY_ITEM_ID_' || l_batch_size,
4513 2,
4514 comp_rec.ref2_value,
4515 sysdate,
4516 0,
4517 'GET_ITEM_STRUCTURE');
4518
4519 --INSERT NEW PARAMETER ORGANIZATION_ID IN EGO_PUB_WS_CONFIG
4520 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4521 odi_session_id,
4522 Parameter_Name,
4523 Data_Type,
4524 Char_value,
4525 creation_date,
4526 created_by,
4527 web_service_name)
4528 VALUES (p_session_id,
4529 -1,
4530 'ORGANIZATION_ID_' || l_batch_size,
4531 2,
4532 comp_rec.ref3_value,
4533 sysdate,
4534 0,
4535 'GET_ITEM_STRUCTURE');
4536
4537 --INSERT NEW PARAMETER REVISION_ID IN EGO_PUB_WS_CONFIG
4538 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4539 odi_session_id,
4540 Parameter_Name,
4541 Data_Type,
4542 Char_value,
4543 creation_date,
4544 created_by,
4545 web_service_name)
4546 VALUES (p_session_id,
4547 -1,
4548 'REVISION_ID_' || l_batch_size,
4549 2,
4550 comp_rec.ref4_value,
4551 sysdate,
4552 0,
4553 'GET_ITEM_STRUCTURE');
4554
4555 --INSERT NEW PARAMETER STRUCTURE_NAME IN EGO_PUB_WS_CONFIG
4556 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4557 odi_session_id,
4558 Parameter_Name,
4559 Data_Type,
4560 Char_value,
4561 creation_date,
4562 created_by,
4563 web_service_name)
4564 VALUES (p_session_id,
4565 -1,
4566 'STRUCTURE_NAME_' || l_batch_size,
4567 2,
4568 comp_rec.ref6_value,
4569 sysdate,
4570 0,
4571 'GET_ITEM_STRUCTURE');
4572
4573
4574 --INSERT NEW PARAMETER ROOT_NODE_ID IN EGO_PUB_WS_CONFIG
4575 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4576 odi_session_id,
4577 Parameter_Name,
4578 Data_Type,
4579 Char_value,
4580 creation_date,
4581 created_by,
4582 web_service_name)
4583 VALUES (p_session_id,
4584 -1,
4585 'ROOT_NODE_ID_' || l_batch_size,
4586 2,
4587 comp_rec.parent_sequence_id,
4588 sysdate,
4589 0,
4590 'GET_ITEM_STRUCTURE');
4591
4592 END IF;
4593
4594
4595 end loop; --end for all 1st level components
4596
4597
4598 --If we need to explode the bom at least for one of the first level components
4599 --then generate parameters to execute EGO_GETITEMSTRUCTURE web service as a
4600 --subroutine (this only happens if at least one first level component is of type
4601 --OPTION_CLASS)
4602 IF l_batch_size > 0 THEN
4603
4604
4605 --Create parameter names
4606 l_parameter_name_array := parameter_name_array_type('MODE',
4607 'PUBLISH_REVISIONS',
4608 'PUBLISH_STRUCT_AGS',
4609 'PUBLISH_COMPONENTS',
4610 'PUBLISH_COMP_REF',
4611 'PUBLISH_COMP_SUBS',
4612 'PUBLISH_COMP_AGS',
4613 'LEVELS_TO_EXPLODE',
4614 'EXPLODE_OPTION',
4615 'EXPLODE_STD_BOM',
4616 'RETURN_PAYLOAD',
4617 'PUBLISH_COMP_OVR_AGS',
4618 'PUBLISH_COMP_EXCLUSIONS',
4619 'PUBLISH_VS_EXCLUSIONS'
4620 );
4621
4622 --Create parameter values
4623 l_parameter_value_array := parameter_value_array_type('SUBROUTINE', --MODE
4624 'Y', --PUBLISH_REVISIONS
4625 'N', --PUBLISH_STRUCT_AGS
4626 'Y', --PUBLISH_COMPONENTS
4627 'N', --PUBLISH_COMP_REF
4628 'N', --PUBLISH_COMP_SUBS
4629 'Y', --PUBLISH_COMP_AGS
4630 '1', --LEVELS_TO_EXPLODE
4631 '2', --EXPLODE_OPTION
4632 'Y', --EXPLODE_STD_BOM
4633 'Y', --RETURN_PAYLOAD
4634 'N', --PUBLISH_COMP_OVR_AGS
4635 'N', --PUBLISH_COMP_EXCLUSIONS
4636 'N' --PUBLISH_VS_EXCLUSIONS
4637 );
4638
4639
4640
4641 FOR position IN 1..l_parameter_name_array.COUNT
4642 LOOP
4643
4644 --INSERTING PARAMETER NAME AND VALUE IN EGO_PUB_WS_CONFIG
4645 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4646 odi_session_id,
4647 Parameter_Name,
4648 Data_Type,
4649 Char_value,
4650 creation_date,
4651 created_by,
4652 web_service_name)
4653 VALUES (p_session_id,
4654 -1,
4655 l_parameter_name_array(position),
4656 2,
4657 l_parameter_value_array(position),
4658 sysdate,
4659 0,
4660 'GET_ITEM_STRUCTURE');
4661
4662 END LOOP;
4663
4664 --retrieving and storing FND_USER_NAME
4665 select fnd_user_name
4666 into l_fnd_user_name
4667 from EGO_PUB_WS_PARAMS
4668 where session_id = p_session_id;
4669
4670 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4671 odi_session_id,
4672 Parameter_Name,
4673 Data_Type,
4674 Char_value,
4675 creation_date,
4676 created_by,
4677 web_service_name)
4678 VALUES (p_session_id,
4679 -1,
4680 'FND_USER_NAME',
4681 2,
4682 l_fnd_user_name,
4683 sysdate,
4684 0,
4685 'GET_ITEM_STRUCTURE');
4686
4687 --retrieving and storing RESPONSIBILITY_NAME
4688 select responsibility_name
4689 into l_responsibility_name
4690 from EGO_PUB_WS_PARAMS
4691 where session_id = p_session_id;
4692
4693 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4694 odi_session_id,
4695 Parameter_Name,
4696 Data_Type,
4697 Char_value,
4698 creation_date,
4699 created_by,
4700 web_service_name)
4701 VALUES (p_session_id,
4702 -1,
4703 'RESPONSIBILITY_NAME',
4704 2,
4705 l_responsibility_name,
4706 sysdate,
4707 0,
4708 'GET_ITEM_STRUCTURE');
4709
4710
4711 --retrieving and storing RESPONSIBILITY_APPL_NAME
4712 select responsibility_appl_name
4713 into l_responsibility_appl_name
4714 from EGO_PUB_WS_PARAMS
4715 where session_id = p_session_id;
4716
4717 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4718 odi_session_id,
4719 Parameter_Name,
4720 Data_Type,
4721 Char_value,
4722 creation_date,
4723 created_by,
4724 web_service_name)
4725 VALUES (p_session_id,
4726 -1,
4727 'RESPONSIBILITY_APPL_NAME',
4728 2,
4729 l_responsibility_appl_name,
4730 sysdate,
4731 0,
4732 'GET_ITEM_STRUCTURE');
4733
4734
4735 --retrieving and storing SECURITY_GROUP_NAME
4736 select security_group_name
4737 into l_security_group_name
4738 from EGO_PUB_WS_PARAMS
4739 where session_id = p_session_id;
4740
4741 INSERT INTO EGO_PUB_WS_CONFIG (session_id,
4742 odi_session_id,
4743 Parameter_Name,
4744 Data_Type,
4745 Char_value,
4746 creation_date,
4747 created_by,
4748 web_service_name)
4749 VALUES (p_session_id,
4750 -1,
4751 'SECURITY_GROUP_NAME',
4752 2,
4753 l_security_group_name,
4754 sysdate,
4755 0,
4756 'GET_ITEM_STRUCTURE');
4757
4758 /*Other parameters: Insert based in the values for ICC web service
4759 LANGUAGE_CODE
4760 LANGUAGE_CODE
4761 HEADER_AG_NAME
4762 (pass value of corresponding ICC node here)
4763 */
4764
4765 --Inserts language options in Config table
4766 Config_Languages(p_session_id,
4767 -1,
4768 '',
4769 'GET_ITEM_STRUCTURE');
4770
4771
4772 END IF; --IF l_batch_size > 0 THEN
4773
4774
4775 END Explode_ICC_Structure;
4776
4777
4778
4779
4780 PROCEDURE Explode_BOM_Structure(p_session_id IN NUMBER,
4781 p_odi_session_id IN NUMBER)
4782 IS
4783
4784 l_mode VARCHAR(100);
4785 l_application_id NUMBER;
4786 l_responsibility_id NUMBER;
4787 l_user_id NUMBER;
4788 l_batch_id NUMBER;
4789
4790 l_session_id NUMBER := p_session_id;
4791 l_inventory_item_id NUMBER;
4792 l_organization_id NUMBER;
4793 l_revision_id NUMBER;
4794 l_structure_name VARCHAR2(100) := 'Flow';
4795
4796 --component revisions information
4797 l_comp_rev VARCHAR2(100);
4798 l_comp_rev_id NUMBER;
4799 l_comp_rev_label VARCHAR2(100);
4800 l_comp_parent_rev VARCHAR2(100);
4801 l_comp_rev_high_date DATE;
4802
4803 --x_rev_date DATE;
4804 --x_rev_id NUMBER;
4805 l_valid BOOLEAN;
4806
4807
4808 --bom explosion configurability
4809 l_levels_to_explode NUMBER;
4810 l_explode_option NUMBER;
4811 l_explode_standard VARCHAR2(10);
4812 l_ordered_by NUMBER :=1;
4813
4814 x_err_msg VARCHAR2(1000);
4815 x_error_code NUMBER;
4816 x_group_id NUMBER :=654;
4817 x_return_status VARCHAR2(1);
4818
4819 CURSOR c_odi_end_items(p_session_id NUMBER, p_odi_session_id NUMBER) IS
4820 SELECT session_id,
4821 odi_session_id,
4822 ITEM_ID,
4823 ITEM_ORG_ID,
4824 ITEM_REV,
4825 ITEM_REV_CODE,
4826 structure_name,
4827 explosion_date,
4828 sequence_number
4829 FROM BOM_ODI_WS_ENTITIES
4830 WHERE session_id = p_session_id
4831 and odi_session_id = p_odi_session_id
4832 and PUBLISH_FLAG = 'Y';
4833
4834 --cursor to retrieve the components generated during the bom explosion for
4835 --a given end-item
4836 cursor c_components(p_group_id NUMBER) is
4837 select rowid row_id,
4838 component_sequence_id,
4839 comp_fixed_revision_id,
4840 parent_comp_seq_id
4841 from bom_explosions_all be
4842 where group_id = p_group_id;
4843
4844
4845 BEGIN
4846
4847 --Initialize FND security
4848 Init_Security_Structure(p_session_id, p_odi_session_id);
4849
4850 --Check on the publish privilege for the end-items.
4851 --If end-item has no publish privilege, then remove end-item
4852 --from BOM_ODI_WS_ENTITIES table.
4853 check_end_item_security(p_session_id => p_session_id,
4854 p_odi_session_id => p_odi_session_id,
4855 p_priv_check => 'EGO_PUBLISH_ITEM',
4856 p_for_exploded_items => 'Y',
4857 x_return_status => x_return_status
4858 );
4859
4860
4861 --READ CONFIGURABILITY OPTIONS FOR BOM EXPLOSION
4862 --reading levels to explode
4863 select to_number(char_value)
4864 into l_levels_to_explode
4865 from EGO_PUB_WS_CONFIG
4866 where session_id = p_session_id
4867 and web_service_name = 'GET_ITEM_STRUCTURE'
4868 and parameter_name = 'LEVELS_TO_EXPLODE';
4869
4870 --Temporary workaround for bug 8768551. The following
4871 --if statement must be deleted once bug is fixed
4872 --IF l_levels_to_explode = 60 THEN
4873 -- l_levels_to_explode := '61';
4874 --END IF;
4875
4876 --reading explode_option
4877 select to_number(char_value)
4878 into l_explode_option
4879 from EGO_PUB_WS_CONFIG
4880 where session_id = p_session_id
4881 and web_service_name = 'GET_ITEM_STRUCTURE'
4882 and parameter_name = 'EXPLODE_OPTION';
4883
4884 --reading EXPLODE_STD_BOM
4885 select char_value
4886 into l_explode_standard
4887 from EGO_PUB_WS_CONFIG
4888 where session_id = p_session_id
4889 and web_service_name = 'GET_ITEM_STRUCTURE'
4890 and parameter_name = 'EXPLODE_STD_BOM';
4891
4892
4893 --EXPLODE BOM FOR ALL END ITEMS WITH PUBLISH PRIVILEGE
4894 --looping through all user selected end-items in the batch
4895 FOR r in c_odi_end_items(p_session_id, p_odi_session_id) LOOP
4896
4897 --computing explosion_date or revision_date
4898 /*l_valid := EGO_ITEM_WS_PVT.validate_revision_details(p_session_id => p_session_id,
4899 p_odi_session_id => p_odi_session_id,
4900 p_inv_id => r.ITEM_ID,
4901 p_org_id => r.ITEM_ORG_ID,
4902 p_rev_id => r.ITEM_REV,
4903 p_revision => r.ITEM_REV_CODE,
4904 p_rev_date => r.explosion_date,
4905 p_index => 1,
4906 p_revision_id => x_rev_id,
4907 p_revision_date => x_rev_date);
4908
4909 */
4910
4911 --debugging statement remove
4912 /*INSERT INTO emt_temp (Session_id, message)
4913 values (p_session_id, 'Inside bom explosion code');
4914 INSERT INTO emt_temp (Session_id, message)
4915 values (p_session_id, 'provided revision code' || r.ITEM_REV_CODE);
4916 INSERT INTO emt_temp (Session_id, message)
4917 values (p_session_id, 'provided revision id:' || r.ITEM_REV);
4918 INSERT INTO emt_temp (Session_id, message)
4919 values (p_session_id, 'provided revision date:' || r.explosion_date);
4920 INSERT INTO emt_temp (Session_id, message)
4921 values (p_session_id, 'computed revision date:' || x_rev_date);
4922 INSERT INTO emt_temp (Session_id, message)
4923 values (p_session_id, 'computed revision_id :' || x_rev_id);
4924 --delete, for debugging only
4925 INSERT INTO emt_temp (Session_id, message)
4926 values (p_session_id, ' l_levels_to_explode: ' || l_levels_to_explode);
4927 INSERT INTO emt_temp (Session_id, message)
4928 values (p_session_id, ' l_explode_option: ' || l_explode_option);
4929 INSERT INTO emt_temp (Session_id, message)
4930 values (p_session_id, ' l_explode_standard: ' || l_explode_standard);
4931 */
4932
4933 --inserted
4934 --explosion_api originally utilized in H-MDM
4935 /*Bom_exploder_pub.Exploder_Userexit(Org_Id => r.ITEM_ORG_ID,
4936 rev_date => x_rev_date,
4937 order_by => l_ordered_by,
4938 Levels_To_Explode => l_levels_to_explode,
4939 alt_desg => r.structure_name,
4940 Error_Code => x_error_code,
4941 Err_Msg => x_err_msg,
4942 explode_option => l_explode_option,
4943 --std_bom_explode_flag => l_explode_standard,
4944 Grp_Id => x_group_id,
4945 pk_value1 => r.ITEM_ID,
4946 pk_value2 => r.ITEM_ORG_ID,
4947 end_item_revision_id => x_rev_id,
4948 p_autonomous_transaction => 1,
4949 end_item_id => r.ITEM_ID,
4950 bom_or_eng => 1
4951 );
4952 */
4953
4954 --New explosion API suggested by Bushan and Naveen for Item Service
4955 Bom_exploder_pub.Exploder_Userexit(Org_Id => r.ITEM_ORG_ID,
4956 rev_date => r.explosion_date,
4957 order_by => l_ordered_by,
4958 Levels_To_Explode => l_levels_to_explode,
4959 impl_flag => 1, /* 1 - Imp Only, 2 - imp and unimpl */
4960 alt_desg => r.structure_name,
4961 Error_Code => x_error_code,
4962 Err_Msg => x_err_msg,
4963 explode_option => l_explode_option,
4964 std_bom_explode_flag => l_explode_standard,
4965 Grp_Id => x_group_id,
4966 pk_value1 => r.ITEM_ID,
4967 pk_value2 => r.ITEM_ORG_ID,
4968 --p_autonomous_transaction => 1,
4969 --end_item_id => r.ITEM_ID,
4970 bom_or_eng => 2, /* 1- BOM , 2 - ENG */
4971 material_ctrl => 1
4972 );
4973
4974
4975 IF x_error_code IS NOT NULL THEN
4976 --dbms_output.put_line('Error code is : '|| x_error_code);
4977 --dbms_output.put_line('Error mesg is : '|| x_err_msg);
4978 --dbms_output.put_line('Error mesg is : '|| SQLERRM);
4979 --delete, debugging only
4980 /*INSERT INTO emt_temp (Session_id, message)
4981 values (p_session_id, 'Error code is : ' || x_error_code);
4982 INSERT INTO emt_temp (Session_id, message)
4983 values (p_session_id, 'Error mesg is : ' || x_err_msg);
4984 */
4985 NULL;
4986 END IF;
4987
4988 UPDATE BOM_ODI_WS_ENTITIES
4989 SET group_id = x_group_id,
4990 EXPLOSION_DATE = bom_exploder_pub.get_explosion_date,
4991 EXPLOSION_OPTION = bom_exploder_pub.get_explode_option,
4992 ITEM_REV_CODE = bom_exploder_pub.get_expl_end_item_rev_code,
4993 ITEM_UNIT_NUMBER = bom_exploder_pub.get_expl_unit_number
4994 WHERE session_id = r.session_id
4995 AND odi_session_id = r.odi_session_id
4996 AND ITEM_ID = r.ITEM_ID
4997 AND ITEM_ORG_ID = r.ITEM_ORG_ID
4998 AND ITEM_REV = r.ITEM_REV;
4999
5000
5001 --looping through all the components found for the end-item during the
5002 --bom explosion procedure to record their current revision and revision_id
5003 for comp_rec in c_components(x_group_id)
5004 loop
5005
5006 --delete, debugging only
5007 /*INSERT INTO emt_temp (Session_id, message)
5008 values (p_session_id, 'comp_rec.component_sequence_id: ' || comp_rec.component_sequence_id);
5009 INSERT INTO emt_temp (Session_id, message)
5010 values (p_session_id, 'bom_exploder_pub.get_explosion_date: ' || bom_exploder_pub.get_explosion_date);
5011 INSERT INTO emt_temp (Session_id, message)
5012 values (p_session_id, 'bom_exploder_pub.get_expl_end_item_rev_code: ' || bom_exploder_pub.get_expl_end_item_rev_code);
5013 INSERT INTO emt_temp (Session_id, message)
5014 values (p_session_id, 'comp_rec.comp_fixed_revision_id: ' || comp_rec.comp_fixed_revision_id);
5015 INSERT INTO emt_temp (Session_id, message)
5016 values (p_session_id, 'comp_rec.parent_comp_seq_id: ' || comp_rec.parent_comp_seq_id);
5017 */
5018
5019 IF comp_rec.component_sequence_id IS NOT NULL THEN
5020 l_comp_rev := bom_exploder_pub.get_component_revision(comp_rec.component_sequence_id);
5021 l_comp_rev_id := bom_exploder_pub.get_component_revision_id(comp_rec.component_sequence_id);
5022 l_comp_rev_label := bom_exploder_pub.get_component_revision_label(comp_rec.component_sequence_id);
5023 ELSE
5024 l_comp_rev := NULL;
5025 l_comp_rev_id :=NULL;
5026 l_comp_rev_label :=NULL;
5027 END IF;
5028
5029 IF comp_rec.comp_fixed_revision_id IS NOT NULL THEN
5030 l_comp_rev_high_date := bom_exploder_pub.get_revision_highdate(comp_rec.comp_fixed_revision_id);
5031 ELSE
5032 l_comp_rev_high_date :=NULL;
5033 END IF;
5034
5035 IF comp_rec.parent_comp_seq_id IS NOT NULL THEN
5036 l_comp_parent_rev := bom_exploder_pub.get_component_revision(comp_rec.parent_comp_seq_id);
5037 ELSE
5038 l_comp_parent_rev :=NULL;
5039 END IF;
5040
5041 INSERT
5042 INTO bom_odi_ws_revisions(
5043 session_id,
5044 --group_id,
5045 --component_sequence_id,
5046 row_id,
5047 revision,
5048 revision_id,
5049 revision_label,
5050 revision_high_date,
5051 parent_revision,
5052 PUBLISH_FLAG,
5053 CREATION_DATE,
5054 CREATED_BY)
5055 VALUES(
5056 l_session_id,
5057 --x_group_id,
5058 --comp_rec.component_sequence_id,
5059 comp_rec.row_id,
5060 l_comp_rev,
5061 l_comp_rev_id,
5062 l_comp_rev_label,
5063 l_comp_rev_high_date,
5064 l_comp_parent_rev,
5065 'Y',
5066 sysdate,
5067 0);
5068
5069 end loop; --end for all components
5070
5071 --Check on the publish privilege for all components of the
5072 --just exploded end-item. If any component has no publish
5073 --privilege, then set PUBLISH_FLAG = N for end-item
5074 --to prevent its publication.
5075 check_component_security(p_session_id => p_session_id,
5076 p_odi_session_id => p_odi_session_id,
5077 p_priv_check => 'EGO_PUBLISH_ITEM',
5078 p_group_id => x_group_id,
5079 p_input_identifier => r.sequence_number,
5080 p_inv_item_id => r.ITEM_ID,
5081 p_org_id => r.ITEM_ORG_ID,
5082 p_rev_id => r.ITEM_REV,
5083 x_return_status => x_return_status);
5084
5085 END LOOP; --end for all items with publish privilege
5086
5087
5088 END Explode_BOM_Structure;
5089
5090
5091
5092 PROCEDURE Preprocess_Input_Structure(p_session_id IN NUMBER,
5093 p_odi_session_id IN NUMBER)
5094 IS
5095 BEGIN
5096
5097 --debugging statement remove
5098 /*INSERT INTO emt_temp (Session_id, message)
5099 values (p_session_id, 'Entering: Create_Params_Structure');
5100 */
5101
5102 --Create Input parameters for ODI
5103 Create_Params_Structure(p_session_id, p_odi_session_id);
5104
5105 --debugging statement remove
5106 /*INSERT INTO emt_temp (Session_id, message)
5107 values (p_session_id, 'Entering: Create_Entities_Structure' );
5108 */
5109
5110 --Create ODI Input table containing entities to process
5111 Create_Entities_Structure(p_session_id, p_odi_session_id);
5112
5113 --debugging statement remove
5114 /*INSERT INTO emt_temp (Session_id, message)
5115 values (p_session_id, 'Entering: Explode_BOM_Structure ' );
5116 */
5117
5118 --Explode BOM for all end-items selected
5119 Explode_BOM_Structure(p_session_id, p_odi_session_id);
5120
5121 END Preprocess_Input_Structure;
5122
5123
5124
5125
5126 --This function reads the ODI output XML from table EGO_PUB_WS_OUTPUT using
5127 --the provided session_id and transforms it using the XSL information stored
5128 --in table EGO_ODI_WS_XSL and pointed by the web service name specified.
5129 --The function returns the transformed XML into a clob variable.
5130 FUNCTION Transform_XML(p_xml_input IN CLOB,
5131 p_web_service_name IN VARCHAR2)
5132 RETURN XmlType
5133 IS
5134
5135 indoc VARCHAR2(2000);
5136 xsldoc VARCHAR2(2000);
5137 myParser dbms_xmlparser.Parser;
5138 indomdoc dbms_xmldom.domdocument;
5139 xsltdomdoc dbms_xmldom.domdocument;
5140 xsl dbms_xslprocessor.stylesheet;
5141 outdomdocf dbms_xmldom.domdocumentfragment;
5142 outnode dbms_xmldom.domnode;
5143 proc dbms_xslprocessor.processor;
5144 buf varchar2(2000);
5145 xmlclob clob;
5146 xslclob clob;
5147 outclob clob;
5148
5149 BEGIN
5150
5151 xmlclob := p_xml_input;
5152
5153 --selecting XLS transformation data from
5154 --table EGO_ODI_WS_XSL for specified web service
5155 select x.xslcontent.getclobval()
5156 into xslclob
5157 from EGO_ODI_WS_XSL x
5158 where web_service_name = p_web_service_name;
5159
5160 myParser := dbms_xmlparser.newParser;
5161 dbms_xmlparser.parseclob(myParser, xmlclob);
5162 indomdoc := dbms_xmlparser.getDocument(myParser);
5163 dbms_xmlparser.parseclob(myParser, xslclob);
5164 xsltdomdoc := dbms_xmlparser.getDocument(myParser);
5165 xsl := dbms_xslprocessor.newstylesheet(xsltdomdoc, '');
5166 proc := dbms_xslprocessor.newProcessor;
5167
5168 --apply stylesheet to DOM document
5169 outdomdocf := dbms_xslprocessor.processxsl(proc, xsl, indomdoc);
5170 outnode := dbms_xmldom.makenode(outdomdocf);
5171
5172 DBMS_LOB.CreateTemporary(outCLOB, TRUE);
5173 dbms_xmldom.writetoclob(outnode,outclob);
5174
5175 RETURN XmlType(outclob);
5176
5177 END Transform_XML;
5178
5179
5180
5181
5182
5183 --Generates an XML payload containg the results of executing a given web service
5184 --from the data stored by the service scenario execution in table EGO_PUB_WS_FLAT_RECS.
5185 --The resulting XML payload is stored in column XMLCONTENT
5186 --of table EGO_PUB_WS_OUTPUT
5187 PROCEDURE Generate_XML(p_session_id IN NUMBER,
5188 p_odi_session_id IN NUMBER,
5189 p_web_service_name IN VARCHAR2,
5190 p_xml_root_element IN VARCHAR2,
5191 p_transform_xml IN BOOLEAN DEFAULT TRUE)
5192 IS
5193
5194 l_session_id NUMBER := p_session_id;
5195 l_odi_session_id NUMBER := p_odi_session_id;
5196 l_web_service_name VARCHAR2(100) := p_web_service_name;
5197 l_entity_type VARCHAR2(100) := NULL;
5198 l_xml CLOB;
5199
5200 l_output_xml XmlType;
5201 l_cr VARCHAR2(10) := fnd_global.local_chr(10);
5202 l_qm VARCHAR2(1) := '?'; -- Question mark in a string may be interpreted by ODI
5203
5204 l_level_stack dbms_sql.number_table;
5205 l_tags_stack dbms_sql.varchar2_table;
5206 l_previous_level NUMBER := -1;
5207 l_previous_entity_type VARCHAR2(100);
5208 l_previous_seqid NUMBER := -1;
5209 l_return_payload VARCHAR2(10) :='TRUE';
5210 l_sequence NUMBER :=1;
5211
5212 l_no_of_entities NUMBER :=0; --No of entities for a session in case of chunk
5213 l_actual_node VARCHAR2(100) :=NULL;
5214 l_end_xml VARCHAR2(100) :=NULL;
5215
5216 l_chunk_detail CLOB; --Chunking
5217 l_err_xml CLOB; --Error Handling
5218
5219 --YJAIN
5220 l_entity_type_tag EGO_PUB_WS_FLAT_RECS.ENTITY_TYPE%TYPE; -- Perf Bug : 9129863
5221 l_xml_header CLOB;
5222
5223 -- Code changes to optimize transform_xml API.
5224 xsldoc VARCHAR2(2000);
5225 myParser dbms_xmlparser.Parser;
5226 indomdoc dbms_xmldom.domdocument;
5227 xsltdomdoc dbms_xmldom.domdocument;
5228 xsl dbms_xslprocessor.stylesheet;
5229 outdomdocf dbms_xmldom.domdocumentfragment;
5230 outnode dbms_xmldom.domnode;
5231 proc dbms_xslprocessor.processor;
5232 xslclob clob;
5233 outclob clob;
5234 --YJAIN
5235
5236
5237 -- Tree query to traverse the flatten xml structurally.
5238 --Cursor to recover top parents
5239 CURSOR c_ws_data(cp_session_id NUMBER)
5240 IS
5241 SELECT SEQUENCE_ID ,
5242 PARENT_SEQUENCE_ID,
5243 LEVEL LEVEL_NUMBER,
5244 ENTITY_TYPE,
5245 Value
5246 FROM EGO_PUB_WS_FLAT_RECS
5247 WHERE session_id = cp_session_id
5248 START WITH session_id = cp_session_id AND Nvl(PARENT_SEQUENCE_ID,-1)=-1
5249 CONNECT BY PRIOR SEQUENCE_ID = PARENT_SEQUENCE_ID AND session_id = cp_session_id;
5250
5251
5252
5253 --Chunking Start--
5254 /*Cursor to get configurable parameter 'return_payload' value*/
5255 CURSOR Cur_config_param(cp_session_id NUMBER,
5256 cp_odi_session_id NUMBER)
5257 IS
5258 SELECT Upper(Nvl(CHAR_VALUE,'TRUE')) param_value
5259 FROM ego_pub_ws_config
5260 WHERE session_id = cp_session_id
5261 AND odi_session_id = cp_odi_session_id
5262 AND upper(parameter_name) = 'RETURN_PAYLOAD';
5263
5264
5265 /*Cursor to get top level entity value and sequence*/
5266 CURSOR c_ws_top_entity (cp_session_id NUMBER)
5267 IS
5268 SELECT sequence_id, parent_sequence_id, entity_type,
5269 LEVEL level_number
5270 FROM ego_pub_ws_flat_recs
5271 WHERE session_id = cp_session_id
5272 START WITH session_id = cp_session_id
5273 AND NVL (parent_sequence_id, -1) = -1
5274 AND sequence_id IN (SELECT sequence_id
5275 FROM ego_pub_ws_flat_recs
5276 WHERE session_id = cp_session_id AND NVL (parent_sequence_id, -1) = -1)
5277 CONNECT BY PRIOR sequence_id = parent_sequence_id AND session_id = cp_session_id
5278 UNION ALL
5279 SELECT -99999, NULL, 'ITEM',1
5280 FROM DUAL;
5281
5282 --YJAIN
5283 /*Cursor to get top level entity value and sequence*/
5284 CURSOR c_ws_entity_val (cp_session_id NUMBER,cp_sequence_id NUMBER,cp_parent_sequence_id NUMBER)
5285 IS
5286 SELECT Value
5287 FROM ego_pub_ws_flat_recs
5288 WHERE session_id = cp_session_id
5289 AND sequence_id = cp_sequence_id
5290 AND NVL (parent_sequence_id, -1) = NVL(cp_parent_sequence_id, -1);
5291
5292 --YJAIN
5293
5294 --Cursor to recover data based on top level entity for chunking
5295 CURSOR c_ws_data_chunk(cp_session_id NUMBER,
5296 cp_sequence_id NUMBER )
5297 IS
5298 SELECT SEQUENCE_ID ,
5299 PARENT_SEQUENCE_ID,
5300 LEVEL LEVEL_NUMBER,
5301 ENTITY_TYPE,
5302 Value
5303 FROM EGO_PUB_WS_FLAT_RECS
5304 WHERE session_id = cp_session_id
5305 START WITH session_id = cp_session_id AND Nvl(PARENT_SEQUENCE_ID,-1)=-1 AND SEQUENCE_ID=cp_sequence_id
5306 CONNECT BY PRIOR SEQUENCE_ID = PARENT_SEQUENCE_ID AND session_id = cp_session_id;
5307
5308 --START WITH session_id = cp_session_id AND Nvl(PARENT_SEQUENCE_ID,-1)=-1
5309 --CONNECT BY PRIOR SEQUENCE_ID = PARENT_SEQUENCE_ID AND session_id = cp_session_id;
5310
5311 --Chunking End--
5312
5313
5314
5315 --Start error handling
5316 CURSOR c_err_detail(cp_session_id NUMBER,
5317 cp_odi_session_id NUMBER)
5318 IS
5319 SELECT session_id,input_id, err_code,err_message
5320 FROM EGO_PUB_WS_ERRORS
5321 WHERE session_id=cp_session_id
5322 AND odi_session_id= cp_odi_session_id;
5323
5324
5325 CURSOR c_err_identifier(cp_session_id NUMBER,
5326 cp_odi_session_id NUMBER,
5327 cp_input_id NUMBER)
5328 IS
5329 SELECT session_id, param_name,param_value
5330 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
5331 WHERE session_id=cp_session_id
5332 AND odi_session_id= cp_odi_session_id
5333 AND input_id=cp_input_id;
5334
5335 --End error handling
5336
5337
5338 --EMTAPIA: Start added for bug 11831151, change sequence of xml so master items are before child items
5339 --if ordering of items as master first, child first is not required, sequence_id starts with one and
5340 --increments for each record. If master child ordering is required, then, we sort the end-items
5341 --according to this (master records first and then child records) using cursor c_master_recs_first and
5342 --create an associative array to record the order of records in this cursor. Later, when we write
5343 --the sequence of the records to the OUTPUT ODI table, we use the new sequence_id.
5344
5345 l_change_sequence NUMBER :=1; --set to 1 to order output XML so that master items XML is fisrt, then child items XML
5346 --l_root_entity_seq_id NUMBER;
5347
5348 --cursor to retrieve ITEM records and order them so that master org items are retuned before child or recs
5349 CURSOR c_master_recs_first(cp_session_id NUMBER)
5350 IS
5351 SELECT SEQUENCE_ID,
5352 decode(organization_id,master_organization_id,0,1) as master_or_child
5353 FROM ego_pub_ws_flat_recs, mtl_parameters
5354 WHERE session_id = cp_session_id
5355 AND entity_type = 'ITEM'
5356 AND NVL (parent_sequence_id, -1) = -1
5357 AND pk2_value = organization_id
5358 order by master_or_child;
5359
5360 --cursor to retrieve all other non Item records (top entity records)
5361 CURSOR c_all_other_recs(cp_session_id NUMBER)
5362 IS
5363 SELECT SEQUENCE_ID
5364 FROM ego_pub_ws_flat_recs
5365 WHERE session_id = cp_session_id
5366 AND entity_type <> 'ITEM'
5367 AND NVL (parent_sequence_id, -1) = -1;
5368
5369 TYPE sequence_order_type IS TABLE OF NUMBER INDEX BY BINARY_INTEGER;
5370 l_sequence_order sequence_order_type;
5371
5372 --EMTAPIA: End added for bug 11831151, change sequence of xml so master items are before child items
5373
5374
5375 BEGIN
5376
5377 --Chunking Start--
5378 /*Get value for configureable parameter 'return_payload'*/
5379 FOR i IN Cur_config_param(l_session_id,l_odi_session_id)
5380 LOOP
5381
5382 l_return_payload:=i.param_value;
5383 END LOOP; --END LOOP FOR i IN Cur_config_param(l_session_id,l_odi_session_id)
5384
5385
5386 IF(l_web_service_name=G_VS_WEBSERVICE)
5387 THEN
5388 l_entity_type :='ValueSets';
5389 END IF;
5390
5391 IF(l_web_service_name=G_ICC_WEBSERVICE)
5392 THEN
5393 l_entity_type :='ItemCatalogCategory';
5394 END IF;
5395
5396 IF(l_web_service_name='GET_ITEM_DETAILS') THEN
5397 l_entity_type :='ITEM';
5398 END IF;
5399
5400 IF(l_web_service_name='GET_ITEM_STRUCTURE') THEN
5401 l_entity_type :='ITEM_STRUCTURE';
5402 END IF;
5403
5404
5405
5406
5407 --Error Handling
5408 l_err_xml := l_err_xml || '<Status>' || l_cr; --YJ
5409
5410 FOR i IN c_err_detail(l_session_id,l_odi_session_id)
5411 LOOP
5412 l_err_xml := l_err_xml || '<Error>' || l_cr;
5413 l_err_xml := l_err_xml || '<Code>' || i.err_code||'</Code>'||l_cr;
5414 l_err_xml := l_err_xml || '<Message>' || i.err_message||'</Message>'||l_cr;
5415 l_err_xml := l_err_xml || '<InputIdentifier>'||l_cr;
5416 --Create identifier tag if parameter entries exist
5417 FOR j IN c_err_identifier(l_session_id,l_odi_session_id,i.input_id)
5418 LOOP
5419 l_err_xml := l_err_xml || '<Parameter>'||l_cr;
5420 l_err_xml := l_err_xml || '<Name>'||j.param_name||'</Name>'||l_cr;
5421 l_err_xml := l_err_xml || '<Value>'||j.param_value||'</Value>'||l_cr;
5422 l_err_xml := l_err_xml || '</Parameter>'||l_cr;
5423 END LOOP; --End FOR j IN c_err_identifier
5424
5425 l_err_xml := l_err_xml || '</InputIdentifier>'|| l_cr;
5426 l_err_xml := l_err_xml || '</Error>' || l_cr;
5427 END LOOP; --End FOR i IN c_err_detail(l_session_id,l_odi_session_id)
5428
5429 l_err_xml := l_err_xml || '</Status>' || l_cr;
5430 --Error Handling
5431
5432
5433 --YJAIN
5434 -- Optimizing parsing statement for transformation of XML
5435
5436 --selecting XLS transformation data from
5437 --table EGO_ODI_WS_XSL for specified web service
5438 select x.xslcontent.getclobval()
5439 into xslclob
5440 from EGO_ODI_WS_XSL x
5441 where web_service_name = p_web_service_name;
5442
5443 myParser := dbms_xmlparser.newParser;
5444
5445 dbms_xmlparser.parseclob(myParser, xslclob);
5446 xsltdomdoc := dbms_xmlparser.getDocument(myParser);
5447 xsl := dbms_xslprocessor.newstylesheet(xsltdomdoc, '');
5448 proc := dbms_xslprocessor.newProcessor;
5449
5450
5451
5452 -- Using XML header appendation operation before loop.
5453 l_xml_header :='<' || l_qm || 'xml version="1.0" encoding="UTF-8"' || l_qm || '>' || l_cr;
5454 l_xml_header := l_xml_header || '<' || p_xml_root_element || '>' || l_cr;
5455 --YJAIN
5456
5457
5458
5459 IF ( l_return_payload ='TRUE' OR l_return_payload ='Y') THEN
5460 --Case to return complete payload
5461 -- Value will be subset of ('Y','N') for Item and ItemStructure and
5462 -- will be subset of ('TRUE','FALSE') for ICC and ValueSet.
5463 --YJ
5464
5465
5466 --YJAIN
5467 l_xml := l_xml_header;
5468 --l_xml := '<' || l_qm || 'xml version="1.0" encoding="UTF-8"' || l_qm || '>' || l_cr;
5469 --l_xml := l_xml || '<'||p_xml_root_element||'>' || l_cr;
5470
5471 FOR r in c_ws_data(l_session_id) LOOP
5472 IF r.level_number = l_previous_level THEN
5473 IF r.entity_type = l_previous_entity_type THEN
5474 --Dbms_Output.put_line(' r.entity_type = '||r.entity_type );
5475 -- End the previous tag only.
5476
5477 -- Perf Bug : 9129863 - Start
5478 l_entity_type_tag := '</' || r.entity_type || '>' || l_cr;
5479 dbms_lob.append(l_xml,to_clob(l_entity_type_tag));
5480 -- l_xml := l_xml || '</' || r.entity_type || '>' || l_cr;
5481 -- Perf Bug : 9129863 - End
5482
5483 ELSE
5484 -- End the previous tag, end the current tag and pop.
5485 WHILE (l_level_stack(l_level_stack.COUNT) >= r.level_number AND l_level_stack.COUNT > 0)
5486 LOOP
5487 -- Perf Bug : 9129863 - Start
5488 l_entity_type_tag := '</' || l_tags_stack(l_tags_stack.COUNT) || '>' || l_cr;
5489 dbms_lob.append(l_xml,to_clob(l_entity_type_tag));
5490 -- l_xml := l_xml || '</' || l_tags_stack(l_tags_stack.COUNT) || '>' || l_cr;
5491 -- Perf Bug : 9129863 - End
5492
5493 l_level_stack.DELETE(l_level_stack.COUNT);
5494 l_tags_stack.DELETE(l_tags_stack.COUNT);
5495 EXIT WHEN l_level_stack.COUNT=0;
5496 END LOOP;
5497
5498 l_level_stack(l_level_stack.COUNT + 1) := r.level_number;
5499 l_tags_stack(l_tags_stack.COUNT + 1) := r.entity_type;
5500 END IF; --End IF r.entity_type = l_previous_entity_type THEN
5501
5502 END IF;--End IF r.level_number = l_previous_level THEN
5503
5504 IF r.level_number > l_previous_level THEN
5505 -- Push the level name into the stack.
5506 l_level_stack(l_level_stack.COUNT + 1) := r.level_number;
5507 l_tags_stack(l_tags_stack.COUNT + 1) := r.entity_type;
5508 END IF;--End IF r.level_number > l_previous_level THEN
5509
5510
5511 IF r.level_number < l_previous_level THEN
5512 -- End the previous tag, end the current tag and pop.
5513 IF l_level_stack.COUNT > 0 THEN
5514
5515 WHILE (l_level_stack(l_level_stack.COUNT) >= r.level_number AND l_level_stack.COUNT > 0)
5516 LOOP
5517 -- Perf Bug : 9129863 - Start
5518 l_entity_type_tag := '</' || l_tags_stack(l_tags_stack.COUNT) || '>' || l_cr;
5519 dbms_lob.append(l_xml,to_clob(l_entity_type_tag));
5520 -- l_xml := l_xml || '</' || l_tags_stack(l_tags_stack.COUNT) || '>' || l_cr;
5521 -- Perf Bug : 9129863 - End
5522
5523 l_level_stack.DELETE(l_level_stack.COUNT);
5524 l_tags_stack.DELETE(l_tags_stack.COUNT);
5525 EXIT WHEN l_level_stack.COUNT=0;
5526 END LOOP;
5527 l_level_stack(l_level_stack.COUNT + 1) := r.level_number;
5528 l_tags_stack(l_tags_stack.COUNT + 1) := r.entity_type;
5529
5530 END IF;
5531
5532 END IF;--END IF r.level_number < l_previous_level THEN
5533
5534 -- Perf Bug : 9129863 - Start
5535 l_entity_type_tag := '<' || r.entity_type || '>' ;
5536 dbms_lob.append(l_xml,to_clob(l_entity_type_tag));
5537 dbms_lob.append(l_xml,r.value);
5538 dbms_lob.writeappend(l_xml,Length(l_cr), l_cr);
5539 -- l_xml := l_xml || '<' || r.entity_type || '>' || r.value || l_cr;
5540 -- Perf Bug : 9129863 - End
5541
5542 l_previous_level := r.level_number;
5543 l_previous_entity_type := r.entity_type;
5544
5545 END LOOP; --END LOOP FOR r in c_ws_data(l_session_id) LOOP
5546
5547 -- Pop and end tag all levels in stack.
5548 FOR i IN REVERSE 1..l_level_stack.COUNT LOOP
5549 -- Perf Bug : 9129863 - Start
5550 l_entity_type_tag := '</' || l_tags_stack(i) || '>' || l_cr;
5551 dbms_lob.append(l_xml,to_clob(l_entity_type_tag));
5552 -- l_xml := l_xml || '</' || l_tags_stack(i) || '>' || l_cr;
5553 -- Perf Bug : 9129863 - End
5554 END LOOP;--END FOR i IN REVERSE 1..l_level_stack.COUNT LOOP
5555 --YJ REMOVE
5556
5557 -- Perf Bug : 9129863 - Start
5558 dbms_lob.append(l_xml,l_err_xml);
5559 -- l_xml := l_xml || l_err_xml;
5560
5561 l_entity_type_tag := '</'||p_xml_root_element||'>' || l_cr;
5562 dbms_lob.append(l_xml,to_clob(l_entity_type_tag));
5563 --l_xml := l_xml || '</'||p_xml_root_element||'>' || l_cr;
5564 -- Perf Bug : 9129863 - End
5565
5566 --If XML transformation option is on, transform the xml
5567 IF p_transform_xml = TRUE
5568 THEN
5569 -- YJAIN
5570 -- Code to do XML transformation
5571 dbms_xmlparser.parseclob(myParser, l_xml);
5572 indomdoc := dbms_xmlparser.getDocument(myParser);
5573 --apply stylesheet to DOM document
5574 outdomdocf := dbms_xslprocessor.processxsl(proc, xsl, indomdoc);
5575 outnode := dbms_xmldom.makenode(outdomdocf);
5576 DBMS_LOB.CreateTemporary(outCLOB, TRUE);
5577 dbms_xmldom.writetoclob(outnode,outclob);
5578 l_output_xml := XmlType(outclob);
5579 --l_output_xml := Transform_XML(l_xml, p_web_service_name);
5580 -- YJAIN
5581 ELSE
5582 l_output_xml := XmlType(l_xml);
5583 END IF;
5584
5585 -- Write final XML payload to output table in XML TYPE column
5586 -- with sequence id as zero
5587 -- This payload will be accessed using serviceutil.java with sequence_id
5588 -- as zero for return_payload as TRUE
5589 INSERT INTO ego_pub_ws_output (session_id,
5590 odi_session_id,
5591 web_service_name,
5592 sequence_id,
5593 xmlcontent,
5594 xml_odi,
5595 creation_date,
5596 created_by)
5597
5598 VALUES (l_session_id,
5599 p_odi_session_id,
5600 p_web_service_name,
5601 0,
5602 l_output_xml,
5603 XmlType(l_xml),
5604 sysdate,
5605 0);
5606
5607 --End YJ
5608 ELSE --Case to return payload in chunk
5609
5610 IF(l_web_service_name=G_VS_WEBSERVICE)
5611 THEN
5612 l_actual_node :='ns1:ListOfValueSets';
5613 l_chunk_detail :='<ns1:ListOfValueSets xmlns:ns1="http://xmlns.oracle.com/apps/ego/extfwk/service/out"><AdditionalInfo><SessionId>'||l_session_id||'</SessionId>';
5614 END IF;
5615
5616 IF(l_web_service_name=G_ICC_WEBSERVICE)
5617 THEN
5618 l_actual_node :='ns1:ListOfICCs';
5619 l_chunk_detail :='<ns1:ListOfICCs xmlns:ns1="http://xmlns.oracle.com/apps/ego/itemcatalog/service/out"><AdditionalInfo><SessionId>'||l_session_id||'</SessionId>';--<EntityCount>
5620 END IF;
5621
5622 IF(l_web_service_name='GET_ITEM_DETAILS') THEN
5623 l_actual_node :='ns1:listOfItems';
5624 --l_chunk_detail :='<ns1:listOfItems xmlns:ns1="http://xmlns.oracle.com/apps/ego/extfwk/service/out"><AdditionalInfo><SessionId>'||l_session_id||'</SessionId>';
5625 -- CHnage done to reflect correct name space
5626 l_chunk_detail :='<ns1:listOfItems xmlns:ns1="http://xmlns.oracle.com/apps/ego/item/service/out"><AdditionalInfo><SessionId>'||l_session_id||'</SessionId>';
5627 END IF;
5628
5629 IF(l_web_service_name='GET_ITEM_STRUCTURE') THEN
5630 l_actual_node :='ns0:listOfStructureHeaders';
5631 -- l_chunk_detail :='<ns0:listOfStructureHeaders xmlns:ns0="http://xmlns.oracle.com/apps/bom/structure/service"><AdditionalInfo><SessionId>'||l_session_id||'</SessionId>';
5632 --pnagasur:Bug 13508104 :changed to reflect proper namespace
5633 l_chunk_detail :='<ns0:listOfStructureHeaders xmlns:ns0="http://xmlns.oracle.com/apps/bom/structure/out"><AdditionalInfo><SessionId>'||l_session_id||'</SessionId>';
5634 END IF;
5635
5636 l_end_xml :='</AdditionalInfo>';
5637
5638
5639 --EMTAPIA: Added for bug 11831151, change sequence of xml so master items are before child items
5640 --if ordering of items as master first, child first is not required, sequence_id starts with one and
5641 --increments for each record. If master child ordering is required, then, we sort the end-items
5642 --according to this (master records first and then child records) using cursor c_master_recs_first and
5643 --create an associative array to record the order of records in this cursor. Later, when we write
5644 --the sequence of the records to the OUTPUT ODI table, we use the new sequence_id.
5645 IF (l_change_sequence = 0)
5646 THEN
5647 l_sequence:=0;
5648 ELSE
5649
5650 l_sequence:=1;
5651
5652 --Generate_XML_Sequence(p_session_id, l_sequence_order);
5653
5654 --find all ITEM records and order them so that master items appear before child items
5655 --while recording their sequence in l_sequence_order
5656 FOR s IN c_master_recs_first (p_session_id)
5657 LOOP
5658 l_sequence_order(s.sequence_id) := l_sequence;
5659 l_sequence := l_sequence + 1;
5660 END LOOP;
5661
5662 --find all other non ITEM records and assign a sequence number in l_sequence_order
5663 FOR s IN c_all_other_recs (p_session_id)
5664 LOOP
5665 l_sequence_order(s.sequence_id) := l_sequence;
5666 l_sequence := l_sequence + 1;
5667 END LOOP;
5668
5669
5670 END IF;
5671 --EMTAPIA: Ennd Added for bug 11831151,
5672
5673
5674 FOR j IN c_ws_top_entity (l_session_id)
5675 LOOP
5676 /*Loop through to get data in chunk for top level entity*/
5677 IF (l_previous_seqid > -1 AND (j.parent_sequence_id IS NULL OR j.parent_sequence_id = -1) AND j.level_number = 1)
5678 THEN
5679 -- Pop and end tag all levels in stack.
5680 FOR i IN REVERSE 1 .. l_level_stack.COUNT
5681 LOOP
5682 -- Perf Bug : 9129863 - Start
5683 l_entity_type_tag := '</' || l_tags_stack (i) || '>' || l_cr;
5684 DBMS_LOB.append (l_xml, to_clob(l_entity_type_tag));
5685 -- l_xml := l_xml || '</' || l_tags_stack(i) || '>' || l_cr;
5686 -- Perf Bug : 9129863 - End
5687
5688 END LOOP;
5689
5690 -- Perf Bug : 9129863 - Start
5691 l_entity_type_tag := '</' || p_xml_root_element || '>' || l_cr;
5692 DBMS_LOB.append (l_xml, to_clob(l_entity_type_tag));
5693
5694 -- l_xml := l_xml || '</'||p_xml_root_element||'>' || l_cr;
5695 -- Perf Bug : 9129863 - End
5696
5697
5698 --If XML transformation option is on, transform the xml
5699 IF p_transform_xml = TRUE
5700 THEN
5701 -- YJAIN
5702 -- Code to do XML transformation
5703 dbms_xmlparser.parseclob(myParser, l_xml);
5704 indomdoc := dbms_xmlparser.getDocument(myParser);
5705 --apply stylesheet to DOM document
5706 outdomdocf := dbms_xslprocessor.processxsl(proc, xsl, indomdoc);
5707 outnode := dbms_xmldom.makenode(outdomdocf);
5708 DBMS_LOB.CreateTemporary(outCLOB, TRUE);
5709 dbms_xmldom.writetoclob(outnode,outclob);
5710 l_output_xml := XmlType(outclob);
5711 --l_output_xml := Transform_XML(l_xml, p_web_service_name);
5712 -- YJAIN
5713
5714 ELSE
5715 l_output_xml := xmltype (l_xml);
5716 END IF;
5717
5718
5719 --EMTAPIA: Start added for bug 11831151, if special ordering of output XML is required (e.. master items are before child items)
5720 --then retrieve sequence_id number to use from associative array containing the correct sequence to use for current item record
5721 IF (l_change_sequence = 0)
5722 THEN
5723 l_sequence := l_sequence + 1;
5724 ELSE
5725 l_sequence:=l_sequence_order(l_previous_seqid);
5726 END IF;
5727 --EMTAPIA: End Added for bug 11831151
5728
5729
5730 -- Write XML payload to output table for each top level entity with
5731 -- sequence_id.
5732 INSERT INTO ego_pub_ws_output (session_id, odi_session_id, web_service_name, sequence_id, xmlcontent, xml_odi, creation_date, created_by)
5733 VALUES (l_session_id, p_odi_session_id, p_web_service_name, l_sequence, l_output_xml, xmltype (l_xml), SYSDATE, 0);
5734
5735 --Re-Initialize all variable
5736 l_xml := NULL;
5737 l_previous_level := -1;
5738 l_previous_entity_type := NULL;
5739 l_no_of_entities := l_no_of_entities + 1; --Counting number of top level entities
5740
5741 IF l_level_stack.COUNT > 0
5742 THEN
5743 WHILE (l_level_stack.COUNT > 0)
5744 LOOP
5745 l_level_stack.delete (l_level_stack.COUNT);
5746 l_tags_stack.delete (l_tags_stack.COUNT);
5747 EXIT WHEN l_level_stack.COUNT = 0;
5748 END LOOP;
5749 END IF;
5750 END IF;
5751
5752
5753 --if the begining of a new root entity has been identified (for which XML needs to be generated)
5754 IF ( (j.parent_sequence_id IS NULL OR j.parent_sequence_id = -1) AND j.level_number = 1)
5755 THEN
5756 l_previous_seqid := j.sequence_id;
5757
5758
5759 --YJAIN
5760 l_xml := l_xml_header;
5761 --l_xml := '<' || l_qm || 'xml version="1.0" encoding="UTF-8"' || l_qm || '>' || l_cr;
5762 --l_xml := l_xml || '<'||p_xml_root_element||'>' || l_cr;
5763 --YJAIN
5764
5765 END IF;
5766
5767 --FOR r IN c_ws_data_chunk (l_session_id, j.sequence_id)
5768 --LOOP
5769 IF j.level_number = l_previous_level
5770 THEN
5771 IF j.entity_type = l_previous_entity_type
5772 THEN
5773 -- End the previous tag only.
5774 -- Perf Bug : 9129863 - Start
5775 l_entity_type_tag := '</' || j.entity_type || '>' || l_cr;
5776 DBMS_LOB.append (l_xml, to_clob(l_entity_type_tag));
5777 -- l_xml := l_xml || '</' || r.entity_type || '>' || l_cr;
5778 -- Perf Bug : 9129863 - End
5779 ELSE
5780 -- End the previous tag, end the current tag and pop.
5781 WHILE (l_level_stack (l_level_stack.COUNT) >= j.level_number AND l_level_stack.COUNT > 0)
5782 LOOP
5783 -- Perf Bug : 9129863 - Start
5784 l_entity_type_tag := '</' || l_tags_stack (l_tags_stack.COUNT) || '>' || l_cr;
5785 DBMS_LOB.append (l_xml, to_clob(l_entity_type_tag));
5786 -- l_xml := l_xml || '</' || l_tags_stack(l_tags_stack.COUNT) || '>' || l_cr;
5787 -- Perf Bug : 9129863 - End
5788
5789 l_level_stack.delete (l_level_stack.COUNT);
5790 l_tags_stack.delete (l_tags_stack.COUNT);
5791 EXIT WHEN l_level_stack.COUNT = 0;
5792 END LOOP;
5793
5794 l_level_stack (l_level_stack.COUNT + 1) := j.level_number;
5795 l_tags_stack (l_tags_stack.COUNT + 1) := j.entity_type;
5796 END IF; --END IF r.entity_type = l_previous_entity_type THEN
5797 END IF; --END IF r.level_number = l_previous_level THEN
5798
5799
5800 IF j.level_number > l_previous_level
5801 THEN
5802 -- Push the level name into the stack.
5803 l_level_stack (l_level_stack.COUNT + 1) := j.level_number;
5804 l_tags_stack (l_tags_stack.COUNT + 1) := j.entity_type;
5805 END IF; --END IF r.level_number > l_previous_level THEN
5806
5807
5808 IF j.level_number < l_previous_level
5809 THEN
5810 -- End the previous tag, end the current tag and pop.
5811
5812 IF l_level_stack.COUNT > 0
5813 THEN
5814 WHILE (l_level_stack (l_level_stack.COUNT) >= j.level_number AND l_level_stack.COUNT > 0)
5815 LOOP
5816 -- End the previous tag only.
5817 -- Perf Bug : 9129863 - Start
5818 l_entity_type_tag := '</' || l_tags_stack (l_tags_stack.COUNT) || '>' || l_cr;
5819 DBMS_LOB.append (l_xml, to_clob(l_entity_type_tag));
5820 -- l_xml := l_xml || '</' || l_tags_stack(l_tags_stack.COUNT) || '>' || l_cr;
5821 -- Perf Bug : 9129863 - End
5822
5823 l_level_stack.delete (l_level_stack.COUNT);
5824 l_tags_stack.delete (l_tags_stack.COUNT);
5825 EXIT WHEN l_level_stack.COUNT = 0;
5826 END LOOP;
5827
5828 l_level_stack (l_level_stack.COUNT + 1) := j.level_number;
5829 l_tags_stack (l_tags_stack.COUNT + 1) := j.entity_type;
5830 END IF;
5831 END IF; --END IF r.level_number < l_previous_level THEN
5832
5833
5834 -- Perf Bug : 9129863 - Start
5835 l_entity_type_tag := '<' || j.entity_type || '>';
5836 DBMS_LOB.append (l_xml, to_clob(l_entity_type_tag));
5837
5838 --YJAIN
5839 --retrieve XML value column by querying directly the table. This XML value column was not
5840 --selected in cursor cs_ws_top_entity as its size is huge and will cause performance issues
5841 FOR k IN c_ws_entity_val (l_session_id,j.sequence_id,j.parent_sequence_id)
5842 LOOP
5843 DBMS_LOB.append (l_xml, k.VALUE);
5844 END LOOP;
5845 --YJAIN
5846
5847 DBMS_LOB.writeappend (l_xml, LENGTH (l_cr), l_cr);
5848 -- l_xml := l_xml || '<' || r.entity_type || '>' || r.value || l_cr;
5849 -- Perf Bug : 9129863 - End
5850
5851 l_previous_level := j.level_number;
5852 l_previous_entity_type := j.entity_type;
5853 --END LOOP; --END FOR r in c_ws_data_chunk(l_session_id,j.sequence_id)
5854 --End of loop for procedding data at each top level entity
5855
5856 END LOOP; -- End FOR j IN c_ws_top_entity(l_session_id)
5857 --End of loop for processing all top level entity.
5858
5859 l_chunk_detail:=l_chunk_detail||'<EntityCount>'||l_no_of_entities||'</EntityCount>'||l_end_xml;
5860 l_chunk_detail := l_chunk_detail || l_err_xml||'</'||l_actual_node||'>';
5861 -- Insert final data in to output table with sequence_id as zero, This
5862 -- will contain session_id and entity_count, End user will use this data
5863 -- to get detail about no of entity for a session, It will use this detail
5864 -- to get data from database view provided to them
5865 INSERT INTO EGO_PUB_WS_OUTPUT (session_id,
5866 odi_session_id,
5867 web_service_name,
5868 sequence_id,
5869 xmlcontent,
5870 xml_odi,
5871 creation_date,
5872 created_by)
5873 VALUES (l_session_id,
5874 l_odi_session_id,
5875 l_web_service_name,
5876 0,
5877 xmltype(l_chunk_detail),
5878 XmlType(l_chunk_detail),
5879 sysdate,
5880 0);
5881
5882 END IF;--End IF l_return_payload='TRUE'
5883 --Chunking End--
5884
5885
5886
5887
5888 --Insert XML as string for debugging
5889 --INSERT INTO EGO_PUB_WS_OUTPUT (session_id,
5890 -- odi_session_id,
5891 -- web_service_name,
5892 -- XMLCLOB,
5893 -- creation_date,
5894 -- created_by))
5895 -- VALUES (l_session_id,
5896 -- p_odi_session_id,
5897 -- p_web_service_name,
5898 -- l_xml,
5899 -- sysdate,
5900 -- 0);
5901
5902
5903 END Generate_XML;
5904
5905
5906
5907
5908 /* Procedure to get invocation Mode and setting batch_id based on invocation mode
5909 If mode is 'BATCH' then it will give some Batch Id, If mode is 'LIST' then
5910 Batch Id will be -1*/
5911 PROCEDURE Invocation_Mode ( p_session_id IN NUMBER,
5912 p_search_str IN VARCHAR2,
5913 x_mode OUT NOCOPY VARCHAR2,
5914 x_batch_id OUT NOCOPY NUMBER )
5915 IS
5916
5917 --Local Variable
5918 l_mode VARCHAR2(10) :='BATCH';
5919 l_batch_id NUMBER:=-1;
5920 l_exists NUMBER;
5921
5922 BEGIN
5923 --if BatchId node exist and It has some value then we are in 'BATCH' mode
5924 SELECT existsNode(xmlcontent, p_search_str)
5925 INTO l_exists
5926 FROM EGO_PUB_WS_PARAMS
5927 WHERE session_id = p_session_id;
5928
5929
5930 IF l_exists=1 THEN
5931 /*If node exist for 'BatchId' then extractValue for BatchId'*/
5932 SELECT Nvl(extractValue(xmlcontent,p_search_str),-1)
5933 INTO l_batch_id
5934 FROM EGO_PUB_WS_PARAMS
5935 WHERE session_id = p_session_id;
5936
5937 IF l_batch_id >-1 THEN
5938 x_mode:= 'BATCH';
5939 ELSE
5940 x_mode:= 'LIST';
5941 END IF;
5942 x_batch_id:= l_batch_id;
5943 ELSE
5944 x_mode:= 'LIST';
5945 x_batch_id:= l_batch_id;
5946 END IF;
5947
5948 /*EXCEPTION
5949 WHEN OTHERS THEN
5950 NULL;*/
5951
5952 END Invocation_Mode;
5953
5954
5955
5956
5957
5958 /* Procedure to insert record for configurable parameter*/
5959 PROCEDURE Create_Config_Param ( p_session_id IN NUMBER,
5960 p_odi_session_id IN NUMBER,
5961 p_webservice_name IN VARCHAR2,
5962 p_lang_search_str IN VARCHAR2,
5963 p_parent_hier IN VARCHAR2,
5964 p_child_hier IN VARCHAR2)
5965 IS
5966
5967 l_lang_code_tab dbms_sql.varchar2_table;
5968 l_UserDefAttrGrps VARCHAR2(10);
5969 l_iccvers_config VARCHAR2(10);
5970 l_transattrs_config VARCHAR2(10);
5971 l_structure_config VARCHAR2(10);
5972 l_langcode_xpath VARCHAR2(100):=p_lang_search_str||'/ListOfLanguages/Language/LanguageCode';
5973 l_langname_xpath VARCHAR2(100):=p_lang_search_str||'/ListOfLanguages/Language/LanguageName';
5974 l_retpay_xpath VARCHAR2(100):=p_lang_search_str||'/ReturnPayload';
5975 l_retpayload VARCHAR2(10) :='TRUE';
5976
5977 BEGIN
5978 /*extract configurable parameter for language */
5979 SELECT extractValue(lang_code, '/LanguageCode')
5980 BULK COLLECT INTO l_lang_code_tab
5981 FROM (SELECT Value(langcode) lang_code
5982 FROM EGO_PUB_WS_PARAMS i,
5983 TABLE(XMLSequence(
5984 extract(i.xmlcontent, l_langcode_xpath) )) langcode
5985 WHERE session_id=p_session_id
5986 );
5987
5988 --Insert record into config table for parameter language
5989 IF l_lang_code_tab.Count> 0 THEN
5990
5991 FOR i IN 1..l_lang_code_tab.Count
5992 LOOP
5993 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by, web_service_name)
5994 VALUES (p_session_id,p_odi_session_id,'LANGUAGE_CODE',2,NULL,l_lang_code_tab(i),NULL,SYSDATE,G_CURRENT_USER_ID, p_webservice_name);
5995 END LOOP;
5996 ELSE
5997 FOR i IN (SELECT language_code FROM FND_LANGUAGES WHERE INSTALLED_FLAG IN ('I','B') ) LOOP
5998 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by, web_service_name)
5999 VALUES (p_session_id,p_odi_session_id,'LANGUAGE_CODE',2,NULL,i.language_code,NULL,SYSDATE,G_CURRENT_USER_ID, p_webservice_name);
6000 END LOOP;
6001 END IF;
6002
6003
6004 --extract configurable parameter 'ReturnPayload'
6005 BEGIN
6006 SELECT Upper(Nvl(extractValue(ret_pay, '/ReturnPayload'),'TRUE'))
6007 INTO l_retpayload
6008 FROM (SELECT Value(retpay) ret_pay
6009 FROM EGO_PUB_WS_PARAMS i,
6010 TABLE(XMLSequence(
6011 extract(i.xmlcontent, l_retpay_xpath) )) retpay
6012 WHERE session_id=p_session_id
6013 );
6014
6015 EXCEPTION
6016 WHEN NO_DATA_FOUND
6017 THEN
6018 l_retpayload:='TRUE';
6019 END;
6020
6021
6022 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
6023 VALUES (p_session_id,p_odi_session_id,'return_payload',2,NULL,Upper(l_retpayload),NULL,SYSDATE,G_CURRENT_USER_ID);
6024
6025
6026
6027 /*If WebService is ICC then create config param for ICC*/
6028 IF (p_webservice_name = G_ICC_WEBSERVICE ) THEN
6029
6030 /*extract configurable parameter Attr Group and insert record into config table */
6031 SELECT Nvl(extractValue(uda_ag, '/UserDefAttrGrps'),'TRUE')
6032 INTO l_UserDefAttrGrps
6033 FROM (SELECT Value(udaag) uda_ag
6034 FROM EGO_PUB_WS_PARAMS i,
6035 TABLE(XMLSequence(
6036 extract(i.xmlcontent, '/ICCQueryParam/ICCPubEntityObject/UserDefAttrGrps') )) udaag
6037 WHERE session_id=p_session_id
6038 );
6039
6040
6041 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
6042 VALUES (p_session_id,p_odi_session_id,'PublishUDA',2,NULL,Upper(l_UserDefAttrGrps),NULL,SYSDATE,G_CURRENT_USER_ID);
6043
6044
6045
6046
6047 /*extract configurable parameter ICCVersions and insert record into config table */
6048 SELECT Nvl(extractValue(uda_ag, '/ICCVersions'),'TRUE')
6049 INTO l_iccvers_config
6050 FROM (SELECT Value(udaag) uda_ag
6051 FROM EGO_PUB_WS_PARAMS i,
6052 TABLE(XMLSequence(
6053 extract(i.xmlcontent, '/ICCQueryParam/ICCPubEntityObject/ICCVersions') )) udaag
6054 WHERE session_id=p_session_id
6055 );
6056
6057
6058 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
6059 VALUES (p_session_id,p_odi_session_id,'PublishICCVersions',2,NULL,Upper(l_iccvers_config),NULL,SYSDATE,G_CURRENT_USER_ID);
6060
6061
6062
6063 /*extract configurable parameter TransAttrs and insert record into config table */
6064 SELECT Nvl(extractValue(uda_ag, '/TransAttrs'),'TRUE')
6065 INTO l_transattrs_config
6066 FROM (SELECT Value(udaag) uda_ag
6067 FROM EGO_PUB_WS_PARAMS i,
6068 TABLE(XMLSequence(
6069 extract(i.xmlcontent, '/ICCQueryParam/ICCPubEntityObject/TransAttrs') )) udaag
6070 WHERE session_id=p_session_id
6071 );
6072
6073
6074 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
6075 VALUES (p_session_id,p_odi_session_id,'PublishTransAttrs',2,NULL,Upper(l_transattrs_config),NULL,SYSDATE,G_CURRENT_USER_ID);
6076
6077
6078 /*extract configurable parameter ICCStructure and insert record into config table */
6079 SELECT Nvl(extractValue(uda_ag, '/ICCStructure'),'TRUE')
6080 INTO l_structure_config
6081 FROM (SELECT Value(udaag) uda_ag
6082 FROM EGO_PUB_WS_PARAMS i,
6083 TABLE(XMLSequence(
6084 extract(i.xmlcontent, '/ICCQueryParam/ICCPubEntityObject/ICCStructure') )) udaag
6085 WHERE session_id=p_session_id
6086 );
6087
6088
6089 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
6090 VALUES (p_session_id,p_odi_session_id,'PublishICCStructure',2,NULL,Upper(l_structure_config),NULL,SYSDATE,G_CURRENT_USER_ID);
6091
6092
6093
6094
6095
6096 /*Insert record into config table for parameter parent and child hierarchy*/
6097 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
6098 VALUES (p_session_id,p_odi_session_id,'PublishParentICCs',2,NULL,Upper(p_parent_hier),NULL,SYSDATE,G_CURRENT_USER_ID);
6099
6100
6101 INSERT INTO EGO_PUB_WS_CONFIG ( session_id,odi_session_id,Parameter_Name,Data_Type,Date_Value,Char_value,Numeric_Value,creation_date,created_by)
6102 VALUES (p_session_id,p_odi_session_id,'PublishChildICCs',2,NULL,Upper(p_child_hier),NULL,SYSDATE,G_CURRENT_USER_ID);
6103
6104
6105 END IF;
6106
6107 /*EXCEPTION
6108 WHEN OTHERS THEN
6109 NULL;*/
6110 END Create_Config_Param;
6111
6112 /* Procedure to finding out List of ICC's and their version and to publish hierarchy of ICC to temporary table*/
6113 PROCEDURE Preprocess_Input_ICC ( p_session_id IN NUMBER,
6114 p_odi_session_id IN NUMBER )
6115
6116 IS
6117
6118 l_icc_id_tab dbms_sql.VARCHAR2_table; --Netsed table of varchar2 to store ICC_Id's
6119 l_icc_ver_tab dbms_sql.NUMBER_table; --Netsed table of varchar2 to store ICC Version
6120 l_count NUMBER;
6121
6122 --Bug 8767131
6123 l_dup_icc_id_tab dbms_sql.Number_Table; --Netsed table of varchar2 to store ICC_Id's
6124 l_dup_icc_ver_tab dbms_sql.Number_Table; --Netsed table of varchar2 to store ICC Version
6125 l_unique_icc_count NUMBER:=1;
6126 l_is_duplicate BOOLEAN :=FALSE;
6127 l_ref1_value VARCHAR2(200):=NULL;
6128 --Bug 8767131
6129
6130
6131 /* Cursor to find out all child ICC's and their effective version as on
6132 1. End date of passed in version of passed in ICC Id for publishing ICC's effective in past.
6133 2. Start date of passed in version of passed in ICC Id for publishing ICC's effective in future..
6134 3. current date for publishing ICC's effective in present.*/
6135
6136 CURSOR cur_icc_ver(cp_icc_id IN NUMBER, cp_icc_ver IN NUMBER,cp_publish_parent IN VARCHAR2, cp_publish_child IN VARCHAR2)
6137 IS
6138 SELECT cp_icc_id ITEM_CATALOG_GROUP_ID,cp_icc_ver VERSION_SEQ_ID,1 lev FROM dual
6139 UNION
6140 SELECT ITEM_CATALOG_GROUP_ID,VERSION_SEQ_ID,lev FROM
6141 ( SELECT iccb.ITEM_CATALOG_GROUP_ID,VERSION_SEQ_ID ,lev
6142 FROM EGO_MTL_CATALOG_GRP_VERS_B iccb,
6143 ( SELECT ITEM_CATALOG_GROUP_ID,LEVEL lev
6144 FROM MTL_ITEM_CATALOG_GROUPS_B
6145 START WITH ITEM_CATALOG_GROUP_ID =cp_icc_id
6146 CONNECT BY PRIOR ITEM_CATALOG_GROUP_ID=PARENT_CATALOG_GROUP_ID
6147 ) hier
6148 WHERE iccb.item_catalog_group_id=hier.item_catalog_group_id
6149 )
6150 WHERE
6151 (
6152 cp_publish_child ='TRUE'
6153 AND
6154 (
6155 LEV > 1
6156 AND (item_catalog_group_id, VERSION_SEQ_ID)
6157 IN
6158 ( SELECT item_catalog_group_id,VERSION_SEQ_ID
6159 FROM EGO_MTL_CATALOG_GRP_VERS_B
6160 WHERE (item_catalog_group_id,start_active_date )
6161 IN
6162 ( SELECT item_catalog_group_id, MAX(start_active_date) start_active_date
6163 FROM EGO_MTL_CATALOG_GRP_VERS_B
6164 WHERE version_seq_id > 0
6165 AND start_active_date <= (
6166 SELECT nvl(end_active_date,SYSDATE)
6167 FROM EGO_MTL_CATALOG_GRP_VERS_B
6168 WHERE ITEM_CATALOG_GROUP_ID =cp_icc_id
6169 AND VERSION_SEQ_ID =cp_icc_ver
6170
6171 )
6172 GROUP BY item_catalog_group_id
6173 HAVING MAX(start_active_date)<=(
6174 SELECT nvl(end_active_date,SYSDATE)
6175 FROM EGO_MTL_CATALOG_GRP_VERS_B
6176 WHERE ITEM_CATALOG_GROUP_ID =cp_icc_id
6177 AND VERSION_SEQ_ID = cp_icc_ver
6178
6179 )
6180
6181 )
6182 )
6183 )
6184 )
6185 UNION
6186 SELECT ITEM_CATALOG_GROUP_ID,VERSION_SEQ_ID,lev FROM
6187 ( SELECT iccb.ITEM_CATALOG_GROUP_ID,VERSION_SEQ_ID ,lev
6188 FROM EGO_MTL_CATALOG_GRP_VERS_B iccb,
6189 ( SELECT ITEM_CATALOG_GROUP_ID,LEVEL lev
6190 FROM MTL_ITEM_CATALOG_GROUPS_B
6191 START WITH ITEM_CATALOG_GROUP_ID =cp_icc_id
6192 CONNECT BY PRIOR PARENT_CATALOG_GROUP_ID=ITEM_CATALOG_GROUP_ID
6193 ) hier
6194 WHERE iccb.item_catalog_group_id=hier.item_catalog_group_id
6195
6196 )
6197 WHERE
6198 (
6199 cp_publish_parent ='TRUE'
6200 AND
6201 (
6202 LEV > 1
6203 AND (item_catalog_group_id, VERSION_SEQ_ID)
6204 IN
6205 ( SELECT item_catalog_group_id,VERSION_SEQ_ID
6206 FROM EGO_MTL_CATALOG_GRP_VERS_B
6207 WHERE (item_catalog_group_id,start_active_date )
6208 IN
6209 ( SELECT item_catalog_group_id, MAX(start_active_date) start_active_date
6210 FROM EGO_MTL_CATALOG_GRP_VERS_B
6211 WHERE creation_date <= ( SELECT CREATION_DATE
6212 FROM EGO_MTL_CATALOG_GRP_VERS_B
6213 WHERE ITEM_CATALOG_GROUP_ID = cp_icc_id
6214 AND VERSION_SEQ_ID = cp_icc_ver
6215 )
6216 AND version_seq_id > 0
6217 AND start_active_date <= (
6218 SELECT CREATION_DATE
6219 FROM EGO_MTL_CATALOG_GRP_VERS_B
6220 WHERE ITEM_CATALOG_GROUP_ID =cp_icc_id
6221 AND VERSION_SEQ_ID = cp_icc_ver
6222
6223 )
6224 GROUP BY item_catalog_group_id
6225 HAVING MAX(start_active_date)<=(
6226 SELECT CREATION_DATE
6227 FROM EGO_MTL_CATALOG_GRP_VERS_B
6228 WHERE ITEM_CATALOG_GROUP_ID =cp_icc_id
6229 AND VERSION_SEQ_ID = cp_icc_ver
6230
6231 )
6232 )
6233 )
6234 )
6235 )
6236
6237 -- Non versioned ICC
6238 UNION
6239 SELECT ITEM_CATALOG_GROUP_ID,NULL AS version_seq_id, lev FROM
6240 ( SELECT ITEM_CATALOG_GROUP_ID,LEVEL lev
6241 FROM MTL_ITEM_CATALOG_GROUPS_B
6242 START WITH ITEM_CATALOG_GROUP_ID =cp_icc_id
6243 CONNECT BY PRIOR ITEM_CATALOG_GROUP_ID=PARENT_CATALOG_GROUP_ID
6244 )
6245 WHERE
6246 (
6247 cp_publish_child ='TRUE'
6248 AND cp_icc_ver IS NULL
6249 AND LEV > 1
6250 )
6251 -- Non versioned ICC
6252 UNION
6253 SELECT ITEM_CATALOG_GROUP_ID,NULL AS version_seq_id, lev FROM
6254 ( SELECT ITEM_CATALOG_GROUP_ID,LEVEL lev
6255 FROM MTL_ITEM_CATALOG_GROUPS_B
6256 START WITH ITEM_CATALOG_GROUP_ID =cp_icc_id
6257 CONNECT BY PRIOR PARENT_CATALOG_GROUP_ID=ITEM_CATALOG_GROUP_ID
6258 )
6259 WHERE
6260 (
6261 cp_publish_parent ='TRUE'
6262 AND cp_icc_ver IS NULL
6263 AND LEV > 1
6264
6265 );
6266
6267
6268
6269
6270
6271
6272
6273
6274
6275
6276 l_parent_hier VARCHAR2(10);
6277 l_child_hier VARCHAR2(10);
6278 batch_entity_rec EGO_PUB_FWK_PK.TBL_OF_BAT_ENT_OBJ_TYPE;
6279 x_return_status VARCHAR2(1);
6280 x_msg_count NUMBER;
6281 x_msg_data VARCHAR2(500);
6282 l_batch_id NUMBER;
6283 l_mode VARCHAR2(30);
6284 l_icc_parent_pub_tab dbms_sql.VARCHAR2_table;
6285 l_icc_child_pub_tab dbms_sql.VARCHAR2_table;
6286 l_batch_search_str VARCHAR2(100):='/ICCQueryParam/BatchId';
6287 l_search_str VARCHAR2(100):='/ICCQueryParam/ICCPubEntityObject';
6288 l_access_priv BOOLEAN :=TRUE;
6289 --l_valid_bat_entity BOOLEAN :=TRUE;
6290 l_valid_entity BOOLEAN :=TRUE;
6291 l_batch_entity_count NUMBER :=0;
6292 BEGIN
6293 -- Check access priviledge for Setup Workbench for a user
6294 l_access_priv:= Check_Access_Priv(p_session_id,p_odi_session_id,G_ICC_WEBSERVICE);
6295 -- If user has access then continue else log information in information table
6296 -- and exit procedure
6297 IF(l_access_priv) THEN
6298
6299 /* Call API to find out invocation mode and batch_id, Batch_Id will be -1 if mode is LIST*/
6300 Invocation_Mode( p_session_id,l_batch_search_str,l_mode,l_batch_id);
6301
6302 --If mode is batch then batch_id will have value greater than -1
6303 IF l_batch_id >-1 THEN
6304 --Validate batch
6305 /*l_valid_bat_entity := validate_entity(p_session_id,p_odi_session_id,l_batch_id,
6306 G_ICC_WEBSERVICE,NULL,NULL,NULL,NULL,NULL);*/
6307
6308
6309 SELECT pk1_value , nvl(pk2_value,-1)
6310 BULK COLLECT INTO l_dup_icc_id_tab, l_dup_icc_ver_tab
6311 FROM Ego_Pub_Bat_Ent_Objs_v --Find out if any other PK's
6312 WHERE batch_id = l_batch_id AND user_entered = 'Y';
6313
6314
6315 /* FIND OUT PARENT AND CHILD ICC's also need to publish
6316 It will return TRUE if need to publish else FALSE */
6317 SELECT Upper(CHAR_VALUE) INTO l_parent_hier FROM EGO_PUB_BAT_PARAMS_b WHERE type_id=l_batch_id AND Upper(parameter_name) ='PUBLISHPARENT';
6318 SELECT Upper(CHAR_VALUE) INTO l_child_hier FROM EGO_PUB_BAT_PARAMS_b WHERE type_id=l_batch_id AND Upper(parameter_name) ='PUBLISHCHILD';
6319
6320 ELSE
6321
6322 /*Extract value into array if ICCId node exist in Input table*/
6323 SELECT extractValue(ICC_Id, '/ICCId')
6324 BULK COLLECT INTO l_dup_icc_id_tab
6325 FROM (SELECT Value(iccid) ICC_Id
6326 FROM EGO_PUB_WS_PARAMS i,
6327 TABLE(XMLSequence(
6328 extract(i.xmlcontent, '/ICCQueryParam/ICCIdentifiersList/ICCIdentifier/ICCId') )) iccid
6329 WHERE session_id=p_session_id
6330 );
6331
6332
6333 /*Extract value into array if VersionSequence node exist in Input table*/
6334 SELECT Nvl(extractValue(ICC_Ver, '/VersionSequence'),-1)
6335 BULK COLLECT INTO l_dup_icc_ver_tab
6336 FROM (SELECT Value(iccver) ICC_Ver
6337 FROM EGO_PUB_WS_PARAMS i,
6338 TABLE(XMLSequence(
6339 extract(i.xmlcontent, '/ICCQueryParam/ICCIdentifiersList/ICCIdentifier/VersionSequence') )) iccver
6340 WHERE session_id=p_session_id
6341 );
6342
6343 /* Find out if parent ICC's need to publish for a ICC*/
6344 SELECT upper(Nvl(extractValue(ICC_Id, '/ParentICCs'),'FALSE'))
6345 INTO l_parent_hier
6346 FROM (SELECT Value(iccid) ICC_Id
6347 FROM EGO_PUB_WS_PARAMS i,
6348 TABLE(XMLSequence(
6349 extract(i.xmlcontent, '/ICCQueryParam/ICCPubEntityObject/ParentICCs') )) iccid
6350 WHERE session_id=p_session_id
6351 );
6352
6353 /* Find out if child ICC's need to publish for a ICC*/
6354 SELECT upper(Nvl(extractValue(ICC_Id, '/ChildICCs'),'FALSE'))
6355 INTO l_child_hier
6356 FROM (SELECT Value(iccid) ICC_Id
6357 FROM EGO_PUB_WS_PARAMS i,
6358 TABLE(XMLSequence(
6359 extract(i.xmlcontent, '/ICCQueryParam/ICCPubEntityObject/ChildICCs') )) iccid
6360 WHERE session_id=p_session_id
6361 );
6362
6363
6364 END IF; --IF l_batch_id >-1 THEN
6365
6366
6367 /*Populating config parameter*/
6368 Create_Config_Param(p_session_id,p_odi_session_id,G_ICC_WEBSERVICE,l_search_str,l_parent_hier,l_child_hier);
6369
6370 IF (l_batch_id >-1) THEN
6371 --IF (l_valid_bat_entity) THEN
6372 --Bug 8767131
6373 /*Execute cursor to publish data into temporary table */
6374 FOR i IN 1..l_dup_icc_id_tab.Count
6375 LOOP
6376
6377 /*If ICC version is not passed then find out current effective version for passed in ICC
6378 and store in version array table*/
6379 IF l_dup_icc_ver_tab(i)=-1 THEN
6380 BEGIN
6381 SELECT version_seq_id INTO l_dup_icc_ver_tab(i)
6382 FROM
6383 ( SELECT item_catalog_group_id,version_seq_id,MAX(start_active_date) start_active_date
6384 FROM EGO_MTL_CATALOG_GRP_VERS_B
6385 WHERE NVL(end_active_date, sysdate) >= SYSDATE
6386 AND start_active_date <= SYSDATE
6387 AND ITEM_CATALOG_GROUP_ID = l_dup_icc_id_tab(i)
6388 AND version_seq_id > 0
6389 GROUP BY item_catalog_group_id,version_seq_id
6390 HAVING MAX(start_active_date)<=SYSDATE
6391 );
6392 EXCEPTION
6393 WHEN No_Data_Found THEN
6394 l_dup_icc_ver_tab(i):=NULL;
6395 END;
6396 END IF;
6397
6398 l_icc_parent_pub_tab(i):= l_parent_hier;
6399 l_icc_child_pub_tab(i):= l_child_hier;
6400
6401 /*Once get ICC id and corresponding version_id get child ICC's for Each ICC*/
6402
6403 /* Executing cursor to get associated child and their version for passed in icc_id and icc_version*/
6404 FOR j IN cur_icc_ver(l_dup_icc_id_tab(i),l_dup_icc_ver_tab(i),l_icc_parent_pub_tab(i),l_icc_child_pub_tab(i))
6405 LOOP
6406
6407 FOR k IN 1..l_icc_id_tab.Count
6408 LOOP
6409 IF(j.item_catalog_group_id = l_icc_id_tab(k) )
6410 THEN
6411 IF(j.version_seq_id=l_icc_ver_tab(k) OR
6412 ( j.version_seq_id IS NULL AND l_icc_ver_tab(k) IS NULL ))
6413 THEN
6414 l_is_duplicate:=TRUE;
6415 ELSE
6416 l_ref1_value:='DUP';
6417 END IF;
6418
6419 END IF; -- End IF(j.item_catalog_group_id = l_icc_id_tab(k) )
6420 END LOOP; --END FOR k IN 1..l_icc_id_tab.Count
6421
6422 IF(NOT l_is_duplicate) THEN
6423 l_icc_id_tab(l_unique_icc_count):= j.item_catalog_group_id;
6424 l_icc_ver_tab(l_unique_icc_count):= j.version_seq_id;
6425 l_unique_icc_count:=l_unique_icc_count+1;
6426
6427
6428 INSERT INTO ego_odi_ws_entities ( session_id,odi_session_id,entity_type,pk1_value,pk2_value,pk3_value,pk4_value,pk5_value,ref1_value)
6429 VALUES (p_session_id,p_odi_session_id,'ItemCatalogCategory',j.item_catalog_group_id,j.version_seq_id,NULL,NULL,NULL,l_ref1_value);
6430
6431
6432 IF( j.item_catalog_group_id <> l_dup_icc_id_tab(i)) THEN --Bug Fix 8708269.Dont insert record for main Entity again
6433 --Bug 8757388
6434 l_batch_entity_count :=l_batch_entity_count+1;
6435 batch_entity_rec(l_batch_entity_count).batch_id:=l_batch_id;
6436 batch_entity_rec(l_batch_entity_count).pk1_value:=j.item_catalog_group_id;
6437 batch_entity_rec(l_batch_entity_count).pk2_value:=j.version_seq_id;
6438 batch_entity_rec(l_batch_entity_count).pk3_value:=NULL ;
6439 batch_entity_rec(l_batch_entity_count).pk4_value:=NULL ;
6440 batch_entity_rec(l_batch_entity_count).pk5_value:=NULL ;
6441 batch_entity_rec(l_batch_entity_count).user_entered:= 'N';
6442 --END Bug 8757388
6443
6444 END IF; --END IF( j.item_catalog_group_id <> l_icc_id_tab(i)) THEN
6445
6446 END IF; -- END IF(NOT l_is_duplicate) THEN
6447
6448 l_is_duplicate:=FALSE;
6449 l_ref1_value:=NULL;
6450
6451 END LOOP; /*End FOR j IN cur_icc_ver(l_icc_id_tab(i),l_icc_ver_tab(i)) */
6452
6453 END LOOP;/*FOR i IN 1..l_icc_id_tab.Count*/
6454 /* Calling Add_Derived_Entitites API once per batch to have status update.*/
6455 --Bug 8757388
6456 EGO_PUB_FWK_PK.add_derived_entities(batch_entity_rec,x_return_status,x_msg_count,x_msg_data);
6457
6458 --END IF;--END IF (l_valid_bat_entity) THEN
6459
6460 ELSE --Case of list of entities
6461
6462 /*Execute cursor to publish data into temporary table */
6463 FOR i IN 1..l_dup_icc_id_tab.Count
6464 LOOP
6465
6466 /*If ICC version is not passed then find out current effective version for passed in ICC
6467 and store in version array table*/
6468 IF l_dup_icc_ver_tab(i)=-1 THEN
6469 BEGIN
6470 SELECT version_seq_id INTO l_dup_icc_ver_tab(i)
6471 FROM
6472 ( SELECT item_catalog_group_id,version_seq_id,MAX(start_active_date) start_active_date
6473 FROM EGO_MTL_CATALOG_GRP_VERS_B
6474 WHERE NVL(end_active_date, sysdate) >= SYSDATE
6475 AND start_active_date <= SYSDATE
6476 AND ITEM_CATALOG_GROUP_ID = l_dup_icc_id_tab(i)
6477 AND version_seq_id > 0
6478 GROUP BY item_catalog_group_id,version_seq_id
6479 HAVING MAX(start_active_date)<=SYSDATE
6480 );
6481 EXCEPTION
6482 WHEN No_Data_Found THEN
6483 l_dup_icc_ver_tab(i):=NULL;
6484 END;
6485 END IF;
6486
6487 l_icc_parent_pub_tab(i):= l_parent_hier;
6488 l_icc_child_pub_tab(i):= l_child_hier;
6489
6490 l_valid_entity:= validate_entity(p_session_id,p_odi_session_id,NULL,
6491 G_ICC_WEBSERVICE,l_dup_icc_id_tab(i),l_dup_icc_ver_tab(i),
6492 NULL,NULL,NULL);
6493
6494 IF(l_valid_entity)
6495 THEN
6496 /*Once get ICC id and corresponding version_id get child ICC's for Each ICC*/
6497 /* Executing cursor to get associated child and their version for passed in icc_id and icc_version*/
6498 FOR j IN cur_icc_ver(l_dup_icc_id_tab(i),l_dup_icc_ver_tab(i),l_icc_parent_pub_tab(i),l_icc_child_pub_tab(i))
6499 LOOP
6500 FOR k IN 1..l_icc_id_tab.Count
6501 LOOP
6502 IF(j.item_catalog_group_id = l_icc_id_tab(k) )
6503 THEN
6504 IF(j.version_seq_id=l_icc_ver_tab(k) OR
6505 ( j.version_seq_id IS NULL AND l_icc_ver_tab(k) IS NULL ))
6506 THEN
6507 l_is_duplicate:=TRUE;
6508 ELSE
6509 l_ref1_value:='DUP';
6510 END IF;
6511 END IF; --End IF(j.item_catalog_group_id = l_icc_id_tab(k) )
6512
6513 END LOOP; --END FOR k IN 1..l_icc_id_tab.Count
6514
6515 IF(NOT l_is_duplicate) THEN
6516 l_icc_id_tab(l_unique_icc_count):= j.item_catalog_group_id;
6517 l_icc_ver_tab(l_unique_icc_count):= j.version_seq_id;
6518 l_unique_icc_count:=l_unique_icc_count+1;
6519
6520 INSERT INTO ego_odi_ws_entities ( session_id,odi_session_id,entity_type,pk1_value,pk2_value,pk3_value,pk4_value,pk5_value,ref1_value)
6521 VALUES (p_session_id,p_odi_session_id,'ItemCatalogCategory',j.item_catalog_group_id,j.version_seq_id,NULL,NULL,NULL,l_ref1_value);
6522
6523 END IF; -- END IF(NOT l_is_duplicate) THEN
6524
6525 l_is_duplicate:=FALSE;
6526 l_ref1_value:=NULL;
6527
6528
6529 END LOOP; /*End FOR j IN cur_icc_ver(l_dup_icc_id_tab(i),l_dup_icc_ver_tab(i)) */
6530 END IF; --END IF(l_valid_entity)
6531
6532 END LOOP;/*FOR i IN 1..l_icc_id_tab.Count*/
6533
6534 END IF;--END IF (l_batch_id >-1) THEN
6535 --END Bug 8767131
6536 END IF; -- END IF(l_access_priv) THEN
6537 COMMIT;
6538 /*EXCEPTION
6539 WHEN OTHERS THEN
6540 ROLLBACK;*/
6541 END Preprocess_Input_ICC;
6542
6543
6544 /* Procedure to finding out List of ICC's and their version and to publish hierarchy of ICC to temporary table*/
6545 PROCEDURE Preprocess_Input_valueSet ( p_session_id IN NUMBER,
6546 p_odi_session_id IN NUMBER )
6547
6548 IS
6549
6550 l_vs_id_tab dbms_sql.Number_Table; --Netsed table of varchar2 to store ICC_Id's
6551 l_vs_ver_tab dbms_sql.Number_Table; --Netsed table of varchar2 to store ICC Version
6552 l_count NUMBER;
6553
6554 --Bug 8767131
6555 l_dup_vs_id_tab dbms_sql.Number_Table; --Netsed table of varchar2 to store ICC_Id's
6556 l_dup_vs_ver_tab dbms_sql.Number_Table; --Netsed table of varchar2 to store ICC Version
6557 l_unique_val_count NUMBER:=1;
6558 l_is_duplicate BOOLEAN :=FALSE;
6559 l_ref1_value VARCHAR2(200):=NULL;
6560 --Bug 8767131
6561
6562 l_parent_hier VARCHAR2(10);
6563 l_child_hier VARCHAR2(10);
6564 batch_entity_rec EGO_PUB_FWK_PK.TBL_OF_BAT_ENT_OBJ_TYPE;
6565 x_return_status VARCHAR2(1);
6566 x_msg_count NUMBER;
6567 x_msg_data VARCHAR2(500);
6568 l_batch_id NUMBER;
6569 l_mode VARCHAR2(30);
6570 l_icc_parent_pub_tab dbms_sql.VARCHAR2_table;
6571 l_icc_child_pub_tab dbms_sql.VARCHAR2_table;
6572 l_batch_search_str VARCHAR2(100):='/ValuesetQueryParam/BatchId';
6573 l_search_str VARCHAR2(100):='/ValuesetQueryParam';
6574 l_access_priv BOOLEAN :=TRUE;
6575 -- l_valid_bat_entity BOOLEAN :=TRUE;
6576 l_valid_entity BOOLEAN :=TRUE;
6577
6578 l_batch_entity_count NUMBER :=0;
6579 /*Cursor to get child value set*/
6580 CURSOR Cur_vs_list(cp_value_set_id NUMBER , cp_version_seq_id NUMBER )
6581 IS
6582 SELECT value_set_id, version_seq_id
6583 FROM
6584 (
6585 ( SELECT value_set_id,NULL AS version_seq_id
6586 FROM ego_value_sets_v
6587 WHERE cp_version_seq_id IS NULL
6588 START WITH value_set_id = cp_value_set_id
6589 CONNECT BY PRIOR value_set_id = parent_value_set_id
6590 )
6591 UNION ALL
6592 /*( SELECT flex_value_set_id value_set_id ,version_seq_id
6593 FROM EGO_FLEX_VALUESET_VERSION_B
6594 WHERE flex_value_set_id= cp_value_set_id
6595 AND cp_version_seq_id IS NOT NULL
6596 AND NVL(end_active_date, sysdate) >= SYSDATE
6597 AND start_active_date <= SYSDATE
6598 AND version_seq_id>0
6599 ) */
6600 (SELECT cp_value_set_id AS value_set_id, cp_version_seq_id AS version_seq_id
6601 FROM dual
6602 WHERE cp_version_seq_id IS NOT NULL
6603 )
6604 );
6605
6606
6607 BEGIN
6608 -- Check access priviledge for Setup Workbench for a user
6609 l_access_priv:= Check_Access_Priv(p_session_id,p_odi_session_id,G_VS_WEBSERVICE);
6610 -- If user has access then continue else log information in information table
6611 -- and exit procedure
6612 IF(l_access_priv) THEN
6613
6614 /* Call API to find out invocation mode and batch_id, Batch_Id will be -1 if mode is LIST*/
6615 Invocation_Mode( p_session_id,l_batch_search_str,l_mode,l_batch_id);
6616
6617 --Bug 8767131
6618 --If mode is batch then batch_id will have value greater than -1
6619 IF l_batch_id >-1 THEN
6620 /*l_valid_bat_entity:= validate_entity(p_session_id,p_odi_session_id,l_batch_id,
6621 G_VS_WEBSERVICE,NULL,NULL,NULL,NULL,NULL);*/
6622
6623 SELECT pk1_value , Nvl(pk2_value,-1) --Bug 8722729
6624 BULK COLLECT INTO l_dup_vs_id_tab, l_dup_vs_ver_tab
6625 FROM Ego_Pub_Bat_Ent_Objs_v --Find out if any other PK's
6626 WHERE batch_id = l_batch_id AND user_entered = 'Y';
6627
6628
6629 ELSE
6630
6631 /*Extract value into array if ICCId node exist in Input table*/
6632 SELECT extractValue(ValueSet_Id, '/ValueSetId')
6633 BULK COLLECT INTO l_dup_vs_id_tab
6634 FROM (SELECT Value(VSId) ValueSet_Id
6635 FROM EGO_PUB_WS_PARAMS i,
6636 TABLE(XMLSequence(
6637 extract(i.xmlcontent, '/ValuesetQueryParam/ValuesetIdentifiersList/ValuesetIdentifier/ValueSetId') )) VSId
6638 WHERE session_id=p_session_id
6639 );
6640
6641
6642 /*Extract value into array if VersionSequence node exist in Input table*/
6643 SELECT Nvl(extractValue(ValueSet_Ver, '/VersionSeqId'),-1)
6644 BULK COLLECT INTO l_dup_vs_ver_tab
6645 FROM (SELECT Value(VSVer) ValueSet_Ver
6646 FROM EGO_PUB_WS_PARAMS i,
6647 TABLE(XMLSequence(
6648 extract(i.xmlcontent, '/ValuesetQueryParam/ValuesetIdentifiersList/ValuesetIdentifier/VersionSeqId') )) VSVer
6649 WHERE session_id=p_session_id
6650 );
6651 END IF; --IF l_batch_id >-1 THEN
6652
6653 /*Populating config parameter*/
6654 --Create_Config_Param_ValueSet(p_session_id,p_odi_session_id);
6655 Create_Config_Param(p_session_id,p_odi_session_id,G_VS_WEBSERVICE,l_search_str,NULL,NULL);
6656
6657 IF (l_batch_id >-1 )
6658 THEN
6659 /*Execute cursor to publish data into temporary table */
6660 FOR i IN 1..l_dup_vs_id_tab.Count
6661 LOOP
6662 --Bug 8722729
6663 /*If VS version is not passed then find out current effective version for passed in VS
6664 and store in version array table*/
6665 IF l_dup_vs_ver_tab(i)=-1 THEN
6666 BEGIN
6667 SELECT version_seq_id INTO l_dup_vs_ver_tab(i)
6668 FROM EGO_FLEX_VALUESET_VERSION_B
6669 WHERE NVL(end_active_date, sysdate) >= SYSDATE
6670 AND start_active_date <= SYSDATE
6671 AND FLEX_VALUE_SET_ID = l_dup_vs_id_tab(i)
6672 AND version_seq_id > 0;
6673 EXCEPTION
6674 WHEN No_Data_Found THEN
6675 l_dup_vs_ver_tab(i):=NULL;
6676 END;
6677 END IF; --END IF l_vs_ver_tab(i)=0 THEN --YJ Changed for bug 8736726
6678
6679
6680 /*Once get ICC id and corresponding version_id get child ICC's for Each ICC*/
6681
6682 /* Executing cursor to get associated child and their version for passed in icc_id and icc_version*/
6683 FOR j IN Cur_vs_list(l_dup_vs_id_tab(i), l_dup_vs_ver_tab(i) )
6684 LOOP
6685 FOR k IN 1..l_vs_id_tab.Count
6686 LOOP
6687 IF(j.value_set_id= l_vs_id_tab(k) )
6688 THEN
6689
6690 IF( j.version_seq_id=l_vs_ver_tab(k) OR
6691 (j.version_seq_id IS NULL AND l_vs_ver_tab(k) IS null ) )
6692 THEN
6693 l_is_duplicate:=TRUE;
6694 ELSE
6695 l_ref1_value:='DUP';
6696 END IF;
6697
6698 END IF; --END IF(l_dup_vs_id_tab(i)= l_vs_id_tab(k) )
6699 END LOOP; --END FOR k IN 1..l_vs_id_tab.Count
6700
6701
6702 IF(NOT l_is_duplicate) THEN
6703 l_vs_id_tab(l_unique_val_count):= j.value_set_id; -- l_dup_vs_id_tab(i);
6704 l_vs_ver_tab(l_unique_val_count):=j.version_seq_id; -- NULL; l_dup_vs_ver_tab(i);
6705 l_unique_val_count:=l_unique_val_count+1;
6706
6707
6708 INSERT INTO ego_odi_ws_entities ( session_id,odi_session_id,entity_type,pk1_value,pk2_value,pk3_value,pk4_value,pk5_value,ref1_value)
6709 VALUES (p_session_id,p_odi_session_id,'ValueSet',j.value_set_id,j.version_seq_id,NULL,NULL,NULL,l_ref1_value);
6710
6711
6712 IF( j.value_set_id <> l_dup_vs_ver_tab(i)) THEN --Bug Fix 8708269.Dont insert record for main Entity again
6713 --Bug 8757388
6714 l_batch_entity_count :=l_batch_entity_count+1;
6715 batch_entity_rec(l_batch_entity_count).batch_id:=l_batch_id;
6716 batch_entity_rec(l_batch_entity_count).pk1_value:=j.value_set_id;
6717 batch_entity_rec(l_batch_entity_count).pk2_value:=NULL ; --A child value set can only be created for a non version VS.
6718 batch_entity_rec(l_batch_entity_count).pk3_value:=NULL ;
6719 batch_entity_rec(l_batch_entity_count).pk4_value:=NULL ;
6720 batch_entity_rec(l_batch_entity_count).pk5_value:=NULL ;
6721 batch_entity_rec(l_batch_entity_count).user_entered:= 'N';
6722 --END Bug 8757388
6723 END IF; --END IF( j.value_set_id <> l_dup_vs_ver_tab(i)) THEN
6724
6725 END IF; --END IF(NOT l_is_duplicate) THEN
6726 l_is_duplicate:=FALSE;
6727 l_ref1_value:=NULL;
6728 END LOOP; -- end FOR j IN cur_child_vs(l_dup_vs_id_tab(i) )
6729
6730
6731 /*FOR k IN 1..l_vs_id_tab.Count
6732 LOOP
6733 IF(l_dup_vs_id_tab(i)= l_vs_id_tab(k) )
6734 THEN
6735
6736 IF( l_dup_vs_ver_tab(i)=l_vs_ver_tab(k) OR
6737 (l_dup_vs_ver_tab(i)IS NULL AND l_vs_ver_tab(k) IS null ) )
6738 THEN
6739 l_is_duplicate:=TRUE;
6740 ELSE
6741 l_ref1_value:='DUP';
6742 END IF;
6743
6744 END IF; --END IF(l_dup_vs_id_tab(i)= l_vs_id_tab(k) )
6745 END LOOP; --END FOR k IN 1..l_vs_id_tab.Count
6746
6747
6748 IF(NOT l_is_duplicate) THEN
6749 l_vs_id_tab(l_unique_val_count):= l_dup_vs_id_tab(i);
6750 l_vs_ver_tab(l_unique_val_count):= l_dup_vs_ver_tab(i);
6751 l_unique_val_count:=l_unique_val_count+1;
6752
6753
6754 INSERT INTO ego_odi_ws_entities ( session_id,odi_session_id,entity_type,pk1_value,pk2_value,pk3_value,pk4_value,pk5_value,ref1_value)
6755 VALUES (p_session_id,p_odi_session_id,'ValueSet',l_dup_vs_id_tab(i),l_dup_vs_ver_tab(i),NULL,NULL,NULL,l_ref1_value);
6756
6757 END IF;
6758
6759 l_is_duplicate:=FALSE;
6760 l_ref1_value:=NULL; */
6761
6762 END LOOP;/*FOR i IN 1..l_dup_vs_id_tab.Count*/
6763 /*Calling API for derived entity*/
6764 EGO_PUB_FWK_PK.add_derived_entities(batch_entity_rec,x_return_status,x_msg_count,x_msg_data);
6765
6766
6767 ELSE -- Case of list mode
6768 /*Execute cursor to publish data into temporary table */
6769 FOR i IN 1..l_dup_vs_id_tab.Count
6770 LOOP
6771
6772 /*If VS version is not passed then find out current effective version for passed in VS
6773 and store in version array table*/
6774 IF l_dup_vs_ver_tab(i)=-1 THEN
6775 BEGIN
6776 SELECT version_seq_id INTO l_dup_vs_ver_tab(i)
6777 FROM EGO_FLEX_VALUESET_VERSION_B
6778 WHERE NVL(end_active_date, sysdate) >= SYSDATE
6779 AND start_active_date <= SYSDATE
6780 AND FLEX_VALUE_SET_ID = l_dup_vs_id_tab(i)
6781 AND version_seq_id > 0;
6782 EXCEPTION
6783 WHEN No_Data_Found THEN
6784 l_dup_vs_ver_tab(i):=NULL;
6785 END;
6786 END IF; --END IF l_vs_ver_tab(i)=0 THEN
6787
6788 l_valid_entity:= validate_entity(p_session_id,p_odi_session_id,NULL,G_VS_WEBSERVICE,
6789 l_dup_vs_id_tab(i),l_dup_vs_ver_tab(i),NULL,NULL,NULL);
6790
6791 IF (l_valid_entity)
6792 THEN
6793
6794 /* Executing cursor to get associated child and their version for passed in icc_id and icc_version*/
6795 FOR j IN Cur_vs_list(l_dup_vs_id_tab(i), l_dup_vs_ver_tab(i) )
6796 LOOP
6797 FOR k IN 1..l_vs_id_tab.Count
6798 LOOP
6799 IF(j.value_set_id = l_vs_id_tab(k) )
6800 THEN
6801 IF( j.version_seq_id=l_vs_ver_tab(k) OR
6802 (j.version_seq_id IS NULL AND l_vs_ver_tab(k) IS null ) )
6803 THEN
6804 l_is_duplicate:=TRUE;
6805 ELSE
6806 l_ref1_value:='DUP';
6807 END IF;
6808
6809 END IF; --END IF(l_dup_vs_id_tab(i)= l_vs_id_tab(k) )
6810 END LOOP; --END FOR k IN 1..l_vs_id_tab.Count
6811
6812 IF(NOT l_is_duplicate) THEN
6813 l_vs_id_tab(l_unique_val_count):= j.value_set_id;
6814 l_vs_ver_tab(l_unique_val_count):= j.version_seq_id;
6815 l_unique_val_count:=l_unique_val_count+1;
6816
6817 INSERT INTO ego_odi_ws_entities ( session_id,odi_session_id,entity_type,pk1_value,pk2_value,pk3_value,pk4_value,pk5_value,ref1_value)
6818 VALUES (p_session_id,p_odi_session_id,'ValueSet',j.value_set_id,j.version_seq_id,NULL,NULL,NULL,l_ref1_value);
6819
6820 END IF;
6821 l_is_duplicate:=FALSE;
6822 l_ref1_value:=NULL;
6823
6824 END LOOP; /*End FOR j IN cur_icc_ver(l_dup_icc_id_tab(i),l_dup_icc_ver_tab(i)) */
6825
6826 END IF; -- end IF (l_valid_entity)
6827
6828 l_valid_entity:=TRUE;
6829
6830 END LOOP;/* FOR i IN 1..l_vs_id_tab.Count*/
6831
6832 END IF; -- END IF (l_batch_id >-1 )
6833 --END Bug 8722729
6834 END IF; -- END IF(l_access_priv) THEN
6835 COMMIT;
6836
6837
6838
6839
6840 /*FOR k IN 1..l_vs_id_tab.Count
6841 LOOP
6842 IF(l_dup_vs_id_tab(i)= l_vs_id_tab(k) )
6843 THEN
6844 IF( l_dup_vs_ver_tab(i)=l_vs_ver_tab(k) OR
6845 (l_dup_vs_ver_tab(i)IS NULL AND l_vs_ver_tab(k) IS null ) )
6846 THEN
6847 l_is_duplicate:=TRUE;
6848 ELSE
6849 l_ref1_value:='DUP';
6850 END IF;
6851
6852 END IF; --END IF(l_dup_vs_id_tab(i)= l_vs_id_tab(k) )
6853 END LOOP; --END FOR k IN 1..l_vs_id_tab.Count
6854
6855 IF(NOT l_is_duplicate) THEN
6856 l_vs_id_tab(l_unique_val_count):= l_dup_vs_id_tab(i);
6857 l_vs_ver_tab(l_unique_val_count):= l_dup_vs_ver_tab(i);
6858 l_unique_val_count:=l_unique_val_count+1;
6859
6860 INSERT INTO ego_odi_ws_entities ( session_id,odi_session_id,entity_type,pk1_value,pk2_value,pk3_value,pk4_value,pk5_value,ref1_value)
6861 VALUES (p_session_id,p_odi_session_id,'ValueSet',l_dup_vs_id_tab(i),l_dup_vs_ver_tab(i),NULL,NULL,NULL,l_ref1_value);
6862
6863 END IF;
6864 l_is_duplicate:=FALSE;
6865 l_ref1_value:=NULL;
6866
6867 END IF; -- end IF (l_valid_entity)
6868
6869 l_valid_entity:=TRUE;
6870
6871 END LOOP; -- FOR i IN 1..l_vs_id_tab.Count
6872
6873 END IF; -- END IF (l_batch_id >-1 )
6874 --END Bug 8722729
6875 END IF; -- END IF(l_access_priv) THEN
6876 COMMIT; */
6877 END Preprocess_Input_valueSet;
6878
6879
6880
6881 /* Function to check for access priviledge to a user and
6882 return boolean value*/
6883 FUNCTION Check_Access_Priv(p_session_id IN NUMBER,
6884 p_odi_session_id IN NUMBER,
6885 p_web_service_name IN VARCHAR2)
6886 RETURN BOOLEAN
6887 IS
6888 l_user_name VARCHAR2(100) :=NULL;
6889 l_appl_name VARCHAR2(100) :=NULL;
6890 l_resp_key VARCHAR2(100) :=NULL;
6891 l_resp_name VARCHAR2(100) :=NULL;
6892 l_user_id NUMBER;
6893 l_resp_id NUMBER;
6894 l_application_id NUMBER;
6895 count_val NUMBER :=0;
6896
6897 /*Cursor to get I/P value for user_name, resp_name and appl_name */
6898 CURSOR Cur_ws_input (cp_session_id NUMBER )
6899 IS
6900 SELECT fnd_user_name,responsibility_appl_name,responsibility_name
6901 FROM ego_pub_ws_params
6902 WHERE session_id=cp_session_id;
6903
6904
6905
6906 /*Cursor to check if access priv is available to a user and to a responsibility for a function */
6907 CURSOR Cur_priv(cp_user_id NUMBER,
6908 cp_resp_id NUMBER)
6909 IS
6910 SELECT Count(furgd.responsibility_id) val
6911 FROM fnd_user_resp_groups_direct furgd, fnd_responsibility fr
6912 WHERE furgd.responsibility_id=fr.responsibility_id
6913 AND fr.menu_id IN
6914 (SELECT menu_id
6915 FROM fnd_menu_entries
6916 START WITH function_id IN
6917 (SELECT function_id
6918 FROM fnd_form_functions
6919 WHERE function_name='EGO_ITEM_ADMINISTRATION'
6920 )
6921 CONNECT BY PRIOR menu_id=sub_menu_id
6922 )
6923 AND furgd.user_id= cp_user_id
6924 AND furgd.responsibility_id= cp_resp_id
6925 AND furgd.start_date <=SYSDATE
6926 AND Nvl(furgd.end_date,sysdate+1) > SYSDATE;
6927
6928
6929
6930 l_icc_search_str VARCHAR2(100) :='/ICCQueryParam/BatchId';
6931 l_vs_search_str VARCHAR2(100) :='/ValuesetQueryParam/BatchId';
6932 l_session_id NUMBER :=p_session_id;
6933 l_mode VARCHAR2(30);
6934 l_batch_id NUMBER:=-1;
6935 BEGIN
6936 --Dbms_Output.put_line('Start of Check_Access_Priv ' );
6937 IF(p_web_service_name=G_ICC_WEBSERVICE)
6938 THEN
6939 Invocation_Mode( l_session_id,l_icc_search_str,l_mode,l_batch_id);
6940
6941 END IF;
6942
6943
6944 IF(p_web_service_name=G_VS_WEBSERVICE)
6945 THEN
6946 Invocation_Mode( l_session_id,l_vs_search_str,l_mode,l_batch_id);
6947 END IF;
6948
6949 --If mode is batch then batch_id will have value greater than -1
6950 IF l_batch_id >-1 THEN
6951 --retrieving user_id and responsability
6952 BEGIN
6953
6954 --Populate batch identifier
6955 Populate_Input_Identifier(p_session_id,p_odi_session_id,1,'batch_id',l_batch_id);
6956
6957
6958 SELECT created_by, responsibility_id
6959 INTO l_user_id,l_resp_id
6960 FROM EGO_PUB_BAT_HDR_B
6961 WHERE batch_id = l_batch_id;
6962
6963 EXCEPTION
6964 WHEN No_Data_Found THEN
6965 Log_Error(p_session_id,p_odi_session_id,1,'EGO_INVALID_BATCH','Input batch is not a valid batch. Please publish valid batch id.');
6966 RETURN FALSE;
6967 END;
6968
6969 --retrieving responsability_id
6970 SELECT application_id
6971 INTO l_application_id
6972 FROM FND_RESPONSIBILITY
6973 WHERE responsibility_id = l_resp_id;
6974
6975
6976 /*Get username for passed in user id*/
6977 BEGIN
6978 SELECT USER_NAME INTO l_user_name
6979 FROM FND_USER
6980 WHERE USER_ID =l_user_id;
6981 EXCEPTION
6982 WHEN No_Data_Found THEN
6983 --Dbms_Output.put_line( ' The User name is not a valid user name.');
6984 RETURN FALSE;
6985 END;
6986
6987
6988 /*Get respId for passed in responsibility name*/
6989 BEGIN
6990 SELECT responsibility_name INTO l_resp_name
6991 FROM fnd_responsibility_vl
6992 WHERE application_id = l_application_id
6993 AND responsibility_id =l_resp_id ;
6994 EXCEPTION
6995 WHEN No_Data_Found THEN
6996 --Dbms_Output.put_line( ' The responsibility name is not a valid responsibility name.');
6997 RETURN FALSE;
6998 END;
6999
7000
7001 ELSE --Case when mode is LIST
7002
7003
7004 FOR i IN Cur_ws_input(p_session_id)
7005 LOOP
7006 l_user_name:=i.fnd_user_name;
7007 l_appl_name:=i.responsibility_appl_name;
7008 l_resp_key:=i.responsibility_name;
7009 END LOOP;
7010
7011 /*Get userId for passed in user name*/
7012 BEGIN
7013 SELECT USER_ID INTO l_user_id
7014 FROM FND_USER
7015 WHERE USER_NAME =l_user_name;
7016 EXCEPTION
7017 WHEN No_Data_Found THEN
7018 --Dbms_Output.put_line( ' The User name is not a valid user name.');
7019 RETURN FALSE;
7020 END;
7021
7022
7023 /*Get appId for passed in application short name*/
7024 BEGIN
7025 SELECT application_id INTO l_application_id
7026 FROM fnd_application
7027 WHERE application_short_name =l_appl_name;
7028 EXCEPTION
7029 WHEN No_Data_Found THEN
7030 --Dbms_Output.put_line( ' The application name is not a valid application name.');
7031 RETURN FALSE;
7032 END;
7033
7034
7035 /*Get respId for passed in responsibility name*/
7036 BEGIN
7037 SELECT responsibility_id,responsibility_name INTO l_resp_id,l_resp_name
7038 FROM fnd_responsibility_vl
7039 WHERE application_id = l_application_id
7040 AND responsibility_key=l_resp_key;
7041 EXCEPTION
7042 WHEN No_Data_Found THEN
7043 --Dbms_Output.put_line( ' The responsibility name is not a valid responsibility name.');
7044 RETURN FALSE;
7045 END;
7046 END IF;
7047
7048
7049 /*Initialize apps context*/
7050 FND_GLOBAL.APPS_INITIALIZE( USER_ID=>l_user_id,
7051 RESP_ID=>l_resp_id,
7052 RESP_APPL_ID=>l_application_id);
7053
7054
7055
7056 --Check if user for a responsibility has access to a function
7057 FOR j IN Cur_priv(l_user_id,l_resp_id)
7058 LOOP
7059 count_val:=j.val;
7060 END LOOP;
7061
7062
7063 IF(count_val>0) --If user for a responsibility has access to a function
7064 THEN
7065
7066 RETURN TRUE;
7067 ELSE
7068 -- Log error if user does not have access to function 'EGO_ITEM_ADMINISTRATION'
7069 Log_Error(p_session_id,p_odi_session_id,NULL,'EGO_FUNCTION_ACCESS_SECURITY','User ' ||l_user_name||' logged in with current responsibility '||l_resp_name ||' does not have access to Setup Workbench ');
7070 RETURN FALSE ;
7071 END IF;
7072
7073
7074
7075 END Check_Access_Priv;
7076
7077
7078
7079 /*Procedure to insert records into Input Identifiers table*/
7080 PROCEDURE Populate_Input_Identifier(p_session_id IN NUMBER,
7081 p_odi_session_id IN NUMBER,
7082 p_input_id IN NUMBER,
7083 p_param_name IN VARCHAR2,
7084 p_param_value IN VARCHAR2)
7085 IS
7086
7087 BEGIN
7088
7089 INSERT INTO EGO_PUB_WS_INPUT_IDENTIFIERS(session_id,
7090 odi_session_id,
7091 input_id,
7092 param_name,
7093 param_value,
7094 creation_date,
7095 created_by)
7096 VALUES(p_session_id,
7097 p_odi_session_id,
7098 p_input_id,
7099 p_param_name,
7100 p_param_value,
7101 SYSDATE,
7102 -1);
7103
7104
7105 END Populate_Input_Identifier;
7106
7107 /*Procedure to Log Errors*/
7108 PROCEDURE Log_Error(p_session_id IN NUMBER,
7109 p_odi_session_id IN NUMBER,
7110 p_input_id IN NUMBER,
7111 p_err_code IN VARCHAR2,
7112 p_err_message IN VARCHAR2)
7113 IS
7114
7115 BEGIN
7116
7117 INSERT INTO EGO_PUB_WS_ERRORS(session_id,
7118 odi_session_id,
7119 input_id,
7120 err_code,
7121 err_message,
7122 creation_date,
7123 created_by)
7124 VALUES(p_session_id,
7125 p_odi_session_id,
7126 p_input_id,
7127 p_err_code,
7128 p_err_message,
7129 SYSDATE,
7130 -1);
7131
7132
7133 END Log_Error;
7134
7135 /*Validate batch and list of entities*/
7136 FUNCTION validate_entity(p_session_id NUMBER,
7137 p_odi_session_id NUMBER,
7138 p_batch_id NUMBER DEFAULT NULL,
7139 p_webservice_name VARCHAR2 DEFAULT NULL,
7140 p_pk1_value VARCHAR2 DEFAULT NULL,
7141 p_pk2_value VARCHAR2 DEFAULT NULL,
7142 p_pk3_value VARCHAR2 DEFAULT NULL,
7143 p_pk4_value VARCHAR2 DEFAULT NULL,
7144 p_pk5_value VARCHAR2 DEFAULT NULL)
7145 RETURN BOOLEAN
7146 AS
7147
7148
7149 l_batch_count NUMBER :=0;
7150 l_icc_count NUMBER :=0;
7151 l_vs_count NUMBER :=0;
7152 l_pk1_value VARCHAR2(100) := NULL;
7153 l_pk2_value VARCHAR2(100) := NULL;
7154 l_pk3_value VARCHAR2(100) := NULL;
7155 l_pk4_value VARCHAR2(100) := NULL;
7156 l_pk5_value VARCHAR2(100) := NULL;
7157 l_input_id NUMBER :=0;
7158
7159 --Validate if passed in Batch_Id to webservices are valid.
7160 CURSOR cur_batch
7161 IS
7162 SELECT Count(batch_id) batch_exist
7163 FROM ego_pub_bat_hdr_b
7164 WHERE BATCH_ID= p_batch_id;
7165
7166 --Cursor for versioned ICC
7167 CURSOR cur_ver_icc(cp_item_catalog_group_id NUMBER,
7168 cp_version_seq_id NUMBER)
7169 IS
7170 SELECT Count(base.item_catalog_group_id) ver_icc_count
7171 FROM mtl_item_catalog_groups_b base ,EGO_MTL_CATALOG_GRP_VERS_B vers
7172 WHERE base.item_catalog_group_id= vers.item_catalog_group_id
7173 AND base.item_catalog_group_id=cp_item_catalog_group_id
7174 AND vers.version_seq_id=Nvl(cp_version_seq_id,vers.version_seq_id)
7175 AND vers.version_seq_id>0; --Yjain
7176
7177
7178 --Cursor for non versioned ICC
7179 CURSOR cur_icc(cp_item_catalog_group_id NUMBER)
7180 IS
7181 SELECT Count(item_catalog_group_id) icc_count
7182 FROM mtl_item_catalog_groups_b
7183 WHERE item_catalog_group_id=cp_item_catalog_group_id;
7184
7185
7186
7187 --Cursor for versioned VS
7188 CURSOR cur_ver_vs( cp_flex_value_set_id NUMBER,
7189 cp_version_seq_id NUMBER)
7190 IS
7191 SELECT Count(base.flex_value_set_id) ver_vs_count
7192 FROM fnd_flex_value_sets base ,EGO_FLEX_VALUESET_VERSION_B vers
7193 WHERE base.flex_value_set_id= vers.flex_value_set_id
7194 AND base.flex_value_set_id=cp_flex_value_set_id
7195 AND vers.version_seq_id =Nvl(cp_version_seq_id,vers.version_seq_id)
7196 AND vers.version_seq_id >0; --Yjain
7197
7198
7199
7200 --Cursor for non versioned VS
7201 CURSOR cur_vs(cp_flex_value_set_id NUMBER)
7202 IS
7203 SELECT Count(flex_value_set_id) vs_count
7204 FROM fnd_flex_value_sets
7205 WHERE flex_value_set_id=cp_flex_value_set_id;
7206
7207
7208 CURSOR cur_input_id(cp_session_id NUMBER,
7209 cp_odi_session_id NUMBER)
7210 IS
7211 SELECT (Nvl(Max(input_id),0)+1) AS input_id
7212 FROM EGO_PUB_WS_INPUT_IDENTIFIERS
7213 WHERE session_id=cp_session_id
7214 AND odi_session_id= cp_odi_session_id;
7215
7216 BEGIN
7217
7218 --Dbms_Output.put_line(' Start of Validate_ENTITY' );
7219 -- If no input has been passed then log error with no input and return with 'FALSE'.
7220 IF(p_batch_id IS NULL AND p_webservice_name IS NULL AND p_pk1_value IS NULL AND p_pk2_value IS NULL
7221 AND p_pk3_value IS NULL AND p_pk4_value IS NULL AND p_pk5_value IS NULL )
7222 THEN
7223
7224 Log_Error(p_session_id,p_odi_session_id,NULL,'EGO_NO_INPUT','No input has been provided to webservices');
7225
7226 /*INSERT INTO EGO_PUB_WS_ERRORS (session_id,odi_session_id,input_id,
7227 err_code,err_message,creation_date,created_by)
7228 VALUES (p_session_id,p_odi_session_id,NULL,'EGO_NO_INPUT','No input has been provided to webservices');*/
7229
7230 RETURN FALSE;
7231 END IF;
7232
7233 --Get Next input_id for identifier
7234 FOR i IN cur_input_id(p_session_id,p_odi_session_id)
7235 LOOP
7236 l_input_id := i.input_id;
7237 END LOOP;
7238
7239
7240 --Batch mode validation
7241 /*IF (p_batch_id IS NOT NULL)
7242 THEN
7243 --dbms_output.put_line(' Validate_ENTITY : BATCH MODE' );
7244 FOR i IN cur_batch
7245 LOOP
7246 l_batch_count:=i.batch_exist;
7247 END LOOP;
7248
7249 --Populate batch identifier
7250 Populate_Input_Identifier(p_session_id,p_odi_session_id,l_input_id,'batch_id',p_batch_id);
7251
7252 --Batch count will be '1' if batch is valid, It will be zero if it is invalid.
7253 --Insert record if batch is not a valid batch
7254 IF (l_batch_count<>1)
7255 THEN
7256
7257 Log_Error(p_session_id,p_odi_session_id,l_input_id,'EGO_INVALID_BATCH','Input batch is not a valid batch. Please publish valid batch id.');
7258 RETURN FALSE;
7259 --INSERT INTO EGO_PUB_WS_ERRORS (session_id,odi_session_id,input_id,
7260 -- err_code,err_message,creation_date,created_by)
7261 --VALUES (p_session_id,p_odi_session_id,NULL,'EGO_INVALID_BATCH','Input batch is not a valid batch. Please publish valid batch id.');
7262 ELSE
7263 RETURN TRUE;
7264 END IF;
7265
7266 --Case of list of entities
7267 ELSE */
7268 IF(p_webservice_name=G_VS_WEBSERVICE)
7269 THEN
7270 IF (p_pk1_value IS NOT NULL AND p_pk2_value IS NOT NULL)
7271 THEN
7272 FOR i IN cur_ver_vs(p_pk1_value,p_pk2_value)
7273 LOOP
7274 l_vs_count := i.ver_vs_count;
7275
7276 END LOOP; -- End FOR i IN cur_ver_vs
7277
7278 --Populate list identifier
7279 Populate_Input_Identifier(p_session_id,p_odi_session_id,l_input_id,'value_set_id',p_pk1_value);
7280 Populate_Input_Identifier(p_session_id,p_odi_session_id,l_input_id,'value_set_version',p_pk2_value);
7281
7282
7283
7284 IF (l_vs_count=0 )
7285 THEN
7286
7287 Log_Error(p_session_id,p_odi_session_id,l_input_id,'EGO_INVALID_VS_LIST','Input ValueSetId and VersionId combination is not a valid combination. Please publish valid combination of ValueSetId and VersionId.');
7288 RETURN FALSE;
7289 /*INSERT INTO EGO_PUB_WS_ERRORS (session_id,odi_session_id,input_id,
7290 err_code,err_message,creation_date,created_by)
7291 VALUES (p_session_id,p_odi_session_id,l_input_id,'EGO_INVALID_BATCH','Input batch is not a valid batch. Please publish valid batch id.',SYSDATE,G_CURRENT_USER_ID);*/
7292 ELSE
7293 RETURN TRUE;
7294
7295 END IF;
7296
7297
7298 ELSIF (p_pk1_value IS NOT NULL AND p_pk2_value IS NULL)
7299 THEN
7300 FOR i IN cur_vs(p_pk1_value)
7301 LOOP
7302 l_vs_count := i.vs_count;
7303
7304 END LOOP; -- End FOR i IN cur_vs
7305
7306 --Populate list identifier
7307 Populate_Input_Identifier(p_session_id,p_odi_session_id,l_input_id,'value_set_id',p_pk1_value);
7308
7309 IF (l_vs_count=0 )
7310 THEN
7311 Log_Error(p_session_id,p_odi_session_id,l_input_id,'EGO_INVALID_VS_LIST','Input ValueSetId is not a valid id. Please publish valid ValueSetId.');
7312 RETURN FALSE;
7313 /*INSERT INTO EGO_PUB_WS_ERRORS (session_id,odi_session_id,input_id,
7314 err_code,err_message,creation_date,created_by)
7315 VALUES (p_session_id,p_odi_session_id,NULL,'EGO_INVALID_BATCH','Input batch is not a valid batch. Please publish valid batch id.',SYSDATE,G_CURRENT_USER_ID);*/
7316 ELSE
7317 RETURN TRUE;
7318 END IF;
7319
7320 END IF; -- END IF (p_pk1_value IS NOT NULL AND p_pk2_value IS NOT NULL)
7321
7322 END IF; --END IF(l_web_service_name=G_VS_WEBSERVICE)
7323
7324 --When ICC webservices are invoked
7325 IF(p_webservice_name=G_ICC_WEBSERVICE)
7326 THEN
7327
7328 IF (p_pk1_value IS NOT NULL AND p_pk2_value IS NOT NULL)
7329 THEN
7330 FOR i IN cur_ver_icc(p_pk1_value,p_pk2_value)
7331 LOOP
7332 l_icc_count := i.ver_icc_count;
7333
7334 END LOOP; -- End FOR i IN cur_ver_icc
7335
7336 --Populate list identifier
7337 Populate_Input_Identifier(p_session_id,p_odi_session_id,l_input_id,'icc_id',p_pk1_value);
7338 Populate_Input_Identifier(p_session_id,p_odi_session_id,l_input_id,'icc_version',p_pk2_value);
7339
7340 IF (l_icc_count=0 )
7341 THEN
7342 Log_Error(p_session_id,p_odi_session_id,l_input_id,'EGO_INVALID_ICC_LIST','Input ICCId and VersionId combination is not a valid combination. Please publish valid combination of ICCId and VersionId.');
7343 RETURN FALSE;
7344 /*INSERT INTO EGO_PUB_WS_ERRORS (session_id,odi_session_id,input_id,
7345 err_code,err_message,creation_date,created_by)
7346 VALUES (p_session_id,p_odi_session_id,NULL,'EGO_INVALID_BATCH','Input batch is not a valid batch. Please publish valid batch id.',SYSDATE,G_CURRENT_USER_ID);*/
7347 ELSE
7348 RETURN TRUE;
7349 END IF;
7350
7351
7352
7353 ELSIF (p_pk1_value IS NOT NULL AND p_pk2_value IS NULL)
7354 THEN
7355 FOR i IN cur_icc(p_pk1_value)
7356 LOOP
7357 l_icc_count := i.icc_count; --Yjain
7358
7359 END LOOP; -- End FOR i IN cur_icc
7360 --Populate list identifier
7361 Populate_Input_Identifier(p_session_id,p_odi_session_id,l_input_id,'icc_id',p_pk1_value);
7362
7363 IF (l_icc_count=0 )
7364 THEN
7365 Log_Error(p_session_id,p_odi_session_id,l_input_id,'EGO_INVALID_ICC_LIST','Input ICCId is not a valid ICCId. Please publish valid ICCId.');
7366 RETURN FALSE;
7367 /*INSERT INTO EGO_PUB_WS_ERRORS (session_id,odi_session_id,input_id,
7368 err_code,err_message,creation_date,created_by)
7369 VALUES (p_session_id,p_odi_session_id,NULL,'EGO_INVALID_BATCH','Input batch is not a valid batch. Please publish valid batch id.',SYSDATE,G_CURRENT_USER_ID);*/
7370 ELSE
7371 RETURN TRUE;
7372
7373 END IF;
7374
7375
7376 END IF; -- END IF (p_pk1_value IS NOT NULL AND p_pk2_value IS NOT NULL)
7377
7378 END IF; -- END IF(l_web_service_name=G_ICC_WEBSERVICE)
7379
7380
7381 /*END IF; -- IF (p_batch_id IS NOT NULL)*/
7382 END validate_entity;
7383
7384
7385 /* Populate transaction attribute into flat table */
7386 PROCEDURE POPULATE_TRANS_ATTR_LIST( p_session_id IN NUMBER,
7387 p_odi_session_id IN NUMBER)
7388
7389 IS
7390
7391 l_icc_start_active_date DATE ;/*ICC start effective date*/
7392 l_icc_create_date DATE ;/*ICC create date*/
7393 l_version_seq_id VARCHAR2(5);
7394
7395
7396 CURSOR Cur_TA_List (cp_item_catalog_category_id NUMBER,
7397 cp_icc_version_number NUMBER,
7398 cp_creation_date DATE ,
7399 cp_start_active_date DATE )
7400 IS
7401
7402 SELECT * FROM
7403 (
7404 SELECT *
7405 FROM
7406 (
7407 SELECT versions.item_catalog_group_id,
7408 versions.icc_version_NUMBER ,
7409 attrs.attr_id ,
7410 attrs.attr_name ,
7411 hier.lev lev
7412 FROM ego_obj_AG_assocs_b assocs ,
7413 ego_attrs_v attrs ,
7414 ego_attr_groups_v ag ,
7415 EGO_TRANS_ATTR_VERS_B versions,
7416 mtl_item_catalog_groups_kfv icv ,
7417 (
7418 SELECT item_catalog_group_id,
7419 LEVEL lev
7420 FROM mtl_item_catalog_groups_b
7421 START WITH item_catalog_group_id = cp_item_catalog_category_id
7422 CONNECT BY PRIOR parent_catalog_group_id = item_catalog_group_id
7423 )
7424 hier
7425 WHERE ag.attr_group_type = 'EGO_ITEM_TRANS_ATTR_GROUP'
7426 AND assocs.attr_group_id = ag.attr_group_id
7427 AND assocs.classification_code = TO_CHAR(hier.item_catalog_group_id)
7428 AND attrs.attr_group_name = ag.attr_group_name
7429 AND TO_CHAR(icv.item_catalog_group_id) = assocs.classification_code
7430 AND TO_CHAR(versions.association_id) = assocs.association_id
7431 AND TO_CHAR(versions.item_catalog_group_id) = assocs.classification_code
7432 AND attrs.attr_id = versions.attr_id
7433
7434 )
7435
7436
7437 )
7438 WHERE
7439 (
7440 ( LEV = 1 AND ICC_VERSION_number =cp_icc_version_number )
7441 OR
7442 ( LEV > 1 AND ( item_catalog_group_id, ICC_VERSION_NUMBER )
7443 IN ( SELECT item_catalog_group_id, VERSION_SEQ_ID
7444 FROM EGO_MTL_CATALOG_GRP_VERS_B
7445 WHERE (item_catalog_group_id,start_active_date )
7446 IN
7447 (SELECT item_catalog_group_id, MAX(start_active_date) start_active_date
7448 FROM EGO_MTL_CATALOG_GRP_VERS_B
7449 WHERE creation_date <= cp_creation_date
7450 AND version_seq_id > 0
7451 AND start_active_date <= cp_start_active_date
7452 GROUP BY item_catalog_group_id
7453 HAVING MAX(start_active_date)<=cp_start_active_date
7454 )
7455 AND version_seq_id > 0
7456 )
7457 )
7458 );
7459
7460
7461 CURSOR cur_icc_list
7462 IS
7463 SELECT sequence_id,parent_sequence_id,pk1_value icc_id ,pk2_value icc_ver
7464 FROM EGO_PUB_WS_FLAT_RECS
7465 WHERE session_id= p_session_id
7466 AND odi_session_id=p_odi_session_id
7467 AND entity_type ='ICCVersion';
7468
7469
7470 l_icc_ta_metadata_tbl EGO_TRAN_ATTR_TBL;
7471 l_return_status VARCHAR2(1):=NULL ;
7472 l_vs_version_number NUMBER;
7473 l_is_inherited Varchar2(10);
7474 l_is_modified Varchar2(10);
7475
7476 BEGIN
7477 --Dbms_Output.put_line(' Start point for POPULATE_TRANS_ATTR_LIST ' );
7478 l_icc_ta_metadata_tbl := EGO_TRAN_ATTR_TBL(NULL);
7479 /* If input parameter has been passed then process data*/
7480 FOR j IN cur_icc_list
7481 LOOP
7482 --IF(p_item_catalog_category_id IS NOT NULL AND p_icc_version IS NOT NULL AND p_icc_version > 0) THEN
7483
7484 --Finding out start effcetive date and creation date of ICC Version
7485 --Dbms_Output.put_line(' In Loop for POPULATE_TRANS_ATTR_LIST j.icc_id = '|| j.icc_id || ' Ver '|| j.icc_ver );
7486 SELECT Nvl(START_ACTIVE_DATE,SYSDATE) ,CREATION_DATE INTO l_icc_start_active_date, l_icc_create_date
7487 FROM EGO_MTL_CATALOG_GRP_VERS_B
7488 WHERE ITEM_CATALOG_GROUP_ID = j.icc_id AND VERSION_SEQ_ID = j.icc_ver;
7489
7490
7491 FOR k IN Cur_TA_List(j.icc_id,j.icc_ver,l_icc_create_date,l_icc_start_active_date)
7492 LOOP
7493 --Dbms_Output.put_line(' In Loop for POPULATE_TRANS_ATTR_LIST j.icc_id = '|| j.icc_id || ' Ver '|| j.icc_ver||' TA Id ='||k.attr_id );
7494 EGO_TRANSACTION_ATTRS_PVT.GET_TRANS_ATTR_METADATA(
7495 x_ta_metadata_tbl =>l_icc_ta_metadata_tbl,
7496 p_item_catalog_category_id => j.icc_id,
7497 p_icc_version => j.icc_ver,
7498 p_attribute_id => k.attr_id,
7499 p_inventory_item_id => null ,
7500 p_organization_id => null,
7501 p_revision_id => NULL,
7502 x_return_status => l_return_status,
7503 x_is_inherited => l_is_inherited,
7504 x_is_modified => l_is_modified );
7505
7506
7507 --Dbms_Output.put_line(' Length for table = l_icc_ta_metadata_tbl.last '||l_icc_ta_metadata_tbl.last );
7508 FOR i IN l_icc_ta_metadata_tbl.first..l_icc_ta_metadata_tbl.last
7509 LOOP
7510 ego_ext_fwk_pub.get_version_number(1,l_icc_ta_metadata_tbl(i).valuesetid,
7511 l_icc_start_active_date,l_icc_create_date,l_vs_version_number,l_return_status);
7512
7513
7514 INSERT
7515 INTO EGO_PUB_WS_FLAT_RECS
7516 (
7517 SESSION_ID ,
7518 ODI_SESSION_ID ,
7519 ENTITY_TYPE ,
7520 SEQUENCE_ID ,
7521 PARENT_SEQUENCE_ID,
7522 PAYLOAD_SEQUENCE ,
7523 PK1_VALUE ,
7524 REF1_VALUE ,
7525 REF2_VALUE ,
7526 REF3_VALUE ,
7527 REF4_VALUE ,
7528 VALUE ,
7529 CREATION_DATE
7530 )
7531 (SELECT p_session_id ,
7532 p_odi_session_id ,
7533 'TransactionAttribute' ,
7534 EGO_PUB_WS_FLAT_RECS_S.NEXTVAL ,
7535 j.sequence_id ,
7536 1 ,
7537 l_icc_ta_metadata_tbl(i).attrid ,
7538 j.icc_id ,
7539 j.icc_ver ,
7540 l_icc_ta_metadata_tbl(i).valuesetid,
7541 l_vs_version_number ,
7542 xmlforest(k.attr_name AS AttrName,
7543 l_icc_ta_metadata_tbl(i).attrid AS AttributeId,
7544 l_icc_ta_metadata_tbl(i).AttrDisplayName AS AttrDisplayName,
7545 l_icc_ta_metadata_tbl(i).SEQUENCE AS AttrSequence,
7546 l_icc_ta_metadata_tbl(i).datatype AS DataTypeCode, -- trudave fix for FP bug 15940029, (FP for bug 14851479)
7547 l_icc_ta_metadata_tbl(i).uomclass AS UOMCLASS,
7548 l_icc_ta_metadata_tbl(i).defaultvalue AS DefaultValue,
7549 l_icc_ta_metadata_tbl(i).rejectedvalue AS RejectedValue,
7550 l_icc_ta_metadata_tbl(i).requiredflag AS RequiredFlag,
7551 l_icc_ta_metadata_tbl(i).readonlyflag AS ReadOnlyFlag,
7552 l_icc_ta_metadata_tbl(i).hiddenflag AS HiddenFlag,
7553 l_icc_ta_metadata_tbl(i).searchableflag AS SearchableFlag,
7554 l_icc_ta_metadata_tbl(i).checkeligibility AS CheckEligibility,
7555 l_is_inherited AS INHERITED,
7556 l_is_modified AS MODIFIED ).getclobval(),
7557 SYSDATE
7558 FROM dual
7559 );
7560
7561 END LOOP;
7562 END LOOP;
7563
7564 --END IF;
7565 END LOOP;
7566 --Dbms_Output.put_line(' End point for POPULATE_TRANS_ATTR_LIST ' );
7567 COMMIT;
7568 END POPULATE_TRANS_ATTR_LIST;
7569
7570 PROCEDURE POPULATE_VSTBLINFO_VSSVC(p_Session_Id IN NUMBER,
7571 p_ODISession_Id IN NUMBER)
7572 IS
7573
7574 CURSOR Table_VS_List IS -- Get all the TableInfo entity type records from Flat table for given Session Id and ODI Session Id
7575 SELECT ego_pub_ws_flat_recs.sequence_id,
7576 ego_validation_table_info_v.flex_value_set_id,
7577 ego_validation_table_info_v.additional_where_clause
7578
7579 FROM ego_pub_ws_flat_recs,
7580 ego_validation_table_info_v
7581
7582 WHERE ego_pub_ws_flat_recs.pk1_value = ego_validation_table_info_v.flex_value_set_id
7583 AND ego_pub_ws_flat_recs.session_id = p_Session_Id
7584 AND ego_pub_ws_flat_recs.odi_session_id = p_ODISession_Id
7585 AND ego_pub_ws_flat_recs.entity_type = 'TableInfo';
7586
7587 TempLong LONG; -- Temporary variable
7588
7589 BEGIN
7590
7591 /* Insert Table Information into Flat except Where Clause because
7592 WhereClause Column is of Type 'LONG' and it is working with XML DB Functions*/
7593 /* Entity Type of the record will be 'TableInfo' which will be child of 'ValueSet' element*/
7594 INSERT
7595 INTO ego_pub_ws_flat_recs
7596 (
7597 session_id ,
7598 odi_session_id ,
7599 entity_type ,
7600 sequence_id ,
7601 parent_sequence_id,
7602 pk1_value ,
7603 value ,
7604 creation_date
7605 )
7606 SELECT p_Session_Id,
7607 p_ODISession_Id,
7608 'TableInfo',
7609 ego_pub_ws_flat_recs_s.nextval,
7610 ego_pub_ws_flat_recs.sequence_id,
7611 ego_validation_table_info_v.flex_value_set_id,
7612 XMLCONCAT( XMLELEMENT("AppName",ego_validation_table_info_v.table_application_name),
7613 XMLELEMENT("AppId",ego_validation_table_info_v.table_application_id),
7614 XMLELEMENT("TableName",ego_validation_table_info_v.application_table_name),
7615 XMLELEMENT("ValueColName",ego_validation_table_info_v.value_column_name),
7616 XMLELEMENT("ValueColType",ego_validation_table_info_v.value_column_type),
7617 XMLELEMENT("ValueColSize",ego_validation_table_info_v.value_column_size),
7618 XMLELEMENT("IDColName",ego_validation_table_info_v.id_column_name),
7619 XMLELEMENT("IDColType",ego_validation_table_info_v.id_column_type),
7620 XMLELEMENT("IDColSize",ego_validation_table_info_v.id_column_size),
7621 XMLELEMENT("MeaningColName",ego_validation_table_info_v.meaning_column_name),
7622 XMLELEMENT("MeaningColType",ego_validation_table_info_v.meaning_column_type),
7623 XMLELEMENT("MeaningColSize",ego_validation_table_info_v.meaning_column_size)
7624 ).getClobVal(),
7625 SYSDATE
7626 FROM ego_pub_ws_flat_recs,
7627 ego_validation_table_info_v
7628 WHERE ego_pub_ws_flat_recs.pk1_value=ego_validation_table_info_v.flex_value_set_id
7629 AND (
7630 ego_pub_ws_flat_recs.session_id = p_Session_Id
7631 AND ego_pub_ws_flat_recs.odi_session_id = p_ODISession_Id
7632 AND ego_pub_ws_flat_recs.entity_type = 'ValueSet'
7633 AND ego_pub_ws_flat_recs.pk2_value IS NULL
7634 AND ego_pub_ws_flat_recs.ref1_value = 'F'
7635 );
7636
7637 /*Insert WhereClause in to Flat table.This record will be Child of 'TableInfo' element*/
7638 /*INSERT
7639 INTO ego_pub_ws_flat_recs
7640 (
7641 session_id ,
7642 odi_session_id ,
7643 entity_type ,
7644 sequence_id ,
7645 parent_sequence_id,
7646 pk1_value ,
7647 value ,
7648 creation_date
7649 )
7650 SELECT p_Session_Id,
7651 p_ODISession_Id,
7652 'WhereClause',
7653 ego_pub_ws_flat_recs_s.nextval,
7654 ego_pub_ws_flat_recs.sequence_id,
7655 ego_validation_table_info_v.flex_value_set_id,
7656 To_Lob(ego_validation_table_info_v.additional_where_clause),
7657 SYSDATE
7658 FROM ego_pub_ws_flat_recs,
7659 ego_validation_table_info_v
7660 WHERE ego_pub_ws_flat_recs.pk1_value=ego_validation_table_info_v.flex_value_set_id
7661 AND (
7662 ego_pub_ws_flat_recs.session_id = p_Session_Id
7663 AND ego_pub_ws_flat_recs.odi_session_id = p_ODISession_Id
7664 AND ego_pub_ws_flat_recs.entity_type = 'TableInfo'
7665 );*/
7666
7667 FOR rec IN Table_VS_List -- For each 'TableInfo' entity type record in Flat table
7668 LOOP
7669
7670 TempLong := '<![CDATA[' || rec.additional_where_clause || ']]>'; --Enclose WhereClause with CDATA to avoid XMLParsing errors if WhereClause contains <,> char.s
7671
7672 INSERT
7673 INTO ego_pub_ws_flat_recs
7674 (
7675 session_id ,
7676 odi_session_id ,
7677 entity_type ,
7678 sequence_id ,
7679 parent_sequence_id,
7680 pk1_value ,
7681 value ,
7682 creation_date
7683 )
7684 VALUES
7685 (
7686 p_Session_Id ,
7687 p_ODISession_Id ,
7688 'WhereClause' ,
7689 ego_pub_ws_flat_recs_s.nextval, -- Sequence Id for record
7690 rec.sequence_id , -- Parent record Sequence Id
7691 rec.flex_value_set_id , -- VlaueSet Id
7692 TempLong , -- enclosed WhereClause value
7693 SYSDATE
7694 );
7695 END LOOP;
7696
7697 COMMIT; --Commit the Data
7698
7699 END POPULATE_VSTBLINFO_VSSVC;
7700
7701
7702 PROCEDURE POPULATE_VSTBLINFO_ICCSVC(p_Session_Id IN NUMBER,
7703 p_ODISession_Id IN NUMBER)
7704 IS
7705
7706 CURSOR Table_VS_List IS -- Get all the 'TableInfo' entity type records from Flat table for given Session Id and ODI Session Id
7707 SELECT ego_pub_ws_flat_recs.sequence_id,
7708 ego_validation_table_info_v.flex_value_set_id,
7709 ego_validation_table_info_v.additional_where_clause
7710
7711 FROM ego_pub_ws_flat_recs,
7712 ego_validation_table_info_v
7713
7714 WHERE ego_pub_ws_flat_recs.pk1_value = ego_validation_table_info_v.flex_value_set_id
7715 AND ego_pub_ws_flat_recs.session_id = p_Session_Id
7716 AND ego_pub_ws_flat_recs.odi_session_id = p_ODISession_Id
7717 AND ego_pub_ws_flat_recs.entity_type = 'TableInfo';
7718
7719 TempLong LONG; -- Temporary variable
7720
7721 BEGIN
7722
7723 /* Insert Table Information into Flat except Where Clause because
7724 WhereClause Column is of Type 'LONG' and it is working with XML DB Functions*/
7725 /* Entity Type of the record will be 'TableInfo' which will be child of 'ValueSet' element*/
7726 INSERT
7727 INTO ego_pub_ws_flat_recs
7728 (
7729 session_id ,
7730 odi_session_id ,
7731 entity_type ,
7732 sequence_id ,
7733 parent_sequence_id,
7734 pk1_value ,
7735 value ,
7736 creation_date
7737 )
7738 SELECT p_Session_Id,
7739 p_ODISession_Id,
7740 'TableInfo',
7741 ego_pub_ws_flat_recs_s.nextval,
7742 ego_pub_ws_flat_recs.sequence_id,
7743 ego_validation_table_info_v.flex_value_set_id,
7744 XMLCONCAT( XMLELEMENT("AppName",ego_validation_table_info_v.table_application_name),
7745 XMLELEMENT("AppId",ego_validation_table_info_v.table_application_id),
7746 XMLELEMENT("TableName",ego_validation_table_info_v.application_table_name),
7747 XMLELEMENT("ValueColName",ego_validation_table_info_v.value_column_name),
7748 XMLELEMENT("ValueColType",ego_validation_table_info_v.value_column_type),
7749 XMLELEMENT("ValueColSize",ego_validation_table_info_v.value_column_size),
7750 XMLELEMENT("IDColName",ego_validation_table_info_v.id_column_name),
7751 XMLELEMENT("IDColType",ego_validation_table_info_v.id_column_type),
7752 XMLELEMENT("IDColSize",ego_validation_table_info_v.id_column_size),
7753 XMLELEMENT("MeaningColName",ego_validation_table_info_v.meaning_column_name),
7754 XMLELEMENT("MeaningColType",ego_validation_table_info_v.meaning_column_type),
7755 XMLELEMENT("MeaningColSize",ego_validation_table_info_v.meaning_column_size)
7756 ).getClobVal(),
7757 SYSDATE
7758 FROM ego_pub_ws_flat_recs,
7759 ego_validation_table_info_v
7760 WHERE ego_pub_ws_flat_recs.pk1_value=ego_validation_table_info_v.flex_value_set_id
7761 AND (
7762 ego_pub_ws_flat_recs.session_id = p_Session_Id
7763 AND ego_pub_ws_flat_recs.odi_session_id = p_ODISession_Id
7764 AND ego_pub_ws_flat_recs.entity_type = 'Valueset'
7765 AND ego_pub_ws_flat_recs.ref1_value = 'UDA'
7766 AND ego_pub_ws_flat_recs.ref2_value = 'F'
7767 );
7768
7769 /*Insert WhereClause in to Flat table.This record will be Child of 'TableInfo' element*/
7770 /*INSERT
7771 INTO ego_pub_ws_flat_recs
7772 (
7773 session_id ,
7774 odi_session_id ,
7775 entity_type ,
7776 sequence_id ,
7777 parent_sequence_id,
7778 pk1_value ,
7779 value ,
7780 creation_date
7781 )
7782 SELECT p_Session_Id,
7783 p_ODISession_Id,
7784 'WhereClause',
7785 ego_pub_ws_flat_recs_s.nextval,
7786 ego_pub_ws_flat_recs.sequence_id,
7787 ego_validation_table_info_v.flex_value_set_id,
7788 To_Lob(ego_validation_table_info_v.additional_where_clause),
7789 SYSDATE
7790 FROM ego_pub_ws_flat_recs,
7791 ego_validation_table_info_v
7792 WHERE ego_pub_ws_flat_recs.pk1_value=ego_validation_table_info_v.flex_value_set_id
7793 AND (
7794 ego_pub_ws_flat_recs.session_id = p_Session_Id
7795 AND ego_pub_ws_flat_recs.odi_session_id = p_ODISession_Id
7796 AND ego_pub_ws_flat_recs.entity_type = 'TableInfo'
7797 );*/
7798
7799 FOR rec IN Table_VS_List -- For each 'TableInfo' entity type record in Flat table
7800 LOOP
7801
7802 TempLong := '<![CDATA[' || rec.additional_where_clause || ']]>'; --Enclose WhereClause with CDATA to avoid XMLParsing errors if WhereClause contains <,> char.s
7803
7804 INSERT
7805 INTO ego_pub_ws_flat_recs
7806 (
7807 session_id ,
7808 odi_session_id ,
7809 entity_type ,
7810 sequence_id ,
7811 parent_sequence_id,
7812 pk1_value ,
7813 value ,
7814 creation_date
7815 )
7816 VALUES
7817 (
7818 p_Session_Id ,
7819 p_ODISession_Id ,
7820 'WhereClause' ,
7821 ego_pub_ws_flat_recs_s.nextval, -- Sequence Id for record
7822 rec.sequence_id , -- Parent record Sequence Id
7823 rec.flex_value_set_id , -- VlaueSet Id
7824 TempLong , -- enclosed WhereClause value
7825 SYSDATE
7826 );
7827 END LOOP;
7828
7829 COMMIT; --Commit the Data
7830
7831 END POPULATE_VSTBLINFO_ICCSVC;
7832
7833
7834 END EGO_ODI_PUB;