DBA Data[Home] [Help]

PACKAGE BODY: APPS.BIS_SAVE_REPORT

Source


1 package body bis_save_report AS
2 /* $Header: BISSAVEB.pls 120.0 2005/06/01 14:43:24 appldev noship $ */
3 -- dbdrv: sql ~PROD ~PATH ~FILE none none none package &phase=plb \
4 -- dbdrv: checkfile(115.12=120.0):~PROD:~PATH:~FILE
5 ----------------------------------------------------------------------------
6 --  PACKAGE:      bis_save_report                                         --
7 --                                                                        --
8 --  DESCRIPTION:  use this package to save and retrieve html output       --
9 --                from fnd_lobs                                           --
10 --                                                                        --
11 --  MODIFICATIONS                                                         --
12 --  Date       User       Modification                                    --
13 --  04/10/2001 aleung     Initial creation                                --
14 --  01/19/2004 nkishore   Save Report to PDF                              --
15 ----------------------------------------------------------------------------
16 
17 /* New Package for saving and retrieving reports */
18 
19 function createEntry (file_name    varchar2 default null,
20                       content_type varchar2 default 'text/plain',
21                       program_name varchar2 default null,
22                       program_tag  varchar2 default null) return number is
23 --pragma autonomous_transaction;
24 
25   file_id number;
26   file_handler_id integer;
27 
28 begin
29      file_handler_id := fnd_gfm.file_create(file_name, content_type, program_name, program_tag);
30      file_id := fnd_gfm.file_close(file_handler_id);
31      return file_id;
32 end createEntry;
33 
34 procedure initWrite (file_id number, buffer varchar2) is
35 --pragma autonomous_transaction;
36 begin
37  if lengthb(buffer) > 0 then
38   initWrite(file_id, lengthb(buffer), utl_raw.cast_to_raw(buffer));
39  end if;
40 end initWrite;
41 
42 procedure initWrite (file_id number, amount binary_integer, buffer raw) is
43 --pragma autonomous_transaction;
44   loc blob;
45   loc_tmp blob;
46   --ocs varchar2(30);
47   offset integer := 1;
48   length number;
49 begin
50 
51   select file_data
52   into   loc
53   from   fnd_lobs
54   where  file_id = initWrite.file_id
55   for update of file_data;
56 
57   length := dbms_lob.getLength(loc);
58   if length > 0 then
59     dbms_lob.trim(loc, offset);
60   end if;
61   --dbms_lob.write(loc, amount, offset, convert(buffer,ocs));
62   dbms_lob.write(loc, amount, offset, buffer);
63   commit;
64 end initWrite;
65 
66 procedure appendWrite (file_id number, buffer varchar2) is
67 --pragma autonomous_transaction;
68 begin
69  if lengthb(buffer) > 0 then
70   appendWrite(file_id, lengthb(buffer), utl_raw.cast_to_raw(buffer));
71  end if;
72 end appendWrite;
73 
74 procedure appendWrite (file_id number, amount binary_integer, buffer raw) is
75 --pragma autonomous_transaction;
76   loc blob;
77   --ocs varchar2(30);
78 begin
79   select file_data
80   into   loc
81   from   fnd_lobs
82   where  file_id = appendWrite.file_id
83   for update of file_data;
84 
85   --dbms_lob.writeappend(loc, amount, convert(buffer,ocs));
86  -- Fix for bug 3336412
87  if lengthb(buffer) > 0 then
88   dbms_lob.writeappend(loc, amount, buffer);
89   commit;
90  end if ;
91 end appendWrite;
92 
93 procedure appendLineBreak (file_id number) is
94 begin
95   appendWrite(file_id, 2, hextoraw('0D0A'));
96 end appendLineBreak;
97 
98 procedure appendWriteLine (file_id number, buffer varchar2) is
99 --pragma autonomous_transaction;
100 begin
101  if lengthb(buffer) > 0 then
102   appendWriteLine(file_id, lengthb(buffer), utl_raw.cast_to_raw(buffer));
103  end if;
104 end appendWriteLine;
105 
106 procedure appendWriteLine (file_id number, amount binary_integer, buffer raw) is
107 --pragma autonomous_transaction;
108 begin
109   appendWrite(file_id, amount, buffer);
110   appendLineBreak(file_id);
111 end appendWriteLine;
112 
113 procedure retrieve (file_id number) is
114 --pragma autonomous_transaction;
115 begin
116     if not icx_sec.ValidateSession then
117       return;
118     end if;
119   fnd_gfm.download_blob(file_id);
120 end retrieve;
121 
122 procedure retrieve_for_php(file_id varchar2) is
123  l_file_id varchar2(100);
124 begin
125   /*gsanap 04/16/04 - Bug Fix 3568859 retrieve_for_php to remove mod_plsql*/
126   l_file_id := icx_call.decrypt(file_id);
127   fnd_gfm.download_blob(l_file_id);
128 end retrieve_for_php;
129 
130 function returnURL(file_id in number) return varchar2 is
131    l_url varchar2(1000);
132    --fid number;
133 begin
134    --fid := icx_call.encrypt2(file_id);
135    l_url := fnd_Web_config.trail_slash(fnd_web_Config.gfm_Agent);
136    l_url := replace(l_url,'HTTPS://', 'HTTP://');
137    l_url := replace(l_url,'https://', 'http://');
138    l_url := replace(l_url,'Https://', 'Http://');
139    l_url := l_url|| 'bis_save_report.retrieve_for_php?file_id='||file_id;
140    return l_url;
141 end returnURL;
142 
143 -- mdamle 07/15/2002 - Set the Expiration date for live portlet graph file at creation time
144 -- itself since we don't keep track of it in our tables.
145 procedure setExpirationDate(
146          p_file_id  in varchar2
147 ) IS
148 BEGIN
149        -- Expire after n days.
150        IF (p_file_id IS NOT NULL) THEN
151             update fnd_lobs
152             SET expiration_date = SYSDATE + 90
153             WHERE file_id = p_file_id;
154 
155             COMMIT;
156        END IF;
157 END setExpirationDate;
158 
159 --Save Report to PDF
160 procedure retrieve_for_pdf(p_file_id  in varchar2) is
161  l_file_id varchar2(100);
162 begin
163   l_file_id := icx_call.decrypt(p_file_id);
164   fnd_gfm.download_blob(l_file_id);
165 end retrieve_for_pdf;
166 
167 end bis_save_report;