DBA Data[Home] [Help]

PACKAGE BODY: APPS.OTA_COST_TRANSFER_TO_GL_PKG

Source


1 Package Body OTA_COST_TRANSFER_TO_GL_PKG as
2 /* $Header: otactxgl.pkb 120.2 2008/01/23 12:31:08 pekasi noship $ */
3 /*================================================================*/
4 /*                    	  PACKAGE GLOBAL DECLARATIONS             */
5 /*================================================================*/
6 
7   v_conc_request_id  fnd_concurrent_requests.request_id%TYPE := -1;
8   v_debug_msg                  VARCHAR2(2000);
9   v_status                     VARCHAR2(80);
10   v_err_num                    VARCHAR2(30) := '';
11   v_err_msg                    VARCHAR2(1000) := '';
12   v_return_boolean             BOOLEAN := FALSE;
13   v_exception_message          VARCHAR2(240) := '';
14   v_user_id  number := fnd_profile.value('USER_ID');
15   v_login_id number := fnd_profile.value('LOGIN_ID');
16   v_sob_id                     NUMBER;
17   l_success                    VARCHAR2(1);
18   l_err_num   VARCHAR2(30) := '';
19   l_err_msg   VARCHAR2(1000) := '';
20 
21 --
22 --
23 /*======================================================================+
24 |                 --- main procedure for insert_gl_line ---             |
25 |                                                                       |
26 *======================================================================*/
27  Procedure otagls (p_user_id    in number,
28                    p_login_id   in number) IS
29    --
30    --
31    --
32    --
33   --  Local Variables
34   --
35     l_cost_center_error          EXCEPTION;
36     l_finance_line_error         EXCEPTION;
37     l_finance_header_error       EXCEPTION;
38     l_amount                     ota_finance_lines.money_amount%TYPE;
39   --  l_success                    VARCHAR2(1) := 'T';
40     l_upd_header                 VARCHAR2(1);
41     l_upd_line                   VARCHAR2(1);
42     l_pay_desc         VARCHAR2(35) := 'ota_paying_cc_batch_generated';
43     l_rec_desc         VARCHAR2(35) := 'ota_receiving_cc_batch_generated';
44     l_value            fnd_profile_option_values.profile_option_value%TYPE;
45     l_finance_header_id          OTA_FINANCE_HEADERS.FINANCE_HEADER_ID%type;
46     l_exist   varchar2(1);
47     l_single_business_group_id 	ota_delegate_bookings.business_group_id%type:=
48 							fnd_profile.value('OTA_HR_GLOBAL_BUSINESS_GROUP_ID');
49     l_business_group_id  	ota_delegate_bookings.business_group_id%type:= null;
50 
51   ---*** New variables declared for Bug#2457158
52     l_booking_id      ota_delegate_bookings.booking_id%TYPE;
53     l_resource_booking_id      ota_resource_bookings.resource_booking_id%TYPE;
54 
55 
56   CURSOR ota_fh_csr is
57       select
58          ofh.FINANCE_HEADER_ID,
59          ofh.LAST_UPDATE_DATE,
60          ofh.LAST_UPDATED_BY,
61          ofh.CREATION_DATE,
62          ofh.CREATED_BY,
63          ofh.TRANSFER_DATE,
64          ofh.OBJECT_VERSION_NUMBER,
65          ofh.PAYMENT_STATUS_FLAG,
66          ofh.TRANSFER_STATUS,
67          ofh.TYPE,
68          ofh.COMMENTS,
69          ofh.EXTERNAL_REFERENCE,
70          ofh.INVOICE_ADDRESS,
71          ofh.INVOICE_CONTACT,
72          ofh.PAYMENT_METHOD,
73          ofh.PYM_ATTRIBUTE1,
74          ofh.PYM_ATTRIBUTE10,
75          ofh.PYM_ATTRIBUTE11,
76          ofh.PYM_ATTRIBUTE12,
77          ofh.PYM_ATTRIBUTE13,
78          ofh.PYM_ATTRIBUTE14,
79          ofh.PYM_ATTRIBUTE15,
80          ofh.PYM_ATTRIBUTE16,
81          ofh.PYM_ATTRIBUTE17,
82          ofh.PYM_ATTRIBUTE18,
83          ofh.PYM_ATTRIBUTE19,
84          ofh.PYM_ATTRIBUTE2,
85          ofh.PYM_ATTRIBUTE20,
86          ofh.PYM_ATTRIBUTE3,
87          ofh.PYM_ATTRIBUTE4,
88          ofh.PYM_ATTRIBUTE5,
89          ofh.PYM_ATTRIBUTE6,
90          ofh.PYM_ATTRIBUTE7,
91          ofh.PYM_ATTRIBUTE8,
92          ofh.PYM_ATTRIBUTE9,
93          ofh.PYM_INFORMATION_CATEGORY,
94          ofh.RECEIVABLE_TYPE,
95          ofh.TRANSFER_MESSAGE,
96          ofh.VENDOR_ID,
97          ofh.CONTACT_ID,
98          ofh.TFH_INFORMATION_CATEGORY,
99          ofh.TFH_INFORMATION1,
100          ofh.TFH_INFORMATION2,
101          ofh.TFH_INFORMATION3,
102          ofh.TFH_INFORMATION4,
103          ofh.TFH_INFORMATION5,
104          ofh.TFH_INFORMATION6,
105          ofh.TFH_INFORMATION7,
106          ofh.TFH_INFORMATION8,
107          ofh.TFH_INFORMATION9,
108          ofh.TFH_INFORMATION10,
109          ofh.TFH_INFORMATION11,
110          ofh.TFH_INFORMATION12,
111          ofh.TFH_INFORMATION13,
112          ofh.TFH_INFORMATION14,
113          ofh.TFH_INFORMATION15,
114          ofh.TFH_INFORMATION16,
115          ofh.TFH_INFORMATION17,
116          ofh.TFH_INFORMATION18,
117          ofh.TFH_INFORMATION19,
118          ofh.TFH_INFORMATION20,
119          ofh.PAYING_COST_CENTER,
120          ofh.RECEIVING_COST_CENTER,
121          ofh.CURRENCY_CODE,
122          ofh.TRANSFER_FROM_SET_OF_BOOKS_ID,
123          ofh.TRANSFER_TO_SET_OF_BOOKS_ID,
124          ofh.FROM_SEGMENT1,
125          ofh.FROM_SEGMENT2,
126          ofh.FROM_SEGMENT3,
127          ofh.FROM_SEGMENT4,
128          ofh.FROM_SEGMENT5,
129          ofh.FROM_SEGMENT6,
130          ofh.FROM_SEGMENT7,
131          ofh.FROM_SEGMENT8,
132          ofh.FROM_SEGMENT9,
133          ofh.FROM_SEGMENT10,
134          ofh.FROM_SEGMENT11,
135          ofh.FROM_SEGMENT12,
136          ofh.FROM_SEGMENT13,
137          ofh.FROM_SEGMENT14,
138          ofh.FROM_SEGMENT15,
139          ofh.FROM_SEGMENT16,
140          ofh.FROM_SEGMENT17,
141          ofh.FROM_SEGMENT18,
142          ofh.FROM_SEGMENT19,
143          ofh.FROM_SEGMENT20,
144          ofh.FROM_SEGMENT21,
145          ofh.FROM_SEGMENT22,
146          ofh.FROM_SEGMENT23,
147          ofh.FROM_SEGMENT24,
148          ofh.FROM_SEGMENT25,
149          ofh.FROM_SEGMENT26,
150          ofh.FROM_SEGMENT27,
151          ofh.FROM_SEGMENT28,
152          ofh.FROM_SEGMENT29,
153          ofh.FROM_SEGMENT30,
154          ofh.TO_SEGMENT1,
155          ofh.TO_SEGMENT2,
156          ofh.TO_SEGMENT3,
157          ofh.TO_SEGMENT4,
158          ofh.TO_SEGMENT5,
159          ofh.TO_SEGMENT6,
160          ofh.TO_SEGMENT7,
161          ofh.TO_SEGMENT8,
162          ofh.TO_SEGMENT9,
163          ofh.TO_SEGMENT10,
164          ofh.TO_SEGMENT11,
165          ofh.TO_SEGMENT12,
166          ofh.TO_SEGMENT13,
167          ofh.TO_SEGMENT14,
168          ofh.TO_SEGMENT15,
169          ofh.TO_SEGMENT16,
170          ofh.TO_SEGMENT17,
171          ofh.TO_SEGMENT18,
172          ofh.TO_SEGMENT19,
173          ofh.TO_SEGMENT20,
174          ofh.TO_SEGMENT21,
175          ofh.TO_SEGMENT22,
176          ofh.TO_SEGMENT23,
177          ofh.TO_SEGMENT24,
178          ofh.TO_SEGMENT25,
179          ofh.TO_SEGMENT26,
180          ofh.TO_SEGMENT27,
181          ofh.TO_SEGMENT28,
182          ofh.TO_SEGMENT29,
183          ofh.TO_SEGMENT30,
184          ofh.TRANSFER_FROM_CC_ID,
185          ofh.TRANSFER_TO_CC_ID
186       FROM   ota_finance_headers ofh
187       WHERE  ofh.TYPE    = 'CT'
188       AND    ofh.TRANSFER_STATUS    = 'AT'
189       AND    ofh.CANCELLED_FLAG   = 'N'
190       ORDER BY
191             ofh.finance_header_id,
192       	    ofh.paying_cost_center,
193       	    ofh.receiving_cost_center,
194       	    ofh.currency_code ;
195      -- FOR UPDATE;
196 
197 /* Bug 3611693 Modified the cursor to take care of new Delivery Mode */
198         CURSOR FL IS
199          SELECT sum(fl.money_amount)
200            FROM ota_finance_lines fl,
201                 ota_delegate_bookings tdb,
202  		    ota_booking_status_types bst,
203                 ota_events evt,
204 		    ota_category_usages ocu,
205                 ota_offerings off
206            WHERE fl.finance_header_id = l_finance_header_id and
207                  tdb.booking_id = fl.booking_id and
208                  bst.booking_status_type_id = tdb.booking_status_type_id  and
209                  evt.event_id = tdb.event_id and
210                  evt.price_basis <> 'N' and
211                  evt.parent_offering_id = off.offering_id and
212 		     off.delivery_mode_id = ocu.category_usage_id and
213                  (((ocu.synchronous_flag = 'Y' or (ocu.synchronous_flag = 'N' and
214                      ocu.online_flag = 'N' ))  and
215                   bst.type in ('A','C')) or
216                   ( (ocu.synchronous_flag = 'N' and ocu.online_flag = 'Y' and
217                      off.learning_object_id is not null and
218                       off.learning_object_id in (
219                      select pfr.learning_object_id from ota_performances pfr
220                      where
221                       pfr.user_id= tdb.delegate_person_id and
222                       pfr.user_type = 'E' and
223                       pfr.lesson_status <> 'N') ) and
224                   bst.type in ('A','C','P','E'))  or
225                   ((ocu.synchronous_flag = 'N' and ocu.online_flag = 'Y' and
226                    off.learning_object_id is null and tdb.content_player_status is not null)
227                    and bst.type in ('A','C','P','E')) )
228                    and
229                  fl.transfer_status = 'AT' and
230                  fl.cancelled_flag = 'N' and
231                  tdb.business_group_id = l_business_group_id;
232 
233 ---*** commented out the definition of FL_CHK cursor. New definition is added
234 ---*** for the cursor FL_CHK for bug#2457158.
235   /*       CURSOR FL_CHK IS
236          SELECT null
237            FROM ota_finance_lines fl,
238                 ota_delegate_bookings tdb,
239  		    ota_booking_status_types bst,
240                 ota_events evt
241            WHERE fl.finance_header_id = l_finance_header_id and
242                  tdb.booking_id = fl.booking_id and
243                  bst.booking_status_type_id = tdb.booking_status_type_id  and
244                  evt.event_id = tdb.event_id and
245                  evt.price_basis <> 'N' and
246                  ((evt.offering_id is null and
247                   bst.type not in ('A','C')) or
248                   (evt.offering_id is not null and
249                   bst.type not in ('A','C','P','E')))
250                  and
251                  fl.transfer_status = 'AT' and
252                  fl.cancelled_flag = 'Y' and
253                  tdb.business_group_id = l_business_group_id; */
254 
255          /* bug no 3611693  Modified the cursor to take care of delivery mode*/
256 	CURSOR FL_CHK IS
257 	SELECT null
258            FROM ota_finance_lines fl,
259                 ota_delegate_bookings tdb,
260        		ota_booking_status_types bst,
261                 ota_events evt,
262 		ota_category_usages ocu,
263                 ota_offerings off
264            WHERE fl.finance_header_id = l_finance_header_id and
265                 tdb.booking_id = fl.booking_id and
266                 bst.booking_status_type_id = tdb.booking_status_type_id  and
267                 evt.event_id = tdb.event_id and
268 		evt.parent_offering_id = off.offering_id and
269 		off.delivery_mode_id = ocu.category_usage_id and
270                 evt.price_basis <> 'N' and
271                 (((ocu.synchronous_flag = 'Y' or (ocu.synchronous_flag = 'N' and
272                      ocu.online_flag = 'N' ))  and
273                   bst.type not in ('A','C')) or
274                   ( (ocu.synchronous_flag = 'N' and ocu.online_flag = 'Y' and
275                      off.learning_object_id is not null and
276                       ((off.learning_object_id in (
277                      select pfr.learning_object_id from ota_performances pfr
278                      where
279                       pfr.user_id= tdb.delegate_person_id and
280                       pfr.user_type = 'E' and
281                       pfr.lesson_status = 'N')) or
282                       ( off.learning_object_id not in(
283                      select pfr.learning_object_id from ota_performances pfr
284                      where
285                       pfr.user_id= tdb.delegate_person_id and
286                       pfr.user_type = 'E')))) and
287                   bst.type in ('A','C','P','W','R','E'))  or
288                   ((ocu.synchronous_flag = 'N' and ocu.online_flag = 'Y' and
289                    off.learning_object_id is null and tdb.content_player_status is null)
290                    and bst.type in ('A','C','P','W','R','E')) )    and
291                 fl.transfer_status = 'AT' and
292                 fl.cancelled_flag = 'N' and
293              	tdb.business_group_id = l_business_group_id;
294 /* bug no 3611693 */
295 
296          CURSOR FH_LOCK
297            IS
298            SELECT Finance_header_id
299            FROM ota_finance_headers
300            WHERE Finance_header_id = l_finance_header_id
301            FOR UPDATE;
302 
303   ---*** Added FL_RESOURCE ,FL_CHECK and CHK_ENR_RES Cursor definitions --Bug#2457158
304 
305           CURSOR FL_RESOURCE IS
306                SELECT  sum(fl.money_amount)
307                  FROM ota_finance_lines fl,
308                       ota_resource_bookings trb,
309                       ota_suppliable_resources tsr
310                  WHERE fl.finance_header_id = l_finance_header_id and
311                        trb.resource_booking_id = fl.resource_booking_id and
312                        trb.required_date_to < (trunc(SYSDATE)+1) and
313                        tsr.supplied_resource_id = trb.supplied_resource_id and
314                        trb.status = 'C' and
315                        fl.transfer_status = 'AT' and
316                        fl.cancelled_flag = 'N' and
317                        tsr.business_group_id = l_business_group_id;
318 
319           CURSOR FL_CHECK IS
320            SELECT null
321             FROM   ota_finance_lines fl
322             WHERE  fl.finance_header_id = l_finance_header_id and
323                    fl.resource_booking_id is not null and
324                    fl.cancelled_flag = 'N';
325 
326          CURSOR chk_Enr_Res(p_finance_header_id ota_finance_headers.finance_header_id%TYPE)
327          IS
328          SELECT count(booking_id),
329                 count(resource_booking_id)
330          FROM ota_finance_lines
331          WHERE finance_header_id=p_finance_header_id and
332                cancelled_flag = 'N'
333          GROUP BY finance_header_id;
334 
335 
336 
337 
338   BEGIN
339 
340   IF l_single_business_group_id is not null then
341      l_business_group_id := l_single_business_group_id;
342   ELSE
343      l_business_group_id := fnd_profile.value('PER_BUSINESS_GROUP_ID');
344   END IF;
345 
346     --
347     --
348     -- Get Set of Books ID
349     --
350    /*    FND_PROFILE.GET('GL_SET_OF_BOOKS_ID', l_value); */
351        v_sob_id  := nvl(to_number(l_value),0);
352     --
353     --
354   /*======================================================================+
355   | Create GL Lines for each OTA Finance Header and Finance Lines         |
356   |                                                                       |
357   *======================================================================*/
358   --
359   -- Main Loop for ota_finance_headers table
360   --
361   FOR ota_fh_row IN ota_fh_csr
362     LOOP
363     FND_FILE.PUT_LINE(FND_FILE.LOG,'Entering Finance Header :'
364             ||to_char(ota_fh_row.finance_header_id));
365 
366       l_success := 'T';
367      --
368      -- Loop to sum money amount for paying_cost_center
369      -- and receiving_cost_center
370      --
371          l_finance_header_id := ota_fh_row.finance_header_id;
372 
373 
374     -- To lock the row explicitly
375  	for ota_fh_lock IN fh_lock
376          LOOP
377             null;
378          END LOOP;
379 
380 
381 
382 
383     BEGIN
384      SAVEPOINT GL_TRANSFER;
385      if fl_chk%ISOPEN then
386         close fl_chk;
387      end if;
388 
389      if fl%ISOPEN then
390         close fl;
391      end if;
392   ---*** added for Bug#2457158
393      l_amount := NULL;
394      l_booking_id := 0;
395      l_resource_booking_id := 0;
396      IF chk_Enr_Res%ISOPEN THEN
397        CLOSE  chk_Enr_Res;
398      END IF;
399 
400      OPEN chk_Enr_Res(l_finance_header_id);
401      FETCH chk_Enr_Res INTO l_booking_id, l_resource_booking_id;
402      CLOSE chk_Enr_Res;
403 
404 IF l_booking_id <> 0 and l_resource_booking_id = 0 THEN
405 
406    OPEN fl_chk;
407    FETCH fl_chk INTO l_exist;
408    IF fl_chk%notfound then          --bug no 3611693 ---*** replaced %notfound with %found for Bug#2457158
409 
410      OPEN fl;
411      FETCH fl INTO l_amount;
412      IF fl%found then
413       If (l_amount is not null or l_amount > 0 ) then
414 
415 
416      --
417          if ota_fh_row.paying_cost_center is null then
418             l_amount := 0;
419          end if;
420      --
421       if ota_fh_row.paying_cost_center is not null then
422           FND_FILE.PUT_LINE(FND_FILE.LOG,'Insert into GL interface table for Paying cost center:' || ','
423             ||ota_fh_row.paying_cost_center);
424          ota_tfh_api_shd.lck(ota_fh_row.finance_header_id,ota_fh_row.object_version_number);  ---*** Bug#2820365
425          l_success  := otagli (ota_fh_row.finance_header_id,
426                            ota_fh_row.paying_cost_center,
427                            ota_fh_row.Transfer_from_set_of_books_id,
428                            l_amount,
429                            0,
430                            ota_fh_row.currency_code,
431                            l_pay_desc,
432  				   ota_fh_row.transfer_from_cc_id);
433      --
434      --
435          if l_success = 'F' then
436             RAISE l_cost_center_error;
437          end if;
438 
439 
440      --
441          if ota_fh_row.receiving_cost_center is not null then
442             if l_amount is null then
443                l_amount := 0;
444             end if;
445 
446      --
447             FND_FILE.PUT_LINE(FND_FILE.LOG,'Insert into GL interface table for Recieving cost center,'
448             ||ota_fh_row.receiving_cost_center);
449             ota_tfh_api_shd.lck(ota_fh_row.finance_header_id,ota_fh_row.object_version_number);    ---*** Bug#2820365
450             l_success  := otagli (ota_fh_row.finance_header_id,
451                            ota_fh_row.receiving_cost_center,
452                            ota_fh_row.Transfer_to_set_of_books_id,
453                            0,
454                            l_amount,
455                            ota_fh_row.currency_code,
456                            l_rec_desc,
457 				   ota_fh_row.transfer_to_cc_id);
458      --
459      --
460             if l_success = 'F' then
461                RAISE l_cost_center_error;
462             end if;
463 
464           end if;
465      --
466      --
467       l_upd_line := upd_ota_line (ota_fh_row.finance_header_id);
468      --
469       if l_upd_line = 'F' then
470          RAISE l_finance_line_error;
471       end if;
472 
473 
474 
475 	     l_upd_header := upd_ota_header (ota_fh_row.finance_header_id,
476                                      ota_fh_row.object_version_number);
477      --
478      	 if l_upd_header = 'F' then
479         	 RAISE l_finance_header_error;
480 	 end if;
481 
482 
483      --
484      else
485      FND_FILE.PUT_LINE(FND_FILE.LOG,'This Finance Header' || ','
486            ||to_char(ota_fh_row.finance_header_id)||' doesnot have paying cost center'  );
487 
488     end if;
489    end if;
490   end if;
491   CLOSE fl;
492 
493     IF l_success = 'F' then
494        FND_FILE.PUT_LINE(FND_FILE.LOG,'Rollback for :'
495             ||to_char(ota_fh_row.finance_header_id));
496        ROLLBACK TO GL_TRANSFER;
497     ELSE
498        FND_FILE.PUT_LINE(FND_FILE.LOG,'Commiting for :'
499             ||to_char(ota_fh_row.finance_header_id));
500        COMMIT;
501     END IF;
502  end if;
503  CLOSE fl_chk;
504 ----------------------------*** Code (start) added for Bug#2457158 ***------------------
505 ELSIF l_booking_id = 0 and l_resource_booking_id <> 0 THEN
506  if fl_check%ISOPEN then
507         close fl_check;
508      end if;
509 
510      if fl_resource%ISOPEN then
511         close fl_resource;
512      end if;
513 
514   OPEN fl_check;
515    FETCH fl_check INTO l_exist;
516    IF fl_check%found then
517      OPEN fl_resource;
518      FETCH fl_resource INTO l_amount;
519 
520 
521      IF fl_resource%found then
522       If l_amount is not null or l_amount > 0 then
523      --
524          if ota_fh_row.paying_cost_center is null then
525             l_amount := 0;
526          end if;
527      --
528       if ota_fh_row.paying_cost_center is not null then
529           FND_FILE.PUT_LINE(FND_FILE.LOG,'Insert into GL interface table for Paying cost center:' || ','
530             ||ota_fh_row.paying_cost_center);
531          ota_tfh_api_shd.lck(ota_fh_row.finance_header_id,ota_fh_row.object_version_number);  ---*** Bug#2820365
532          l_success  := otagli (ota_fh_row.finance_header_id,
533                            ota_fh_row.paying_cost_center,
534                            ota_fh_row.Transfer_from_set_of_books_id,
535                            l_amount,
536                            0,
537                            ota_fh_row.currency_code,
538                            l_pay_desc,
539  				   ota_fh_row.transfer_from_cc_id);
540      --
541      --
542          if l_success = 'F' then
543             RAISE l_cost_center_error;
544          end if;
545 
546 
547      --
548          if ota_fh_row.receiving_cost_center is not null then
549             if l_amount is null then
550                l_amount := 0;
551             end if;
552 
553      --
554             FND_FILE.PUT_LINE(FND_FILE.LOG,'Insert into GL interface table for Recieving cost center,'
555             ||ota_fh_row.receiving_cost_center);
556             ota_tfh_api_shd.lck(ota_fh_row.finance_header_id,ota_fh_row.object_version_number);    ---*** Bug#2820365
557             l_success  := otagli (ota_fh_row.finance_header_id,
558                            ota_fh_row.receiving_cost_center,
559                            ota_fh_row.Transfer_to_set_of_books_id,
560                            0,
561                            l_amount,
562                            ota_fh_row.currency_code,
563                            l_rec_desc,
564 				   ota_fh_row.transfer_to_cc_id);
565      --
566      --
567             if l_success = 'F' then
568                RAISE l_cost_center_error;
569             end if;
570 
571           end if;
572      --
573      --
574       l_upd_line := upd_ota_line (ota_fh_row.finance_header_id);
575      --
576       if l_upd_line = 'F' then
577          RAISE l_finance_line_error;
578       end if;
579 
580 
581       l_upd_header := upd_ota_header (ota_fh_row.finance_header_id,
582                                      ota_fh_row.object_version_number);
583      --
584       if l_upd_header = 'F' then
585          RAISE l_finance_header_error;
586       end if;
587 
588      --
589      else
590      FND_FILE.PUT_LINE(FND_FILE.LOG,'This Finance Header' || ','
591            ||to_char(ota_fh_row.finance_header_id)||' doesnot have paying cost center'  );
592 
593     end if;
594    end if;
595   end if;
596   CLOSE fl_resource;
597 
598     IF l_success = 'F' then
599        FND_FILE.PUT_LINE(FND_FILE.LOG,'Rollback for :'
600             ||to_char(ota_fh_row.finance_header_id));
601        ROLLBACK TO GL_TRANSFER;
602     ELSE
603        FND_FILE.PUT_LINE(FND_FILE.LOG,'Commiting for :'
604             ||to_char(ota_fh_row.finance_header_id));
605        COMMIT;
606     END IF;
607 
608  end if;
609  CLOSE fl_check;
610 
611  ELSIF l_booking_id <> 0 and l_resource_booking_id <> 0 THEN
612  FND_FILE.PUT_LINE(FND_FILE.LOG,'This Finance Header ' ||to_char(ota_fh_row.finance_header_id)||
613     ' has not transferred to GL because it includes ');
614 
615 FND_FILE.PUT_LINE(FND_FILE.LOG,'both Enrollment and Resource Booking finance lines. You must submit ');
616 
617 FND_FILE.PUT_LINE(FND_FILE.LOG,'Resource Booking and Enrollment lines under separate finance headers.');
618 
619 end if;
620 ----------------------------*** Code (end  ) added for Bug#2457158 ***------------------
621 
622     EXCEPTION
623         WHEN l_finance_header_error then
624         l_err_num := SQLCODE;
625         l_err_msg := SUBSTR(SQLERRM, 1, 100);
626 
627         FND_FILE.PUT_LINE(FND_FILE.LOG,'Error occured in Updating Finance header' || ','
628            ||to_char(ota_fh_row.finance_header_id)||','||  l_err_msg);
629 
630    --   fnd_message.raise_error;
631         ROLLBACK TO GL_TRANSFER;
632    WHEN l_finance_line_error then
633         l_err_num := SQLCODE;
634         l_err_msg := SUBSTR(SQLERRM, 1, 100);
635 
636         FND_FILE.PUT_LINE(FND_FILE.LOG,'Error occured in Updating Finance line for header ' || ','
637             ||to_char(ota_fh_row.finance_header_id)||','||  l_err_msg);
638 
639  --     fnd_message.raise_error;
640         ROLLBACK TO GL_TRANSFER;
641     WHEN l_cost_center_error then
642         l_err_num := SQLCODE;
643         l_err_msg := SUBSTR(SQLERRM, 1, 100);
644 
645         FND_FILE.PUT_LINE(FND_FILE.LOG,'Error occured in creating GL ' || ','
646          ||to_char(ota_fh_row.finance_header_id) ||','|| l_err_msg);
647 
648  --     fnd_message.raise_error;
649         ROLLBACK TO GL_TRANSFER;
650     WHEN OTHERS then
651         l_err_num := SQLCODE;
652         l_err_msg := SUBSTR(SQLERRM, 1, 100);
653 
654         FND_FILE.PUT_LINE(FND_FILE.LOG,'When Others Error occured in ' || ','
655          ||to_char(ota_fh_row.finance_header_id)||','||l_err_msg);
656 
657   --    fnd_message.raise_error;
658 
659     ROLLBACK TO GL_TRANSFER;
660 
661     END;
662 
663     END LOOP;  /* This is to close OTA Finance Header cursor loop */
664      --
665   --  COMMIT;
666      --
667    EXCEPTION
668 
669      WHEN l_cost_center_error THEN
670 
671              if ota_fh_csr%ISOPEN then
672                close ota_fh_csr;
673              end if;
674 
675              --
676       v_err_num := SQLCODE;
677       v_err_msg := SUBSTR(SQLERRM, 1, 100);
678      FND_FILE.PUT_LINE(FND_FILE.LOG,'L_Cost_Center_error occured:' || ','
679          ||v_err_msg);
680       --
681       --
682    --   fnd_message.raise_error;
683       --
684       --
685     --  ROLLBACK;
686 
687 
688 
689       WHEN OTHERS THEN
690 
691              if ota_fh_csr%ISOPEN then
692                close ota_fh_csr;
693              end if;
694 
695              --
696       v_err_num := SQLCODE;
697       v_err_msg := SUBSTR(SQLERRM, 1, 100);
698 
699     FND_FILE.PUT_LINE(FND_FILE.LOG,'When Others Error occured : ' || ','
700          ||v_err_msg);
701       --
702       --
703  --     fnd_message.raise_error;
704       --
705       --
706     --  ROLLBACK;
707   --
708   --
709  END otagls;
710 --
711 
712  FUNCTION otagli (p_finance_header_id   in number,
713                   p_code_combination_id in varchar2,
714                   p_set_of_books_id     in number,
715                   p_debited_amount      in number,
716                   p_credited_amount     in number,
717                   p_currency_code       in varchar2,
718                   p_desc                in varchar2,
719 			p_cc_id               in number
720 ) RETURN VARCHAR2 IS
721 
722    -- l_success   VARCHAR2(1) := 'T';
723 
724  --
725  -- Insert to gl interface
726  --
727    BEGIN
728       FND_FILE.PUT_LINE(FND_FILE.LOG,'Inserting in Insert to GL interface ');
729     --
730      INSERT INTO gl_interface
731                             (STATUS
732                             ,LEDGER_ID  -- Bug#6763652
733                             ,SET_OF_BOOKS_ID
734                             ,ACCOUNTING_DATE
735                             ,CURRENCY_CODE
736                             ,DATE_CREATED
737                             ,CREATED_BY
738                             ,ACTUAL_FLAG
739                             ,USER_JE_CATEGORY_NAME
740                             ,USER_JE_SOURCE_NAME
741                             ,CURRENCY_CONVERSION_DATE
742                             ,ENCUMBRANCE_TYPE_ID
743                             ,BUDGET_VERSION_ID
744                             ,USER_CURRENCY_CONVERSION_TYPE
745                             ,CURRENCY_CONVERSION_RATE
746                             ,SEGMENT1
747                             ,SEGMENT2
748                             ,SEGMENT3
749                             ,SEGMENT4
750                             ,SEGMENT5
751                             ,SEGMENT6
752                             ,SEGMENT7
753                             ,SEGMENT8
754                             ,SEGMENT9
755                             ,SEGMENT10
756                             ,SEGMENT11
757                             ,SEGMENT12
758                             ,SEGMENT13
759                             ,SEGMENT14
760                             ,SEGMENT15
761                             ,SEGMENT16
762                             ,SEGMENT17
763                             ,SEGMENT18
764                             ,SEGMENT19
765                             ,SEGMENT20
766                             ,SEGMENT21
767                             ,SEGMENT22
768                             ,SEGMENT23
769                             ,SEGMENT24
770                             ,SEGMENT25
771                             ,SEGMENT26
772                             ,SEGMENT27
773                             ,SEGMENT28
774                             ,SEGMENT29
775                             ,SEGMENT30
776                             ,ENTERED_DR
777                             ,ENTERED_CR
778                             ,ACCOUNTED_DR
779                             ,ACCOUNTED_CR
780                             ,TRANSACTION_DATE
781                             ,REFERENCE1
782                             ,REFERENCE2
783                             ,REFERENCE3
784                             ,REFERENCE4
785                             ,REFERENCE5
786                             ,REFERENCE6
787                             ,REFERENCE7
788                             ,REFERENCE8
789                             ,REFERENCE9
790                             ,REFERENCE10
791                             ,REFERENCE11
792                             ,REFERENCE12
793                             ,REFERENCE13
794                             ,REFERENCE14
795                             ,REFERENCE15
796                             ,REFERENCE16
797                             ,REFERENCE17
798                             ,REFERENCE18
799                             ,REFERENCE19
800                             ,REFERENCE20
801                             ,REFERENCE21
802                             ,REFERENCE22
803                             ,REFERENCE23
804                             ,REFERENCE24
805                             ,REFERENCE25
806                             ,REFERENCE26
807                             ,REFERENCE27
808                             ,REFERENCE28
809                             ,REFERENCE29
810                             ,REFERENCE30
811                             ,JE_BATCH_ID
812                             ,PERIOD_NAME
813                             ,JE_HEADER_ID
814                             ,JE_LINE_NUM
815                             ,CHART_OF_ACCOUNTS_ID
816                             ,FUNCTIONAL_CURRENCY_CODE
817                             ,CODE_COMBINATION_ID
818                             ,DATE_CREATED_IN_GL
819                             ,WARNING_CODE
820                             ,STATUS_DESCRIPTION
821                             ,STAT_AMOUNT
822                             ,GROUP_ID
823                             ,REQUEST_ID
824                             ,SUBLEDGER_DOC_SEQUENCE_ID
825                             ,SUBLEDGER_DOC_SEQUENCE_VALUE
826                             ,ATTRIBUTE1
827                             ,ATTRIBUTE2
828                             ,ATTRIBUTE3
829                             ,ATTRIBUTE4
830                             ,ATTRIBUTE5
831                             ,ATTRIBUTE6
832                             ,ATTRIBUTE7
833                             ,ATTRIBUTE8
834                             ,ATTRIBUTE9
835                             ,ATTRIBUTE10
836                             ,ATTRIBUTE11
837                             ,ATTRIBUTE12
838                             ,ATTRIBUTE13
839                             ,ATTRIBUTE14
840                             ,ATTRIBUTE15
841                             ,ATTRIBUTE16
842                             ,ATTRIBUTE17
843                             ,ATTRIBUTE18
844                             ,ATTRIBUTE19
845                             ,ATTRIBUTE20
846                             ,CONTEXT
847                             ,CONTEXT2
848                             ,INVOICE_DATE
849                             ,TAX_CODE
850                             ,INVOICE_IDENTIFIER
851                             ,INVOICE_AMOUNT
852                             ,CONTEXT3
853                             ,USSGL_TRANSACTION_CODE
854                             ,DESCR_FLEX_ERROR_MESSAGE
855                             )
856      VALUES
857       (
858     'NEW',                    -- STATUS          --required
859      p_set_of_books_id,       -- LEDGER_ID - new column added in R12 Bug#6763652
860      p_set_of_books_id,       -- SET_OF_BOOKS_ID --required
861      SYSDATE,                 -- ACCOUNTING_DATE --required
862      p_currency_code,         -- CURRENCY_CODE   --required
863      SYSDATE,                 -- DATE_CREATED    --required
864      v_login_id,              -- CREATED_BY      --required
865      'A',                     -- ACTUAL_FLAG     --required
866      'Transfer',              -- USER_JE_CATEGORY_NAME --required
867      'Transfer',              -- USER_JE_SOURCE_NAME   --required
868      NULL,                           -- CURRENCY_CONVERSION_DATE
869      NULL,                           -- ENCUMBRANCE_TYPE_ID
870      NULL,                           -- BUDGET_VERSION_ID
871      NULL,                           -- USER_CURRENCY_CONVERSION_TYPE
872      NULL,                           -- CURRENCY_CONVERSION_RATE
873      NULL,					 -- SEGMENT1
874      NULL,                           -- SEGMENT2
875      NULL,                           -- SEGMENT3
876      NULL,                           -- SEGMENT4
877      NULL,                           -- SEGMENT5
878      NULL,                           -- SEGMENT6
879      NULL,                           -- SEGMENT7
880      NULL,                           -- SEGMENT8
881      NULL,                           -- SEGMENT9
882      NULL,                           -- SEGMENT10
883      NULL,                           -- SEGMENT11
884      NULL,                           -- SEGMENT12
885      NULL,                           -- SEGMENT13
886      NULL,                           -- SEGMENT14
887      NULL,                           -- SEGMENT15
888      NULL,                           -- SEGMENT16
889      NULL,                           -- SEGMENT17
890      NULL,                           -- SEGMENT18
891      NULL,                           -- SEGMENT19
892      NULL,                           -- SEGMENT20
893      NULL,                           -- SEGMENT21
894      NULL,                           -- SEGMENT22
895      NULL,                           -- SEGMENT23
896      NULL,                           -- SEGMENT24
897      NULL,                           -- SEGMENT25
898      NULL,                           -- SEGMENT26
899      NULL,                           -- SEGMENT27
900      NULL,                           -- SEGMENT28
901      NULL,                           -- SEGMENT29
902      NULL,                           -- SEGMENT30
903      p_debited_amount,               -- ENTERED_DR
904      p_credited_amount,              -- ENTERED_CR
905      NULL,                           -- ACCOUNTED_DR
906      NULL,                           -- ACCOUNTED_CR
907      NULL,                           -- TRANSACTION_DATE-required NULL by JI
908      'OTA_GL_BATCH',       		 -- REFERENCE1-batch name ** JTH Previous Value NULL
909      'Cross Charge Transfer to GL',  -- REFERENCE2-batch desc
910      NULL,                           -- required NULL by JI
911      'Cost Transfer',        		 -- REFERENCE4-JE name   ** JTH Previous Value NULL
912      NULL,                           -- REFERENCE5-JE desc
913      NULL,                           -- REFERENCE6-JE ref
914      NULL,                           -- REFERENCE7-JE Reversal period
915      NULL,                           -- REFERENCE8-JE line desc
916      NULL,                           -- required NULL by JI
917      p_desc,                         --REFERENCE10-JE line desc
918      NULL,                           -- REFERENCE11-required NULL by JI
919      NULL,                           -- REFERENCE12-required NULL by JI
920      NULL,                           -- REFERENCE13-required NULL by JI
921      NULL,                           -- REFERENCE14-required NULL by JI
922      NULL,                           -- REFERENCE15-required NULL by JI
923      NULL,                           -- REFERENCE16-required NULL by JI
924      NULL,                           -- REFERENCE17-required NULL by JI
925      NULL,                           -- REFERENCE18-required NULL by JI
926      NULL,                           -- REFERENCE19-required NULL by JI
927      NULL,                           -- REFERENCE20-required NULL by JI
928      NULL,                           -- REFERENCE21
929      NULL,                           -- REFERENCE22
930      NULL,                           -- REFERENCE23
931      NULL,                           -- REFERENCE24
932      NULL,                           -- REFERENCE25
933      NULL,                           -- REFERENCE26
934      NULL,                           -- REFERENCE27
935      NULL,                           -- REFERENCE28
936      NULL,                           -- REFERENCE29
937      to_char(p_finance_header_id),            -- REFERENCE30
938      NULL,                           -- JE_BATCH_ID-required NULL by JI
939      NULL,    -- PERIOD_NAME-enter value only if ACTUAL_FLAG = 'B' (Budget Data)
940      NULL,                      -- JE_HEADER_ID-required NULL by JI
941      NULL,                      -- JE_LINE_NUM-required NULL by JI
942      NULL,                      -- CHART_OF_ACCOUNTS_ID-required NULL by JI
943      NULL,                      -- FUNCTIONAL_CURRENCY_CODE-required NULL by JI
944      p_cc_id, 			   -- CODE_COMBINATION_ID
945      NULL,    -- DATE_CREATED_IN_GL-required NULL by JI
946      NULL,                           -- WARNING_CODE-required NULL by JI
947      NULL,                           -- STATUS_DESCRIPTION-required NULL by JI
948      NULL,                           -- STAT_AMOUNT
949      NULL,                           -- GROUP_ID
950      NULL,                           -- REQUEST_ID-required NULL by JI
951      NULL,                  -- SUBLEDGER_DOC_SEQUENCE_ID-required NULL by JI
952      NULL,                  -- SUBLEDGER_DOC_SEQUENCE_VALUE-required NULL by JI
953      NULL,              -- ATTRIBUTE1
954      NULL,              -- ATTRIBUTE2
955      NULL,              -- ATTRIBUTE3
956      NULL,              -- ATTRIBUTE4
957      NULL,              -- ATTRIBUTE5
958      NULL,              -- ATTRIBUTE6
959      NULL,              -- ATTRIBUTE7
960      NULL,              -- ATTRIBUTE8
961      NULL,              -- ATTRIBUTE9
962      NULL,              -- ATTRIBUTE10
963      NULL,              -- ATTRIBUTE11
964      NULL,              -- ATTRIBUTE12
965      NULL,              -- ATTRIBUTE13
966      NULL,              -- ATTRIBUTE14
967      NULL,              -- ATTRIBUTE15
968      NULL,              -- ATTRIBUTE16
969      NULL,              -- ATTRIBUTE17
970      NULL,              -- ATTRIBUTE18
971      NULL,              -- ATTRIBUTE19
972      NULL,              -- ATTRIBUTE20
973      NULL,              -- CONTEXT
974      NULL,              -- CONTEXT2
975      NULL,              -- INVOICE_DATE
976      NULL,              -- TAX_CODE
977      NULL,              -- INVOICE_IDENTIFIER
978      NULL,              -- INVOICE_AMOUNT
979      NULL,              -- CONTEXT3
980      NULL,              -- USSGL_TRANSACTION_CODE
981      NULL               -- DESCR_FLEX_ERROR_MESSAGE-required NULL by JI
982     );
983     --
984     --
985        return(l_success);
986 
987       EXCEPTION
988        WHEN OTHERS THEN
989         l_err_num := SQLCODE;
990         l_err_msg := SUBSTR(SQLERRM, 1, 100);
991     --
992         FND_FILE.PUT_LINE(FND_FILE.LOG,'Error occured in Inserting into GL interface '||' '||
993 		to_char(p_finance_header_id)||','||l_err_msg);
994 
995         l_success := 'F';
996         return(l_success);
997     --
998    END otagli;
999     --
1000     -- Update OTA Finance Headers for Cost Transfer
1001     --
1002 
1003 -- ----------------------------------------------------------------------------
1004 -- |---------------------------------< Upd_ota_header  >----------------------|
1005 -- ----------------------------------------------------------------------------
1006 -- {Start Of Comments}
1007 --
1008 -- Description:
1009 --   This function  will be used to update finance header information.
1010 --
1011 --   This function can be only called by  otagls procedure.
1012 --
1013 -- Pre Conditions:
1014 --   None.
1015 --
1016 -- In Arguments:
1017 --   p_finance_header_id
1018 --
1019 -- Post Success:
1020 --   Processing continues.
1021 --
1022 --
1023 -- Post Failure:
1024 --   None.
1025 --
1026 -- Access Status:
1027 --   Public.
1028 --
1029 -- {End Of Comments}
1030 ----------------------------------------------------------------------------
1031 FUNCTION upd_ota_header (p_finance_header_id in number,
1032                          p_object_version_number in number)
1033 RETURN VARCHAR2 AS
1034  l_upd_header VARCHAR2(1);
1035  l_object_version_number  number(15);
1036 
1037  BEGIN
1038 
1039     l_object_version_number := p_object_version_number;
1040 
1041       /*ota_tfh_api_upd.upd( p_finance_header_id 	      =>    p_finance_header_id
1042 		    		  ,p_object_version_number    => l_object_version_number
1043 		    		  ,p_transfer_status	      => 'ST'
1044            			  ,p_external_reference       => 'OTA_GL_BATCH'
1045                           ,p_transfer_date         	=> SYSDATE
1046 		     		  ,p_validate			=> False
1047 		     		  ,p_Transaction_type		=> 'UPDATE'); */
1048 
1049       UPDATE  ota_finance_headers
1050       SET  last_update_date       = SYSDATE
1051           ,last_updated_by        = v_user_id
1052           ,last_update_login      = v_login_id
1053           ,transfer_status        = 'ST'
1054           ,external_reference     = 'OTA_GL_BATCH'
1055           ,transfer_date          = SYSDATE
1056       WHERE    finance_header_id    = p_finance_header_id;
1057     --
1058     l_upd_header := 'T';
1059     return(l_upd_header);
1060     --
1061     --
1062     EXCEPTION
1063       WHEN OTHERS THEN
1064     --
1065     --
1066       l_err_num := SQLCODE;
1067       l_err_msg := SUBSTR(SQLERRM, 1, 100);
1068       FND_FILE.PUT_LINE(FND_FILE.LOG,'Error occured in ' ||
1069                        'Updating finance header'||' '||
1070 		           to_char(p_finance_header_id)||','||l_err_msg);
1071       l_success := 'F';
1072            --
1073       l_upd_header := 'F';
1074       return(l_upd_header);
1075 
1076     END upd_ota_header ;
1077 
1078 -- ----------------------------------------------------------------------------
1079 -- |---------------------------------< Upd_ota_line  >----------------------|
1080 -- ----------------------------------------------------------------------------
1081 -- {Start Of Comments}
1082 --
1083 -- Description:
1084 --   This function  will be used to update finance lines information.
1085 --
1086 --   This function can be only called by  otagls procedure.
1087 --
1088 -- Pre Conditions:
1089 --   None.
1090 --
1091 -- In Arguments:
1092 --   p_finance_header_id
1093 --
1094 -- Post Success:
1095 --   Processing continues.
1096 --
1097 --
1098 -- Post Failure:
1099 --   None.
1100 --
1101 -- Access Status:
1102 --   Public.
1103 --
1104 -- {End Of Comments}
1105 ----------------------------------------------------------------------------
1106 
1107  FUNCTION upd_ota_line (p_finance_header_id in number) RETURN VARCHAR2 AS
1108    l_upd_line VARCHAR2(1);
1109    l_line_ovn   number(9);
1110    l_date_raised  date;
1111    l_sequence_number  number(15);
1112    --
1113      /* CURSOR fh IS
1114         SELECT finance_line_id,
1115                object_version_number,
1116                date_raised,
1117                sequence_number
1118          FROM ota_finance_lines
1119       WHERE finance_header_id = p_finance_header_id and
1120                  booking_id  in (Select Booking_id
1121  					   from  OTA_DELEGATE_BOOKINGS
1122  					   WHERE booking_status_type_id in
1123                                  (Select Booking_status_type_id
1124                                   FROM OTA_BOOKING_STATUS_TYPES
1125 					    WHERE Type = 'A')); */
1126 
1127 
1128 /* Bug 3611693 Modified the cursor to take care of new Delivery Mode */
1129 
1130     CURSOR FL IS
1131          SELECT fl.finance_line_id,
1132                fl.object_version_number,
1133                fl.date_raised,
1134                fl.sequence_number
1135            FROM ota_finance_lines fl,
1136                 ota_delegate_bookings tdb,
1137  		    ota_booking_status_types bst,
1138                 ota_events evt,
1139 		    ota_category_usages ocu,
1140                 ota_offerings off
1141            WHERE fl.finance_header_id = p_finance_header_id and
1142                  tdb.booking_id = fl.booking_id and
1143                  bst.booking_status_type_id = tdb.booking_status_type_id  and
1144                  evt.event_id = tdb.event_id and
1145                  evt.price_basis <> 'N' and
1146                  evt.parent_offering_id = off.offering_id and
1147 		     off.delivery_mode_id = ocu.category_usage_id and
1148                  (((ocu.synchronous_flag = 'Y' or (ocu.synchronous_flag = 'N' and
1149                      ocu.online_flag = 'N' ))  and
1150                   bst.type in ('A','C')) or
1151                   ( (ocu.synchronous_flag = 'N' and ocu.online_flag = 'Y' and
1152                       off.learning_object_id is not null and
1153                       off.learning_object_id in (
1154                      select pfr.learning_object_id from ota_performances pfr
1155                      where
1156                       pfr.user_id= tdb.delegate_person_id and
1157                       pfr.user_type = 'E' and
1158                       pfr.lesson_status <> 'N') ) and
1159                   bst.type in ('A','C','P','E'))  or
1160                   ((ocu.synchronous_flag = 'N' and ocu.online_flag = 'Y' and
1161                    off.learning_object_id is null and tdb.content_player_status is not null)
1162                    and bst.type in ('A','C','P','E')) )
1163                    and
1164                  fl.transfer_status = 'AT' and
1165                  fl.cancelled_flag = 'N'
1166                 FOR UPDATE OF fl.finance_line_id;
1167 
1168 
1169 
1170 
1171    ---*** Cursor FL_RESOURCE definition added for Bug#2457158
1172    CURSOR FL_RESOURCE IS
1173              SELECT  fl.finance_line_id,
1174                      fl.object_version_number,
1175                      fl.date_raised,
1176                      fl.sequence_number
1177                  FROM ota_finance_lines fl,
1178                       ota_resource_bookings trb
1179                  WHERE fl.finance_header_id = p_finance_header_id and
1180                        trb.resource_booking_id = fl.resource_booking_id and
1181                        trb.required_date_to < (trunc(SYSDATE)+1) and
1182                        trb.status = 'C' and
1183                        fl.transfer_status = 'AT' and
1184                        fl.cancelled_flag = 'N'
1185                  FOR UPDATE OF fl.finance_line_id;
1186 
1187 
1188    --
1189    BEGIN
1190        FND_FILE.PUT_LINE(FND_FILE.LOG,'Inserting into Update Finance Line ');
1191    --
1192       FOR fl_rec IN fl LOOP
1193          l_date_raised := fl_rec.date_raised;
1194          l_sequence_number := fl_rec.sequence_number;
1195          l_line_ovn := fl_rec.object_version_number;
1196 
1197        /*  ota_tfl_api_upd.upd(
1198 					p_finance_line_id 	=> fl_rec.finance_line_id,
1199 					p_date_raised		=> l_date_raised,
1200 					p_object_version_number => l_line_ovn,
1201 					p_transfer_status		=> 'ST',
1202 					p_sequence_number		=> l_sequence_number,
1203                               p_transfer_date         => sysdate,
1204 					p_validate			=> false,
1205 					p_transaction_type 	=> 'UPDATE'); */
1206 
1207       FND_FILE.PUT_LINE(FND_FILE.LOG,'Updating Finance line: ' ||
1208 		           to_char(fl_rec.finance_line_id));
1209 
1210       UPDATE  ota_finance_lines
1211         SET  last_update_date       = SYSDATE
1212             ,last_updated_by        = v_user_id
1213             ,last_update_login      = v_login_id
1214             ,transfer_status        = 'ST'
1215             ,transfer_date          = SYSDATE
1216         WHERE    finance_line_id = fl_rec.finance_line_id;
1217 
1218       END LOOP;
1219    --
1220    -------------------- *** Code (start) added for Bug#2457158 ***---------------
1221    FOR fl_rec IN fl_resource LOOP
1222          l_date_raised := fl_rec.date_raised;
1223          l_sequence_number := fl_rec.sequence_number;
1224          l_line_ovn := fl_rec.object_version_number;
1225       FND_FILE.PUT_LINE(FND_FILE.LOG,'Updating Finance line: ' ||
1226 		           to_char(fl_rec.finance_line_id));
1227 
1228       UPDATE  ota_finance_lines
1229         SET  last_update_date       = SYSDATE
1230             ,last_updated_by        = v_user_id
1231             ,last_update_login      = v_login_id
1232             ,transfer_status        = 'ST'
1233             ,transfer_date          = SYSDATE
1234         WHERE    finance_line_id = fl_rec.finance_line_id;
1235 
1236       END LOOP;
1237    -------------------- *** Code (end  ) added for Bug#2457158 ***---------------
1238     l_upd_line := 'T';
1239     return(l_upd_line);
1240    --
1241    EXCEPTION
1242      WHEN OTHERS THEN
1243     --
1244     --
1245      l_err_num := SQLCODE;
1246      l_err_msg := SUBSTR(SQLERRM, 1, 100);
1247     --
1248      FND_FILE.PUT_LINE(FND_FILE.LOG,'Error occured in ' ||
1249                      'Updating finance lines for header'||' '||
1250 		           to_char(p_finance_header_id)||','||l_err_msg);
1251 
1252     --
1253      --
1254       l_success := 'F';
1255       l_upd_line := 'F';
1256       return(l_upd_line);
1257    --
1258    END upd_ota_line ;
1259 --
1260 --
1261 --
1262 END OTA_COST_TRANSFER_TO_GL_PKG;