DBA Data[Home] [Help]

PACKAGE BODY: APPS.INV_ENHANCED_TM_PERF

Source


1 PACKAGE BODY INV_ENHANCED_TM_PERF AS
2 /*  $Header: INVENTMB.pls 120.1.12020000.3 2012/07/11 05:26:56 ksivasa ship $*/
3 
4   G_PKG_NAME           CONSTANT VARCHAR2(30) := 'INV_ENHANCED_TM_PERF';
5   g_debug              NUMBER :=  NVL(FND_PROFILE.VALUE('INV_DEBUG_TRACE'),0);
6 
7   procedure print_debug(msg varchar2) is
8   begin
9       if (g_debug = 1) then
10         inv_log_util.trace(msg,g_pkg_name,15);
11       end if;
12   end print_debug;
13 
14   procedure launch_worker( p_maxrows      in number
15                           ,p_applid       in number
16                           ,p_progid       in number
17                           ,p_userid       in number
18                           ,p_reqstid      in number
19                           ,p_loginid      in number
20                           ,p_src_type     in varchar2 DEFAULT 'SO'
21                           ,x_ret_status   out nocopy number
22                           ,x_ret_message  out nocopy varchar2)  is
23 
24 
25        TYPE mti_rec_type IS RECORD (item_id NUMBER, rec_count NUMBER) ;
26 
27        type mti_rec_table is table of mti_rec_type index by binary_integer;
28 
29        l_mti_rec  mti_rec_table;
30 
31        cursor mti_so_rec is
32        select rowid from mtl_transactions_interface mti
33        where PROCESS_FLAG = 1
34        AND NVL(LOCK_FLAG,2) = 2
35        AND TRANSACTION_MODE = 3
36        AND EXISTS (
37                  SELECT 'X'
38                  FROM MTL_TRANSACTION_TYPES MTT
39                  WHERE MTT.TRANSACTION_TYPE_ID = MTI.TRANSACTION_TYPE_ID
40                  AND MTT.TRANSACTION_SOURCE_TYPE_ID IN (2,8,16))
41        and exists (
42                  select 1
43                  from   org_organization_definitions ood
44                  where  ood.organization_id = mti.organization_id
45                  and    nvl(ood.disable_date, sysdate + 1) > sysdate)
46        order by mti.inventory_item_id;
47 
48        cursor mti_inv_rec is
49        select rowid from mtl_transactions_interface mti
50        where PROCESS_FLAG = 1
51        AND NVL(LOCK_FLAG,2) = 2
52        AND TRANSACTION_MODE = 3
53        AND EXISTS (
54                  SELECT 'X'
55                  FROM MTL_TRANSACTION_TYPES MTT
56                  WHERE MTT.TRANSACTION_TYPE_ID = MTI.TRANSACTION_TYPE_ID
57                  AND MTT.TRANSACTION_SOURCE_TYPE_ID NOT IN (2,5,8,16))
58        and exists (
59                  select 1
60                  from   org_organization_definitions ood
61                  where  ood.organization_id = mti.organization_id
62                  and    nvl(ood.disable_date, sysdate + 1) > sysdate)
63        order by mti.inventory_item_id;
64 
65         l_cur_count  NUMBER := 0;
66         l_org_id     NUMBER;
67         l_item_id    NUMBER;
68         l_total      NUMBER := 0;
69         l_done       NUMBER := 0;
70         l_header_id  number;
71         l_unique     number := 0;
72         l_rowcount     NUMBER := 0;
73 
74         type rowid_type is table of rowid index by binary_integer;
75         l_rowid rowid_type;
76         l_req_id   number;
77 
78   begin
79 
80        print_debug('entered INV_ENHANCED_TM_PERF.launch_worker ');
81 
82        print_debug('p_maxrows '|| p_maxrows);
83        print_debug('p_applid '|| p_applid);
84        print_debug('p_progid '|| p_progid);
85        print_debug('p_userid '|| p_userid);
86        print_debug('p_reqstid '|| p_reqstid);
87        print_debug('p_loginid '|| p_loginid);
88        print_debug('p_src_type '|| p_src_type);
89 
90        /* Not grouping the records by org_id as the volume test that was conducted by starbucks
91           showed that by launching one worker per item across orgs significantly reduces the
92           latch contention and increases the throughput by almost 100%.
93        */
94 
95        if (p_src_type = 'SO') then
96 
97           print_debug('Processing SO source type transactions');
98 
99           select inventory_item_id, count(1) record_count
100           bulk collect into l_mti_rec
101           from mtl_transactions_interface mti
102           where PROCESS_FLAG = 1
103           AND NVL(LOCK_FLAG,2) = 2
104           AND TRANSACTION_MODE = 3
105           AND EXISTS (
106                     SELECT 'X'
107                     FROM MTL_TRANSACTION_TYPES MTT
108                     WHERE MTT.TRANSACTION_TYPE_ID = MTI.TRANSACTION_TYPE_ID
109                     AND MTT.TRANSACTION_SOURCE_TYPE_ID IN (2,8,16))
110           and exists (
111                     select 1
112                     from   org_organization_definitions ood
113                     where  ood.organization_id = mti.organization_id
114                     and    nvl(ood.disable_date, sysdate + 1) > sysdate)
115           group by inventory_item_id
116           having count(*) >= p_maxrows
117           order by record_count desc;
118 
119           print_debug('processing '|| l_mti_rec.count || ' items having records more than maxrows ');
120 
121           for i in 1..l_mti_rec.COUNT loop
122 
123              l_header_id := get_seq_nextval;
124              print_debug('updating item_id '|| l_mti_rec(i).item_id || ' with header_id '||l_header_id);
125 
126              l_rowcount := 0;
127 
128              update mtl_transactions_interface mti
129                 set transaction_header_id = l_header_id,
130                            last_update_date = sysdate,
131                            last_updated_by = p_userid,
132                            LAST_UPDATE_LOGIN = p_loginid,
133                            PROGRAM_APPLICATION_ID = p_applid,
134                            program_id = p_progid,
135                            REQUEST_ID = p_reqstid,
136                            PROGRAM_UPDATE_DATE = SYSDATE,
137                            LOCK_FLAG = 1,
138                            error_code = null,
139                            error_explanation = null
140               where inventory_item_id = l_mti_rec(i).item_id
141                 and process_flag = 1
142                 and nvl(lock_flag,2) = 2
143                 and transaction_mode = 3
144                 and exists (
145                       select 'X'
146                       FROM MTL_TRANSACTION_TYPES MTT
147                       where mtt.transaction_type_id = mti.transaction_type_id
148                       and mtt.transaction_source_type_id in (2,8,16))
149                 and exists (
150                       select 1
151                       from   org_organization_definitions ood
152                       where  ood.organization_id = mti.organization_id
153                       and    nvl(ood.disable_date, sysdate + 1) > sysdate);
154 
155               l_rowcount := l_rowcount + sql%rowcount;
156               print_debug('l_rowcount is '||l_rowcount);
157 
158               print_debug('updating rows with same batch_id ');
159               update mtl_transactions_interface mti
160                        set transaction_header_id = l_header_id,
161                            last_update_date = sysdate,
162                      last_updated_by = p_userid,
163                      LAST_UPDATE_LOGIN = p_loginid,
164                      PROGRAM_APPLICATION_ID = p_applid,
165                      program_id = p_progid,
166                      request_id = p_reqstid,
167                            program_update_date = sysdate,
168                            lock_flag = 1,
169                            error_code = null,
170                            error_explanation = null
171                where process_flag = 1
172                        and nvl(lock_flag,2) = 2
173                        and transaction_mode = 3
174                        and exists (
175                                   select 'X'
176                                   from mtl_transaction_types mtt
177                       where mtt.transaction_type_id = mti.transaction_type_id
178                                   and mtt.transaction_source_type_id in (2,8,16))
179                        and transaction_batch_id is not null
180                        and transaction_batch_id in (
181                       select mti2.transaction_batch_id
182                       from mtl_transactions_interface mti2
183                                               where mti2.transaction_header_id = l_header_id
184                                               and mti2.transaction_batch_id is not null
185                                               and mti2.lock_flag = 1
186                                               and mti2.error_code is null
187                                               and mti2.error_explanation is null)
188                        and exists (                                           /* Bug 6223219 */
189                                         select 1
190                                         from   org_organization_definitions ood
191                                   where  ood.organization_id = mti.organization_id
192                                         and    nvl(ood.disable_date, sysdate + 1) > sysdate);
193 
194               l_rowcount := l_rowcount + sql%rowcount;
195               print_debug('l_rowcount is '||l_rowcount);
196 
197               print_debug('launching INCTCW Worker');
198               l_req_id := fnd_request.submit_request( application => 'INV'
199                                           ,program     => 'INCTCW'
200                                           ,argument1   => l_header_id
201                                           ,argument2   => 3 --l_table
202                                           ,argument3   =>''
203                                           ,argument4   =>'');
204 
205               if (l_req_id = 0) then
206                 -- Handle submission error --
207                 print_debug('Error launching INCTCW Worker');
208                 raise fnd_api.g_exc_error;
209               else
210                 commit;
211               END IF;
212 
213               print_debug('INCTCW Concurrent Request_id is ' || l_req_id);
214 
215           end loop;
216 
217 
218           print_debug('processing items having records less than maxrows ');
219 
220           loop
221              l_rowid.DELETE;
222 
223              print_debug('opening mti_so_rec cursor ');
224 
225              open mti_so_rec;
226              EXIT WHEN mti_so_rec%notfound;
227 
228              fetch mti_so_rec bulk collect into l_rowid limit p_maxrows;
229 
230              if l_rowid.first is null then
231                 print_debug('rowid list is empty... exiting ');
232                 exit;
233              end if;
234 
235              print_debug('updating '|| l_rowid.COUNT || ' rows ');
236 
237              l_header_id := get_seq_nextval;
238 
239              print_debug('l_header_id '|| l_header_id);
240 
241              l_rowcount := 0;
242 
243              forall j in l_rowid.first..l_rowid.last
244                    update mtl_transactions_interface
245                       SET transaction_header_id = l_header_id,
246                            last_update_date = sysdate,
247                            last_updated_by = p_userid,
248                            LAST_UPDATE_LOGIN = p_loginid,
249                            PROGRAM_APPLICATION_ID = p_applid,
250                            program_id = p_progid,
251                            REQUEST_ID = p_reqstid,
252                            PROGRAM_UPDATE_DATE = SYSDATE,
253                            LOCK_FLAG = 1,
254                            error_code = null,
255                            error_explanation = null
256                     where  rowid = l_rowid(j);
257 
258              l_rowcount := l_rowcount + sql%rowcount;
259 
260              print_debug('l_rowcount is '||l_rowcount);
261 
262              if (l_rowcount = 0) then
263                print_debug('no more rows to process... exiting ');
264                exit;
265              end if;
266 
267              print_debug('updating rows with same item_id ');
268 
269              update mtl_transactions_interface mti
270                SET TRANSACTION_HEADER_ID = l_header_id,
271                    last_update_date = sysdate,
272                    last_updated_by = p_userid,
273                    LAST_UPDATE_LOGIN = p_loginid,
274                    PROGRAM_APPLICATION_ID = p_applid,
275                    program_id = p_progid,
276                    REQUEST_ID = p_reqstid,
277                    PROGRAM_UPDATE_DATE = SYSDATE,
278                    LOCK_FLAG = 1,
279                    ERROR_CODE = NULL,
280                    error_explanation = null
281              WHERE PROCESS_FLAG = 1
282                and nvl(lock_flag,2) = 2
283                and transaction_mode = 3
284                and exists (
285                   select 'X'
286                   from mtl_transaction_types mtt
287                   where mtt.transaction_type_id = mti.transaction_type_id
288                   and mtt.transaction_source_type_id in (2,8,16))
289                and inventory_item_id in (
290                          select mti2.inventory_item_id
291                          from mtl_transactions_interface mti2
292                          where mti2.transaction_header_id = l_header_id
293                          and mti2.LOCK_FLAG = 1
294                          and mti2.error_code is null
295                          and mti2.ERROR_EXPLANATION is NULL)
296                and exists (                                            /* Bug 5951465 */
297                    SELECT 1
298                    from   org_organization_definitions ood
299                    where  ood.organization_id = mti.organization_id
300                    and    nvl(ood.disable_date, sysdate + 1) > sysdate);
301 
302              l_rowcount := l_rowcount + sql%rowcount;
303 
304              print_debug('l_rowcount is ' || l_rowcount);
305 
306              print_debug('updating rows with same batch_id ');
307 
308              update mtl_transactions_interface mti
309                        set transaction_header_id = l_header_id,
310                            last_update_date = sysdate,
311                            last_updated_by = p_userid,
312                      last_update_login = p_loginid,
313                      program_application_id = p_applid,
314                      program_id = p_progid,
315                      REQUEST_ID = p_reqstid,
316                            program_update_date = sysdate,
317                            lock_flag = 1,
318                            error_code = null,
319                            error_explanation = null
320                where process_flag = 1
321                        and nvl(lock_flag,2) = 2
322                        and transaction_mode = 3
323                        and exists (
324                                   select 'X'
325                                   from mtl_transaction_types mtt
326                       where mtt.transaction_type_id = mti.transaction_type_id
327                                   and mtt.transaction_source_type_id in (2,8,16))
328                        and transaction_batch_id is not null
329                        and transaction_batch_id in (
330                       select mti2.transaction_batch_id
331                       from mtl_transactions_interface mti2
332                                               where mti2.transaction_header_id = l_header_id
333                                               and mti2.transaction_batch_id is not null
334                                               and mti2.lock_flag = 1
335                                               and mti2.error_code is null
336                                               and mti2.error_explanation is null)
337                        and exists (                                           /* Bug 6223219 */
338                                         select 1
339                                         from   org_organization_definitions ood
340                                   where  ood.organization_id = mti.organization_id
341                                         and    nvl(ood.disable_date, sysdate + 1) > sysdate);
342 
343              l_rowcount := l_rowcount + SQL%ROWCOUNT;
344 
345              print_debug('l_rowcount is ' || l_rowcount);
346 
347              print_debug('launching INCTCW Worker');
348              l_req_id := fnd_request.submit_request( application => 'INV'
349                                           ,program     => 'INCTCW'
350                                           ,argument1   => l_header_id
351                                           ,argument2   => 3 --l_table
352                                           ,argument3   =>''
353                                           ,argument4   =>'' );
354 
355              if (l_req_id = 0) then
356                 -- Handle submission error --
357                 print_debug('Error launching INCTCW Worker');
358                 raise fnd_api.g_exc_error;
359              else
360                 commit;
361              END IF;
362 
363              print_debug('INCTCW Concurrent Request_id is ' || l_req_id);
364 
365              if  mti_so_rec%isopen then
366                 close mti_so_rec;
367              END IF;
368 
369           end loop;
370        elsif (p_src_type = 'INV') then
371 
372           print_debug('Processing INV source type transactions');
373 
374           select inventory_item_id, count(1) record_count
375           bulk collect into l_mti_rec
376           from mtl_transactions_interface mti
377           where PROCESS_FLAG = 1
378           AND NVL(LOCK_FLAG,2) = 2
379           AND TRANSACTION_MODE = 3
380           AND EXISTS (
381                     SELECT 'X'
382                     FROM MTL_TRANSACTION_TYPES MTT
383                     WHERE MTT.TRANSACTION_TYPE_ID = MTI.TRANSACTION_TYPE_ID
384                     AND MTT.TRANSACTION_SOURCE_TYPE_ID NOT IN (2,5,8,16))
385           and exists (
386                     select 1
387                     from   org_organization_definitions ood
388                     where  ood.organization_id = mti.organization_id
389                     and    nvl(ood.disable_date, sysdate + 1) > sysdate)
390           group by inventory_item_id
391           having count(*) >= p_maxrows
392           order by record_count desc;
393 
394           print_debug('processing '|| l_mti_rec.count || ' items having records more than maxrows ');
395 
396           for i in 1..l_mti_rec.COUNT loop
397 
398              l_header_id := get_seq_nextval;
399              print_debug('updating item_id '|| l_mti_rec(i).item_id || ' with header_id '||l_header_id);
400 
401              l_rowcount := 0;
402 
403              update mtl_transactions_interface mti
404                 set transaction_header_id = l_header_id,
405                            last_update_date = sysdate,
406                            last_updated_by = p_userid,
407                            LAST_UPDATE_LOGIN = p_loginid,
408                            PROGRAM_APPLICATION_ID = p_applid,
409                            program_id = p_progid,
410                            REQUEST_ID = p_reqstid,
411                            PROGRAM_UPDATE_DATE = SYSDATE,
412                            LOCK_FLAG = 1,
413                            error_code = null,
414                            error_explanation = null
415               where inventory_item_id = l_mti_rec(i).item_id
416                 and process_flag = 1
417                 and nvl(lock_flag,2) = 2
418                 and transaction_mode = 3
419                 and exists (
420                       select 'X'
421                       FROM MTL_TRANSACTION_TYPES MTT
422                       where mtt.transaction_type_id = mti.transaction_type_id
423                       and mtt.transaction_source_type_id not in (2,5,8,16))
424                 and exists (
425                       select 1
426                       from   org_organization_definitions ood
427                       where  ood.organization_id = mti.organization_id
428                       and    nvl(ood.disable_date, sysdate + 1) > sysdate);
429 
430               l_rowcount := l_rowcount + sql%rowcount;
431               print_debug('l_rowcount is '||l_rowcount);
432 
433               print_debug('updating rows with same batch_id ');
434               update mtl_transactions_interface mti
435                        set transaction_header_id = l_header_id,
436                            last_update_date = sysdate,
437                      last_updated_by = p_userid,
438                      LAST_UPDATE_LOGIN = p_loginid,
439                      PROGRAM_APPLICATION_ID = p_applid,
440                      program_id = p_progid,
441                      request_id = p_reqstid,
442                            program_update_date = sysdate,
443                            lock_flag = 1,
444                            error_code = null,
445                            error_explanation = null
446                where process_flag = 1
447                        and nvl(lock_flag,2) = 2
448                        and transaction_mode = 3
449                        and exists (
450                                   select 'X'
451                                   from mtl_transaction_types mtt
452                       where mtt.transaction_type_id = mti.transaction_type_id
453                                   and mtt.transaction_source_type_id not in (2,5,8,16))
454                        and transaction_batch_id is not null
455                        and transaction_batch_id in (
456                       select mti2.transaction_batch_id
457                       from mtl_transactions_interface mti2
458                                               where mti2.transaction_header_id = l_header_id
459                                               and mti2.transaction_batch_id is not null
460                                               and mti2.lock_flag = 1
461                                               and mti2.error_code is null
462                                               and mti2.error_explanation is null)
463                        and exists (                                           /* Bug 6223219 */
464                                         select 1
465                                         from   org_organization_definitions ood
466                                   where  ood.organization_id = mti.organization_id
467                                         and    nvl(ood.disable_date, sysdate + 1) > sysdate);
468 
469               l_rowcount := l_rowcount + sql%rowcount;
470               print_debug('l_rowcount is '||l_rowcount);
471 
472               print_debug('launching INCTCW Worker');
473               l_req_id := fnd_request.submit_request( application => 'INV'
474                                           ,program     => 'INCTCW'
475                                           ,argument1   => l_header_id
476                                           ,argument2   => 3 --l_table
477                                           ,argument3   =>''
478                                           ,argument4   =>'');
479 
480               if (l_req_id = 0) then
481                 -- Handle submission error --
482                 print_debug('Error launching INCTCW Worker');
483                 raise fnd_api.g_exc_error;
484               else
485                 commit;
486               END IF;
487 
488               print_debug('INCTCW Concurrent Request_id is ' || l_req_id);
489 
490           end loop;
491 
492 
493           print_debug('processing items having records less than maxrows ');
494 
495           loop
496              l_rowid.DELETE;
497 
498              print_debug('opening mti_inv_rec cursor ');
499 
500              open mti_inv_rec;
501              EXIT WHEN mti_inv_rec%notfound;
502 
503              fetch mti_inv_rec bulk collect into l_rowid limit p_maxrows;
504 
505              if l_rowid.first is null then
506                 print_debug('rowid list is empty... exiting ');
507                 exit;
508              end if;
509 
510              print_debug('updating '|| l_rowid.COUNT || ' rows ');
511 
512              l_header_id := get_seq_nextval;
513 
514              print_debug('l_header_id '|| l_header_id);
515 
516              l_rowcount := 0;
517 
518              forall j in l_rowid.first..l_rowid.last
519                    update mtl_transactions_interface
520                       SET transaction_header_id = l_header_id,
521                            last_update_date = sysdate,
522                            last_updated_by = p_userid,
523                            LAST_UPDATE_LOGIN = p_loginid,
524                            PROGRAM_APPLICATION_ID = p_applid,
525                            program_id = p_progid,
526                            REQUEST_ID = p_reqstid,
527                            PROGRAM_UPDATE_DATE = SYSDATE,
528                            LOCK_FLAG = 1,
529                            error_code = null,
530                            error_explanation = null
531                     where  rowid = l_rowid(j);
532 
533              l_rowcount := l_rowcount + sql%rowcount;
534 
535              print_debug('l_rowcount is '||l_rowcount);
536 
537              if (l_rowcount = 0) then
538                print_debug('no more rows to process... exiting ');
539                exit;
540              end if;
541 
542              print_debug('updating rows with same item_id ');
543 
544              update mtl_transactions_interface mti
545                SET TRANSACTION_HEADER_ID = l_header_id,
546                    last_update_date = sysdate,
547                    last_updated_by = p_userid,
548                    LAST_UPDATE_LOGIN = p_loginid,
549                    PROGRAM_APPLICATION_ID = p_applid,
550                    program_id = p_progid,
551                    REQUEST_ID = p_reqstid,
552                    PROGRAM_UPDATE_DATE = SYSDATE,
553                    LOCK_FLAG = 1,
554                    ERROR_CODE = NULL,
555                    error_explanation = null
556              WHERE PROCESS_FLAG = 1
557                and nvl(lock_flag,2) = 2
558                and transaction_mode = 3
559                and exists (
560                   select 'X'
561                   from mtl_transaction_types mtt
562                   where mtt.transaction_type_id = mti.transaction_type_id
563                   and mtt.transaction_source_type_id not in (2,5,8,16))
564                and inventory_item_id in (
565                          select mti2.inventory_item_id
566                          from mtl_transactions_interface mti2
567                          where mti2.transaction_header_id = l_header_id
568                          and mti2.LOCK_FLAG = 1
569                          and mti2.error_code is null
570                          and mti2.ERROR_EXPLANATION is NULL)
571                and exists (                                            /* Bug 5951465 */
572                    SELECT 1
573                    from   org_organization_definitions ood
574                    where  ood.organization_id = mti.organization_id
575                    and    nvl(ood.disable_date, sysdate + 1) > sysdate);
576 
577              l_rowcount := l_rowcount + sql%rowcount;
578 
579              print_debug('l_rowcount is ' || l_rowcount);
580 
581              print_debug('updating rows with same batch_id ');
582 
583              update mtl_transactions_interface mti
584                 set transaction_header_id = l_header_id,
585                     last_update_date = sysdate,
586                     last_updated_by = p_userid,
587                     last_update_login = p_loginid,
588                     program_application_id = p_applid,
589                     program_id = p_progid,
590                     REQUEST_ID = p_reqstid,
591                     program_update_date = sysdate,
592                     lock_flag = 1,
593                     error_code = null,
594                     error_explanation = null
595                where process_flag = 1
596                        and nvl(lock_flag,2) = 2
597                        and transaction_mode = 3
598                        and exists (
599                                   select 'X'
600                                   from mtl_transaction_types mtt
601                       where mtt.transaction_type_id = mti.transaction_type_id
602                                   and mtt.transaction_source_type_id not in (2,5,8,16))
603                        and transaction_batch_id is not null
604                        and transaction_batch_id in (
605                       select mti2.transaction_batch_id
606                       from mtl_transactions_interface mti2
607                                               where mti2.transaction_header_id = l_header_id
608                                               and mti2.transaction_batch_id is not null
609                                               and mti2.lock_flag = 1
610                                               and mti2.error_code is null
611                                               and mti2.error_explanation is null)
612                        and exists (                                           /* Bug 6223219 */
613                                         select 1
614                                         from   org_organization_definitions ood
615                                   where  ood.organization_id = mti.organization_id
616                                         and    nvl(ood.disable_date, sysdate + 1) > sysdate);
617 
618              l_rowcount := l_rowcount + SQL%ROWCOUNT;
619 
620              print_debug('l_rowcount is ' || l_rowcount);
621 
622              print_debug('launching INCTCW Worker');
623              l_req_id := fnd_request.submit_request( application => 'INV'
624                                           ,program     => 'INCTCW'
625                                           ,argument1   => l_header_id
626                                           ,argument2   => 3 --l_table
627                                           ,argument3   =>''
628                                           ,argument4   =>'' );
629 
630              if (l_req_id = 0) then
631                 -- Handle submission error --
632                 print_debug('Error launching INCTCW Worker');
633                 raise fnd_api.g_exc_error;
634              else
635                 commit;
636              END IF;
637 
638              print_debug('INCTCW Concurrent Request_id is ' || l_req_id);
639 
640              if  mti_inv_rec%isopen then
641                 close mti_inv_rec;
642              END IF;
643 
644           end loop;
645        end if; -- p_src_type
646 
647        IF mti_so_rec%ISOPEN THEN
648           CLOSE mti_so_rec;
649        END IF;
650        IF mti_inv_rec%ISOPEN THEN
651           CLOSE mti_inv_rec;
652        END IF;
653 
654        x_ret_status := 0;
655        print_debug('x_ret_status ' || x_ret_status);
656 
657   exception
658     WHEN OTHERS THEN
659       print_debug('Error :'||substr(sqlerrm, 1, 200));
660 
661       IF mti_so_rec%ISOPEN THEN
662           CLOSE mti_so_rec;
663       END IF;
664       IF mti_inv_rec%ISOPEN THEN
665           CLOSE mti_inv_rec;
666       END IF;
667 
668       x_ret_status  := 1;
669       x_ret_message := substr(sqlerrm, 1, 200);
670 
671   end launch_worker;
672 
673   function get_seq_nextval
674   RETURN number
675   is
676 
677     l_value number;
678   begin
679 
680     select mtl_material_transactions_s.nextval
681       into l_value
682     from dual;
683 
684     return l_value;
685 
686   exception
687     when others then
688        l_value := -1;
689        print_debug('Error in get_seq_nextval:'||substr(sqlerrm, 1, 200));
690        return l_value;
691 
692   END get_seq_nextval;
693 
694 END INV_ENHANCED_TM_PERF ;