DBA Data[Home] [Help]

PACKAGE BODY: APPS.CTO_MANUAL_LINK_CONFIG

Source


1 package body CTO_MANUAL_LINK_CONFIG as
2 /* $Header: CTOLINKB.pls 120.1.12000000.2 2007/10/10 07:51:40 abhissri ship $ */
3 /*============================================================================+
4 |  Copyright (c) 1993 Oracle Corporation    Belmont, California, USA          |
5 |                        All rights reserved.                                 |
6 |                        Oracle Manufacturing                                 |
7 +=============================================================================+
8 |                                                                             |
9 | FILE NAME   : CTOLINKB.pls                                                  |
10 | DESCRIPTION:                                                                |
11 |               This file creates a package that contains procedures called   |
12                 for the Manual Link action from Sales Order Pad.              | |
13 |                                                                             |
14 |                                                                             |
15 | HISTORY     :                                                               |
16 |               Dec 13, 99  Angela Makalintal   Initial version               |
17 |               jul 09,2004  Kiran Konada       3755608
18 |                                               OM api was called with
19 |                                               'Bom and rtg created' status
20 |                                               Now calling display_wf_status
21 |                                               central API to update status
22 |
23 =============================================================================*/
24 
25 /*****************************************************************************
26    Function:  link_config
27    Parameters:  p_model_line_id   - line id of the top model in
28                                     oe_order_lines_all
29                 p_config_item_id - config id of the selected configuration
30                                    item to which the model line will be linked.
31                 x_error_message   - error message if match function fails
32                 x_message_name    - name of error message if match
33                                     function fails
34 
35   Description:  This function is called from the Sales Order Pad to manually
36                 link a selected configuration item to an ATO model order
37                 line.
38 
39                 After linking a configuration item to the model line,
40                 this link_config function updates the ATO model workflow
41                 to complete the 'CREATE CONFIG ITEM ELIGIBLE' block
42                 activity.
43 
44                 A manual link can only be done if the ATO model order line
45                 is not linked to a configuration item.
46 *****************************************************************************/
47 PG_DEBUG Number := NVL(FND_PROFILE.value('ONT_DEBUG_LEVEL'), 0);
48 
49 TYPE config_bcol_rec IS RECORD
50   (
51      config_item_id   CTO_MSUTIL_PUB.NUMTAB,
52      base_item_id     CTO_MSUTIL_PUB.NUMTAB,
53      ship_from_org_id CTO_MSUTIL_PUB.NUMTAB
54   );  --Bugfix 6398466
55 
56 PROCEDURE get_all_configs
57     (
58          pconfigId IN NUMBER,
59          new_config_dtls IN OUT NOCOPY config_bcol_rec,
60          pshipOrg IN NUMBER
61     );  --Bugfix 6398466
62 
63 function link_config(
64         p_model_line_id         in  number,
65         p_config_item_id        in  number,
66         x_error_message         out NOCOPY varchar2,
67         x_message_name          out NOCOPY varchar2
68 )
69 RETURN boolean
70 
71 IS
72 
73 	l_stmt_num     		number := 0;
74 	l_cfm_value    		number;
75 	l_config_id    		number;
76 	l_config_line_id 	number;
77 	l_return_status 	varchar2(1);
78 	l_x_error_msg_count    	number;
79 	l_x_error_msg     	varchar2(240);
80 	l_x_error_msg_name 	varchar2(30);
81 	l_x_table_name 		varchar2(30);
82 	l_org_id       		number;
83 	l_model_id     		number;
84 	x_message_count		number;
85 	x_message_data		varchar2(2000);
86 	l_active_activity 	varchar2(30);
87 	l_x_bill_seq_id 	number;
88 	l_status       		integer;
89 	l_header_id		number;
90 
91 	PROCESS_ERROR      	exception;
92 
93         v_aps_version   number ;
94 
95         --New variables introduced as part of Bugfix 6398466
96         old_config_dtls config_bcol_rec;
97         new_config_dtls config_bcol_rec;
98 
99         l_org number;
100         l_bom_exists number;
101         flag NUMBER := 0;
102         bmodel_exists number;
103 
104         v_sourcing_rule_exists VARCHAR2(10);
105         v_source_type NUMBER;
106         v_t_sourcing_info CTO_MSUTIL_PUB.SOURCING_INFO;
107 
108         x_exp_error_code NUMBER;
109         x_return_status VARCHAR2(30);
110 
111 
112 
113 BEGIN
114 
115         /*---------------------+
116          Validate model line.
117         +----------------------*/
118         l_stmt_num := 100;
119 	IF PG_DEBUG <> 0 THEN
120 		oe_debug_pub.add ('link_config: ' || 'Inside CTO_MANUAL_LINK_CONFIG.link_config..',2);
121 
122 		oe_debug_pub.add ('link_config: ' || 'Calling CTO_WORKFLOW.validate_line..',2);
123 	END IF;
124 
128             x_message_name := 'CTO_LINE_STATUS_NOT_ELIGIBLE';
125         if (CTO_WORKFLOW.validate_line(p_model_line_id) = FALSE) then
126 
127             cto_msg_pub.cto_message('BOM','CTO_LINE_STATUS_NOT_ELIGIBLE');
129             IF PG_DEBUG <> 0 THEN
130             	oe_debug_pub.add('link_config: ' || 'Model Line not valid.',1);
131             END IF;
132             return FALSE;
133 
134         end if;
135 
136         l_stmt_num := 105;
137         select oel.inventory_item_id, oel.ship_from_org_id
138         into   l_model_id, l_org_id
139         from   oe_order_lines_all oel
140         where  oel.line_id = p_model_line_id;
141 
142        /*------------------------------------------+
143         Link only if config line does not exist.
144         +-----------------------------------------*/
145 	IF PG_DEBUG <> 0 THEN
146 		oe_debug_pub.add ('link_config: ' || 'Calling CTO_MATCH_AND_RESERVE.config_line_exists..',2);
147 	END IF;
148         l_stmt_num := 110;
149         if (CTO_MATCH_AND_RESERVE.config_line_exists(
150 				p_model_line_id		=> p_model_line_id,
151                                 x_config_line_id	=> l_config_line_id,
152                                 x_config_item_id	=> l_config_id)  = TRUE)
153         then
154 
155             IF PG_DEBUG <> 0 THEN
156             	oe_debug_pub.add('link_config: ' || 'Config Line Exists.', 1);
157             END IF;
158             cto_msg_pub.cto_message('BOM','CTO_CONFIG_ITEM_EXISTS');
159             x_message_name := 'CTO_CONFIG_ITEM_EXISTS';
160             return FALSE;
161 
162         end if;
163 
164 
165 
166 
167 
168 
169         v_aps_version := msc_atp_global.get_aps_version  ;
170 
171         oe_debug_pub.add('link_config: ' || 'APS version::'|| v_aps_version , 2);
172 
173 
174 
175 
176 
177 
178         /*------------------------------------+
179         Check Workflow status of model line.
180         +-------------------------------------*/
181         IF PG_DEBUG <> 0 THEN
182         	oe_debug_pub.add('link_config: ' || 'Configuration Line does not exist.', 2);
183         END IF;
184         l_stmt_num := 120;
185         CTO_WORKFLOW_API_PK.get_activity_status(
186 				itemtype	=> 'OEOL',
187                                 itemkey		=> to_char(p_model_line_id),
188                                 linetype	=> 'MODEL',
189                                 activity_name	=> l_active_activity);
190 
191 
192 
193 
194         if( v_aps_version <> 10 ) then
195             if (l_active_activity = 'NULL') then	-- note: it is character NULL, not regular null
196 
197                  /*-----------------------------+
198                    Model line workflow status
199                    is not eligible for Link.
200                  +-----------------------------*/
201                  IF PG_DEBUG <> 0 THEN
202             	    oe_debug_pub.add
203                      ('link_config: ' || 'Model Workflow Status not Eligible for Link.', 1);
204                  END IF;
205 
206                  cto_msg_pub.cto_message('BOM', 'CTO_INVALID_WORKFLOW_STATUS');
207                  x_message_name := 'CTO_INVALID_WORKFLOW_STATUS';
208                  return FALSE;
209 
210              end if;
211 
212              IF PG_DEBUG <> 0 THEN
213         	oe_debug_pub.add('link_config: ' || 'Workflow Status is: ' || l_active_activity, 2);
214              END IF;
215 
216              -- Link the config item.
217              l_stmt_num := 130;
218              IF PG_DEBUG <> 0 THEN
222 
219         	oe_debug_pub.add('link_config: ' || 'Config Item: ' || to_char(p_config_item_id),2);
220              END IF;
221 
223 
224         else
225 
226 
227         	oe_debug_pub.add('link_config: ' || '************ workflow need not necessarily be at CREATE_CONFIG_ITEM_ELIGIBLE as APS patchset J is installed '
228                                                  || ' and order is scheduled '    ,2);
229 
230 
231         end if ;
232 
233 
234         l_status := CTO_CONFIG_ITEM_PK.link_item(
235 				pOrgId		=> l_org_id,
236                                 pModelId	=> l_model_id,
237                                 pConfigId	=> p_config_item_id,
238                                 pLineId		=> p_model_line_id,
239                                 xMsgCount	=> x_message_count,
240                                 xMsgData	=> x_message_data);
241 
242         IF (l_status <> 1) THEN
243             IF PG_DEBUG <> 0 THEN
244             	oe_debug_pub.add ('link_config: ' || 'Failed in link_item function', 1);
245             END IF;
246             raise PROCESS_ERROR;
247         END IF;
248         IF PG_DEBUG <> 0 THEN
249         	oe_debug_pub.add ('link_config: ' || 'Success in link_item function', 1);
250         END IF;
251 
252 
253 
254 
255         if( l_active_activity = 'CREATE_CONFIG_ITEM_ELIGIBLE'   ) then
256 
257 
258 
259               /*------------------------------+
260               Update Model Line's workflow.
261               +-------------------------------*/
262               IF (CTO_WORKFLOW_API_PK.start_model_workflow(p_model_line_id) = FALSE)
263               THEN
264                   IF PG_DEBUG <> 0 THEN
265             	     oe_debug_pub.add('link_config: ' || 'Failed in call to start_model_workflow',1);
266                   END IF;
267                   raise PROCESS_ERROR;
268               END IF;
269 
270 	      IF PG_DEBUG <> 0 THEN
271 		oe_debug_pub.add ('link_config: ' || 'Getting config line id.', 2);
272 	      END IF;
273 
274 
275 
276 
277        else
278 
279 
280 		oe_debug_pub.add ('link_config: ' || 'did not call cto_workflow_api_pk.start_model_workflow as l_active_activity
281                                                       is not at CREATE_CONFIG_ITEM_ELIGIBLE.', 2);
282 
283         end if ;
284 
285 
286        	l_stmt_num := 140;
287 	select line_id, header_id
288 	into   l_config_line_id, l_header_id
289 	from   oe_order_lines_all
290 	where  ato_line_id = p_model_line_id
291 	and    item_type_code = 'CONFIG';
292 
293 	IF PG_DEBUG <> 0 THEN
294 		oe_debug_pub.add ('link_config: ' || 'Config line id is ' || to_char(l_config_line_id), 2);
295 
296 		oe_debug_pub.add('link_config: ' || 'header ID: ' || to_char(l_header_id), 2);
297 	END IF;
298 
299 
300 	l_stmt_num := 160;
301 	IF PG_DEBUG <> 0 THEN
302 
303                 oe_debug_pub.add('link_config: ' || 'Calling display wf status API ',2);
304 	END IF;
305 
306 
307         --bugfix 3755608 changed the call to display_wf_status from OM api
308         l_return_status  := CTO_WORKFLOW_API_PK.display_wf_status( p_order_line_id => l_config_line_id );
309 
310 	IF PG_DEBUG <> 0 THEN
311 		oe_debug_pub.add('link_config: ' || 'Return from display_wf status'||l_return_status,1);
312 	END IF;
313 
314         --Begin Bugfix 6398466
315 
316         l_stmt_num := 170;
317         begin
318 
319           SELECT  config_item_id,
320                   inventory_item_id,
321                   ship_from_org_id
322           BULK COLLECT INTO old_config_dtls.config_item_id,
323                             old_config_dtls.base_item_id,
324                             old_config_dtls.ship_from_org_id
325           FROM bom_cto_order_lines
326           WHERE top_model_line_id = p_model_line_id
327           AND config_item_id IS NOT NULL
328           AND line_id <> top_model_line_id;
329 
330         exception
331           when no_data_found then
332             null;
333         end;
334 
335         IF old_config_dtls.config_item_id.Count = 0 THEN
336 
337           IF PG_DEBUG <> 0 THEN
338 		oe_debug_pub.add('link_config: ' || 'Delinked config did not have child configs. Updating only the top config.', 1);
339 	  END IF;
340 
341           l_stmt_num := 180;
342 
343           UPDATE bom_cto_order_lines
344           SET config_item_id = p_config_item_id
345           WHERE line_id = p_model_line_id;
346 
347         ELSE
348           IF PG_DEBUG <> 0 THEN
349              oe_debug_pub.add('link_config: ' || 'Looking if bom for '|| p_config_item_id || 'exists in shipping org ' || old_config_dtls.ship_from_org_id(1), 1);
350           END IF;
351 
352           BEGIN
353             l_stmt_num := 190;
354 
355             SELECT 1
356               INTO l_bom_exists
357                 FROM bom_bill_of_materials bom
358                 WHERE bom.assembly_item_id = p_config_item_id
359                 AND bom.organization_id = old_config_dtls.ship_from_org_id(1)
360                 AND bom.alternate_bom_designator IS NULL;
361 
362           EXCEPTION
363             WHEN No_Data_Found THEN
364               l_bom_exists := 0;
365           END;
366 
367           IF l_bom_exists = 0 THEN
368             IF PG_DEBUG <> 0 THEN
369                oe_debug_pub.add('link_config: ' || 'BOM not found in ship org ' || old_config_dtls.ship_from_org_id(1), 1);
370                oe_debug_pub.add('link_config: ' || 'Going to call query sourcing orgs', 1);
371             END IF;
372 
373             IF PG_DEBUG <> 0 THEN
374                oe_debug_pub.add('link_config: ' || 'Top level model l_model_id= ' || l_model_id, 1);
375             END IF;
376 
377             l_stmt_num := 200;
378             CTO_MSUTIL_PUB.query_sourcing_org_ms(
379                                  p_inventory_item_id  => l_model_id
380                                , p_organization_id  => old_config_dtls.ship_from_org_id(1)
381                                , p_sourcing_rule_exists => v_sourcing_rule_exists
382                                , p_source_type => v_source_type
383                                , p_t_sourcing_info => v_t_sourcing_info
384                                , x_exp_error_code => x_exp_error_code
385                                , x_return_status => x_return_status     );
386 
387             IF x_return_status <>  FND_API.G_RET_STS_SUCCESS THEN
388                oe_debug_pub.add(' Error in query_sourcing_org_ms.. ', 1);
389                raise PROCESS_ERROR;
390             END IF;
391 
392             l_stmt_num := 210;
393 
394             FOR i IN 1..v_t_sourcing_info.sourcing_rule_id.Count LOOP
395               IF PG_DEBUG <> 0 THEN
396                  oe_debug_pub.add('****$$$$ org ' || v_t_sourcing_info.source_organization_id(i)
397                                                         ||  '****$$$$ rule  ' || v_t_sourcing_info.sourcing_rule_id(i)
398                                                         ||  '****$$$$ type  ' || v_t_sourcing_info.source_type(i)
399                                                         ||  '****$$$$ rank ' || v_t_sourcing_info.rank(i)
400                                                         ||  '****$$$$ assig id  ' || v_t_sourcing_info.assignment_id(i),1);
401               END IF;
402             END LOOP;
403 
404             FOR i IN 1..v_t_sourcing_info.sourcing_rule_id.Count LOOP
405               l_org := v_t_sourcing_info.source_organization_id(i);
406 
407               IF PG_DEBUG <> 0 THEN
408                  oe_debug_pub.add('link_config: ' || 'Inside for loop****$$$$ org ' || l_org, 1);
409                  oe_debug_pub.add('link_config: ' || 'Looking if bom for '|| p_config_item_id || 'exists in org ' || l_org, 1);
410               END IF;
411 
412               BEGIN
413 
414                 l_stmt_num := 220;
415 
416                 SELECT 1
417                   INTO flag
418                     FROM bom_bill_of_materials bom
419                     WHERE bom.assembly_item_id = p_config_item_id
420                     AND bom.organization_id = l_org
421                     AND bom.alternate_bom_designator IS NULL;
422 
423               EXCEPTION
424                 WHEN No_Data_Found THEN
425                   NULL;
426               END;
427 
428               IF flag = 1 THEN
429                 IF PG_DEBUG <> 0 THEN
430                   oe_debug_pub.add('link_config: ' || 'BOM found in org ' || l_org, 1);
431                 END IF;
432 
433                 EXIT;
434 
435               END IF;  --flag = 1
436 
437             END LOOP;  --loop for i
438 
439           ELSE
440             IF PG_DEBUG <> 0 THEN
441                oe_debug_pub.add('link_config: ' || 'BOM found in ship org ' || old_config_dtls.ship_from_org_id(1), 1);
442             END IF;
443 
444             flag := 1;
445             l_org := old_config_dtls.ship_from_org_id(1);
446 
447           END IF;  --l_bom_exists <> 1
448 
449           IF flag = 0 THEN   --bom doesn't exist in any orgs in sourcing chain. Updating the top level config
450             l_stmt_num := 230;
454             WHERE line_id = p_model_line_id;
451 
452             UPDATE bom_cto_order_lines
453             SET config_item_id = p_config_item_id
455 
456             UPDATE bom_cto_order_lines  --Updating the lower level configs to NULL
457             SET config_item_id = NULL
458             WHERE top_model_line_id = p_model_line_id
459             AND config_item_id IS NOT NULL
460             AND line_id <> top_model_line_id;
461 
462           ELSE
463             l_stmt_num := 240;
464             get_all_configs(p_config_item_id, new_config_dtls, l_org);
465 
466             l_stmt_num := 250;
467 
468             IF PG_DEBUG <> 0 THEN
469                oe_debug_pub.add('link_config: ' || 'Printing values in new_config_dtls',1);
470             END IF;
471 
472             FOR i IN 1..new_config_dtls.config_item_id.Count LOOP
473               IF PG_DEBUG <> 0 THEN
474                  oe_debug_pub.add('link_config: ' || i||' '||'Config '||new_config_dtls.config_item_id(i)||' Model '||new_config_dtls.base_item_id(i),1);
475               END IF;
476             END LOOP;
477 
478             IF new_config_dtls.config_item_id.Count = 0 THEN
479               --New config doesn't have child configs. Updating only the top level config
480               l_stmt_num := 260;
481 
482               UPDATE bom_cto_order_lines
483               SET config_item_id = p_config_item_id
484               WHERE line_id = p_model_line_id;
485 
486               --Updating lower level configs of original config to NULL
487               UPDATE bom_cto_order_lines
488               SET config_item_id = NULL
489               WHERE top_model_line_id = p_model_line_id
490               AND config_item_id IS NOT NULL
491               AND line_id <> top_model_line_id;
492 
493             ELSE
494               FOR i IN 1..old_config_dtls.config_item_id.Count LOOP
495                 bmodel_exists := 0;
496                 FOR j IN 1..new_config_dtls.config_item_id.Count LOOP
497 
498                   IF old_config_dtls.base_item_id(i) = new_config_dtls.base_item_id(j) THEN
499                      IF PG_DEBUG <> 0 THEN
500                         oe_debug_pub.add('link_config: ' || i||'old_config_dtls.base_item_id(i) '||old_config_dtls.base_item_id(i)||j||'new_config_dtls.base_item_id(j) '||new_config_dtls.base_item_id(j), 1);
501                         oe_debug_pub.add('link_config: ' ||'Model '||old_config_dtls.base_item_id(i)||' exists in BOM of ' ||new_config_dtls.config_item_id(j), 1);
502                      END IF;
503 
504                      bmodel_exists := 1;
505                      l_stmt_num := 270;
506 
507                      --Updating config id corresponding to the model old_config_dtls.base_item_id(i)
508                      UPDATE bom_cto_order_lines
509                      SET config_item_id = new_config_dtls.config_item_id(j)
510                      WHERE ato_line_id = p_model_line_id
511                      AND inventory_item_id = new_config_dtls.base_item_id(j);
512 
513                      EXIT;
514 
515                   END IF;
516                 END LOOP;  --loop for j
517 
518                 IF bmodel_exists = 0 THEN  --BOM of new config doesn't have this model
519                   l_stmt_num := 280;
520 
521                   UPDATE bom_cto_order_lines
522                     SET config_item_id = NULL
523                     WHERE ato_line_id = p_model_line_id
524                     AND inventory_item_id = old_config_dtls.base_item_id(i);
525                 END IF;
526               END LOOP;  --loop for i
527             END IF;  --new_config_dtls.config_item_id.Count = 0
528           END IF;  --flag = 0
529         END IF;  --old_config_dtls.config_item_id.Count = 0
530 
531       IF old_config_dtls.config_item_id.Count = 0 OR flag = 0 OR ( flag = 1 AND new_config_dtls.config_item_id.Count = 0 ) THEN
532          --In these cases, we have already updated the top level config
533          NULL;
534       ELSE
535           l_stmt_num := 290;
536 
537           UPDATE bom_cto_order_lines
538           SET config_item_id = p_config_item_id
539           WHERE line_id = p_model_line_id;
540       END IF;
541        --End Bugfix 6398466
542 
543         x_message_name := 'SUCCESS';
544         return TRUE;
545 
546 EXCEPTION
547 
548        when PROCESS_ERROR then
549 	   x_message_name := 'CTO_LINK_ERROR' ;
550 	   cto_msg_pub.cto_message('BOM', x_message_name);
551            IF PG_DEBUG <> 0 THEN
552            	oe_debug_pub.add('link_config: ' || 'CTOLINKB: ' || l_stmt_num || ':' || x_error_message, 1);
553            END IF;
554            return FALSE;
555 
556        when OTHERS then
557            x_message_name := 'CTO_LINK_ERROR';
558 	   cto_msg_pub.cto_message('BOM', x_message_name);
559            x_error_message := 'CTOLINKB:link_config : ' || to_char(l_stmt_num) || ':' || substrb(sqlerrm,1,100);
560            IF PG_DEBUG <> 0 THEN
561            	oe_debug_pub.add('link_config: ' || x_error_message, 1);
562            END IF;
563            return FALSE;
564 END link_config;
565 
566 
567 
568 FUNCTION Validate_Link(p_model_line_id         in  number,
569         		p_config_item_id        in  number,
570         		x_error_message         out NOCOPY varchar2,
571         		x_message_name          out NOCOPY varchar2
572 )
573 RETURN integer
574 
575 IS
576 
577 l_valid	number := 0;
578 
579 BEGIN
580 
581 	IF (p_model_line_id is null) OR (p_config_item_id is null) THEN
582 		IF PG_DEBUG <> 0 THEN
583 			oe_debug_pub.add('Validate_Link: ' || 'Invalid model line or config item',2);
584 		END IF;
585 		return(0);
586 	END IF;
587 
588 
589 	select distinct 1
590 	into l_valid
591 	from oe_order_lines_all oel,	--model line
592 		mtl_system_items msi	--config item
593 	where oel.line_id = p_model_line_id
594 	and oel.inventory_item_id = msi.base_item_id
595 	and msi.inventory_item_id = p_config_item_id;
596 
597 	IF l_valid = 1 THEN
598 		IF PG_DEBUG <> 0 THEN
599 			oe_debug_pub.add('Validate_Link: ' || 'Item to be linked is valid',2);
600 		END IF;
601 		return(1);
602 	ELSE
603 		IF PG_DEBUG <> 0 THEN
604 			oe_debug_pub.add('Validate_Link: ' || 'Item to be linked is invalid',2);
605 		END IF;
606 		x_message_name := 'CTO_LINK_ERROR';
607            	x_error_message := 'CTLINKB:validate_link:not a valid link:';
608 		return(0);
609 	END IF;
610 
611 EXCEPTION
612 	when no_data_found then
613 		IF PG_DEBUG <> 0 THEN
614 			oe_debug_pub.add('Validate_Link: ' || 'Item to be linked is invalid',1);
615 		END IF;
616 		x_message_name := 'CTO_LINK_ERROR';
617            	x_error_message := 'CTOLINKB:validate_link:ndf: '
618                               ||substrb(sqlerrm,1,100);
619 		return(0);
620 	when others then
621 		IF PG_DEBUG <> 0 THEN
622 			oe_debug_pub.add('Validate_Link: ' || 'Item to be linked is invalid::others exception',1);
623 		END IF;
624 		x_message_name := 'CTO_LINK_ERROR';
625            	x_error_message := 'CTOLINKB:validate_link:others: '
626                               ||substrb(sqlerrm,1,100);
627 		return(0);
628 		return(0);
629 
630 END Validate_Link;
631 
632 
633 /*
634 Bugfix 6398466: Introduced this procedure. This procedure is called recursively and collects all the
635 child configuration item ids in table cfg_tbl.
636 */
637 
638 PROCEDURE get_all_configs(
639   pconfigId IN NUMBER,
640   new_config_dtls IN OUT NOCOPY config_bcol_rec,
641   pshipOrg IN NUMBER
642   ) AS
643 
644  l_index NUMBER;
645 
646  CURSOR get_configs IS
647    SELECT inventory_item_id, base_item_id
648       FROM mtl_system_items msi
649       WHERE inventory_item_id IN
650       ( SELECT component_item_id
651           FROM bom_inventory_components bic, bom_bill_of_materials bom
652           WHERE bom.assembly_item_id = pconfigId                       --p_config_id
653           AND bom.common_bill_sequence_id = bic.bill_sequence_id
654           AND bom.alternate_bom_designator IS NULL
655           AND bom.organization_id = pshipOrg
656       )
657       AND auto_created_config_flag = 'Y'
658       AND organization_id = pshipOrg;
659 
660   BEGIN
661 
662     IF PG_DEBUG <> 0 THEN
663        oe_debug_pub.add('Inside get_all_configs', 1);
664        oe_debug_pub.add('Value of config id passed: '|| pconfigId, 1);
665     END IF;
666 
667     OPEN get_configs;
668 
669     LOOP
670       l_index := new_config_dtls.config_item_id.Count + 1;
671 
672       IF PG_DEBUG <> 0 THEN
673          oe_debug_pub.add('l_index '||l_index, 1);
674       END IF;
675 
676       FETCH get_configs INTO new_config_dtls.config_item_id(l_index),
677                              new_config_dtls.base_item_id(l_index);
678 
679       EXIT WHEN get_configs%NOTFOUND;
680 
681       get_all_configs(new_config_dtls.config_item_id(l_index), new_config_dtls, pshipOrg);
682 
683     END LOOP;
684 
685     CLOSE get_configs;
686 
687     IF PG_DEBUG <> 0 THEN
688        oe_debug_pub.add('Count '||new_config_dtls.config_item_id.count, 1);
689     END IF;
690 
691   END get_all_configs;
692 
693 end CTO_MANUAL_LINK_CONFIG;