DBA Data[Home] [Help]

PACKAGE BODY: APPS.IGIRRGPP

Source


1 Package Body      IGIRRGPP AS
2 -- $Header: igirrgpb.pls 120.6.12000000.1 2007/08/31 05:53:13 mbremkum ship $
3 
4   l_debug_level number:=FND_LOG.G_CURRENT_RUNTIME_LEVEL;
5 
6   l_state_level number:=FND_LOG.LEVEL_STATEMENT;
7   l_proc_level number:=FND_LOG.LEVEL_PROCEDURE;
8   l_event_level number:=FND_LOG.LEVEL_EVENT;
9   l_excep_level number:=FND_LOG.LEVEL_EXCEPTION;
10   l_error_level number:=FND_LOG.LEVEL_ERROR;
11   l_unexp_level number:=FND_LOG.LEVEL_UNEXPECTED;
12 
13 --Commenting out WriteToLogFile as fnd_logging to be used bug 3199481 (Start)
14 /*
15 PROCEDURE WriteToLogFile(pp_mesg in varchar2) IS
16  IsDebugMode BOOLEAN := TRUE;
17 BEGIN
18 	IF IsDebugMode THEN
19 		fnd_file.put_line(FND_FILE.LOG,pp_mesg);
20 	ELSE
21 		null;
22 	END IF;
23 END WriteToLogFile;
24 */
25 --Commenting out WriteToLogFile as fnd_logging to be used bug 3199481 (End)
26 
27 PROCEDURE CreateLines ( pp_run_id                 in number
28                       , pp_item_code_from         in varchar2
29                       , pp_item_code_to           in varchar2
30                       , pp_amount                 in number
31                       , pp_percentage_amount      in number
32                       , pp_incr_decr_flag         in varchar2
33                       , pp_update_effective_date  in date
34                       , pp_creation_date          in date
35                       , pp_created_by             in number
36                       , pp_last_update_date       in date
37                       , pp_last_updated_by        in number
38                       , pp_last_update_login      in number
39                       , pp_option_flag            in varchar2
40                       )
41                      IS
42 
43       CURSOR c_rpi_charge_lines_d Is
44       SELECT pp_run_id 			run_id,
45              standing_charge_id,
46              line_item_id,
47              item_id,
48              price,
49 	     org_id,			/*MOAC Impact*/
50              current_effective_date 	effective_date,
51              pp_amount            	change_amount,
52              pp_percentage_amount 	change_percent,
53              pp_incr_decr_flag    	incr_decr_flag,
54              pp_update_effective_date 	update_effective_date,
55              revised_price,
56              revised_effective_date,
57              null 			updated_price,
58              null 			select_flag,
59              pp_creation_date       	creation_date,
60              pp_created_by          	created_by,
61              pp_last_update_date    	last_update_date,
62              pp_last_updated_by     	last_updated_by,
63              pp_last_update_login   	last_update_login
64       FROM   igi_rpi_line_details lines
65       WHERE  exists ( select item_id
66                           from   igi_rpi_items items
67                           where  item_code >= pp_item_code_from
68                           AND    item_code <= pp_item_code_to
69                           AND    items.item_id = lines.item_id
70                         )
71       AND    exists
72              ( select 'x'
73                from   igi_rpi_standing_charges charges
74                where  lines.standing_charge_id = charges.standing_charge_id
75                and    set_of_books_id = ( select set_of_books_id from ar_system_parameters )
76              )
77       AND    exists
78              ( select  'x'
79                from    igi_rpi_items items
80                where   decode(sign(trunc(nvl(lines.revised_effective_date, (pp_update_effective_date + 1)))
81                        - trunc(pp_update_effective_date)),1, lines.price, lines.revised_price)
82                        = decode(sign(trunc(nvl(items.revised_price_eff_date, (pp_update_effective_date + 1)))
83                          - trunc(pp_update_effective_date)),1, items.price, items.revised_price)
84              );
85 
86       CURSOR c_rpi_charge_lines_a Is
87       SELECT pp_run_id                  run_id,
88              standing_charge_id,
89              line_item_id,
90              item_id,
91              price,
92     	     org_id,			/*MOAC Impact*/
93              current_effective_date 	effective_date,
94              pp_amount            	change_amount,
95              pp_percentage_amount 	change_percent,
96 	     pp_incr_decr_flag  	incr_decr_flag,
97 	     pp_update_effective_date 	update_effective_date,
98              revised_price,
99              revised_effective_date,
100              null 			updated_price,
101              null 			select_flag,
102              pp_creation_date       	creation_date,
103              pp_created_by          	created_by,
104              pp_last_update_date    	last_update_date,
105              pp_last_updated_by     	last_updated_by,
106              pp_last_update_login   	last_update_login
107       FROM   igi_rpi_line_details lines
108       WHERE  exists ( select item_id
109                           from   igi_rpi_items items
110                           where  item_code >= pp_item_code_from
111                           AND    item_code <= pp_item_code_to
112                           AND    items.item_id = lines.item_id
113                         )
114       AND    exists
115              ( select 'x'
116                from   igi_rpi_standing_charges charges
117                where  lines.standing_charge_id = charges.standing_charge_id
118                and    set_of_books_id = ( select set_of_books_id from ar_system_parameters )
119              )
120       ;
121 
122    CURSOR c_rpi_items Is
123       SELECT pp_run_id 			run_id,
124              item_code,
125              item_id,
126              price,
127              org_id,			/*Added for MOAC Impact*/
128              price_effective_date 	effective_date,
129              pp_amount  		change_amount,
130              pp_percentage_amount 	change_percent,
131              pp_incr_decr_flag    	incr_decr_flag,
132              pp_update_effective_date   update_effective_date,
133              revised_price,
134              revised_price_eff_date 	revised_effective_date,
135              null 			updated_price,
136              null 			select_flag,
137              pp_creation_date       	creation_date,
138              pp_created_by          	created_by,
139              pp_last_update_date    	last_update_date,
140              pp_last_updated_by     	last_updated_by,
141              pp_last_update_login   	last_update_login
142       FROM   igi_rpi_items
143       where  item_code >= pp_item_code_from
144       AND    item_code <= pp_item_code_to
145       AND    set_of_books_id =
146             ( select set_of_books_id from ar_system_parameters )
147       ;
148 
149       lv_updated_price   igi_rpi_update_lines.updated_price%TYPE;
150       lv_select_flag     igi_rpi_update_lines.select_flag%TYPE;
151       lv_mesg    VARCHAR2(200);
152 BEGIN
153 
154 /*
155 -- Update the item templates now
156 */
157 
158  IF igi_gen.is_req_installed('RPI') THEN
159     NULL;
160  ELSE
161     fnd_message.set_name('IGI','IGI_RPI_IS_DISABLED');
162     lv_mesg := fnd_message.get;
163     --Bug 3199481 (start)
164     If (l_unexp_level >= l_debug_level) then
165        FND_LOG.MESSAGE(l_unexp_level,'igi.plsql.igirrgpp.createlines.Msg1',FALSE);
166     End if;
167     --Bug 3199481 (end)
168     raise_application_error ( -20000, lv_mesg);
169     return;
170   END IF;
171 
172   FOR l_items in c_rpi_items LOOP
173 
174       lv_updated_price := null;
175       lv_select_flag   := 'Y';
176 
177 	IF (l_items.change_amount is not NULL) THEN
178 		IF (l_items.revised_effective_date is not NULL AND l_items.revised_effective_date < l_items.update_effective_date) THEN
179 			IF l_items.incr_decr_flag = 'Y' THEN
180 				lv_updated_price := l_items.revised_price + l_items.change_amount;
181 			ELSE
182 				lv_updated_price := l_items.revised_price - l_items.change_amount;
183 			END IF;
184 		ELSIF (l_items.revised_effective_date is NULL AND l_items.effective_date < l_items.update_effective_date) THEN
185 			IF(l_items.incr_decr_flag = 'Y') THEN
186 				lv_updated_price := l_items.price + l_items.change_amount;
187 			ELSE
188 				lv_updated_price := l_items.price - l_items.change_amount;
189 			END IF;
190 		END IF;
191 	ELSIF (l_items.change_percent is not NULL) THEN
192 		IF (l_items.revised_effective_date is not NULL AND l_items.revised_effective_date < l_items.update_effective_date) THEN
193 			IF(l_items.incr_decr_flag = 'Y') THEN
194 				lv_updated_price := l_items.revised_price *(100+ l_items.change_percent)/100;
195 			ELSE
196 				lv_updated_price := l_items.revised_price *( 100 - l_items.change_percent)/100;
197 			END IF;
198 		ELSIF (l_items.revised_effective_date is NULL AND l_items.effective_date < l_items.update_effective_date) THEN
199 			IF(l_items.incr_decr_flag = 'Y') THEN
200 				lv_updated_price := l_items.price *(100+ l_items.change_percent)/100;
201 			ELSE
202 				lv_updated_price := l_items.price *( 100 - l_items.change_percent)/100;
203 			END IF;
204 		END IF;
205 	END IF;
206 
207 	IF ((lv_updated_price is not NULL) AND (lv_updated_price >= 0)) THEN
208 	/* Added ORG_ID in the insert statement*/
209 	       insert into igi_rpi_update_lines
210 	        (  run_id, item_id, price, effective_date,
211 	           revised_price,   revised_effective_date,
212 	           updated_price, select_flag,
213 	           creation_date, created_by, last_update_date,
214 	           last_updated_by, last_update_login, org_id
215 	        )
216 	        values ( l_items.run_id, l_items.item_id, l_items.price, l_items.effective_date,
217 	           l_items.revised_price, l_items.revised_effective_date,
218 	           lv_updated_price, lv_select_flag,
219 	           l_items.creation_date, l_items.created_by, l_items.last_update_date,
220 	           l_items.last_updated_by, l_items.last_update_login, l_items.org_id );
221 	END IF;
222 
223   END LOOP;
224 
225 /*
226 -- If option flag is 'All', update the ALL the existing standing charge line information
227 -- also.
228 */
229 
230   if pp_option_flag = 'A' then
231 
232      FOR  l_details in c_rpi_charge_lines_a LOOP
233 
234       lv_updated_price := null;
235       lv_select_flag   := 'Y';
236 
237 	IF (l_details.change_amount is not NULL) THEN
238 		IF (l_details.revised_effective_date is not NULL AND l_details.revised_effective_date < l_details.update_effective_date) THEN
239 			IF(l_details.incr_decr_flag = 'Y') THEN
240 				lv_updated_price := l_details.revised_price + l_details.change_amount;
241 			ELSE
242 				lv_updated_price := l_details.revised_price - l_details.change_amount;
243 			END IF;
244 		ELSIF (l_details.revised_effective_date is NULL AND l_details.effective_date < l_details.update_effective_date) THEN
245 			IF(l_details.incr_decr_flag = 'Y') THEN
246 				lv_updated_price := l_details.price + l_details.change_amount;
247 			ELSE
248 				lv_updated_price := l_details.price - l_details.change_amount;
249 			END IF;
250 		END IF;
251 	ELSIF (l_details.change_percent is not NULL) THEN
252 		IF (l_details.revised_effective_date is not NULL AND l_details.revised_effective_date < l_details.update_effective_date) THEN
253 			IF(l_details.incr_decr_flag = 'Y') THEN
254 				lv_updated_price := l_details.revised_price * (100 + l_details.change_percent)/100;
255 			ELSE
256 				lv_updated_price := l_details.revised_price * (100 - l_details.change_percent)/100;
257 			END IF;
258 		ELSIF (l_details.revised_effective_date is NULL AND l_details.effective_date < l_details.update_effective_date) THEN
259 			IF(l_details.incr_decr_flag = 'Y') THEN
260 				lv_updated_price := l_details.price * (100 + l_details.change_percent)/100;
261 			ELSE
262 				lv_updated_price := l_details.price * (100 - l_details.change_percent)/100;
263 			END IF;
264 		END IF;
265 	END IF;
266 
267 	IF ((lv_updated_price is not NULL) AND (lv_updated_price >= 0)) THEN
268 
269 	/*R12 uptake Added ORG_ID for MOAC Impact Bug No 5905216*/
270 
271 	      insert into igi_rpi_update_lines
272 	        (run_id, standing_charge_id, line_item_id, item_id, price, effective_date,
273 	        revised_price, revised_effective_date,
274 	        updated_price, select_flag,
275 	        creation_date, created_by, last_update_date, last_updated_by,
276 	        last_update_login, org_id)
277 	      values ( l_details.run_id, l_details.standing_charge_id, l_details.line_item_id,
278 	               l_details.item_id, l_details.price, l_details.effective_date,
279 	               l_details.revised_price, l_details.revised_effective_date,
280 	               lv_updated_price, lv_select_flag,
281 	               l_details.creation_date, l_details.created_by,
282 	               l_details.last_update_date, l_details.last_updated_by,
283 	               l_details.last_update_login, l_details.org_id );
284 	END IF;
285 
286      END LOOP;
287 
288    elsif pp_option_flag = 'D' then
289 
290  /*
291  -- this update updates the standing charges whose defaulted price is not yet modified
292  */
293 
294      FOR  l_details in c_rpi_charge_lines_d LOOP
295 
296       lv_updated_price := null;
297       lv_select_flag   := 'Y';
298 
299 	IF (l_details.change_amount is not NULL) THEN
300 		IF (l_details.revised_effective_date is not NULL AND l_details.revised_effective_date < l_details.update_effective_date) THEN
301 			IF(l_details.incr_decr_flag = 'Y') THEN
302 				lv_updated_price := l_details.revised_price + l_details.change_amount;
303 			ELSE
304 				lv_updated_price := l_details.revised_price - l_details.change_amount;
305 			END IF;
306 		ELSIF (l_details.revised_effective_date is NULL AND l_details.effective_date < l_details.update_effective_date) THEN
307 			IF(l_details.incr_decr_flag = 'Y') THEN
308 				lv_updated_price := l_details.price + l_details.change_amount;
309 			ELSE
310 				lv_updated_price := l_details.price - l_details.change_amount;
311 			END IF;
312 		END IF;
313 	ELSIF (l_details.change_percent is not NULL) THEN
314 		IF (l_details.revised_effective_date is not NULL AND l_details.revised_effective_date < l_details.update_effective_date) THEN
315 			IF(l_details.incr_decr_flag = 'Y') THEN
316 				lv_updated_price := l_details.revised_price * (100 + l_details.change_percent)/100;
317 			ELSE
318 				lv_updated_price := l_details.revised_price * (100 - l_details.change_percent)/100;
319 			END IF;
320 		ELSIF (l_details.revised_effective_date is NULL AND l_details.effective_date < l_details.update_effective_date) THEN
321 			IF(l_details.incr_decr_flag = 'Y') THEN
322 				lv_updated_price := l_details.price * (100 + l_details.change_percent)/100;
323 			ELSE
324 				lv_updated_price := l_details.price * (100 - l_details.change_percent)/100;
325 			END IF;
326 		END IF;
327 	END IF;
328 
329 	IF ((lv_updated_price is not NULL) AND (lv_updated_price >= 0)) THEN
330 
331 	/*R12 Uptake Added ORG_ID for MOAC Impact bug No 5905216*/
332 
333 	      insert into igi_rpi_update_lines
334 	        (run_id, standing_charge_id, line_item_id, item_id, price, effective_date,
335 	        revised_price, revised_effective_date,
336 	        updated_price, select_flag,
337 	        creation_date, created_by, last_update_date, last_updated_by,
338 	        last_update_login, org_id)
339 	      values ( l_details.run_id, l_details.standing_charge_id, l_details.line_item_id,
340 	               l_details.item_id, l_details.price, l_details.effective_date,
341 	               l_details.revised_price, l_details.revised_effective_date,
342 	               lv_updated_price, lv_select_flag,
343 	               l_details.creation_date, l_details.created_by,
344 	               l_details.last_update_date, l_details.last_updated_by,
345 	               l_details.last_update_login, l_details.org_id );
346 	END IF;
347 
348      END LOOP;
349 
350   END IF;
351 
352 EXCEPTION WHEN OTHERS THEN
353           raise_application_error (-20000, SQLERRM );
354 
355 END;
356 
357 PROCEDURE UpdatePrice  (pp_run_id in number ) IS
358 
359     Cursor C_rul (cp_run_id in number) IS
360         SELECT item_id,
361         	standing_charge_id,
362         	line_item_id,
363                 price,
364                 effective_date,
365                 revised_effective_date,
366                 revised_price,
367                 updated_price,
371                 last_update_login
368                 previous_price,
369                 previous_effective_date,
370                 last_updated_by,
372         FROM   igi_rpi_update_lines_all  /*MOAC Impact Bug No 5905216*/
373         WHERE  run_id = cp_run_id
374          and   UPPER(select_flag) = UPPER('y') ;
375 
376    CURSOR c_ruh IS
377         SELECT  rowid row_id,
378         	run_id,
379         	item_id_from,
380         	item_id_to,
381         	effective_date,
382         	option_flag,
383         	amount,
384         	percentage_amount,
385         	status,
386 		org_id
387         FROM    igi_rpi_update_hdr_all  /*MOAC Impact Bug No 5905216*/
388         WHERE   run_id = pp_run_id ;
389 
390     CURSOR c_charge_item_number(p_standing_charge_id igi_rpi_line_details.standing_charge_id%TYPE,
391     				p_line_item_id igi_rpi_line_details.line_item_id%TYPE) IS
392     	SELECT charge_item_number
393     		FROM igi_rpi_line_details
394     		WHERE line_item_id = p_line_item_id
395     		AND standing_charge_id = p_standing_charge_id;
396 
397 --   l_org_id 	VARCHAR2(15);	/*MOAC Impact Bug No 5905216*/
398    l_org_id	NUMBER;
399    l_rowid	VARCHAR2(25) := NULL;
400    l_charge_item_number igi_rpi_line_details.charge_item_number%TYPE;
401 
402 BEGIN
403 
404     --WriteToLogFile('Start of Processing of records for Update');
405     -- bug 3199481, start block
406     IF (l_state_level >= l_debug_level) THEN
407         FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.updateprice.Msg1',
408                                       'Start of Processing of records for Update');
409     END IF;
410     -- bug 3199481, end block
411 
412     FOR l_ruh IN c_ruh LOOP
413 
414 	/*Bug No 5905216 MOAC Impact. Set policy Context*/
415 	mo_global.set_policy_context('S',l_ruh.org_id);
416 	l_org_id := l_ruh.org_id;
417 	--WriteToLogFile('Updating status of Update Header to ERROR');
418         -- bug 3199481, start block
419         IF (l_state_level >= l_debug_level) THEN
420            FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg2',
421                                          'Updating status of Update Header to ERROR');
422         END IF;
423         -- bug 3199481, end block
424         update igi_rpi_update_hdr
425         set    status = 'ERROR'
426         where rowid = l_ruh.row_id ;
427 
428         FOR l_rul IN c_rul ( l_ruh.run_id ) LOOP
429 
430 /*Bug No 5905216. Do not get ORG_ID from FND_PROFILE*/
431 --        	fnd_profile.get('ORG_ID',l_org_id);
432 
433 		--WriteToLogFile('Item Id :'|| to_char(l_rul.item_id));
434 		--WriteToLogFile('Standing Charge Id :'|| to_char(l_rul.Standing_charge_id));
435 		--WriteToLogFile('Update Effective Date :'|| to_char(l_ruh.effective_date));
436 		--WriteToLogFile('Revised Price :'|| to_char(l_rul.revised_price));
437 		--WriteToLogFile('Revised Effective Date :'||to_char(l_rul.revised_effective_date));
438 
439                 -- bug 3199481, start block
440                 IF (l_state_level >= l_debug_level) THEN
441                     FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg3',
442                                                   'Item Id :'|| to_char(l_rul.item_id));
443                     FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg4',
444                                                   'Standing Charge Id :'|| to_char(l_rul.Standing_charge_id));
445                     FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg5',
446                                                   'Update Effective Date :'|| to_char(l_ruh.effective_date));
447                     FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg6',
448                                                   'Revised Price :'|| to_char(l_rul.revised_price));
449                     FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg7',
450                                                   'Revised Effective Date :'||to_char(l_rul.revised_effective_date));
451                 END IF;
452                 -- bug 3199481, end block
453 
454 		IF (l_rul.standing_charge_id is NULL) THEN
455 			IF (l_rul.revised_price is NULL) THEN
456 				--WriteToLogFile('Updating revised price of Charge Item');
457                                  -- bug 3199481, start block
458                                  IF (l_state_level >= l_debug_level) THEN
459                                      FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg8',
460                                                                    'Updating revised price of Charge Item');
461                                  END IF;
462                                  -- bug 3199481, end block
463 				update igi_rpi_items
464 				set revised_price 		= l_rul.updated_price,
465 				    revised_price_eff_date 	= l_ruh.effective_date,
466 				    last_update_date 		= sysdate,
467 				    last_updated_by 		= l_rul.last_updated_by,
468 				    last_update_login 		= l_rul.last_update_login
469 				where item_id 			= l_rul.item_id;
470 
471 			ELSIF (l_ruh.effective_date > l_rul.revised_effective_date) THEN
472 				--WriteToLogFile('Inserting record into audit table');
473                                  -- bug 3199481, start block
474                                  IF (l_state_level >= l_debug_level) THEN
475                                      FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg9',
476                                                                    'Inserting record into audit table');
477                                  END IF;
478                                  -- bug 3199481, end block
479 				igi_rpi_audit_items_all_pkg.insert_row( X_rowid 	=> l_rowid,
483 									X_revised_effective_date => l_rul.revised_effective_date,
480 									X_item_id 	=> l_rul.item_id,
481 									X_price		=> l_rul.price,
482 									X_effective_date => l_rul.effective_date,
484 									X_revised_price => l_rul.revised_price,
485 									X_run_id	=> l_ruh.run_id,
486 									/*X_org_id	=> to_number(l_org_id));*/	/*Bug No 5905216*/
487 									X_org_id	=> l_org_id);
488 
489 				--WriteToLogFile('Updating revised price of Charge Item');
490                                  -- bug 3199481, start block
491                                  IF (l_state_level >= l_debug_level) THEN
492                                      FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg10',
493                                                                    'Updating revised price of Charge Item');
494                                  END IF;
495                                  -- bug 3199481, end block
496 				update igi_rpi_items
497 				set price			= l_rul.revised_price,
498 				    price_effective_date	= l_rul.revised_effective_date,
499 				    revised_price 		= l_rul.updated_price,
500 				    revised_price_eff_date 	= l_ruh.effective_date,
501 				    last_update_date 		= sysdate,
502 				    last_updated_by 		= l_rul.last_updated_by,
503 				    last_update_login 		= l_rul.last_update_login
504 				where item_id 			= l_rul.item_id;
505 			END IF;
506 		ELSE
507 			--WriteToLogFile('Updating revised price of Standing Charge Line Item');
508                         -- bug 3199481, start block
509                         IF (l_state_level >= l_debug_level) THEN
510                             FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg11',
511                                                           'Updating revised price of Standing Charge Line Item');
512                         END IF;
513                         -- bug 3199481, end block
514 			update igi_rpi_line_details
515 			set revised_price 		= l_rul.updated_price,
516 			    revised_effective_date	= l_ruh.effective_date,
517 			    last_update_date		= sysdate,
518 			    last_updated_by		= l_rul.last_updated_by,
519 			    last_update_login		= l_rul.last_update_login
520 			where item_id = l_rul.item_id
521 			and   line_item_id = l_rul.line_item_id
522 			and   standing_charge_id = l_rul.standing_charge_id;
523 
524 			open c_charge_item_number(l_rul.standing_charge_id, l_rul.line_item_id);
525 			fetch c_charge_item_number into l_charge_item_number;
526 			close c_charge_item_number;
527 
528 			l_rowid := NULL;
529 			--WriteToLogFile('Insert record into Line Item Price Audit table with the run id');
530                         -- bug 3199481, start block
531                         IF (l_state_level >= l_debug_level) THEN
532                             FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg12',
533                                                           'Insert record into Line Item Price Audit table with the run id');
534                         END IF;
535                         -- bug 3199481, end block
536 			igi_rpi_line_audit_det_all_pkg.insert_row( X_rowid	=> l_rowid,
537 								   X_standing_charge_id => l_rul.standing_charge_id,
538 								   X_line_item_id 	=> l_rul.line_item_id,
539 								   X_charge_item_number => l_charge_item_number,
540 								   X_item_id		=> l_rul.item_id,
541 								   X_price		=> l_rul.price,
542 								   X_effective_date	=> l_rul.effective_date,
543 								   X_revised_price	=> l_rul.revised_price,
544 								   X_revised_effective_date => l_rul.revised_effective_date,
545 								   X_run_id 		=> l_ruh.run_id,
546 								   X_org_id		=> to_number(l_org_id),
547 								   X_previous_price	=> l_rul.previous_price,
548 								   X_previous_effective_date => l_rul.previous_effective_date);
549 
550 		END IF;
551 
552         END LOOP;
553 
554 	--WriteToLogFile('Updating status of Update Header to COMPLETED');
555         -- bug 3199481, start block
556         IF (l_state_level >= l_debug_level) THEN
557             FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg13',
558                                           'Updating status of Update Header to COMPLETED');
559         END IF;
560         -- bug 3199481, end block
561         update igi_rpi_update_hdr
562         set    status = 'COMPLETED'
563         where  run_id = l_ruh.run_id ;
564 
565     END LOOP;
566     -- bug 3199481, start block
567     IF (l_state_level >= l_debug_level) THEN
568        FND_LOG.STRING(l_state_level, 'igi.plsql.igirrgpp.update_price.Msg14',
569                                      'End of processing of Items for Price update');
570     END IF;
571     -- bug 3199481, end block
572     --WriteToLogFile('End of processing of Items for Price update');
573 
574 END UpdatePrice;
575 
576 PROCEDURE UpdatePriceCP (
577                          errbuf  out NOCOPY   varchar2
578                         ,retcode out NOCOPY  number
579                         ,pp_run_id in number
580                         )
581 IS
582 BEGIN
583 
584    UpdatePrice ( pp_run_id ) ;
585 
586    retcode := 0;
587    errbuf  := null;
588    commit;
589 EXCEPTION WHEN OTHERS THEN
590       retcode := 2;
591       errbuf  := SQLERRM;
592       rollback;
593 END UpdatePriceCP;
594 
595 END;