DBA Data[Home] [Help]

PACKAGE BODY: APPS.INV_ATTACHMENTS_UTILS

Source


1 PACKAGE BODY INV_ATTACHMENTS_UTILS  AS
2 /* $Header: INVATCHB.pls 120.3 2010/05/27 22:03:19 sahmahes ship $ */
3 
4 g_pkg_name CONSTANT VARCHAR2(30) := 'INV_ATTACHMENTS_UTILS';
5 
6 PROCEDURE print_debug(p_err_msg VARCHAR2,
7                       p_level 	NUMBER default 4)
8 IS
9     l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
10 BEGIN
11    IF (l_debug = 1) THEN
12       inv_mobile_helper_functions.tracelog
13      (p_err_msg 	=> p_err_msg,
14       p_module 		=> 'INV_ATTACHMENTS_UTILS',
15       p_level 		=> p_level);
16    END IF;
17 
18 
19    /*   dbms_output.put_line(p_err_msg); */
20 END print_debug;
21 
22 /*
23 ** -------------------------------------------------------------------------
24 ** Procedure:   get_item_and_catgy_attachments
25 ** Description:
26 ** Output:
27 **      x_return_status
28 **              return status indicating success, error, unexpected error
29 **      x_msg_count
33 **              message text
30 **              number of messages in message list
31 **      x_msg_data
32 **              if the number of messages in message list is 1, contains
34 **	x_attachments_number
35 **		number of category and item attachments for given item
36 ** 	x_concat_attachment
37 ** 		concatenated string of attachments for given item
38 ** Input:
39 **	p_inventory_item_id
40 **		item whose attachment is required
41 **	p_organization_id
42 **		organization of item whose attachment is required
43 **  	p_document_category
44 **		document category of attached document. this
45 **		maps to a Mobile Applications functionality
46 **		1 - 'To Mobile Receiver'
47 **		2 - 'To Mobile Putaway'
48 ** 		3 - 'To Mobile Picker'
49 **      p_transaction_temp id
50 **              unique identifier of the transaction and is null by default.
51 **
52 ** Returns:
53 **      none
54 ** --------------------------------------------------------------------------
55 */
56 
57 procedure get_item_and_catgy_attachments(
58   x_return_status               OUT NOCOPY VARCHAR2
59 , x_msg_count                   OUT NOCOPY NUMBER
60 , x_msg_data                    OUT NOCOPY VARCHAR2
61 , x_attachments_number          OUT NOCOPY NUMBER
62 , x_concat_attachment           OUT NOCOPY VARCHAR2
63 , p_inventory_item_id           IN         NUMBER
64 , p_organization_id             IN         NUMBER
65 , p_document_category           IN         NUMBER
66 , p_transaction_temp_id         IN         NUMBER default NULL)
67 is
68 
69  l_concat_attachment		varchar2(2000);
70  l_short_text        		varchar2(2000);
71  l_long_text        		varchar2(2000);
72  l_attachments_number           number := 0;
73  l_category_id           	number;
74  l_trx_source_line_id           number;
75 /*Fixed for bug#8347410
76  When query fnd_document_categories_vl use of user_name should not done since it is translated value. Instead of column 'NAME' should be used which will not be translated and
77 unique with language_code
78 */
79 l_To_Mobile_Receiver CONSTANT VARCHAR2(30) := 'CUSTOM1323';
80 l_To_Mobile_Putaway  CONSTANT VARCHAR2(30) := 'CUSTOM1324';
81 l_To_Mobile_Picker   CONSTANT VARCHAR2(30) := 'CUSTOM1325';
82 
83  /* Category - Short Text */
84  cursor category_st_cursor(
85     k_organization_id    NUMBER
86   , k_inventory_item_id  NUMBER
87   , k_document_category  NUMBER)
88  is
89  select f.short_text
90  from fnd_attached_documents     a,
91       fnd_documents              b,
92       fnd_documents_vl           c,
93       fnd_document_categories_vl d,
94       fnd_documents_short_text   f
95  where a.ENTITY_NAME             = 'MTL_CATEGORIES'
96  and   a.PK1_VALUE               in (select distinct e.category_id
97       				     from   mtl_item_categories_v e
98 				     where  e.organization_id   = k_organization_id
99 				     and    e.inventory_item_id = k_inventory_item_id)
100  and   a.DOCUMENT_ID             = b.document_id
101  and   b.datatype_id             = 1 -- short text
102  and   b.category_id             = d.category_id
103 /*Fixed for bug#8347410
104   When query fnd_document_categories_vl use of user_name should not
105   done since it is translated value. Instead of column 'NAME'
106   should be used which will not be translated and
107   unique with language_code
108 */
109  and   d.NAME               = decode(k_document_category,
110                                             1,l_To_Mobile_Receiver,
111                                             2,l_To_Mobile_Putaway,
112                                             3,l_To_Mobile_Picker)
113  --and   d.SOURCE_LANG             = 'US'
114  and   b.document_id             = c.document_id
115  and   f.media_id                = c.media_id;
116 
117  /* Category */
118  cursor category_cursor(
119     k_organization_id    NUMBER
120   , k_inventory_item_id  NUMBER)
121  is
122  select distinct category_id
123  from mtl_item_categories_v
124  where organization_id   = k_organization_id
125  and   inventory_item_id = k_inventory_item_id;
126 
127  /* Category - Long Text */
128  cursor category_lt_cursor(
129     k_document_category  NUMBER
130   , k_category_id        NUMBER)
131  is
132  select f.long_text
133  from fnd_attached_documents    a,
134       fnd_documents             b,
135      fnd_documents_vl           c,
136      fnd_document_categories_vl d,
137      fnd_documents_long_text    f
138  where a.ENTITY_NAME             = 'MTL_CATEGORIES'
139  and   a.PK1_VALUE               = k_category_id
140  and   a.DOCUMENT_ID             = b.document_id
141  and   b.datatype_id             = 2 -- long text
142  and   b.category_id             = d.category_id
143 /*Fixed for bug#8347410
144   When query fnd_document_categories_vl use of user_name should not
145   done since it is translated value. Instead of column 'NAME'
146   should be used which will not be translated and
147   unique with language_code
148 */
149 
150  and   d.NAME               = decode(k_document_category,
151                                             1,l_To_Mobile_Receiver,
152                                             2,l_To_Mobile_Putaway,
153                                             3,l_To_Mobile_Picker)
154  --and   d.SOURCE_LANG             = 'US'
155  and   b.document_id             = c.document_id
156  and   f.media_id                = c.media_id;
157 
158  /* Item Attachment - Short Text */
159  cursor item_st_cursor(
160     k_organization_id    NUMBER
161   , k_inventory_item_id  NUMBER
162   , k_document_category  NUMBER)
163  is
164  select f.short_text
165  from fnd_attached_documents     a,
166       fnd_documents              b,
167       fnd_documents_vl           c,
171  and   a.PK1_VALUE               = k_organization_id
168       fnd_document_categories_vl d,
169       fnd_documents_short_text   f
170  where a.ENTITY_NAME             = 'MTL_SYSTEM_ITEMS'
172  and   a.PK2_VALUE               = k_inventory_item_id
173  and   a.DOCUMENT_ID             = b.document_id
174  and   b.datatype_id             = 1 -- short text
175  and   b.category_id             = d.category_id
176 /*Fixed for bug#8347410
177   When query fnd_document_categories_vl use of user_name should not
178   done since it is translated value. Instead of column 'NAME'
179   should be used which will not be translated and
180   unique with language_code
181 */
182  and   d.NAME               = decode(p_document_category,
183                                           1,l_To_Mobile_Receiver,
184                                           2,l_To_Mobile_Putaway,
185                                           3,l_To_Mobile_Picker)
186  --and   d.SOURCE_LANG             = 'US'
187  and   b.document_id             = c.document_id
188  and   f.media_id                = c.media_id;
189 
190 
191 
192  /* Item Attachment - Long Text */
193  cursor item_lt_cursor(
194     k_organization_id    NUMBER
195   , k_inventory_item_id  NUMBER
196   , k_document_category  NUMBER)
197  is
198  select f.long_text
199  from fnd_attached_documents     a,
200       fnd_documents              b,
201       fnd_documents_vl           c,
202       fnd_document_categories_vl d,
203       fnd_documents_long_text    f
204  where a.ENTITY_NAME             = 'MTL_SYSTEM_ITEMS'
205  and   a.PK1_VALUE               = k_organization_id
206  and   a.PK2_VALUE               = k_inventory_item_id
207  and   a.DOCUMENT_ID             = b.document_id
208  and   b.datatype_id             = 2 -- long text
209  and   b.category_id             = d.category_id
210 /*Fixed for bug#8347410
211   When query fnd_document_categories_vl use of user_name should not
212   done since it is translated value. Instead of column 'NAME'
213   should be used which will not be translated and
214   unique with language_code
215 */
216  and   d.NAME               = decode(p_document_category,
217                                           1,l_To_Mobile_Receiver,
218                                           2,l_To_Mobile_Putaway,
219                                           3,l_To_Mobile_Picker)
220  --and   d.SOURCE_LANG             = 'US'
221  and   b.document_id             = c.document_id
222  and   f.media_id                = c.media_id;
223 
224 
225 /* Transaction Source Line Id cursor */
226 
227  cursor trx_source_line_cursor(k_transaction_temp_id  NUMBER)
228  is
229  select distinct trx_source_line_id
230  from   mtl_material_transactions_temp
231  where  transaction_source_type_id in (2,8,12)
232  and    ( nvl(parent_transaction_temp_id,0) = k_transaction_temp_id
233         or
234           (transaction_temp_id = k_transaction_temp_id
235            and
236            not exists ( select 1
237                         from   mtl_material_transactions_temp
238                         where
239                           nvl(parent_transaction_temp_id,0) = k_transaction_temp_id
240                       )
241           )
242         );
243 
244 /* Sales Order Line Short Text cursor */
245 cursor sales_order_line_st_cursor(
246     k_trx_source_line_id    NUMBER )
247  is
248 select f.short_text
249 from fnd_attached_documents 	a,
250      fnd_documents          	b,
251      fnd_documents_vl       	c,
252      fnd_document_categories_vl	d,
253      fnd_documents_short_text   f
254 where a.ENTITY_NAME 		= 'OE_ORDER_LINES'
255 and   a.PK1_VALUE   		= to_char(k_trx_source_line_id)  --Performance bug#9743038
256 and   a.DOCUMENT_ID 		= b.document_id
257 and   b.datatype_id 		= 1 -- short text
258 and   b.category_id 		= d.category_id
259 /*Fixed for bug#8347410
260   When query fnd_document_categories_vl use of user_name should not
261   done since it is translated value. Instead of column 'NAME'
262   should be used which will not be translated and
263   unique with language_code
264 */
265 and   d.NAME           = l_To_Mobile_Picker
266 --and   d.SOURCE_LANG         = 'US'
267 and   b.document_id 		= c.document_id
268 and   f.media_id 	     	= c.media_id;
269 
270 /* Sales Order Line Long Text cursor */
271 
272 cursor sales_order_line_lt_cursor(
273    k_trx_source_line_id  NUMBER)
274  is
275 select f.long_text
276 from fnd_attached_documents     a,
277      fnd_documents              b,
278      fnd_documents_vl           c,
279      fnd_document_categories_vl d,
280      fnd_documents_long_text   f
281 where a.ENTITY_NAME             = 'OE_ORDER_LINES'
282 and   a.PK1_VALUE               = to_char(k_trx_source_line_id)    --Performance bug#9743038
283 and   a.DOCUMENT_ID             = b.document_id
284 and   b.datatype_id             = 2 -- long text
285 and   b.category_id             = d.category_id
286 /*Fixed for bug#8347410
287   When query fnd_document_categories_vl use of user_name should not
288   done since it is translated value. Instead of column 'NAME'
289   should be used which will not be translated and
290   unique with language_code
291 */
292 and   d.NAME               = l_To_Mobile_Picker
293 --and   d.SOURCE_LANG             = 'US'
294 and   b.document_id             = c.document_id
295 and   f.media_id                = c.media_id;
296 
297 
298     l_debug number := NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
299 begin
300   	x_return_status := fnd_api.g_ret_sts_success;
301 
302 	IF (l_debug = 1) THEN
303    	print_debug('Item ID : ' || p_inventory_item_id, 1);
304    	print_debug('Org ID : ' || to_char(p_organization_id), 1);
308   	-- Open Category Attachments Short Text cursor
305    	print_debug('Document Category: ' || to_char(p_document_category), 1);
306 	END IF;
307 
309         open category_st_cursor(
310           p_organization_id
311         , p_inventory_item_id
312         , p_document_category);
313 
314 	IF (l_debug = 1) THEN
315    	print_debug('category_st_cursor open', 1);
316 	END IF;
317 
318 	while(1 > 0)
319         loop
320                 fetch category_st_cursor into
321                   l_short_text;
322 
323                 if category_st_cursor%notfound then
324 			IF (l_debug = 1) THEN
325    			print_debug('Count attach: ' || to_char(l_attachments_number), 1);
326 			END IF;
327                         exit;
328                 end if;
329 
330  		l_attachments_number := l_attachments_number + 1;
331 
332                 l_concat_attachment := l_concat_attachment || l_short_text;
333 
334 		IF (l_debug = 1) THEN
335    		print_debug('Count attach: ' || to_char(l_attachments_number), 1 );
336    		print_debug('Text : ' || l_short_text, 1);
337    		print_debug('Total Text : ' || l_concat_attachment, 1);
338 		END IF;
339         end loop;
340 
341         /*
342 	** Not very elegant, BUT....
343 	** To get unique category_ids for an item,
344         ** Adding category to category_lt_cursor like category_st_cursor
345 	** doesn't work. It gives invalid operation of long datatype
346 	** Hence adopting this method where we will have 2 cursors -
347 	** category cursor and category_lt_cursor
348 	*/
349 
350   	-- Open Category cursor
351         open category_cursor(
352           p_organization_id
353         , p_inventory_item_id);
354 
355 	IF (l_debug = 1) THEN
356    	print_debug('category_cursor open', 1);
357 	END IF;
358 
359 	while(1 > 0)
360         loop
361                 fetch category_cursor into
362                   l_category_id;
363 
364                 if category_cursor%notfound then
365 			IF (l_debug = 1) THEN
366    			print_debug('Count attach: ' || to_char(l_attachments_number), 1);
367 			END IF;
368                         exit;
369                 end if;
370 
371   		-- Open Category Attachments Long Text cursor
372         	open category_lt_cursor(
373         	  p_document_category
374         	, l_category_id);
375 
376 		while(1 > 0)
377         	loop
378                 	fetch category_lt_cursor into
379                   		l_long_text;
380 
381                 	if category_lt_cursor%notfound then
382 				IF (l_debug = 1) THEN
383    				print_debug('Count attach: ' || to_char(l_attachments_number), 1);
384 				END IF;
385                         	exit;
386                 	end if;
387 
388  			l_attachments_number := l_attachments_number + 1;
389 
390                 	l_concat_attachment := l_concat_attachment || l_long_text;
391 
392                  	IF (l_debug = 1) THEN
393                     	print_debug('Count attach: ' || to_char(l_attachments_number), 1);
394                     	print_debug('Text : ' || l_long_text, 1);
395                    	print_debug('Total Text : ' || l_concat_attachment, 1);
396                  	END IF;
397         	end loop;
398 
399       		IF (category_lt_cursor%isopen) THEN
400         		close category_lt_cursor;
401       		END IF;
402         end loop;
403 
404   	-- Open Item Attachments Short Text cursor
405         open item_st_cursor(
406           p_organization_id
407         , p_inventory_item_id
408         , p_document_category);
409 
410 	IF (l_debug = 1) THEN
411    	print_debug('item_st_cursor open', 1);
412 	END IF;
413 
414 	while(1 > 0)
415         loop
416                 fetch item_st_cursor into
417                   l_short_text;
418 
419                 if item_st_cursor%notfound then
420 			IF (l_debug = 1) THEN
421    			print_debug('Count attach: ' || to_char(l_attachments_number), 1);
422 			END IF;
423                         exit;
424                 end if;
425 
426  		l_attachments_number := l_attachments_number + 1;
427 
428                 l_concat_attachment := l_concat_attachment || l_short_text;
429 
430                 IF (l_debug = 1) THEN
431                    print_debug('Count attach: ' || to_char(l_attachments_number), 1);
432                    print_debug('Text : ' || l_short_text, 1);
433                    print_debug('Total Text : ' || l_concat_attachment, 1);
434                 END IF;
435 
436         end loop;
437 
438   	-- Open Item Attachments Long Text cursor
439         open item_lt_cursor(
440           p_organization_id
441         , p_inventory_item_id
442         , p_document_category);
443 
444 	IF (l_debug = 1) THEN
445    	print_debug('item_lt_cursor open', 1);
446 	END IF;
447 
448 	while(1 > 0)
449         loop
450                 fetch item_lt_cursor into
451                   l_long_text;
452 
453                 if item_lt_cursor%notfound then
454 			IF (l_debug = 1) THEN
455    			print_debug('Count attach: ' || to_char(l_attachments_number), 1);
456 			END IF;
457                         exit;
458                 end if;
459 
460  		l_attachments_number := l_attachments_number + 1;
461 
462                 l_concat_attachment := l_concat_attachment || l_long_text;
463                 IF (l_debug = 1) THEN
464                    print_debug('Count attach: ' || to_char(l_attachments_number), 1);
465                    print_debug('Text : ' || l_long_text, 1);
466                    print_debug('Total Text : ' || l_concat_attachment, 1);
470 
467                 END IF;
468 
469         end loop;
471 
472     -- sales order Line Attachment begins
473 
474     if ( p_transaction_temp_id is not null and p_transaction_temp_id > 0) then
475 
476       -- Open Transaction source line id cursor
477           open trx_source_line_cursor(p_transaction_temp_id);
478 
479 	  IF (l_debug = 1) THEN
480    	  print_debug('Transaction source line id cursor open', 1);
481 	  END IF;
482 
483 	while(1 > 0)
484         loop
485                 fetch trx_source_line_cursor into l_trx_source_line_id;
486 
487                 if trx_source_line_cursor%notfound then
488                   IF (l_debug = 1) THEN
489                      print_debug('Count attach: ' || to_char(l_attachments_number), 1);
490                   END IF;
491                   exit;
492                  end if;
493 
494   		-- Open Sales Order Line Short Text cursor
495         	open sales_order_line_st_cursor(l_trx_source_line_id);
496 
497 		while(1 > 0)
498         	loop
499                 	fetch sales_order_line_st_cursor into l_short_text;
500 
501                 	if sales_order_line_st_cursor%notfound then
502                            IF (l_debug = 1) THEN
503                               print_debug('Count attach: ' ||to_char(l_attachments_number), 1);
504                            END IF;
505                            exit;
506                 	end if;
507 
508  			l_attachments_number := l_attachments_number + 1;
509 
510                 	l_concat_attachment := l_concat_attachment || l_short_text;
511 
512                  	IF (l_debug = 1) THEN
513                     	print_debug('Count attach: ' || to_char(l_attachments_number), 1);
514                     	print_debug('Text : ' || l_short_text, 1);
515                    	print_debug('Total Text : ' || l_concat_attachment, 1);
516                  	END IF;
517         	end loop;
518 
519       		IF (sales_order_line_st_cursor%isopen) THEN
520         		close sales_order_line_st_cursor;
521       		END IF;
522 
523   		-- Open Sales Order Line Long Text cursor
524         	open sales_order_line_lt_cursor(
525         	  l_trx_source_line_id);
526 
527 		while(1 > 0)
528         	loop
529                 	fetch sales_order_line_lt_cursor into  l_long_text;
530 
531                 	if sales_order_line_lt_cursor%notfound then
532 		           IF (l_debug = 1) THEN
533    		           print_debug('Count attach: ' || to_char(l_attachments_number),1);
534 		           END IF;
535                            exit;
536                 	end if;
537 
538  			l_attachments_number := l_attachments_number + 1;
539 
540                 	l_concat_attachment := l_concat_attachment || l_long_text;
541                         IF (l_debug = 1) THEN
542                            print_debug('Count attach: ' || to_char(l_attachments_number), 1);
543                     	print_debug('Text : ' || l_long_text, 1);
544                    	print_debug('Total Text : ' || l_concat_attachment, 1);
545                         END IF;
546         	end loop;
547 
548       		IF (sales_order_line_lt_cursor%isopen) THEN
549         		close sales_order_line_lt_cursor;
550       		END IF;
551 
552         end loop;
553 
554     end if;
555 
556     if (l_attachments_number > 0) then
557 		x_concat_attachment  := l_concat_attachment;
558                 x_attachments_number := l_attachments_number;
559 	else
560 		x_concat_attachment  := NULL;
561                 x_attachments_number := 0;
562 	end if;
563 
564         IF (l_debug = 1) THEN
565            print_debug('Count attach: ' || to_char(l_attachments_number), 1);
566            print_debug('Total Text : ' || l_concat_attachment, 1);
567         END IF;
568 
569        	IF (category_st_cursor%isopen) THEN
570         	CLOSE category_st_cursor;
571       	END IF;
572 
573       	IF (category_cursor%isopen) THEN
574         	close category_cursor;
575       	END IF;
576 
577       	IF (category_lt_cursor%isopen) THEN
578         	CLOSE category_lt_cursor;
579       	END IF;
580 
581       	IF (item_st_cursor%isopen) THEN
582         	CLOSE item_st_cursor;
583       	END IF;
584 
585         IF (trx_source_line_cursor%isopen) THEN
586       		close trx_source_line_cursor;
587       	END IF;
588 
589         IF (sales_order_line_st_cursor%isopen) THEN
590       		close sales_order_line_st_cursor;
591         END IF;
592 
593       	IF (sales_order_line_lt_cursor%isopen) THEN
594       		close sales_order_line_lt_cursor;
595       	END IF;
596 
597 
598 exception
599    when fnd_api.g_exc_error THEN
600       x_return_status      := fnd_api.g_ret_sts_error;
601       x_concat_attachment  := NULL;
602       x_attachments_number := 0;
603 
604       IF (l_debug = 1) THEN
605          print_debug('g_ret_sts_error', 1);
606       END IF;
607 
608       --  Get message count and data
609       fnd_msg_pub.count_and_get
610           (  p_count  => x_msg_count
611            , p_data   => x_msg_data
612             );
613 
614       IF (category_st_cursor%isopen) THEN
615         CLOSE category_st_cursor;
616       END IF;
617 
618       IF (category_cursor%isopen) THEN
619     	close category_cursor;
620       END IF;
621 
622       IF (category_lt_cursor%isopen) THEN
623         CLOSE category_lt_cursor;
624       END IF;
625 
626       IF (item_st_cursor%isopen) THEN
627         CLOSE item_st_cursor;
628       END IF;
629 
630       IF (item_lt_cursor%isopen) THEN
631         CLOSE item_lt_cursor;
632       END IF;
633 
634       IF (trx_source_line_cursor%isopen) THEN
635       	close trx_source_line_cursor;
636       END IF;
637 
638       IF (sales_order_line_st_cursor%isopen) THEN
639         close sales_order_line_st_cursor;
640       END IF;
641 
642       IF (sales_order_line_lt_cursor%isopen) THEN
643         close sales_order_line_lt_cursor;
644       END IF;
645 
646 
647    when fnd_api.g_exc_unexpected_error THEN
648       x_return_status      := fnd_api.g_ret_sts_unexp_error ;
649       x_concat_attachment  := NULL;
650       x_attachments_number := 0;
651 
652       IF (l_debug = 1) THEN
653          print_debug('g_ret_sts_unexp_error', 1);
654       END IF;
655 
656       --  Get message count and data
657       fnd_msg_pub.count_and_get
658           (  p_count  => x_msg_count
659            , p_data   => x_msg_data
660             );
661 
662       IF (category_st_cursor%isopen) THEN
663         CLOSE category_st_cursor;
664       END IF;
665 
666       IF (category_cursor%isopen) THEN
667     	close category_cursor;
668       END IF;
669 
670       IF (category_lt_cursor%isopen) THEN
671         CLOSE category_lt_cursor;
672       END IF;
673 
674       IF (item_st_cursor%isopen) THEN
675         CLOSE item_st_cursor;
676       END IF;
677 
678       IF (item_lt_cursor%isopen) THEN
679         CLOSE item_lt_cursor;
680       END IF;
681 
682       IF (trx_source_line_cursor%isopen) THEN
683       	close trx_source_line_cursor;
684       END IF;
685 
686       IF (sales_order_line_st_cursor%isopen) THEN
687         close sales_order_line_st_cursor;
688       END IF;
689 
690       IF (sales_order_line_lt_cursor%isopen) THEN
691         close sales_order_line_lt_cursor;
692       END IF;
693 
694 
695     when others THEN
696 
697       x_return_status 	   := fnd_api.g_ret_sts_unexp_error ;
698       x_concat_attachment  := NULL;
699       x_attachments_number := 0;
700       --
701       IF (l_debug = 1) THEN
702          print_debug('others', 1);
703       END IF;
704 
705       IF fnd_msg_pub.check_msg_level(fnd_msg_pub.g_msg_lvl_unexp_error)
706       THEN
707          fnd_msg_pub.add_exc_msg
708            (  g_pkg_name
709               , 'get_item_and_catgy_attachments'
710               );
711       END IF;
712 
713       --  Get message count and data
714       fnd_msg_pub.count_and_get
715           (  p_count  => x_msg_count
716            , p_data   => x_msg_data
717             );
718 
719       IF (category_st_cursor%isopen) THEN
720         CLOSE category_st_cursor;
721       END IF;
722 
723       IF (category_cursor%isopen) THEN
724 	    close category_cursor;
725       END IF;
726 
727       IF (category_lt_cursor%isopen) THEN
728         CLOSE category_lt_cursor;
729       END IF;
730 
731       IF (item_st_cursor%isopen) THEN
732         CLOSE item_st_cursor;
733       END IF;
734 
735       IF (item_lt_cursor%isopen) THEN
736         CLOSE item_lt_cursor;
737       END IF;
738 
739       IF (trx_source_line_cursor%isopen) THEN
740       	close trx_source_line_cursor;
741       END IF;
742 
743 
744       IF (sales_order_line_st_cursor%isopen) THEN
745        	close sales_order_line_st_cursor;
746       END IF;
747 
748       IF (sales_order_line_lt_cursor%isopen) THEN
749        	close sales_order_line_lt_cursor;
750       END IF;
751 
752 
753 end get_item_and_catgy_attachments;
754 
755 end inv_attachments_utils;