DBA Data[Home] [Help]

PACKAGE BODY: APPS.ARP_UPGRADE_COMMON_UTIL

Source


1 PACKAGE BODY ARP_UPGRADE_COMMON_UTIL AS
2 /* $Header: ARUPGCOB.pls 115.5 2002/12/18 18:47:40 snambiar ship $*/
3 --
4 
5 /*-------------------------------------------------------------------------+
6  |                                                                         |
7  | PRIVATE VARIABLES                                                       |
8  |                                                                         |
9  +-------------------------------------------------------------------------*/
10 pg_file_name    VARCHAR2(100) := NULL;
11 pg_path_name    VARCHAR2(100) := NULL;
12 pg_fp           utl_file.file_type;
13 
14 debug_flag boolean := false;
15 
16 /*===========================================================================+
17  | PROCEDURE                                                                 |
18  |    insert_p                                                               |
19  |                                                                           |
20  | DESCRIPTION                                                               |
21  |    Inserts a record into AR_DISTRIBUTIONS_ALL table, inserts org_id       |
22  |    column for Multi Org.                                                  |
23  |                                                                           |
24  | SCOPE - PUBLIC                                                            |
25  |                                                                           |
26  | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED                                    |
27  |                                                                           |
28  | ARGUMENTS                                                                 |
29  |    IN:                                                                    |
30  |    p_dist_rec        - Distribution record to be inserted                 |
31  |                                                                           |
32  |    OUT:                                                                   |
33  |    p_line_id         - Line Id of the distribution created                |
34  |                                                                           |
35  | RETURNS                                                                   |
36  |                                                                           |
37  | NOTES                                                                     |
38  |                                                                           |
39  | MODIFICATION HISTORY                                                      |
40  |                                                                           |
41  |    07-DEC-98 VAHLUWAL        Created for Release 11.5 upgrade             |
42  |                                                                           |
43  +===========================================================================*/
44 PROCEDURE insert_p( p_dist_rec 	IN ar_distributions_all%ROWTYPE,
45 	            p_line_id	OUT NOCOPY ar_distributions_all.line_id%TYPE ) IS
46 
47 l_line_id	ar_distributions_all.line_id%TYPE;
48 
49 BEGIN
50       --
51       SELECT ar_distributions_s.nextval
52       INTO   l_line_id
53       FROM   dual;
54       --
55 
56       INSERT INTO  ar_distributions_all (
57 		   line_id,
58 		   source_id,
59  		   source_table,
60  		   source_type,
61  		   code_combination_id,
62  		   amount_dr,
63  		   amount_cr,
64  		   acctd_amount_dr,
65  		   acctd_amount_cr,
66  		   created_by,
67  		   creation_date,
68  		   last_updated_by,
69  		   last_update_date,
70                    last_update_login,
71                    source_id_secondary,
72                    source_table_secondary,
73                    currency_code        ,
74                    currency_conversion_rate,
75                    currency_conversion_type,
76                    currency_conversion_date,
77                    third_party_id,
78                    third_party_sub_id,
79                    tax_code_id,
80                    location_segment_id,
81                    reversed_source_id,
82                    taxable_entered_dr,
83                    taxable_entered_cr,
84                    taxable_accounted_dr,
85                    taxable_accounted_cr,
86                    tax_link_id,
87                    org_id
88  		 )
89        VALUES (    l_line_id,
90                    p_dist_rec.source_id,
91                    p_dist_rec.source_table,
92                    p_dist_rec.source_type,
93                    p_dist_rec.code_combination_id,
94                    p_dist_rec.amount_dr,
95                    p_dist_rec.amount_cr,
96                    p_dist_rec.acctd_amount_dr,
97                    p_dist_rec.acctd_amount_cr,
98 		   -2001,                       --identifies that AR Upgrade created the data
99  		   SYSDATE,
100 		   -2001,
101  		   SYSDATE,
102 		   -2001,
103                    p_dist_rec.source_id_secondary,
104                    p_dist_rec.source_table_secondary,
105                    p_dist_rec.currency_code        ,
106                    p_dist_rec.currency_conversion_rate,
107                    p_dist_rec.currency_conversion_type,
108                    p_dist_rec.currency_conversion_date,
109                    p_dist_rec.third_party_id,
110                    p_dist_rec.third_party_sub_id,
111                    p_dist_rec.tax_code_id,
112                    p_dist_rec.location_segment_id,
113                    p_dist_rec.reversed_source_id,
114                    p_dist_rec.taxable_entered_dr,
115                    p_dist_rec.taxable_entered_cr,
116                    p_dist_rec.taxable_accounted_dr,
117                    p_dist_rec.taxable_accounted_cr,
118                    p_dist_rec.tax_link_id,
119                    p_dist_rec.org_id
120 	       );
121 
122     p_line_id := l_line_id;
123 
124     EXCEPTION
125 	WHEN OTHERS THEN
126 	    debug( 'EXCEPTION: ARP_UPGRADE_COMMON_UTIL.insert_p' );
127 	    RAISE;
128 
129 END insert_p;
130 
131 /*===========================================================================+
132  | PROCEDURE                                                                 |
133  |    file_debug                                                             |
134  |                                                                           |
135  | DESCRIPTION                                                               |
136  |    Actual procedure which writes message using file handler.              |
137  |                                                                           |
138  | SCOPE - PRIVATE                                                           |
139  |                                                                           |
140  | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED                                    |
141  |                                                                           |
142  | ARGUMENTS                                                                 |
143  |    IN:                                                                    |
144  |    p_line            - Message to be written to file                      |
145  |                                                                           |
146  |    OUT:                                                                   |
147  |                                                                           |
148  | RETURNS                                                                   |
149  |                                                                           |
150  | NOTES                                                                     |
151  |                                                                           |
152  | MODIFICATION HISTORY                                                      |
153  |                                                                           |
154  |    07-DEC-98 VAHLUWAL        Created for Release 11.5 upgrade             |
155  |                                                                           |
156  +===========================================================================*/
157 PROCEDURE file_debug(p_line in varchar2) IS
158 x number;
159 
160 BEGIN
161 
162   IF (pg_file_name IS NOT NULL) THEN
163 
164     utl_file.put_line(pg_fp, p_line);
165     utl_file.fflush(pg_fp);
166 
167   END IF;
168 
169 EXCEPTION  --we only write using the io file so theres not much that can be done other than exception
170    WHEN OTHERS THEN
171         RAISE;
172 
173 END file_debug;
174 
175 /*===========================================================================+
176  | PROCEDURE                                                                 |
177  |    enable_file_debug                                                      |
178  |                                                                           |
179  | DESCRIPTION                                                               |
180  |    Opens file to which debug messages are written.                        |
181  |                                                                           |
182  | SCOPE - PRIVATE                                                           |
183  |                                                                           |
184  | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED                                    |
185  |                                                                           |
186  | ARGUMENTS                                                                 |
187  |    IN:                                                                    |
188  |    p_path_name       - Path in which file will be created                 |
189  |    p_file_name       - File name to which messages are written            |
190  |                                                                           |
191  |    OUT:                                                                   |
192  |                                                                           |
193  | RETURNS                                                                   |
194  |                                                                           |
195  | NOTES                                                                     |
196  |                                                                           |
197  | MODIFICATION HISTORY                                                      |
198  |                                                                           |
199  |    07-DEC-98 VAHLUWAL        Created for Release 11.5 upgrade             |
200  |                                                                           |
201  +===========================================================================*/
202 PROCEDURE enable_file_debug(p_path_name in varchar2,
203                             p_file_name in varchar2) IS
204 x number;
205 BEGIN
206 
207   IF (pg_file_name is null) THEN
208 
209     pg_fp := utl_file.fopen(p_path_name, p_file_name, 'w');
210     pg_file_name := p_file_name;
211     pg_path_name := p_path_name;
212 
213   END IF;
214 
215 EXCEPTION  -- always raise exception as cannot write to file
216      WHEN OTHERS THEN
217         RAISE;
218 END;
219 
220 PROCEDURE disable_file_debug IS
221 BEGIN
222 
223   IF (pg_file_name IS NOT NULL) THEN
224     utl_file.fclose(pg_fp);
225   END IF;
226 
227 EXCEPTION  -- always raise exception as cannot write to file
228      WHEN OTHERS THEN
229         RAISE;
230 END;
231 
232 /*===========================================================================+
233  | PROCEDURE                                                                 |
234  |    debug                                                                  |
235  |                                                                           |
236  | DESCRIPTION                                                               |
237  |    Function which writes specific message to a file                       |
238  |                                                                           |
239  | SCOPE - PRIVATE                                                           |
240  |                                                                           |
241  | EXTERNAL PROCEDURES/FUNCTIONS ACCESSED                                    |
242  |                                                                           |
243  | ARGUMENTS                                                                 |
244  |    IN:                                                                    |
245  |    p_line            - Message string                                     |
246  |                                                                           |
247  |    OUT:                                                                   |
248  |                                                                           |
249  | RETURNS                                                                   |
250  |                                                                           |
251  | NOTES                                                                     |
252  |                                                                           |
253  | MODIFICATION HISTORY                                                      |
254  |                                                                           |
255  |    07-DEC-98 VAHLUWAL        Created for Release 11.5 upgrade             |
256  |                                                                           |
257  +===========================================================================*/
258 PROCEDURE debug(p_line in varchar2) IS
259 
260 l_rest VARCHAR2(32767);
261 
262 BEGIN
263 
264     IF (pg_file_name IS NOT NULL) THEN
265       file_debug(p_line);
266     ELSE
267       if debug_flag then
268         l_rest := p_line;
269         loop
270             if( l_rest is null ) then
271                 exit;
272             else
273                 l_rest := substrb(l_rest, 256);
274             end if;
275 
276         end loop;
277       end if;
278     END IF;
279 
280 EXCEPTION
281   WHEN OTHERS THEN
282       RAISE;
283 END;
284 
285 procedure enable_debug is
286 begin
287    debug_flag := true;
288 end;
289 
290 procedure enable_debug( buffer_size NUMBER ) is
291 begin
292    debug_flag := true;
293 end;
294 
295 procedure disable_debug is
296 begin
297    debug_flag := false;
298 end;
299 
300 --
301 END ARP_UPGRADE_COMMON_UTIL;