DBA Data[Home] [Help]

PACKAGE BODY: APPS.FII_AR_COLLECTORS_PKG

Source


1 PACKAGE BODY FII_AR_COLLECTORS_PKG AS
2 /* $Header: FIIARCOLLB.pls 120.7.12000000.2 2007/03/16 20:51:22 vkazhipu ship $ */
3 
4         g_phase                VARCHAR2(120);
5         g_schema_name          VARCHAR2(120)   := 'FII';
6         g_retcode              VARCHAR2(20)    := NULL;
7         g_debug_mode           VARCHAR2(1)
8                      := NVL(FND_PROFILE.value('FII_DEBUG_MODE'), 'N');
9  --added by vkazhipu for bug 5763652
10         g_collection_to_date DATE := SYSDATE;
11 -- *******************************************************************
12 --   Initialize (get log file directory and login details)
13 
14    PROCEDURE Initialize  IS
15          l_dir        VARCHAR2(160);
16 
17    BEGIN
18 
19      IF (FIIDIM_Debug) THEN
20 	FII_MESSAGE.Func_Ent ('FII_AR_COLLECTORS_PKG.Initialize');
21      END IF;
22 
23      g_phase := 'Do set up for log file';
24      ----------------------------------------------
25      -- Do set up for log file
26      ----------------------------------------------
27 
28      l_dir := fnd_profile.value('BIS_DEBUG_LOG_DIRECTORY');
29      ------------------------------------------------------
30      -- Set default directory in case if the profile option
31      -- BIS_DEBUG_LOG_DIRECTORY is not set up
32      ------------------------------------------------------
33      IF l_dir IS NULL then
34        l_dir := FII_UTIL.get_utl_file_dir;
35      END IF;
36 
37      ----------------------------------------------------------------
38      -- FII_UTIL.initialize will set up the directory where
39      -- the log files and output files are written to
40      ----------------------------------------------------------------
41      FII_UTIL.initialize('FII_AR_COLLECTORS_PKG.log',
42                          'FII_AR_COLLECTORS_PKG.out',l_dir,'FII_AR_COLLECTORS_PKG');
43 
44 
45        -- Obtain FII schema name
46      g_phase := 'Obtain Schema name, User ID, Login ID';
47      g_schema_name := FII_UTIL.get_schema_name ('FII');
48 
49      -- Obtain user ID, login ID and initialize package variables
50      FII_USER_ID 	:= FND_GLOBAL.USER_ID;
51      FII_LOGIN_ID	:= FND_GLOBAL.LOGIN_ID;
52 
53      -- If any of the above values is not set, error out
54      IF (FII_USER_ID is NULL OR FII_LOGIN_ID is NULL) THEN
55        FII_UTIL.Write_Log ('>>> Failed Initialization');
56        RAISE CODIM_fatal_err;
57      END IF;
58 
59      -- Turn trace on if process is running in debug mode
60      IF (FIIDIM_Debug) THEN
61        -- Program running in debug mode, turning trace on
62        EXECUTE IMMEDIATE 'ALTER SESSION SET SQL_TRACE TRUE';
63        FII_UTIL.Write_Log ('Initialize: Set Trace On');
64 	FII_MESSAGE.Func_Succ ('FII_AR_COLLECTORS_PKG.Initialize');
65      END IF;
66 
67    EXCEPTION
68 
69   WHEN CODIM_fatal_err THEN
70        FII_UTIL.Write_Log ('FII_AR_COLLECTORS_PKG.Initialize : '|| 'User defined error');
71        FND_CONCURRENT.Af_Rollback;
72        FII_MESSAGE.Func_Fail(func_name => 'FII_AR_COLLECTORS_PKG.Initialize');
73        RAISE;
74 
75      WHEN OTHERS THEN
76         FII_UTIL.Write_Log ('Unexpected error when calling Initialize...');
77         FII_UTIL.Write_Log ( 'g_phase: ' || g_phase);
78 	FII_UTIL.Write_Log ('Error Message: '|| substr(sqlerrm,1,180));
79         RAISE;
80 
81    END Initialize;
82 
83  -- **************************************************************************
84 -- This is the main procedure of Collector dimension program in Initial mode.
85 
86    PROCEDURE Init_Load (errbuf		OUT NOCOPY VARCHAR2,
87 	 	        retcode		OUT NOCOPY VARCHAR2) IS
88 
89     ret_val      BOOLEAN := FALSE;
90     l_max_batch_party_id NUMBER (15);
91 
92   BEGIN
93 
94      -- Determine if process will be run in debug mode
95      IF (NVL(g_debug_mode, 'N') <> 'N') THEN
96        FIIDIM_Debug := TRUE;
97      ELSE
98        FIIDIM_Debug := FALSE;
99      END IF;
100 
101      IF (FIIDIM_Debug) THEN
102        FII_MESSAGE.Func_Ent(func_name => 'FII_AR_COLLECTORS_PKG.Init_Load');
103        FII_UTIL.Write_Log (' Debug On');
104      ELSE
105 	FII_UTIL.Write_Log (' Debug Off');
106       END IF;
107 
108     --First do the initialization
109 
110       Initialize;
111 
112    --Added by vkazhipu for customer bug 5763652
113    --added for registering the program name
114    --used in BIS_REFRESH_LOG
115 
116    IF(NOT BIS_COLLECTION_UTILITIES.setup('FII_DIM_COLL_INIT_C')) THEN
117            raise_application_error(-20000, errbuf);
118            return;
119      END IF;
120 
121 
122      g_phase := 'Populating COLL_BATCH_PARTY_ID in fii_change_log';
123      IF (FIIDIM_Debug) THEN
124        FII_UTIL.Write_Log(g_phase);
125      End if;
126 
127           select nvl(max(batch_party_id), -1)
128           into l_max_batch_party_id
129           from hz_merge_party_history m,
130                hz_merge_dictionary d
131           where m.merge_dict_id = d.merge_dict_id
132           and d.entity_name = 'HZ_PARTIES';
133 
134           INSERT INTO fii_change_log
135           (log_item, item_value, CREATION_DATE, CREATED_BY,
136            LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN)
137           (SELECT 'COLL_MAX_BATCH_PARTY_ID',
138                 l_max_batch_party_id,
139                 sysdate,        --CREATION_DATE,
140                 fii_user_id,  --CREATED_BY,
141                 sysdate,        --LAST_UPDATE_DATE,
142                 fii_user_id,  --LAST_UPDATED_BY,
143                 fii_login_id  --LAST_UPDATE_LOGIN
144            FROM DUAL
145            WHERE NOT EXISTS
146               (select 1 from fii_change_log
147                where log_item = 'COLL_MAX_BATCH_PARTY_ID'));
148 
149           IF (SQL%ROWCOUNT = 0) THEN
150               UPDATE fii_change_log
151               SET item_value = l_max_batch_party_id,
152                   last_update_date  = sysdate,
153                   last_update_login = fii_login_id,
154                   last_updated_by   = fii_user_id
155               WHERE log_item = 'COLL_MAX_BATCH_PARTY_ID';
156           END IF;
157 
158 
159       IF (FIIDIM_Debug) THEN
160        FII_UTIL.Write_Log ('Now start processing '|| 'Collector dimension');
161       END IF;
162 
163       --Secondly populate the table FII_COLLECTORS
164 
165     g_phase := 'populating FII_COLLECTORS table';
166 
167     FII_UTIL.truncate_table ('FII_COLLECTORS', 'FII', g_retcode);
168 
169  /* For transactions, the AR UI requires the account and site use to be specified. However, for receipts,
170  it can be created with just the account information. Hence, in first sql, apart from picking up
171  non-null site_use_ids to get the collectors assigned at the site level, we do NVL(site_use_id, -2)
172 to get the collector for a receipt that has only a customer account assigned to it. */
173 
174  /* second sql gets all collectors assigned at the account level */
175 
176 /* Bug 5019882. Records with cust_account_id = -2 may be seeded accounts and
177 we don't need to pick them up. So, added > 0 check to filter such records.. */
178 
179 
180 -- Added following statement for performance bug 5093270
181 
182    EXECUTE IMMEDIATE 'ALTER SESSION ENABLE PARALLEL DML';
183  --added last_update_date filter by vkazhipu for bug 5763652
184 	INSERT  /*+ APPEND PARALLEL(COLL) */ INTO FII_COLLECTORS COLL
185 		       (party_id,
186 			cust_account_id,
187 		        site_use_id,
188 			collector_id,
189 		        creation_date,
190 		        created_by,
191 		        last_update_date,
192 		        last_updated_by,
193 		        last_update_login)
194 
195 		SELECT	/*+ PARALLEL(prof) */
196 			NVL(prof.party_id,-2),
197 			prof.cust_account_id,
198 			NVL(site_use_id,-2),
199 			prof.collector_id,
200 			SYSDATE,
201 			FII_USER_ID,
202 			SYSDATE,
203 			FII_USER_ID,
204 			FII_LOGIN_ID
205 		FROM	hz_customer_profiles prof
206 		WHERE   prof.cust_account_id > 0
207 		AND prof.last_update_date <= g_collection_to_date
208 		UNION ALL
209 
210 		-- site_use_code DRAWEE is for Bills Receivable
211 SELECT	/*+ PARALLEL(prof) PARALLEL(acct) PARALLEL(sites) PARALLEL(uses) */
212 			NVL(prof.party_id,-2),
213 			prof.cust_account_id,
214 			uses.site_use_id,
215 			prof.collector_id,
216 			SYSDATE,
217 			FII_USER_ID,
218 			SYSDATE,
219 			FII_USER_ID,
220 			FII_LOGIN_ID
221 		FROM	hz_customer_profiles prof,
222 		        hz_cust_accounts acct,
223 		        hz_cust_acct_sites_all sites,
224 		        hz_cust_site_uses_all uses
225 		WHERE	prof.site_use_id IS NULL
226 			AND acct.cust_account_id = prof.cust_account_id
227 			AND acct.cust_account_id = sites.cust_account_id
228 			AND sites.cust_acct_site_id = uses.cust_acct_site_id
229 			AND uses.site_use_code IN ('BILL_TO','DRAWEE')
230 			AND prof.last_update_date <= g_collection_to_date
231 			AND NOT EXISTS (SELECT	/*+ PARALLEL(profs) */
232 						cust_account_id, site_use_id
233 					FROM	hz_customer_profiles profs
234 					WHERE	site_use_id IS NOT NULL
235                             and acct.cust_account_id = profs.cust_account_id
236                             and uses.site_use_id = profs.site_use_id
237                             AND profs.last_update_date <= g_collection_to_date);
238 
239         IF (FIIDIM_Debug) THEN
240         	FII_UTIL.Write_Log('Inserted ' || SQL%ROWCOUNT || ' rows IN FII_COLLECTORS');
241         END IF;
242 
243 -- Statistics for FII_COLLECTORS will be anyway gathered via RSG so NOT gathering stats in the program
244 
245 -- Since FII_COLLECTORS is used in MV query,  we need to gather statistics for its MLOG as well
246 
247        g_phase := 'gather_table_stats for MLOG$_FII_COLLECTORS';
248        FND_STATS.gather_table_stats
249   	       (ownname	=> g_schema_name,
250 	        tabname	=> 'MLOG$_FII_COLLECTORS');
251 
252      FND_CONCURRENT.Af_Commit;
253 
254      IF (FIIDIM_Debug) THEN
255       FII_MESSAGE.Func_Succ(func_name => 'FII_AR_COLLECTORS_PKG.Init_Load');
256      END IF;
257 
258        --Added by vkazhipu for customer bug 5763652
259 
260       BIS_COLLECTION_UTILITIES.wrapup(
261        p_status => TRUE,
262        p_period_from => BIS_COMMON_PARAMETERS.Get_Global_Start_Date,
263        p_period_to => g_collection_to_date);
264 
265 
266     -- Exception handling
267 
268   EXCEPTION
269 
270     WHEN CODIM_fatal_err THEN
271 
272       FII_UTIL.Write_Log ('FII_AR_COLLECTORS_PKG.Init_Load: '||
273                         'User defined error');
274 
275       FND_CONCURRENT.Af_Rollback;
276       FII_MESSAGE.Func_Fail(func_name	=> 'FII_AR_COLLECTORS_PKG.Init_Load');
277       retcode := sqlcode;
278       ret_val := FND_CONCURRENT.Set_Completion_Status
279 		(status	 => 'ERROR', message => substr(sqlerrm,1,180));
280 
281     WHEN OTHERS THEN
282       FII_UTIL.Write_Log ('Init_Load -> phase: '|| g_phase);
283       FII_UTIL.Write_Log (
284           'Other error IN FII_AR_COLLECTORS_PKG.Init_Load: ' || substr(sqlerrm,1,180));
285 
286 
287       FND_CONCURRENT.Af_Rollback;
288       FII_MESSAGE.Func_Fail(func_name	=> 'FII_AR_COLLECTORS_PKG.Init_Load');
289       retcode := sqlcode;
290       ret_val := FND_CONCURRENT.Set_Completion_Status
291 		(status	 => 'ERROR', message => substr(sqlerrm,1,180));
292 
293    END Init_Load;
294 
295 -- *****************************************************************
296 
297 -- This is the main procedure of collector dimension program in Incremental mode.
298 
299    PROCEDURE Incre_Update (errbuf		OUT NOCOPY VARCHAR2,
300 	 	           retcode		OUT NOCOPY VARCHAR2) IS
301 
302 	ret_val             BOOLEAN := FALSE;
303 	l_last_update_join VARCHAR2(300);
304 	l_last_update_join1 VARCHAR2(300);
308 	l_last_period_from   DATE := NULL;
305 	l_last_update_join2 VARCHAR2(300);
306 	l_last_start_date    DATE := NULL;
307 	l_last_end_date      DATE := NULL;
309 	l_last_period_to     DATE := NULL;
310 	l_last_period_to_incr     DATE := NULL;
311 	l_last_period_to_init     DATE := NULL;
312 	l_stmt VARCHAR2(32000);
313         l_max_batch_party_id NUMBER(15);
314 
315    BEGIN
316 
317        -- Determine if process will be run in debug mode
318      IF (NVL(g_debug_mode, 'N') <> 'N') THEN
319        FIIDIM_Debug := TRUE;
320      ELSE
321        FIIDIM_Debug := FALSE;
322      END IF;
323 
324      IF (FIIDIM_Debug) THEN
325        FII_MESSAGE.Func_Ent(func_name => 'FII_AR_COLLECTORS_PKG.Incre_Update');
326        FII_UTIL.Write_Log (' Debug On');
327      ELSE
328 	FII_UTIL.Write_Log (' Debug Off');
329       END IF;
330 
331 
332     --First do the initialization
333 
334       Initialize;
335 
336      g_phase := 'Getting maximum batch_party_id from fii_change_log table';
337      IF (FIIDIM_Debug) THEN
338 	FII_UTIL.Write_Log (g_phase);
339      END IF;
340 
341         select item_value
342         into l_max_batch_party_id
343         from fii_change_log
344         where log_item = 'COLL_MAX_BATCH_PARTY_ID';
345 
346      FII_UTIL.Write_Log ('COLL_MAX_BATCH_PARTY_ID = '||l_max_batch_party_id);
347 
348     g_phase := 'Deleting merged parties.';
349     IF (FIIDIM_Debug) THEN
350 	FII_UTIL.Write_Log (g_phase);
351     END IF;
352 
353         Delete from fii_collectors
354         where party_id in
355         (select from_entity_id
356         from hz_merge_party_history m,
357              hz_merge_dictionary d
358         where m.merge_dict_id = d.merge_dict_id
359         and d.entity_name = 'HZ_PARTIES'
360         and batch_party_id > l_max_batch_party_id);
361 
362     g_phase := 'Logging maximum batch_party_id into fii_change_log table';
363      IF (FIIDIM_Debug) THEN
364 	FII_UTIL.Write_Log (g_phase);
365      END IF;
366 
367     select nvl(max(batch_party_id), -1)
368     into l_max_batch_party_id
369     from hz_merge_party_history m,
370          hz_merge_dictionary d
371     where m.merge_dict_id = d.merge_dict_id
372     and d.entity_name = 'HZ_PARTIES';
373 
374 
375 
376     INSERT INTO fii_change_log
377     (log_item, item_value, CREATION_DATE, CREATED_BY,
378      LAST_UPDATE_DATE, LAST_UPDATED_BY, LAST_UPDATE_LOGIN)
379     (SELECT 'COLL_MAX_BATCH_PARTY_ID',
380           l_max_batch_party_id,
381           sysdate,        --CREATION_DATE,
382           fii_user_id,  --CREATED_BY,
383           sysdate,        --LAST_UPDATE_DATE,
384           fii_user_id,  --LAST_UPDATED_BY,
385           fii_login_id  --LAST_UPDATE_LOGIN
386      FROM DUAL
387      WHERE NOT EXISTS
388         (select 1 from fii_change_log
389          where log_item = 'COLL_MAX_BATCH_PARTY_ID'));
390 
391     IF (SQL%ROWCOUNT = 0) THEN
392         UPDATE fii_change_log
393         SET item_value = l_max_batch_party_id,
394             last_update_date  = sysdate,
395             last_update_login = fii_login_id,
396             last_updated_by   = fii_user_id
397         WHERE log_item = 'COLL_MAX_BATCH_PARTY_ID';
398     END IF;
399 
400     FND_CONCURRENT.Af_Commit;
401 
402     IF (FIIDIM_Debug) THEN
403        FII_UTIL.Write_Log ('Now start processing Collector dimension');
404     END IF;
405 
406 	g_phase := 'Getting last refresh dates';
407 
408 	IF (FIIDIM_Debug) THEN
409 	   FII_UTIL.Write_Log ( 'g_phase: ' || g_phase);
410         END IF;
411 
412 --Added by vkazhipu for customer bug 5763652
413 
414 IF(NOT BIS_COLLECTION_UTILITIES.setup('FII_DIM_COLL_INCRE_C')) THEN
415            raise_application_error(-20000, errbuf);
416            return;
417      END IF;
418 
419 BIS_COLLECTION_UTILITIES.get_last_refresh_dates('FII_DIM_COLL_INIT_C',
420                                                    l_last_start_date, l_last_end_date,
421                                                    l_last_period_from, l_last_period_to_init);
422 
423 
424 BIS_COLLECTION_UTILITIES.get_last_refresh_dates('FII_DIM_COLL_INCRE_C',
425                                                    l_last_start_date, l_last_end_date,
426                                                    l_last_period_from, l_last_period_to_incr);
427 
428 
429 --BIS_COLLECTION_UTILITIES.get_last_refresh_dates('FII_COLLECTORS',
430 --                                                  l_last_start_date,
431  --                                                 l_last_end_date,
432 --                                                  l_last_period_from,
433  --                                                 l_last_period_to);
434 	-- --------------------------------------------------------------------------
435 	-- l_last_period_to is the 'period to' parameter of the most recent initial load.
436 	-- If it is null, it is set to the global start date.
437 	-- The incremental load will not pick up collector assignments done before global start date.
438 	-- --------------------------------------------------------------------------
439 
440 l_last_period_to := GREATEST(NVL(l_last_period_to_init, BIS_COMMON_PARAMETERS.Get_Global_Start_Date),
441                            NVL(l_last_period_to_incr, BIS_COMMON_PARAMETERS.Get_Global_Start_Date));
442 
443 
444 	IF(l_last_period_to IS NULL) THEN
445            l_last_period_to := bis_common_parameters.get_global_start_date;
446         END IF;
447 
448 	IF (FIIDIM_Debug) THEN
449 	   FII_UTIL.Write_Log ( 'last refresh date is ' || l_last_period_to);
450 
451         END IF;
455 	l_last_update_join2 := 'AND TRUNC(profs.last_update_date) >=''' ||l_last_period_to||''' AND TRUNC(profs.last_update_date) <=''' ||g_collection_to_date||'''';
452 
453 	l_last_update_join := 'AND TRUNC(prof.last_update_date) >=''' ||l_last_period_to||''' AND TRUNC(prof.last_update_date) <=''' ||g_collection_to_date||'''';
454 	l_last_update_join1 := 'WHERE TRUNC(prof.last_update_date) >=''' ||l_last_period_to||''' AND TRUNC(prof.last_update_date) <=''' ||g_collection_to_date||'''';
456 
457  /* For transactions, the AR UI requires the account and site use to be specified. However, for receipts,
458  it can be created with just the account information. Hence, in first sql, apart from picking up
459  non-null site_use_ids to get the collectors assigned at the site level, we do NVL(site_use_id, -2)
460 to get the collector for a receipt that has only a customer account assigned to it. */
461 
462  /* second sql gets all collectors assigned at the account level */
463 
464      -- Incremental Dimension Maintence
465      --	The sql in USING clause only considers the records changed after the
466      -- date of last initial/incremental run. The records thus obtained are
467      -- merged into the dimension table FII_COLLECTORS using MERGE command.
468      -- The changed records are updated whereas new records are inserted into FII_COLLECTORS.
469 
470 /* Bug 5019882. Records with cust_account_id = -2 may be seeded accounts and
471 we don't need to pick them up. So, added > 0 check to filter such records.. */
472 
473 -- Added following statement for performance bug 5093270
474 
475    EXECUTE IMMEDIATE 'ALTER SESSION ENABLE PARALLEL DML';
476 
477 	l_stmt := 'MERGE INTO FII_COLLECTORS dim
478 	USING (SELECT	NVL(prof.party_id,-2) party_id,
479 			prof.cust_account_id cust_account_id,
480 			NVL(site_use_id,-2) site_use_id,
481 			prof.collector_id collector_id,
482 			SYSDATE creation_date,
483 			'||FII_USER_ID||' created_by,
484 			SYSDATE last_update_date,
485 			'||FII_USER_ID||' last_updated_by,
486 			'||FII_LOGIN_ID||' last_update_login
487 
488 		FROM	hz_customer_profiles prof
489 
490 			'||l_last_update_join1||'
491 			AND prof.cust_account_id > 0
492 
493 		UNION ALL
494 
495 		SELECT	NVL(prof.party_id,-2) party_id,
496 			prof.cust_account_id cust_account_id,
497 			uses.site_use_id site_use_id,
498 			prof.collector_id collector_id,
499 			SYSDATE creation_date,
500 			'||FII_USER_ID||' created_by,
501 			SYSDATE last_update_date,
502 			'||FII_USER_ID||' last_updated_by,
503 			'||FII_LOGIN_ID||' last_update_login
504 
505 		FROM	hz_customer_profiles prof,
506 		        hz_cust_accounts acct,
507 		        hz_cust_acct_sites_all sites,
508 		        hz_cust_site_uses_all uses
509 
510 		WHERE	 prof.site_use_id IS NULL
511 			 AND acct.cust_account_id = prof.cust_account_id
512 			 AND acct.cust_account_id = sites.cust_account_id
513 			 AND sites.cust_acct_site_id = uses.cust_acct_site_id
514 			 AND uses.site_use_code IN (''BILL_TO'',''DRAWEE'')
515 			 AND NOT EXISTS (SELECT	  cust_account_id, site_use_id
516 					 FROM	  hz_customer_profiles profs
517 				         WHERE	  site_use_id IS NOT NULL
518 					          and acct.cust_account_id = profs.cust_account_id
519 			                          and uses.site_use_id = profs.site_use_id
520 					          '||l_last_update_join2||'
521 					)
522 			 '||l_last_update_join||') inline
523 
524 	-- ON (dim.party_id = inline.party_id and dim.cust_account_id = inline.cust_account_id AND dim.site_use_id = inline.site_use_id)
525 	ON (dim.cust_account_id = inline.cust_account_id AND dim.site_use_id = inline.site_use_id)
526 	WHEN MATCHED THEN UPDATE SET	dim.collector_id = inline.collector_id,
527 					                dim.party_id = inline.party_id,
528 					dim.creation_date = inline.creation_date,
529 					dim.created_by = inline.created_by,
530 					dim.last_update_date = inline.last_update_date,
531 				        dim.last_updated_by = inline.last_updated_by,
532 				        dim.last_update_login = inline.last_update_login
533 	WHEN NOT MATCHED THEN INSERT (	dim.party_id,
534 					dim.cust_account_id,
535 					dim.site_use_id,
536 					dim.collector_id,
537 					dim.creation_date,
538 					dim.created_by,
539 					dim.last_update_date,
540 					dim.last_updated_by,
541 					dim.last_update_login)
542 
543 				VALUES (inline.party_id,
544 					inline.cust_account_id,
545 					inline.site_use_id,
546 					inline.collector_id,
547 					inline.creation_date,
548 					inline.created_by,
549 					inline.last_update_date,
550 					inline.last_updated_by,
551 					inline.last_update_login)';
552 
553 EXECUTE IMMEDIATE l_stmt;
554 
555 	IF (FIIDIM_Debug) THEN
556 	FII_UTIL.Write_Log('Modified (Updation + Insertion) ' || SQL%ROWCOUNT || ' rows into FII_COLLECTORS');
557        END IF;
558 
559 	-- Statistics for FII_COLLECTORS will be anyway gathered via RSG so NOT gathering stats in the program
560 
561 	-- From past experience, perf team has suggested not to analyze MLOG in incremental run.
562 	-- So we will not be gathering stats for MLOG during incremental run.
563 
564       FND_CONCURRENT.Af_Commit;
565 
566       IF (FIIDIM_Debug) THEN
567        FII_MESSAGE.Func_Succ(func_name => 'FII_AR_COLLECTORS_PKG.Incre_Update');
568       END IF;
569 
570    --Added by vkazhipu for customer bug 5763652
571     BIS_COLLECTION_UTILITIES.wrapup(
572        p_status => TRUE,
573        p_period_from => l_last_period_to,
574        p_period_to => g_collection_to_date);
575 
576    -- Exception handling
577 
578    EXCEPTION
579      WHEN CODIM_fatal_err THEN
580        FII_UTIL.Write_Log ('FII_AR_COLLECTORS_PKG.Incre_Update'||
581                          'User defined error');
582 
583        FND_CONCURRENT.Af_Rollback;
584        FII_MESSAGE.Func_Fail(func_name	=> 'FII_AR_COLLECTORS_PKG.Incre_Update');
585        retcode := sqlcode;
586        ret_val := FND_CONCURRENT.Set_Completion_Status
587 	        	(status	 => 'ERROR', message => substr(sqlerrm,1,180));
588 
589      WHEN OTHERS THEN
590        FII_UTIL.Write_Log ('Incre_Update -> phase: '|| g_phase);
591        FII_UTIL.Write_Log (
592           'Other error IN FII_AR_COLLECTORS_PKG.Incre_Update: ' || substr(sqlerrm,1,180));
593 
594        FND_CONCURRENT.Af_Rollback;
595        FII_MESSAGE.Func_Fail(func_name	=> 'FII_AR_COLLECTORS_PKG.Incre_Update');
596        retcode := sqlcode;
597        ret_val := FND_CONCURRENT.Set_Completion_Status
598 	        	(status	 => 'ERROR', message => substr(sqlerrm,1,180));
599 
600    END Incre_Update;
601 
602 
603 
604 END FII_AR_COLLECTORS_PKG;