DBA Data[Home] [Help]

PACKAGE BODY: APPS.ICX_RELATED_CATEGORIES_PUB

Source


1 PACKAGE BODY ICX_Related_Categories_PUB AS
2 /* $Header: ICXPCATB.pls 115.1 99/07/17 03:20:00 porting ship $ */
3 
4 
5 PROCEDURE Insert_Relation
6 ( p_api_version_number 	IN	NUMBER			    		,
7   p_init_msg_list	IN  	VARCHAR2 := FND_API.G_FALSE		,
8   p_simulate		IN	VARCHAR2 := FND_API.G_FALSE 		,
9   p_commit		IN	VARCHAR2 := FND_API.G_FALSE 		,
10   p_validation_level	IN	NUMBER   := FND_API.G_VALID_LEVEL_FULL	,
11   p_return_status	OUT 	VARCHAR2				,
12   p_msg_count		OUT	NUMBER					,
13   p_msg_data		OUT 	VARCHAR2	    			,
14   p_category_set_id	IN	NUMBER	 DEFAULT NULL			,
15   p_category_set	IN 	VARCHAR2 DEFAULT NULL			,
16   p_category_id		IN 	NUMBER	 DEFAULT NULL			,
17   p_category		IN	VARCHAR2 DEFAULT NULL			,
18   p_related_category_id	IN	NUMBER 	 DEFAULT NULL			,
19   p_related_category	IN	VARCHAR2 DEFAULT NULL			,
20   p_relationship_type	IN 	VARCHAR2				,
21   p_created_by		IN      NUMBER
22 ) IS
23 
24 cursor l_category_set_csr is
25 select category_set_id
26 from   mtl_category_sets
27 where  category_set_name = p_category_set;
28 
29 cursor l_category_csr(l_cat_name in varchar2,
30                       l_cat_set_id in number) is
31 select mck.category_id
32 from   mtl_categories_kfv mck,
33        mtl_category_sets mcs
34 where  (mcs.validate_flag = 'Y' and
35 	mck.category_id in (
36             select mcsv.category_id
37             from   mtl_category_set_valid_cats mcsv
38             where  mcsv.category_set_id = l_cat_set_id) and
39 	mck.concatenated_segments = l_cat_name)
40 or     (mcs.validate_flag <> 'Y' and
41 	mcs.structure_id = mck.structure_id and
42 	mck.concatenated_segments = l_cat_name);
43 
44 
45 l_api_version_number    CONSTANT    NUMBER  :=  1.0;
46 l_validation_error	BOOLEAN		    := FALSE;
47 l_id_resolve_error	BOOLEAN		    := FALSE;
48 l_category_set_id	NUMBER;
49 l_category_id		NUMBER;
50 l_related_category_id	NUMBER;
51 l_title       		varchar2(80);
55 BEGIN
52 l_prompts     		icx_util.g_prompts_table;
53 l_count			NUMBER;
54 
56 
57     --  Standard Start of API savepoint
58 
59     SAVEPOINT Insert_Relation_PUB;
60 
61 
62     --  Standard call to check for call compatibility
63 
64     IF NOT FND_API.Compatible_API_Call(l_api_version_number,
65         p_api_version_number,
66 	'Insert_Relation',
67 	G_PKG_NAME)
68     THEN
69 	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
70     END IF;
71 
72 
73     --  Initialize message list if p_init_msg_list is set to TRUE
74 
75     IF FND_API.to_Boolean(p_init_msg_list) THEN
76  	FND_MSG_PUB.initialize;
77     END IF;
78 
79 
80     --  Initialize p_return_status
81     p_return_status := FND_API.G_RET_STS_SUCCESS;
82 
83 
84     --  Get prompts table for translation of messages
85     icx_util.getPrompts(601,'ICX_RELATED_CATEGORIES_R',l_title,l_prompts);
86 
87 
88     --  Perform manditory validation
89 
90 	-- check that necessary in parameters are present
91 	if (p_category_set_id is null and
92 	    p_category_set is null) or
93 	   (p_category_id is null and
94 	    p_category is null) or
95 	   (p_related_category_id is null and
96 	    p_related_category is null) then
97 
98 	    if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
99 		-- add message: Required API parameters are missing
100 		FND_MESSAGE.SET_NAME('ICX','ICX_API_MISS_PARAM');
101 		FND_MSG_PUB.Add;
102 	    end if;
103 	    RAISE FND_API.G_EXC_ERROR;
104 	end if;
105 
106 
107 
108     --  Resolve id's from names if id's are absent
109 
110 	-- Resolve category set id
111 	if p_category_set_id is not null then
112 	    l_category_set_id := p_category_set_id;
113 	else
114 	    open l_category_set_csr;
115 	    l_count := 0;
116 	    loop
117 		fetch l_category_set_csr into l_category_set_id;
118 		exit when l_category_set_csr%NOTFOUND;
119 		l_count := l_count + 1;
120 	    end loop;
121 	    close l_category_set_csr;
122 	    if l_count <> 1 then
123 		if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
124 		    -- add message: Category Set is invalid
125 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
126 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(2));
127 		    FND_MSG_PUB.Add;
128 		end if;
129 		l_id_resolve_error := TRUE;
130 	    end if;
131 	end if;  -- resolve category set id
132 
133 
134     	-- Resolve category_id
135 	if p_category_id is not null then
136 	    l_category_id := p_category_id;
137 	else
138 	    open l_category_csr(p_category,l_category_set_id);
139 	    l_count := 0;
140 	    loop
141 		fetch l_category_csr into l_category_id;
142 		exit when l_category_csr%NOTFOUND;
143 		l_count := l_count + 1;
144 	    end loop;
145 	    close l_category_csr;
146 	    if l_count = 0 then
147 		if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
148 		    -- add message: Category is invalid
149 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
150 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(4));
151 		    FND_MSG_PUB.Add;
152 		end if;
153 		l_id_resolve_error := TRUE;
154 	    end if;
155 	end if;  -- resolve category id
156 
157 
158     	-- Resolve related category_id
159 	if p_related_category_id is not null then
160 	    l_related_category_id := p_related_category_id;
161 	else
162 	    open l_category_csr(p_related_category,l_category_set_id);
163 	    l_count := 0;
164 	    loop
165 		fetch l_category_csr into l_related_category_id;
166 		exit when l_category_csr%NOTFOUND;
167 		l_count := l_count + 1;
168 	    end loop;
169 	    close l_category_csr;
170 	    if l_count = 0 then
171 		if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
172 		    -- add message: Related Category is invalid
173 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
174 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(7));
175 		    FND_MSG_PUB.Add;
176 		end if;
177 		l_id_resolve_error := TRUE;
178 	    end if;
179 	end if;  -- resolve related category id
180 
181 
182     -- If any id resolution failed, raise error
183     IF l_id_resolve_error THEN
184 	RAISE FND_API.G_EXC_ERROR;
185     END IF;
186 
187 
188 
189     --	Perform validation
190     IF p_validation_level = FND_API.G_VALID_LEVEL_FULL THEN
191 
192 	-- check category set id if it was not looked up previously
193 	if p_category_set_id is not null then
194 	    select count(*) into l_count
195    	    from   mtl_category_sets
196 	    where  category_set_id = l_category_set_id;
197 
198 	    if l_count <> 1 then
199 	        if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
200 		    -- add message: Category Set ID is invalid
201 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
202 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(1));
203 		    FND_MSG_PUB.Add;
204 		end if;
205 		l_validation_error := TRUE;
206 	    end if;
207 	end if;  -- check category set id
208 
209 
210 	-- check category id if it was not looked up previously
211 	if p_category_id is not null then
212 	    select count(*) into l_count
213    	    from   mtl_categories_kfv mck,
214        		   mtl_category_sets mcs
215 	    where  (mcs.validate_flag = 'Y' and
216 	            mck.category_id in (
217             	        select mcsv.category_id
218             		from   mtl_category_set_valid_cats mcsv
219             		where  mcsv.category_set_id = l_category_set_id) and
220 		    mck.category_id = l_category_id)
224 
221 	    or     (mcs.validate_flag <> 'Y' and
222 	            mcs.structure_id = mck.structure_id and
223 	            mck.category_id = l_category_id);
225 	    if l_count = 0 then
226 	        if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
227 		    -- add message: Category ID is invalid
228 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
229 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(3));
230 		    FND_MSG_PUB.Add;
231 		end if;
232 		l_validation_error := TRUE;
233 	    end if;
234 	end if;  -- check category id
235 
236 
237 	-- check related category id if it was not looked up previously
238 	if p_related_category_id is not null then
239 	    select count(*) into l_count
240    	    from   mtl_categories_kfv mck,
241        		   mtl_category_sets mcs
242 	    where  (mcs.validate_flag = 'Y' and
243 	            mck.category_id in (
244             	        select mcsv.category_id
245             		from   mtl_category_set_valid_cats mcsv
246             		where  mcsv.category_set_id = l_category_set_id) and
247 		    mck.category_id = l_related_category_id)
248 	    or     (mcs.validate_flag <> 'Y' and
249 	            mcs.structure_id = mck.structure_id and
250 	            mck.category_id = l_related_category_id);
251 
252 	    if l_count = 0 then
253 	        if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
254 		    -- add message: Related Category ID is invalid
255 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
256 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(6));
257 		    FND_MSG_PUB.Add;
258 		end if;
259 		l_validation_error := TRUE;
260 	    end if;
261 	end if;  -- check related category id
262 
263 
264 	-- check that category id and related category id are not the same
265 	if (p_relationship_type <> 'TOP' and
266             l_category_id = l_related_category_id) then
267 	    if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
268 		-- add message: Related Category may not be the same as
269 		--              its parent category
270 	        FND_MESSAGE.SET_NAME('ICX','ICX_CAT_PARENT');
271 		FND_MSG_PUB.Add;
272 	    end if;
273 	    l_validation_error := TRUE;
274 	end if;
275 
276 
277 	-- check that top relationship does not already exist if needed
278 	if p_relationship_type = 'TOP' then
279 	    select count(*) into l_count
280 	    from   icx_related_categories
281 	    where  category_set_id = l_category_set_id
282 	    and    category_id = l_category_id
283 	    and    related_category_id = l_category_id;
284 
285 	    if l_count > 0 then
286 	        if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
287 		    -- add message: CATEGORY is already a top category
288 		    FND_MESSAGE.SET_NAME('ICX','ICX_CAT_TOP');
289 		    if p_category is not null then
290 		      FND_MESSAGE.SET_TOKEN('CATEGORY',p_category);
291 		    else
292 		      FND_MESSAGE.SET_TOKEN('CATEGORY',l_category_id);
293 		    end if;
294 		    FND_MSG_PUB.Add;
295 	        end if;
296 	        l_validation_error := TRUE;
297 	    end if;
298 	end if;
299 
300 
301 	-- check that relationship does not already exist
302 	if l_category_id <> l_related_category_id then
303 	    select count(*) into l_count
304 	    from   icx_related_categories
305 	    where  category_set_id = l_category_set_id
306 	    and    category_id = l_category_id
307 	    and    related_category_id = l_related_category_id;
308 
309 	    if l_count > 0 then
310 	        if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
311 		    -- add message: This category relationship already exists
312 		    FND_MESSAGE.SET_NAME('ICX','ICX_CAT_DUP_RELATION');
313 		    FND_MSG_PUB.Add;
314 	        end if;
315 	        l_validation_error := TRUE;
316 	    end if;
317 	end if;
318 
319 
320 	-- check that relationship type is valid
321 	select count(*) into l_count
322 	from   fnd_lookups
323 	where  lookup_type = 'ICX_RELATIONS'
324 	and    enabled_flag = 'Y'
325 	and    lookup_code = p_relationship_type;
326 
327 	if l_count <> 1 then
328 	    if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
329 		-- add message: Relation is not valid
330 		FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
331 		FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(5));
332 		FND_MSG_PUB.Add;
333 	    end if;
334 	    l_validation_error := TRUE;
335 	end if;
336 
337     END IF;  --  Validation
338 
339 
340     -- If any validation failed, raise error
341     IF l_validation_error THEN
342 	RAISE FND_API.G_EXC_ERROR;
343     END IF;
344 
345 
346 
347     -- API body
348 
349     insert into icx_related_categories
350        (category_set_id,
351 	category_id,
352 	related_category_id,
353 	relationship_type,
354 	created_by,
355 	creation_date,
356 	last_updated_by,
357 	last_update_date)
358     values
359        (l_category_set_id,
360 	l_category_id,
361 	l_related_category_id,
362 	p_relationship_type,
363 	p_created_by,
364 	sysdate,
365 	p_created_by,
366 	sysdate);
367 
368 
369     -- End of API body
370 
371 
372     -- Standard check of p_simulate and p_commit parameter
373 
374     IF FND_API.To_Boolean(p_simulate) THEN
375 
376 	ROLLBACK TO Insert_Relation_PUB;
380 	COMMIT WORK;
377 
378     ELSIF FND_API.To_Boolean(p_commit) THEN
379 
381 
382     END IF;
383 
384 
385     -- Get message count and if 1, return message data
386 
387     FND_MSG_PUB.Count_And_Get
388         (p_count => p_msg_count,
389          p_data  => p_msg_data
390     );
391 
392 
393 EXCEPTION
394 
395     WHEN FND_API.G_EXC_ERROR THEN
396 
397     	p_return_status := FND_API.G_RET_STS_ERROR;
398 
399         -- Get message count and if 1, return message data
400 
401         FND_MSG_PUB.Count_And_Get
402             (p_count => p_msg_count,
403              p_data  => p_msg_data
404         );
405 
406     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
407 
408     	p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
409 
410         -- Get message count and if 1, return message data
411 
412         FND_MSG_PUB.Count_And_Get
413             (p_count => p_msg_count,
414              p_data  => p_msg_data
415         );
416 
417     WHEN OTHERS THEN
418 
419     	p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
420 
421     	IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
422     	    FND_MSG_PUB.Build_Exc_Msg
423     	    (   G_PKG_NAME  	    ,
424     	        'Insert_Relation'
425 	    );
426    	END IF;
427 
428         -- Get message count and if 1, return message data
429 
430         FND_MSG_PUB.Count_And_Get
431             (p_count => p_msg_count,
432              p_data  => p_msg_data
433         );
434 
435 
436 END; -- Insert_Relation
437 
438 
439 
440 
441 PROCEDURE Delete_Relation
442 ( p_api_version_number 	IN	NUMBER			    		,
443   p_init_msg_list	IN  	VARCHAR2 := FND_API.G_FALSE		,
444   p_simulate		IN	VARCHAR2 := FND_API.G_FALSE 		,
445   p_commit		IN	VARCHAR2 := FND_API.G_FALSE 		,
446   p_validation_level	IN	NUMBER   := FND_API.G_VALID_LEVEL_FULL	,
447   p_return_status	OUT 	VARCHAR2				,
448   p_msg_count		OUT	NUMBER					,
449   p_msg_data		OUT 	VARCHAR2	    			,
450   p_category_set_id	IN	NUMBER	 DEFAULT NULL			,
451   p_category_set	IN 	VARCHAR2 DEFAULT NULL			,
452   p_category_id		IN 	NUMBER	 DEFAULT NULL			,
453   p_category		IN	VARCHAR2 DEFAULT NULL			,
454   p_related_category_id	IN	NUMBER 	 DEFAULT NULL			,
455   p_related_category	IN	VARCHAR2 DEFAULT NULL
456 ) IS
457 
458 cursor l_category_set_csr is
459 select category_set_id
460 from   mtl_category_sets
461 where  category_set_name = p_category_set;
462 
463 cursor l_category_csr(l_cat_name in varchar2,
464                       l_cat_set_id in number) is
465 select mck.category_id
466 from   mtl_categories_kfv mck,
467        mtl_category_sets mcs
468 where  (mcs.validate_flag = 'Y' and
469 	mck.category_id in (
470             select mcsv.category_id
471             from   mtl_category_set_valid_cats mcsv
472             where  mcsv.category_set_id = l_cat_set_id) and
473 	mck.concatenated_segments = l_cat_name)
474 or     (mcs.validate_flag <> 'Y' and
475 	mcs.structure_id = mck.structure_id and
476 	mck.concatenated_segments = l_cat_name);
477 
478 l_api_version_number    CONSTANT    NUMBER  :=  1.0;
479 l_validation_error	BOOLEAN		    := FALSE;
480 l_id_resolve_error	BOOLEAN		    := FALSE;
481 l_category_set_id	NUMBER;
482 l_category_id		NUMBER;
483 l_related_category_id	NUMBER;
484 l_title       		varchar2(80);
485 l_prompts     		icx_util.g_prompts_table;
486 l_count			NUMBER;
487 
488 BEGIN
489 
490     --  Standard Start of API savepoint
491 
492     SAVEPOINT Delete_Relation_PUB;
493 
494 
495     --  Standard call to check for call compatibility
496 
497     IF NOT FND_API.Compatible_API_Call(l_api_version_number,
498         p_api_version_number,
499 	'Delete Relation',
500 	G_PKG_NAME)
501     THEN
502 	RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
503     END IF;
504 
505 
506     --  Initialize message list if p_init_msg_list is set to TRUE
507 
508     IF FND_API.to_Boolean(p_init_msg_list) THEN
509  	FND_MSG_PUB.initialize;
510     END IF;
511 
512 
513     --  Initialize p_return_status
514 
515     p_return_status := FND_API.G_RET_STS_SUCCESS;
516 
517 
518     --  Get prompts table for translation of messages
519 
520     icx_util.getPrompts(601,'ICX_RELATED_CATEGORIES_R',l_title,l_prompts);
521 
522 
523     --	Perform manditory validation
524 
525 	-- check that necessary in parameters are present
526 	if (p_category_set_id is null and
527 	    p_category_set is null) or
528 	   (p_category_id is null and
529 	    p_category is null) or
530 	   (p_related_category_id is null and
531 	    p_related_category is null) then
532 
533 	    if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
534 		-- add message: Required API parameters are missing
535 		FND_MESSAGE.SET_NAME('ICX','ICX_API_MISS_PARAM');
536 		FND_MSG_PUB.Add;
537 	    end if;
538 	    RAISE FND_API.G_EXC_ERROR;
539 	end if;
540 
541 
542 
543     --  Resolve id's from names if id's are absent
544 
545 	-- Resolve category set id
546 	if p_category_set_id is not null then
547 	    l_category_set_id := p_category_set_id;
548 	else
549 	    open l_category_set_csr;
550 	    l_count := 0;
551 	    loop
552 		fetch l_category_set_csr into l_category_set_id;
553 		exit when l_category_set_csr%NOTFOUND;
554 		l_count := l_count + 1;
555 	    end loop;
556 	    close l_category_set_csr;
560 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
557 	    if l_count <> 1 then
558 		if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
559 		    -- add message: Category Set is invalid
561 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(2));
562 		    FND_MSG_PUB.Add;
563 		end if;
564 		l_id_resolve_error := TRUE;
565 	    end if;
566 	end if;  -- resolve category set id
567 
568 
569     	-- Resolve category_id
570 	if p_category_id is not null then
571 	    l_category_id := p_category_id;
572 	else
573 	    open l_category_csr(p_category,l_category_set_id);
574 	    l_count := 0;
575 	    loop
576 		fetch l_category_csr into l_category_id;
577 		exit when l_category_csr%NOTFOUND;
578 		l_count := l_count + 1;
579 	    end loop;
580 	    close l_category_csr;
581 	    if l_count <> 1 then
582 		if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
583 		    -- add message: Category is invalid
584 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
585 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(4));
586 		    FND_MSG_PUB.Add;
587 		end if;
588 		l_id_resolve_error := TRUE;
589 	    end if;
590 	end if;  -- resolve category id
591 
592 
593     	-- Resolve related category_id
594 	if p_related_category_id is not null then
595 	    l_related_category_id := p_related_category_id;
596 	else
597 	    open l_category_csr(p_related_category,l_category_set_id);
598 	    l_count := 0;
599 	    loop
600 		fetch l_category_csr into l_related_category_id;
601 		exit when l_category_csr%NOTFOUND;
602 		l_count := l_count + 1;
603 	    end loop;
604 	    close l_category_csr;
605 	    if l_count <> 1 then
606 		if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
607 		    -- add message: Related Category is invalid
608 		    FND_MESSAGE.SET_NAME('ICX','ICX_INVALID_ENTRY');
609 		    FND_MESSAGE.SET_TOKEN('INVALID_TOKEN',l_prompts(7));
610 		    FND_MSG_PUB.Add;
611 		end if;
612 		l_id_resolve_error := TRUE;
613 	    end if;
614 	end if;  -- resolve related category id
615 
616 
617     -- If any id resolution failed, raise error
618     IF l_id_resolve_error THEN
619 	RAISE FND_API.G_EXC_ERROR;
620     END IF;
621 
622 
623 
624     -- API body
625 
626     delete from icx_related_categories
627     where  category_set_id = l_category_set_id
628     and    category_id = l_category_id
629     and    related_category_id = l_related_category_id;
630 
631     -- End of API body
632 
633 
634 
635     -- Standard check of p_simulate and p_commit parameter
636 
637     IF FND_API.To_Boolean(p_simulate) THEN
638 
639 	ROLLBACK TO Insert_Relation_PUB;
640 
641     ELSIF FND_API.To_Boolean(p_commit) THEN
642 
643 	COMMIT WORK;
644 
645     END IF;
646 
647 
648     -- Get message count and if 1, return message data
649 
650     FND_MSG_PUB.Count_And_Get
651         (p_count => p_msg_count,
652          p_data  => p_msg_data
653     );
654 
655 
656 EXCEPTION
657 
658     WHEN NO_DATA_FOUND THEN
659 
660 	p_return_status := FND_API.G_RET_STS_ERROR;
661 
662 	if FND_MSG_PUB.Check_Msg_Level(FND_MSG_PUB.G_MSG_LVL_ERROR) then
663 	    -- add message: Relation to delete does not exist
664 	    FND_MESSAGE.SET_NAME('ICX','ICX_CAT_DELETE');
665 	    FND_MSG_PUB.Add;
666 	end if;
667 
668         -- Get message count and if 1, return message data
669 
670         FND_MSG_PUB.Count_And_Get
671             (p_count => p_msg_count,
672              p_data  => p_msg_data
673         );
674 
675     WHEN FND_API.G_EXC_ERROR THEN
676 
677     	p_return_status := FND_API.G_RET_STS_ERROR;
678 
679         -- Get message count and if 1, return message data
680 
681         FND_MSG_PUB.Count_And_Get
682             (p_count => p_msg_count,
683              p_data  => p_msg_data
684         );
685 
686     WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
687 
688     	p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
689 
690         -- Get message count and if 1, return message data
691 
692         FND_MSG_PUB.Count_And_Get
693             (p_count => p_msg_count,
694              p_data  => p_msg_data
695         );
696 
697     WHEN OTHERS THEN
698 
699     	p_return_status := FND_API.G_RET_STS_UNEXP_ERROR ;
700 
701     	IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR) THEN
702     	    FND_MSG_PUB.Build_Exc_Msg
703     	    (   G_PKG_NAME  	    ,
704     	        'Delete_Relation'
705 	    );
706     	END IF;
707 
708         -- Get message count and if 1, return message data
709 
710         FND_MSG_PUB.Count_And_Get
711             (p_count => p_msg_count,
712              p_data  => p_msg_data
713         );
714 
715 
716 END; -- Delete_Relation
717 
718 
719 
720 END ICX_Related_Categories_PUB;