DBA Data[Home] [Help]

PACKAGE BODY: APPS.IBC_CITEM_RUNTIME_PUB

Source


1 Package Body IBC_CITEM_RUNTIME_PUB as
2 /* $Header: ibcpcirb.pls 120.0 2005/05/27 15:06:21 appldev noship $ */
3 
4 G_PKG_NAME      CONSTANT VARCHAR2(30) := 'IBC_CITEM_RUNTIME_PUB';
5 G_FILE_NAME     CONSTANT VARCHAR2(12) := 'ibcpcirb.pls';
6 
7 
8 --------------------------------------------------------------------------------
9 -- Start of comments
10 --    API name   : Get_Citems_Meta_By_Assoc
11 --    Type       : Public
12 --    Pre-reqs   : None
13 --    Function   : Return a list of content items with their meta-data
14 --		   based on association.
15 --    Parameters :
16 --    IN         : p_api_version                IN  NUMBER    Required
17 --                 p_init_msg_list              IN  VARCHAR2  Optional
18 --                        Default = FND_API.G_FALSE
19 --		   p_association_type_code	IN  VARCHAR2  Required
20 --		   p_associated_object_val1	IN  VARCHAR2  Required
21 --		   p_associated_object_val2	IN  VARCHAR2  Optional
22 --			  Default = NULL
23 --		   p_associated_object_val3	IN  VARCHAR2  Optional
24 --			  Default = NULL
25 --		   p_associated_object_val4	IN  VARCHAR2  Optional
26 --			  Default = NULL
27 --		   p_associated_object_val5	IN  VARCHAR2  Optional
28 --			  Default = NULL
29 --		   p_label_code			IN  VARCHAR2  Optional
30 --			  Default = NULL
31 --    OUT        : x_return_status              OUT VARCHAR2
32 --                 x_msg_count                  OUT NUMBER
33 --                 x_msg_data                   OUT VARCHAR2
34 --		   x_content_item_meta_tbl	OUT CONTENT_ITEM_META_TBL
35 --------------------------------------------------------------------------------
36 PROCEDURE Get_Citems_Meta_By_Assoc (
37 	p_api_version			IN    	NUMBER,
38         p_init_msg_list			IN    	VARCHAR2,
39 	p_association_type_code		IN    	VARCHAR2,
40 	p_associated_object_val1	IN	VARCHAR2,
41 	p_associated_object_val2	IN	VARCHAR2,
42 	p_associated_object_val3	IN	VARCHAR2,
43 	p_associated_object_val4	IN	VARCHAR2,
44 	p_associated_object_val5	IN	VARCHAR2,
45 	p_label_code			IN	VARCHAR2,
46 	x_return_status			OUT NOCOPY   	VARCHAR2,
47         x_msg_count			OUT NOCOPY    	NUMBER,
48         x_msg_data			OUT NOCOPY   	VARCHAR2,
49 	x_content_item_meta_tbl		OUT NOCOPY CONTENT_ITEM_META_TBL
50 ) AS
51         --******** local variable for standards **********
52         l_api_name              CONSTANT VARCHAR2(30)   := 'Get_Citems_Meta_By_Assoc';
53 	l_api_version		CONSTANT NUMBER := 1.0;
54 --
55 	l_citem_count		NUMBER := 1;
56 	l_citem_meta_rec	Content_Item_Meta_Rec;
57 	l_item_found		VARCHAR2(1) := FND_API.G_TRUE;
58 --
59 	CURSOR Get_Citems_By_Assoc IS
60 	select CONTENT_ITEM_ID
61 	from IBC_ASSOCIATIONS
62 	where ASSOCIATION_TYPE_CODE = p_association_type_code
63         and ASSOCIATED_OBJECT_VAL1 = p_associated_object_val1
64 	and NVL(ASSOCIATED_OBJECT_VAL2, '0') = NVL(p_associated_object_val2, '0')
65 	and NVL(ASSOCIATED_OBJECT_VAL3, '0') = NVL(p_associated_object_val3, '0')
66 	and NVL(ASSOCIATED_OBJECT_VAL4, '0') = NVL(p_associated_object_val4, '0')
67 	and NVL(ASSOCIATED_OBJECT_VAL5, '0') = NVL(p_associated_object_val5, '0');
68 
69 BEGIN
70       -- ******* Standard Begins ********
71 
72       -- Standard call to check for call compatibility.
73       IF NOT FND_API.Compatible_API_Call (
74 		l_api_version,
75 		p_api_version,
76 		l_api_name,
77 		G_PKG_NAME)
78       THEN
79            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
80       END IF;
81       -- Initialize message list if p_init_msg_list is set to TRUE.
82       IF FND_API.to_Boolean( p_init_msg_list )
83       THEN
84           FND_MSG_PUB.initialize;
85       END IF;
86 
87       -- Initialize API return status to success
88       x_return_status := FND_API.G_RET_STS_SUCCESS;
89 
90       --******************* Real Logic Start *********************
91 
92       x_content_item_meta_tbl := CONTENT_ITEM_META_TBL();
93 
94       FOR citem_id_rec IN Get_Citems_By_Assoc LOOP
95 
96 	IBC_CITEM_RUNTIME_PVT.Get_Citem_Meta(	p_init_msg_list,
97 						citem_id_rec.content_item_id,
98 						p_label_code,
99 						l_citem_meta_rec,
100 						l_item_found,
101 						x_return_status,
102 						x_msg_count,
103 						x_msg_data);
104 	-- Content Item is not valid
105         IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
106 	  RAISE FND_API.G_EXC_ERROR;
107         END IF;
108 
109 	IF (l_item_found = FND_API.G_TRUE) THEN
110 	   x_content_item_meta_tbl.EXTEND();
111 	   x_content_item_meta_tbl(l_citem_count) := l_citem_meta_rec;
112 	   l_citem_count := l_citem_count + 1;
113 	END IF;
114 
115       END LOOP;
116 
117       -- If no matches, check if p_association_type_code is valid
118       IF (l_citem_count = 1) THEN
119 	IF (Ibc_Validate_Pvt.isValidAssocType(p_association_type_code) = FND_API.g_false) THEN
120 	   IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
121 	       FND_MESSAGE.Set_Name('IBC', 'INVALID_ASSOC_TYPE_CODE');
122 	       FND_MESSAGE.Set_token('ASSOC_TYPE_CODE', p_association_type_code);
123                FND_MSG_PUB.ADD;
124 	   END IF;
125 	   RAISE FND_API.G_EXC_ERROR;
126 	END IF;
127       END IF;
128 
129       --******************* Real Logic End ***********************
130 
131       -- Standard call to get message count and if count=1, get the message
132       FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
133 					p_data  => x_msg_data);
134 EXCEPTION
135    WHEN FND_API.G_EXC_ERROR THEN
136        x_return_status := FND_API.G_RET_STS_ERROR;
137        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
138 					p_data  => x_msg_data);
139    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
140        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
141        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
142 					p_data  => x_msg_data);
143    WHEN OTHERS THEN
144        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
145        IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
146        THEN
147 	   FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
148        END IF;
149        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
150 					p_data  => x_msg_data);
151 END Get_Citems_Meta_By_Assoc;
152 
153 
154 --------------------------------------------------------------------------------
155 -- Start of comments
156 --    API name   : Get_Citems_Meta_By_Assoc_Ctyp
157 --    Type       : Public
158 --    Pre-reqs   : None
159 --    Function   : Return a list of content items with their meta-data
160 --		   based on association and content type.
161 --    Parameters :
162 --    IN         : p_api_version                IN  NUMBER    Required
163 --                 p_init_msg_list              IN  VARCHAR2  Optional
164 --                        Default = FND_API.G_FALSE
165 --		   p_association_type_code	IN  VARCHAR2  Required
166 --		   p_associated_object_val1	IN  VARCHAR2  Required
167 --		   p_associated_object_val2	IN  VARCHAR2  Optional
168 --			  Default = NULL
169 --		   p_associated_object_val3	IN  VARCHAR2  Optional
170 --			  Default = NULL
171 --		   p_associated_object_val4	IN  VARCHAR2  Optional
172 --			  Default = NULL
173 --		   p_associated_object_val5	IN  VARCHAR2  Optional
174 --			  Default = NULL
175 --		   p_content_type_code		IN  VARCHAR2  Required
176 --		   p_label_code			IN  VARCHAR2  Optional
177 --			  Default = NULL
178 --    OUT        : x_return_status              OUT VARCHAR2
179 --                 x_msg_count                  OUT NUMBER
180 --                 x_msg_data                   OUT VARCHAR2
181 --		   x_content_item_meta_tbl	OUT CONTENT_ITEM_META_TBL
182 --------------------------------------------------------------------------------
183 PROCEDURE Get_Citems_Meta_By_Assoc_Ctyp (
184 	p_api_version			IN    	NUMBER,
185         p_init_msg_list			IN    	VARCHAR2,
186 	p_association_type_code		IN    	VARCHAR2,
187 	p_associated_object_val1	IN	VARCHAR2,
188 	p_associated_object_val2	IN	VARCHAR2,
189 	p_associated_object_val3	IN	VARCHAR2,
190 	p_associated_object_val4	IN	VARCHAR2,
191 	p_associated_object_val5	IN	VARCHAR2,
192 	p_content_type_code		IN    	VARCHAR2,
193 	p_label_code			IN	VARCHAR2,
194 	x_return_status			OUT NOCOPY   	VARCHAR2,
195         x_msg_count			OUT NOCOPY    	NUMBER,
196         x_msg_data			OUT NOCOPY   	VARCHAR2,
197 	x_content_item_meta_tbl		OUT NOCOPY CONTENT_ITEM_META_TBL
198 ) AS
199         --******** local variable for standards **********
200         l_api_name              CONSTANT VARCHAR2(30)   := 'Get_Citems_Meta_By_Assoc_Ctype';
201 	l_api_version		CONSTANT NUMBER := 1.0;
202 --
203 	l_citem_count		NUMBER := 1;
204 	l_citem_meta_rec	Content_Item_Meta_Rec;
205         l_item_found		VARCHAR2(1) := FND_API.g_true;
206 	l_invalid_input		VARCHAR2(1) := FND_API.g_false;
207 --
208 	CURSOR Get_Citems_By_Assoc_Ctype IS
209 	select c.CONTENT_ITEM_ID
210 	from IBC_ASSOCIATIONS a, IBC_CONTENT_ITEMS c
211 	where a.ASSOCIATION_TYPE_CODE = p_association_type_code
212         and a.ASSOCIATED_OBJECT_VAL1 = p_associated_object_val1
213 	and NVL(a.ASSOCIATED_OBJECT_VAL2, '0') = NVL(p_associated_object_val2, '0')
214 	and NVL(a.ASSOCIATED_OBJECT_VAL3, '0') = NVL(p_associated_object_val3, '0')
215 	and NVL(a.ASSOCIATED_OBJECT_VAL4, '0') = NVL(p_associated_object_val4, '0')
216 	and NVL(a.ASSOCIATED_OBJECT_VAL5, '0') = NVL(p_associated_object_val5, '0')
217 	and a.CONTENT_ITEM_ID = c.CONTENT_ITEM_ID
218 	and c.CONTENT_TYPE_CODE = p_content_type_code;
219 
220 BEGIN
221       -- ******* Standard Begins ********
222 
223       -- Standard call to check for call compatibility.
224       IF NOT FND_API.Compatible_API_Call (
225 		l_api_version,
226 		p_api_version,
227 		l_api_name,
228 		G_PKG_NAME)
229       THEN
230            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
231       END IF;
232       -- Initialize message list if p_init_msg_list is set to TRUE.
233       IF FND_API.to_Boolean( p_init_msg_list )
234       THEN
235           FND_MSG_PUB.initialize;
236       END IF;
237 
238       -- Initialize API return status to success
239       x_return_status := FND_API.G_RET_STS_SUCCESS;
240 
241       --******************* Real Logic Start *********************
242 
243       x_content_item_meta_tbl := CONTENT_ITEM_META_TBL();
244 
245       FOR citem_id_rec IN Get_Citems_By_Assoc_Ctype LOOP
246 
247 	IBC_CITEM_RUNTIME_PVT.Get_Citem_Meta(	p_init_msg_list,
248 						citem_id_rec.content_item_id,
249 						p_label_code,
250 						l_citem_meta_rec,
251 					        l_item_found,
252 						x_return_status,
253 						x_msg_count,
254 						x_msg_data);
255 	-- Content Item is not valid
256         IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
257 	  RAISE FND_API.G_EXC_ERROR;
258         END IF;
259 
260 	IF (l_item_found = FND_API.G_TRUE) THEN
261 	   x_content_item_meta_tbl.EXTEND();
262 	   x_content_item_meta_tbl(l_citem_count) := l_citem_meta_rec;
263 	   l_citem_count := l_citem_count + 1;
264 	END IF;
265 
266       END LOOP;
267 
268       -- If no matches, check if p_association_type_code, p_content_type_code are valid
269       IF (l_citem_count = 1) THEN
270 	IF (Ibc_Validate_Pvt.isValidAssocType(p_association_type_code) = FND_API.g_false) THEN
271 	   IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
272 	       FND_MESSAGE.Set_Name('IBC', 'INVALID_ASSOC_TYPE_CODE');
273 	       FND_MESSAGE.Set_token('ASSOC_TYPE_CODE', p_association_type_code);
274                FND_MSG_PUB.ADD;
275 	   END IF;
276 	   l_invalid_input := FND_API.g_true;
277 	END IF;
278 	IF (Ibc_Validate_Pvt.isValidCType(p_content_type_code) = FND_API.g_false) THEN
279 	   IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
280 	       FND_MESSAGE.Set_Name('IBC', 'INVALID_CONTENT_TYPE_CODE');
281 	       FND_MESSAGE.Set_token('CONTENT_TYPE_CODE', p_content_type_code);
282                FND_MSG_PUB.ADD;
283 	   END IF;
284 	   l_invalid_input := FND_API.g_true;
285 	END IF;
286 	IF (l_invalid_input = FND_API.g_true) THEN
287 	   RAISE FND_API.G_EXC_ERROR;
288 	END IF;
289       END IF;
290 
291       --******************* Real Logic End ***********************
292 
293       -- Standard call to get message count and if count=1, get the message
294       FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
295 					p_data  => x_msg_data);
296 EXCEPTION
297    WHEN FND_API.G_EXC_ERROR THEN
298        x_return_status := FND_API.G_RET_STS_ERROR;
299        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
300 					p_data  => x_msg_data);
301    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
302        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
303        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
304 					p_data  => x_msg_data);
305    WHEN OTHERS THEN
306        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
307        IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
308        THEN
309 	   FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
310        END IF;
311        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
312 					p_data  => x_msg_data);
313 END Get_Citems_Meta_By_Assoc_Ctyp;
314 
315 
316 
317 --------------------------------------------------------------------------------
318 -- Start of comments
319 --    API name   : Get_Citems_Meta
320 --    Type       : Public
321 --    Pre-reqs   : None
322 --    Function   : Return a list of content items with their meta-data
323 --		   based on the given list of content item ids.
324 --    Parameters :
325 --    IN         : p_api_version                IN  NUMBER    Required
326 --                 p_init_msg_list              IN  VARCHAR2  Optional
327 --                        Default = FND_API.G_FALSE
328 --		   p_content_item_ids		IN  CONTENT_ITEM_ID_TBL Required
329 --		   p_label_code			IN  VARCHAR2  Optional
330 --			  Default = NULL
331 --    OUT        : x_return_status              OUT VARCHAR2
332 --                 x_msg_count                  OUT NUMBER
333 --                 x_msg_data                   OUT VARCHAR2
334 --		   x_content_item_meta_tbl	OUT CONTENT_ITEM_META_TBL
335 --------------------------------------------------------------------------------
336 PROCEDURE Get_Citems_Meta (
337 	p_api_version          	IN    	NUMBER,
338         p_init_msg_list        	IN    	VARCHAR2,
339 	p_content_item_ids	IN	CONTENT_ITEM_ID_TBL,
340 	p_label_code		IN	VARCHAR2,
341 	x_return_status        	OUT NOCOPY   	VARCHAR2,
342         x_msg_count            	OUT NOCOPY    	NUMBER,
343         x_msg_data             	OUT NOCOPY   	VARCHAR2,
344 	x_content_item_meta_tbl	OUT NOCOPY CONTENT_ITEM_META_TBL
345 ) AS
346         --******** local variable for standards **********
347         l_api_name              CONSTANT VARCHAR2(30)   := 'Get_Citems_Meta';
348 	l_api_version		CONSTANT NUMBER := 1.0;
349 --
350 	l_citem_count 		NUMBER := 1;
351 	l_citem_id_count	NUMBER := 1;
352 	l_citem_meta_rec	Content_Item_Meta_Rec;
353 	l_item_found		VARCHAR2(1) := FND_API.G_TRUE;
354 
355 BEGIN
356       -- ******* Standard Begins ********
357 
358       -- Standard call to check for call compatibility.
359       IF NOT FND_API.Compatible_API_Call (
360 		l_api_version,
361 		p_api_version,
362 		l_api_name,
363 		G_PKG_NAME)
364       THEN
365            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
366       END IF;
367       -- Initialize message list if p_init_msg_list is set to TRUE.
368       IF FND_API.to_Boolean( p_init_msg_list )
369       THEN
370           FND_MSG_PUB.initialize;
371       END IF;
372 
373       -- Initialize API return status to success
374       x_return_status := FND_API.G_RET_STS_SUCCESS;
375 
376       --******************* Real Logic Start *********************
377 
378       x_content_item_meta_tbl := CONTENT_ITEM_META_TBL();
379 
380       -- Validate each content item id passed in
381       WHILE l_citem_id_count <= p_content_item_ids.COUNT LOOP
382 
383 	IBC_CITEM_RUNTIME_PVT.Get_Citem_Meta(	p_init_msg_list,
384 						p_content_item_ids(l_citem_id_count),
385 						p_label_code,
386 						l_citem_meta_rec,
387 						l_item_found,
388 						x_return_status,
389 						x_msg_count,
390 						x_msg_data);
391 	-- Content item is not valid
392 	IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
393            RAISE FND_API.G_EXC_ERROR;
394         END IF;
395 
396 	IF (l_item_found = FND_API.G_TRUE) THEN
397 	   x_content_item_meta_tbl.EXTEND();
398 	   x_content_item_meta_tbl(l_citem_count) := l_citem_meta_rec;
399 	   l_citem_count := l_citem_count + 1;
400 	END IF;
401 
402 	l_citem_id_count := l_citem_id_count + 1;
403       END LOOP;
404 
405       --******************* Real Logic End *********************
406 
407       -- Standard call to get message count and if count=1, get the message
408       FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
409 					p_data  => x_msg_data);
410 EXCEPTION
411    WHEN FND_API.G_EXC_ERROR THEN
412        x_return_status := FND_API.G_RET_STS_ERROR;
413        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
414 					p_data  => x_msg_data);
415    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
416        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
417        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
418 					p_data  => x_msg_data);
419    WHEN OTHERS THEN
420        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
421        IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
422        THEN
423 	   FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
424        END IF;
425        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
426 					p_data  => x_msg_data);
427 END Get_Citems_Meta;
428 
429 
430 --------------------------------------------------------------------------------
431 -- Start of comments
432 --    API name   : Get_Citem_Meta
433 --    Type       : Public
434 --    Pre-reqs   : None
435 --    Function   : Return a content item with just the meta-data.
436 --    Parameters :
437 --    IN         : p_api_version                IN  NUMBER    Required
438 --                 p_init_msg_list              IN  VARCHAR2  Optional
439 --                        Default = FND_API.G_FALSE
440 --		   p_content_item_id		IN  NUMBER    Required
441 --		   p_label_code			IN  VARCHAR2  Optional
442 --			  Default = NULL
443 --    OUT        : x_return_status              OUT VARCHAR2
444 --                 x_msg_count                  OUT NUMBER
445 --                 x_msg_data                   OUT VARCHAR2
446 --		   x_content_item_meta		OUT CONTENT_ITEM_META_REC
447 --------------------------------------------------------------------------------
448 PROCEDURE Get_Citem_Meta (
449 	p_api_version          	IN    	NUMBER,
450         p_init_msg_list        	IN    	VARCHAR2,
451 	p_content_item_id	IN	NUMBER,
452 	p_label_code		IN	VARCHAR2,
453 	x_return_status        	OUT NOCOPY   	VARCHAR2,
454         x_msg_count            	OUT NOCOPY    	NUMBER,
455         x_msg_data             	OUT NOCOPY   	VARCHAR2,
456 	x_content_item_meta	OUT NOCOPY CONTENT_ITEM_META_REC
457 ) AS
458         --******** local variable for standards **********
459         l_api_name              CONSTANT VARCHAR2(30) := 'Get_Citem_Meta';
460 	l_api_version		CONSTANT NUMBER := 1.0;
461 --
462 	l_item_found		VARCHAR2(1) := FND_API.G_TRUE;
463 
464 BEGIN
465       -- ******* Standard Begins ********
466 
467       -- Standard call to check for call compatibility.
468       IF NOT FND_API.Compatible_API_Call (
469 		l_api_version,
470 		p_api_version,
471 		l_api_name,
472 		G_PKG_NAME)
473       THEN
474            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
475       END IF;
476       -- Initialize message list if p_init_msg_list is set to TRUE.
477       IF FND_API.to_Boolean( p_init_msg_list )
478       THEN
479           FND_MSG_PUB.initialize;
480       END IF;
481 
482       -- Initialize API return status to success
483       x_return_status := FND_API.G_RET_STS_SUCCESS;
484 
485       --******************* Real Logic Start *********************
486 
487       IBC_CITEM_RUNTIME_PVT.Get_Citem_Meta(	p_init_msg_list,
488 						p_content_item_id,
489 						p_label_code,
490 						x_content_item_meta,
491 						l_item_found,
492 						x_return_status,
493 						x_msg_count,
494 						x_msg_data);
495       -- Content Item is not valid
496       IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
497 	RAISE FND_API.G_EXC_ERROR;
498       END IF;
499 
500       --******************* Real Logic End *********************
501 
502       -- Standard call to get message count and if count=1, get the message
503       FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
504 					p_data  => x_msg_data);
505 EXCEPTION
506    WHEN FND_API.G_EXC_ERROR THEN
507        x_return_status := FND_API.G_RET_STS_ERROR;
508        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
509 					p_data  => x_msg_data);
510    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
511        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
512        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
513 					p_data  => x_msg_data);
514    WHEN OTHERS THEN
515        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
516        IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
517        THEN
518 	   FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
519        END IF;
520        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
521 					p_data  => x_msg_data);
522 END Get_Citem_Meta;
523 
524 
525 --------------------------------------------------------------------------------
526 -- Start of comments
527 --    API name   : Get_Citem_Basic
528 --    Type       : Public
529 --    Pre-reqs   : None
530 --    Function   : Return a content item with basic data.
531 --    Parameters :
532 --    IN         : p_api_version                IN  NUMBER    Required
533 --                 p_init_msg_list              IN  VARCHAR2  Optional
534 --                        Default = FND_API.G_FALSE
535 --		   p_content_item_id		IN  NUMBER    Required
536 --		   p_label_code			IN  VARCHAR2  Optional
537 --			  Default = NULL
538 --    OUT        : x_return_status              OUT VARCHAR2
539 --                 x_msg_count                  OUT NUMBER
540 --                 x_msg_data                   OUT VARCHAR2
541 --		   x_content_item_basic		OUT CONTENT_ITEM_BASIC_REC
542 --------------------------------------------------------------------------------
543 PROCEDURE Get_Citem_Basic (
544 	p_api_version			IN    	NUMBER,
545         p_init_msg_list			IN    	VARCHAR2,
546 	p_content_item_id		IN	NUMBER,
547 	p_label_code			IN	VARCHAR2,
548 	x_return_status			OUT NOCOPY   	VARCHAR2,
549         x_msg_count			OUT NOCOPY    	NUMBER,
550         x_msg_data			OUT NOCOPY   	VARCHAR2,
551 	x_content_item_basic		OUT NOCOPY CONTENT_ITEM_BASIC_REC
552 ) AS
553         --******** local variable for standards **********
554         l_api_name              CONSTANT VARCHAR2(30)   := 'Get_Citem_Basic';
555 	l_api_version		CONSTANT NUMBER := 1.0;
556 --
557 	l_live_citem_version_id		NUMBER;
558 	l_citem_version_id		NUMBER;
559 	l_content_type_code		VARCHAR2(100);
560 	l_item_reference_code		VARCHAR2(100);
561 	l_encrypt_flag			VARCHAR2(1);
562 
563 	l_attribute_file_id		NUMBER;
564 	l_attribute_bundle		CLOB := NULL;
565 	l_mime_type			VARCHAR2(30);
566 	l_count				NUMBER := 1;
567 --
568 	CURSOR Get_Citem_Ver_By_Label IS
569 	select citem_version_id
570 	from IBC_CITEM_VERSION_LABELS
571 	where label_code = p_label_code and
572 	      content_item_id = p_content_item_id;
573 
574 	CURSOR Get_Citem_Meta_Csr IS
575 	select ATTRIBUTE_FILE_ID, CONTENT_ITEM_NAME, DESCRIPTION,
576 	       DEFAULT_RENDITION_MIME_TYPE, ATTACHMENT_FILE_NAME, ATTACHMENT_FILE_ID
577 	from IBC_CITEM_VERSIONS_TL
578         where citem_version_id = l_citem_version_id
579         and language = userenv('LANG');
580 
581 	CURSOR Get_Renditions IS
582 	select FILE_ID, FILE_NAME, MIME_TYPE
583 	from IBC_RENDITIONS
584 	where citem_version_id = l_citem_version_id and
585         language = userenv('LANG');
586 
587 	CURSOR Get_Rendition_Name IS
588 	SELECT NVL(DESCRIPTION, MEANING)
589 	FROM FND_LOOKUP_VALUES
590 	WHERE LOOKUP_TYPE = IBC_UTILITIES_PVT.G_REND_LOOKUP_TYPE
591 	AND LANGUAGE = userenv('LANG')
592 	AND LOOKUP_CODE = l_mime_type;
593 
594 	CURSOR Get_Compound_Item_Ref IS
595 	select ATTRIBUTE_TYPE_CODE, CONTENT_ITEM_ID
596 	from IBC_COMPOUND_RELATIONS
597 	where CITEM_VERSION_ID = l_citem_version_id
598 	order by SORT_ORDER;
599 
600 BEGIN
601       -- ******* Standard Begins ********
602 
603       -- Standard call to check for call compatibility.
604       IF NOT FND_API.Compatible_API_Call (
605 		l_api_version,
606 		p_api_version,
607 		l_api_name,
608 		G_PKG_NAME)
609       THEN
610            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
611       END IF;
612       -- Initialize message list if p_init_msg_list is set to TRUE.
613       IF FND_API.to_Boolean( p_init_msg_list )
614       THEN
615           FND_MSG_PUB.initialize;
616       END IF;
617 
618       -- Initialize API return status to success
619       x_return_status := FND_API.G_RET_STS_SUCCESS;
620 
621       --******************* Real Logic Start *********************
622 
623 	IBC_CITEM_RUNTIME_PVT.Validate_Citem (
624 		p_init_msg_list =>		p_init_msg_list,
625 		p_content_item_id =>		p_content_item_id,
626 		x_content_type_code =>		l_content_type_code,
627 		x_item_reference_code =>	l_item_reference_code,
628 		x_live_citem_version_id	=>	l_live_citem_version_id,
629 		x_encrypt_flag =>		l_encrypt_flag,
630 		x_return_status =>		x_return_status,
631 		x_msg_count =>			x_msg_count,
632 		x_msg_data =>			x_msg_data
633 	);
634 	-- Content Item requested is not valid
635 	IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
636 	   RAISE FND_API.G_EXC_ERROR;
637 	END IF;
638 
639 	x_content_item_basic.content_item_id := p_content_item_id;
640 	x_content_item_basic.content_type_code := l_content_type_code;
641 	x_content_item_basic.item_reference_code := l_item_reference_code;
642 	x_content_item_basic.encrypt_flag := l_encrypt_flag;
643 
644 	-- Check if there is a label for this content item
645 	IF (p_label_code is NULL) THEN
646 	   l_citem_version_id := l_live_citem_version_id;
647 	ELSE
648            OPEN Get_Citem_Ver_By_Label;
649 	      FETCH Get_Citem_Ver_By_Label INTO l_citem_version_id;
650 	      -- Label doesn't exist for this content item id
651 	      IF (Get_Citem_Ver_By_Label%NOTFOUND) THEN
652 		-- Validate Label
653 		IF (Ibc_Validate_Pvt.isValidLabel(p_label_code) = FND_API.g_false) THEN
654 		   IF FND_MSG_PUB.Check_Msg_Level (FND_MSG_PUB.G_MSG_LVL_ERROR) THEN
655 		      FND_MESSAGE.Set_Name('IBC', 'INVALID_LABEL_CODE');
656 	              FND_MESSAGE.Set_token('LABEL_CODE', p_label_code);
657                       FND_MSG_PUB.ADD;
658 	           END IF;
659 		   RAISE FND_API.G_EXC_ERROR;
660 		END IF;
661 	        x_content_item_basic := NULL;
662 		return;
663 	      END IF;
664            CLOSE Get_Citem_Ver_By_Label;
665 	END IF;
666 
667 	-- check start/end date
668         IBC_CITEM_RUNTIME_PVT.Validate_Start_End_Date (
669 		p_init_msg_list =>		p_init_msg_list,
670 		p_content_item_id =>		p_content_item_id,
671 		p_citem_version_id =>		l_citem_version_id,
672 	        x_version_number =>		x_content_item_basic.version_number,
673 		x_start_date =>			x_content_item_basic.available_date,
674 		x_end_date =>			x_content_item_basic.expiration_date,
675 		x_return_status =>		x_return_status,
676 		x_msg_count =>			x_msg_count,
677 		x_msg_data =>			x_msg_data
678 	);
679 	-- Start/End date not valid
680 	IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
681 	   RAISE FND_API.G_EXC_ERROR;
682 	END IF;
683 
684 	-- Retrieve content item meta-data
685 	OPEN Get_Citem_Meta_Csr;
686 	   FETCH Get_Citem_Meta_Csr INTO l_attribute_file_id,
687 					 x_content_item_basic.content_item_name,
688 					 x_content_item_basic.description,
689                                          l_mime_type,
690 					 x_content_item_basic.attachment_file_name,
691 					 x_content_item_basic.attachment_file_id;
692         CLOSE Get_Citem_Meta_Csr;
693 
694 	x_content_item_basic.default_mime_type := LOWER(l_mime_type);
695 	-- Retrieve default rendition name
696 	IF (l_mime_type IS NOT NULL) THEN
697 	   OPEN Get_Rendition_Name;
698 	   FETCH Get_Rendition_Name INTO x_content_item_basic.default_rendition_name;
699 	   IF Get_Rendition_Name%NOTFOUND THEN
700 	      CLOSE Get_Rendition_Name;
701 	      l_mime_type := IBC_UTILITIES_PVT.G_REND_UNKNOWN_MIME;
702 	      OPEN Get_Rendition_Name;
703 	         FETCH Get_Rendition_Name INTO x_content_item_basic.default_rendition_name;
704 	      CLOSE Get_Rendition_Name;
705 	   ELSE
706 	      CLOSE Get_Rendition_Name;
707 	   END IF;
708 	ELSE
709 	   x_content_item_basic.default_rendition_name := NULL;
710 	END IF;
711 
712         -- Retrieve renditions info
713         x_content_item_basic.rendition_file_names := Rendition_File_Name_Tbl();
714 	x_content_item_basic.rendition_file_ids := Rendition_File_Id_Tbl();
715 	x_content_item_basic.rendition_mime_types := Rendition_Mime_Type_Tbl();
716         x_content_item_basic.rendition_names := Rendition_Name_Tbl();
717         FOR rendition_rec IN Get_Renditions LOOP
718            x_content_item_basic.rendition_file_names.EXTEND();
719 	   x_content_item_basic.rendition_file_ids.EXTEND();
720 	   x_content_item_basic.rendition_mime_types.EXTEND();
721            x_content_item_basic.rendition_names.EXTEND();
722 
723 	   x_content_item_basic.rendition_file_names(l_count) := rendition_rec.file_name;
724 	   x_content_item_basic.rendition_file_ids(l_count) := rendition_rec.file_id;
725 	   x_content_item_basic.rendition_mime_types(l_count) := LOWER(rendition_rec.mime_type);
726 
727 	   l_mime_type := rendition_rec.mime_type;
728 	   OPEN Get_Rendition_Name;
729 	   FETCH Get_Rendition_Name INTO x_content_item_basic.rendition_names(l_count);
730 	   IF Get_Rendition_Name%NOTFOUND THEN
731 	      CLOSE Get_Rendition_Name;
732 	      l_mime_type := IBC_UTILITIES_PVT.G_REND_UNKNOWN_MIME;
733 	      OPEN Get_Rendition_Name;
734 	         FETCH Get_Rendition_Name INTO x_content_item_basic.rendition_names(l_count);
735 	      CLOSE Get_Rendition_Name;
736 	   ELSE
737 	      CLOSE Get_Rendition_Name;
738 	   END IF;
739 
740 	   l_count := l_count + 1;
741         END LOOP;
742 
743 	-- Retrieve attribute bundle and build output xml
744 	IF (l_attribute_file_id is NULL) THEN
745 	   x_content_item_basic.attribute_bundle := NULL;
746 	ELSE
747 	   DBMS_LOB.CREATETEMPORARY(l_attribute_bundle, TRUE);
748            IBC_UTILITIES_PVT.Build_Citem_Open_Tag (
749 		p_content_type_code	=>  l_content_type_code
750 		,p_content_item_id	=>  p_content_item_id
751 		,p_version_number	=>  x_content_item_basic.version_number
752 		,p_item_reference_code	=>  l_item_reference_code
753 		,p_item_label		=>  p_label_code
754 		,p_xml_clob_loc		=>  l_attribute_bundle
755 	   );
756 	   IBC_UTILITIES_PVT.Build_Attribute_Bundle (
757 		l_attribute_file_id,	-- p_file_id IN NUMBER
758 		l_attribute_bundle	-- p_xml_clob_loc IN OUT CLOB
759 	   );
760 	   IBC_UTILITIES_PVT.Build_Close_Tag (
761 		l_content_type_code,	-- p_close_tag IN VARCHAR2
762 		l_attribute_bundle	-- p_xml_clob_loc IN OUT CLOB
763 	   );
764 	   x_content_item_basic.attribute_bundle := l_attribute_bundle;
765 	END IF;
766 
767 	-- Retrieve compounded items
768 	x_content_item_basic.comp_item_attrib_tcodes := Comp_Item_Attrib_Tcode_Tbl();
769 	x_content_item_basic.comp_item_citem_ids := Comp_Item_Citem_Id_Tbl();
770         l_count := 1;
771 	FOR compound_item_rec IN Get_Compound_Item_Ref LOOP
772 	   x_content_item_basic.comp_item_attrib_tcodes.EXTEND();
773 	   x_content_item_basic.comp_item_citem_ids.EXTEND();
774 
775 	   x_content_item_basic.comp_item_attrib_tcodes(l_count) := compound_item_rec.attribute_type_code;
776 	   x_content_item_basic.comp_item_citem_ids(l_count) := compound_item_rec.content_item_id;
777 
778 	   l_count := l_count + 1;
779         END LOOP;
780 
781       --******************* Real Logic End *********************
782 
783       -- Standard call to get message count and if count=1, get the message
784       FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
785 					p_data  => x_msg_data);
786 EXCEPTION
787    WHEN FND_API.G_EXC_ERROR THEN
788        x_return_status := FND_API.G_RET_STS_ERROR;
789        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
790 					p_data  => x_msg_data);
791    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
792        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
793        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
794 					p_data  => x_msg_data);
795    WHEN OTHERS THEN
796        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
797        IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
798        THEN
799 	   FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
800        END IF;
801        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
802 					p_data  => x_msg_data);
803 END Get_Citem_Basic;
804 
805 
806 
807 --------------------------------------------------------------------------------
808 -- Start of comments
809 --    API name   : Get_Citem_Basic_Xml
810 --    Type       : Public
811 --    Pre-reqs   : None
812 --    Function   : Return a content item with basic data as an XML Document.
813 --		   The item's compounded items are returned as references in
814 --		   the Xml.
815 --    Parameters :
816 --    IN         : p_api_version                IN  NUMBER    Required
817 --                 p_init_msg_list              IN  VARCHAR2  Optional
818 --                        Default = FND_API.G_FALSE
819 --		   p_content_item_id		IN  NUMBER    Required
820 --		   p_label_code			IN  VARCHAR2  Optional
821 --			  Default = NULL
822 --    OUT        : x_return_status              OUT VARCHAR2
823 --                 x_msg_count                  OUT NUMBER
824 --                 x_msg_data                   OUT VARCHAR2
825 --		   x_content_item_xml		OUT CLOB
826 --------------------------------------------------------------------------------
827 PROCEDURE Get_Citem_Basic_Xml (
828 	p_api_version          	IN    	NUMBER,
829         p_init_msg_list        	IN    	VARCHAR2,
830 	p_content_item_id	IN	NUMBER,
831 	p_label_code		IN	VARCHAR2,
832 	x_return_status        	OUT NOCOPY   	VARCHAR2,
833         x_msg_count            	OUT NOCOPY    	NUMBER,
834         x_msg_data             	OUT NOCOPY   	VARCHAR2,
835 	x_content_item_xml	OUT NOCOPY CLOB
836 ) AS
837         --******** local variable for standards **********
838         l_api_name              CONSTANT VARCHAR2(30)   := 'Get_Citem_Basic_Xml';
839 	l_api_version		CONSTANT NUMBER := 1.0;
840 --
841 	x_num_levels_loaded	NUMBER;
842 	l_xml_encoding		VARCHAR2(50);
843 BEGIN
844       -- ******* Standard Begins ********
845 
846       -- Standard call to check for call compatibility.
847       IF NOT FND_API.Compatible_API_Call (
848 		l_api_version,
849 		p_api_version,
850 		l_api_name,
851 		G_PKG_NAME)
852       THEN
853            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
854       END IF;
855       -- Initialize message list if p_init_msg_list is set to TRUE.
856       IF FND_API.to_Boolean( p_init_msg_list )
857       THEN
858           FND_MSG_PUB.initialize;
859       END IF;
860 
861       -- Initialize API return status to success
862       x_return_status := FND_API.G_RET_STS_SUCCESS;
863 
864       --******************* Real Logic Start *********************
865 
866       DBMS_LOB.CREATETEMPORARY(x_content_item_xml, TRUE);
867 
868       l_xml_encoding := '<?xml version="1.0" encoding="'||
869                         IBC_UTILITIES_PVT.getEncoding() ||
870                         '"?>';
871       DBMS_LOB.WRITEAPPEND(x_content_item_xml, LENGTH(l_xml_encoding), l_xml_encoding);
872 
873       IBC_CITEM_RUNTIME_PVT.Get_Citem_Xml (
874 	p_init_msg_list =>	p_init_msg_list,	-- p_init_msg_list IN VARCHAR2
875 	p_content_item_id =>	p_content_item_id,	-- p_content_item_id IN NUMBER
876 	p_xml_clob_loc =>	x_content_item_xml,	-- p_xml_clob_loc IN OUT CLOB
877 	p_num_levels =>		0,			-- p_num_levels IN NUMBER
878 	p_label_code =>		p_label_code,		-- p_label_code IN VARCHAR2
879 	p_validate_dates =>	FND_API.G_TRUE,		-- p_validate_dates
880 	x_num_levels_loaded =>	x_num_levels_loaded,
881 	x_return_status =>	x_return_status,
882 	x_msg_count =>		x_msg_count,
883 	x_msg_data =>		x_msg_data
884       );
885       -- Content Item is not valid
886       IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
887 	RAISE FND_API.G_EXC_ERROR;
888       END IF;
889 
890       --******************* Real Logic End *********************
891 
892       -- Standard call to get message count and if count=1, get the message
893       FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
894 					p_data  => x_msg_data);
895 EXCEPTION
896    WHEN FND_API.G_EXC_ERROR THEN
897        x_return_status := FND_API.G_RET_STS_ERROR;
898        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
899 					p_data  => x_msg_data);
900    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
901        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
902        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
903 					p_data  => x_msg_data);
904    WHEN OTHERS THEN
905        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
906        IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
907        THEN
908 	   FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
909        END IF;
910        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
911 					p_data  => x_msg_data);
912 END Get_Citem_Basic_Xml;
913 
914 
915 --------------------------------------------------------------------------------
916 -- Start of comments
917 --    API name   : Get_Citem_Deep_Xml
918 --    Type       : Public
919 --    Pre-reqs   : None
920 --    Function   : Return a content item with full data as an XML Document.
921 --		   The item's component items are fully expanded in
922 --		   the Xml rather than as references. If the item's component
923 --		   in turn has some other components, they will be fully expanded
924 --		   also.
925 --    Parameters :
926 --    IN         : p_api_version                IN  NUMBER    Required
927 --                 p_init_msg_list              IN  VARCHAR2  Optional
928 --                        Default = FND_API.G_FALSE
929 --		   p_content_item_id		IN  NUMBER    Required
930 --		   p_label_code			IN  VARCHAR2  Optional
931 --			  Default = NULL
932 --    OUT        : x_return_status              OUT VARCHAR2
933 --                 x_msg_count                  OUT NUMBER
934 --                 x_msg_data                   OUT VARCHAR2
935 --		   x_content_item_xml		OUT CLOB
936 --		   x_num_levels_loaded		OUT NUMBER
937 --------------------------------------------------------------------------------
938 PROCEDURE Get_Citem_Deep_Xml (
939 	p_api_version          	IN    	NUMBER,
940         p_init_msg_list        	IN    	VARCHAR2,
941 	p_content_item_id	IN	NUMBER,
942 	p_label_code		IN	VARCHAR2,
943 	x_return_status        	OUT NOCOPY VARCHAR2,
944         x_msg_count            	OUT NOCOPY NUMBER,
945         x_msg_data             	OUT NOCOPY VARCHAR2,
946 	x_content_item_xml	OUT NOCOPY CLOB,
947 	x_num_levels_loaded	OUT NOCOPY NUMBER
948 ) AS
949         --******** local variable for standards **********
950         l_api_name              CONSTANT VARCHAR2(30)   := 'Get_Citem_Deep_Xml';
951 	l_api_version		CONSTANT NUMBER := 1.0;
952 --
953 	l_xml_encoding		VARCHAR2(50);
954 BEGIN
955       -- ******* Standard Begins ********
956 
957       -- Standard call to check for call compatibility.
958       IF NOT FND_API.Compatible_API_Call (
959 		l_api_version,
960 		p_api_version,
961 		l_api_name,
962 		G_PKG_NAME)
963       THEN
964            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
965       END IF;
966       -- Initialize message list if p_init_msg_list is set to TRUE.
967       IF FND_API.to_Boolean( p_init_msg_list )
968       THEN
969           FND_MSG_PUB.initialize;
970       END IF;
971 
972       -- Initialize API return status to success
973       x_return_status := FND_API.G_RET_STS_SUCCESS;
974 
975       --******************* Real Logic Start *********************
976 
977       DBMS_LOB.CREATETEMPORARY(x_content_item_xml, TRUE);
978 
979       l_xml_encoding := '<?xml version="1.0" encoding="'||
980                         IBC_UTILITIES_PVT.getEncoding() ||
981                         '"?>';
982       DBMS_LOB.WRITEAPPEND(x_content_item_xml, LENGTH(l_xml_encoding), l_xml_encoding);
983 
984       IBC_CITEM_RUNTIME_PVT.Get_Citem_Xml (
985 	p_init_msg_list =>	p_init_msg_list,	-- p_init_msg_list IN VARCHAR2
986 	p_content_item_id =>	p_content_item_id,	-- p_content_item_id IN NUMBER
987 	p_xml_clob_loc =>	x_content_item_xml,	-- p_xml_clob_loc IN OUT CLOB
988 	p_num_levels =>		NULL,			-- p_num_levels IN NUMBER
989 	p_label_code =>		p_label_code,		-- p_label_code IN VARCHAR2
990 	p_validate_dates =>	FND_API.G_TRUE,		-- p_validate_dates
991 	x_num_levels_loaded =>	x_num_levels_loaded,
992 	x_return_status =>	x_return_status,
993 	x_msg_count =>		x_msg_count,
994 	x_msg_data =>		x_msg_data
995       );
996       -- Content Item is not valid
997       IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
998 	RAISE FND_API.G_EXC_ERROR;
999       END IF;
1000 
1001       --******************* Real Logic End *********************
1002 
1003       -- Standard call to get message count and if count=1, get the message
1004       FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
1005 					p_data  => x_msg_data);
1006 EXCEPTION
1007    WHEN FND_API.G_EXC_ERROR THEN
1008        x_return_status := FND_API.G_RET_STS_ERROR;
1009        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
1010 					p_data  => x_msg_data);
1011    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1012        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1013        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
1014 					p_data  => x_msg_data);
1015    WHEN OTHERS THEN
1016        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1017        IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1018        THEN
1019 	   FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
1020        END IF;
1021        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
1022 					p_data  => x_msg_data);
1023 END Get_Citem_Deep_Xml;
1024 
1025 
1026 --------------------------------------------------------------------------------
1027 -- Start of comments
1028 --    API name   : Get_Citem_Deep_Xml
1029 --    Type       : Public
1030 --    Pre-reqs   : None
1031 --    Function   : Return a content item with full data as an XML Document.
1032 --		   This returns a specific content item version
1033 --		   The item's component items are fully expanded in
1034 --		   the Xml rather than as references. If the item's component
1035 --		   in turn has some other components, they will be fully expanded
1036 --		   also.
1037 --    Parameters :
1038 --    IN         : p_api_version                IN  NUMBER    Required
1039 --                 p_init_msg_list              IN  VARCHAR2  Optional
1040 --                        Default = FND_API.G_FALSE
1041 --		   p_content_item_id		IN  NUMBER    Required
1042 --		   p_citem_version_id		IN  NUMBER    Required
1043 --    OUT        : x_return_status              OUT VARCHAR2
1044 --                 x_msg_count                  OUT NUMBER
1045 --                 x_msg_data                   OUT VARCHAR2
1046 --		   x_content_item_xml		OUT CLOB
1047 --		   x_num_levels_loaded		OUT NUMBER
1048 --------------------------------------------------------------------------------
1049 PROCEDURE Get_Citem_Deep_Xml (
1050 	p_api_version          	IN    	NUMBER,
1051         p_init_msg_list        	IN    	VARCHAR2,
1052 	p_content_item_id	IN	NUMBER,
1053 	p_citem_version_id 	IN	NUMBER,
1054 	x_return_status        	OUT NOCOPY VARCHAR2,
1055         x_msg_count            	OUT NOCOPY NUMBER,
1056         x_msg_data             	OUT NOCOPY VARCHAR2,
1057 	x_content_item_xml	OUT NOCOPY CLOB,
1058 	x_num_levels_loaded	OUT NOCOPY NUMBER
1059 ) AS
1060         --******** local variable for standards **********
1061         l_api_name              CONSTANT VARCHAR2(30)   := 'Get_Citem_Deep_Xml';
1062 	l_api_version		CONSTANT NUMBER := 1.0;
1063 --
1064 	l_xml_encoding		VARCHAR2(50);
1065 BEGIN
1066       -- ******* Standard Begins ********
1067 
1068       -- Standard call to check for call compatibility.
1069       IF NOT FND_API.Compatible_API_Call (
1070 		l_api_version,
1071 		p_api_version,
1072 		l_api_name,
1073 		G_PKG_NAME)
1074       THEN
1075            RAISE FND_API.G_EXC_UNEXPECTED_ERROR;
1076       END IF;
1077       -- Initialize message list if p_init_msg_list is set to TRUE.
1078       IF FND_API.to_Boolean( p_init_msg_list )
1079       THEN
1080           FND_MSG_PUB.initialize;
1081       END IF;
1082 
1083       -- Initialize API return status to success
1084       x_return_status := FND_API.G_RET_STS_SUCCESS;
1085 
1086       --******************* Real Logic Start *********************
1087 
1088       DBMS_LOB.CREATETEMPORARY(x_content_item_xml, TRUE);
1089 
1090       l_xml_encoding := '<?xml version="1.0" encoding="'||
1091                         IBC_UTILITIES_PVT.getEncoding() ||
1092                         '"?>';
1093       DBMS_LOB.WRITEAPPEND(x_content_item_xml, LENGTH(l_xml_encoding), l_xml_encoding);
1094 
1095       IBC_CITEM_RUNTIME_PVT.Get_Citem_Xml (
1096 	p_init_msg_list =>	p_init_msg_list,	-- p_init_msg_list IN VARCHAR2
1097 	p_content_item_id =>	p_content_item_id,	-- p_content_item_id IN NUMBER
1098 	p_xml_clob_loc =>	x_content_item_xml,	-- p_xml_clob_loc IN OUT CLOB
1099 	p_num_levels =>	NULL,-- p_num_levels IN NUMBER
1100 	p_citem_version_id  =>	p_citem_version_id, -- p_citem_version_id IN NUMBER
1101 	p_validate_dates =>	FND_API.G_TRUE,	-- p_validate_dates
1102 	x_num_levels_loaded =>x_num_levels_loaded,
1103 	x_return_status =>x_return_status,
1104 	x_msg_count =>x_msg_count,
1105 	x_msg_data =>x_msg_data
1106       );
1107       -- Content Item is not valid
1108       IF (x_return_status = FND_API.G_RET_STS_ERROR) THEN
1109 	RAISE FND_API.G_EXC_ERROR;
1110       END IF;
1111 
1112       --******************* Real Logic End *********************
1113 
1114       -- Standard call to get message count and if count=1, get the message
1115       FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
1116 					p_data  => x_msg_data);
1117 EXCEPTION
1118    WHEN FND_API.G_EXC_ERROR THEN
1119        x_return_status := FND_API.G_RET_STS_ERROR;
1120        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
1121 					p_data  => x_msg_data);
1122    WHEN FND_API.G_EXC_UNEXPECTED_ERROR THEN
1123        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1124        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
1125 					p_data  => x_msg_data);
1126    WHEN OTHERS THEN
1127        x_return_status := FND_API.G_RET_STS_UNEXP_ERROR;
1128        IF FND_MSG_PUB.Check_Msg_Level ( FND_MSG_PUB.G_MSG_LVL_UNEXP_ERROR)
1129        THEN
1130 	   FND_MSG_PUB.Add_Exc_Msg(G_PKG_NAME, l_api_name);
1131        END IF;
1132        FND_MSG_PUB.Count_And_Get (	p_count => x_msg_count,
1133 					p_data  => x_msg_data);
1134 END Get_Citem_Deep_Xml;
1135 
1136 
1137 END IBC_CITEM_RUNTIME_PUB;