DBA Data[Home] [Help]

PACKAGE BODY: APPS.OKL_CNTRCT_FIN_EXT_MASTER_PVT

Source


1 PACKAGE BODY OKL_CNTRCT_FIN_EXT_MASTER_PVT AS
2 /* $Header: OKLRFECB.pls 120.0.12010000.7 2009/09/25 22:03:57 sechawla noship $*/
3 
4   -- -------------------------------------------------
5   -- To print log messages
6   -- -------------------------------------------------
7 
8 
9   PROCEDURE write_to_log(
10                          p_message IN VARCHAR2
11                         ) IS
12   BEGIN
13 
14     fnd_file.put_line(fnd_file.log, p_message);
15   END write_to_log;
16 
17 
18   PROCEDURE write_to_output(
19                          p_message IN VARCHAR2
20                         ) IS
21   BEGIN
22 
23     fnd_file.put_line(fnd_file.output, p_message);
24   END write_to_output;
25 
26 
27   /*========================================================================
28  | PUBLIC PROCEDURE Process_Spawner
29  |
30  | DESCRIPTION
31  |    This procedure identifies contracts for Contract Financial Report, based
32  |    upon a few primary input paramaters, inserts these contracts into a temp table and
33  |    assigns a worker to each contract. It then spawns child request(s), based upon
34  |    the parameter 'p_num_processes'. Once child requests complete, it launches
35  |    request for Contract Financial Report
36  |
37  | CALLED FROM
38  |    Concurrent Program "Master Program -- Contract Financial Report"
39  |
40  | CALLS PROCEDURES/FUNCTIONS
41  |
42  | KNOWN ISSUES
43  |
44  | NOTES
45  |
46  |
47  | MODIFICATION HISTORY
48  | Date                  Author            Description of Changes
49  | 19-Sep-2008           SECHAWLA           Created
50  *=======================================================================*/
51 
52   PROCEDURE Process_Spawner (
53 
54   							errbuf             		OUT NOCOPY VARCHAR2,
55                             retcode            		OUT NOCOPY NUMBER,
56                             P_OPERATING_UNIT       	IN NUMBER,
57                             --P_REPORT_DATE			IN VARCHAR2, sechawla 25-sep-09 8890513
58                             P_DATA_SOURCE_CODE      IN VARCHAR2,
59                             P_REPORT_TEMPLATE_NAME  IN VARCHAR2,
60 							P_REPORT_LANGUAGE		IN VARCHAR2,
61                             P_REPORT_FORMAT			IN VARCHAR2,
62                             P_START_DATE_FROM  	    IN VARCHAR2,
63                             P_START_DATE_TO    	    IN VARCHAR2,
64                             P_AR_INFO_YN			IN VARCHAR2,
65                             P_BOOK_CLASS			IN VARCHAR2,
66                             P_LEASE_PRODUCT			IN VARCHAR2,
67                             P_CONTRACT_STATUS		IN VARCHAR2,
68                             P_CUSTOMER_NUMBER		IN VARCHAR2,
69 							P_CUSTOMER_NAME			IN VARCHAR2,
70 							P_SIC_CODE				IN VARCHAR2,
71 							P_VENDOR_NUMBER			IN VARCHAR2,
72 							P_VENDOR_NAME			IN VARCHAR2,
73 							P_SALES_CHANNEL			IN VARCHAR2,
74 							P_GEN_ACCRUAL			IN VARCHAR2,
75 							P_END_DATE_FROM		    IN VARCHAR2,
76                             P_END_DATE_TO			IN VARCHAR2,
77                             P_TERMINATE_DATE_FROM   IN VARCHAR2,
78 							P_TERMINATE_DATE_TO		IN VARCHAR2,
79 							P_DELETE_DATA_YN		IN VARCHAR2,
80                             p_num_processes    		IN NUMBER
81 
82 
83                          ) IS
84 
85 
86    CURSOR l_parallel_worker_csr(cp_assigned_process IN VARCHAR2) IS
87    SELECT object_value, khr_id, assigned_process
88    FROM   OKL_PARALLEL_PROCESSES
89    WHERE  object_type = 'CONTRACT_FIN_EXTRACT'
90    AND    assigned_process = cp_assigned_process
91    AND    process_status = 'PENDING_ASSIGNMENT';
92 
93    CURSOR parent_sts_csr(p_request_id NUMBER) IS
94 	SELECT count(*)
95 		from fnd_concurrent_requests req,
96 		     fnd_concurrent_programs pgm
97 		where req.PRIORITY_REQUEST_ID = p_request_id
98 		and req.concurrent_program_id = pgm.concurrent_program_id
99 		and req.PHASE_CODE = 'C'
100 		and request_id <> p_request_id
101 		and STATUS_CODE = 'E';
102 
103   CURSOR parent_warn_sts_csr(p_request_id NUMBER) IS
104 	SELECT count(*)
105         from fnd_concurrent_requests req,
106              fnd_concurrent_programs pgm
107         where req.priority_request_id = p_request_id
108         and req.concurrent_program_id = pgm.concurrent_program_id
109         and req.phase_code = 'C'
110         and request_id <> p_request_id
111         and status_code = 'G';
112 
113   l_int_counter       			INTEGER;
114   l_init_loop         			BOOLEAN := TRUE;
115   l_seq_next          			NUMBER;
116   l_char_seq_num				VARCHAR2(30);
117   l_data_found        			BOOLEAN := FALSE;
118   lp_k_start_date_from        	DATE;
119   lp_k_start_date_to          	DATE;
120   lp_k_end_date_from        	DATE;
121   lp_k_end_date_to          	DATE;
122   l_req_data          			VARCHAR2(10);
123   l_req_counter       			NUMBER;
124   request_id 					NUMBER := 0;
125   l_last_worker_used			NUMBER;
126   TYPE parallel_worker_tbl_type IS TABLE OF l_parallel_worker_csr%ROWTYPE INDEX BY BINARY_INTEGER;
127 
128   l_parallel_worker_tbl			parallel_worker_tbl_type;
129   l_parallel_worker_temp_tbl	parallel_worker_tbl_type;
130 
131   l_fetch_size                  NUMBER := 10000;
132   l_total_rows 					NUMBER := 0;
133   l_this_row					NUMBER;
134   l_max_worker_used				NUMBER;
135 
136   -- Org Id and standard who columns
137   l_last_updated_by     		okl_parallel_processes.last_updated_by%TYPE := Fnd_Global.USER_ID;
138   l_last_update_login   		okl_parallel_processes.last_update_login%TYPE := Fnd_Global.LOGIN_ID;
139   l_request_id          		okl_parallel_processes.request_id%TYPE := Fnd_Global.CONC_REQUEST_ID;
140   l_program_id          		okl_parallel_processes.program_id%TYPE := Fnd_Global.CONC_PROGRAM_ID;
141   l_org_id              		okl_parallel_processes.org_id%type;
142 
143   l_child_in_error       		NUMBER;
144   l_child_in_warn       		NUMBER;
145 
146   i								NUMBER;
147   report_request_id				NUMBER := 0;
148   l_row_count					NUMBER;
149   p_ret_add_layout 				BOOLEAN := true;
150   --lp_report_date				DATE; --sechawla 25-sep-09 8890513
151 
152 begin
153 
154 
155   -- The following block is added to control the sub-request program
156   -- submission. It ensures that this program is not executed recurrsively.
157   l_req_data := fnd_conc_global.request_data;
158   -- If l_req_data has a value within this session, the program is attempting to
159   -- run again, therefore break out of the loop.
160 
161 
162    -- Add couple of blank lines
163   fnd_file.new_line(fnd_file.log,2);
164   fnd_file.new_line(fnd_file.output,2);
165 
166 
167   write_to_log('l_req_data : '||l_req_data);
168 
169   MO_GLOBAL.set_policy_context('S',p_operating_unit);
170 
171   if l_req_data is not null and l_req_data = '1' then
172 
173 
174     l_child_in_error := 0;
175     OPEN  parent_sts_csr( l_request_id );
176     FETCH parent_sts_csr INTO l_child_in_error;
177     CLOSE parent_sts_csr;
178 
179     write_to_log('l_child_in_error : '||l_child_in_error);
180     l_child_in_warn := 0;
181     OPEN  parent_warn_sts_csr( l_request_id );
182     FETCH parent_warn_sts_csr INTO l_child_in_warn;
183     CLOSE parent_warn_sts_csr;
184 
185     write_to_log('l_child_in_warn : '||l_child_in_warn);
186 
187     if l_child_in_error > 0 then
188         errbuf := 'Done, but with error!';
189         retcode := 2;
190         return;
191     end if;
192 
193     if l_child_in_warn > 0 then
194         errbuf := 'Done, but with warning(s)!';
195         retcode := 1;
196         return;
197     end if;
198 
199 
200 
201     FND_REQUEST.set_org_id(mo_global.get_current_org_id); --MOAC- Concurrent request
202 
203     --P_REPORT_TEMPLATE_NAME <-> value set 'OKL_XDO_REP_TEMPLATE' <-> stores the template code (in ID column)
204     --P_REPORT_LANGUAGE <-> value set 'OKL_XDO_REP_LANGUAGE' <-> stores language code e.g 'en' (in ID column)
205     --P_REPORT_FORMAT <-> value set 'OKL_XDO_REP_FORMAT' <-> stores format code e.g 'RTF' (in ID column)
206     p_ret_add_layout := FND_REQUEST.add_layout(	template_appl_name=>'OKL',
207 																template_code=> P_REPORT_TEMPLATE_NAME, --'OKLFINEXTR',
208 																template_language=> P_REPORT_LANGUAGE, --'en', --sechawla 7628379
209 																template_territory=>'00',
210 																output_format=>P_REPORT_FORMAT); --'RTF');--sechawla 7628379
211 	IF 	p_ret_add_layout THEN
212 	    write_to_log('p_ret_add_layout = TRUE');
213 	ELSE
214 	    write_to_log('p_ret_add_layout = FALSE');
215 	END IF;
216 
217     report_request_id := FND_REQUEST.SUBMIT_REQUEST(
218                           application => 'OKL',
219                           program     => 'OKLFINEXTR',
220                           sub_request => TRUE,
221                           argument1   => P_OPERATING_UNIT,
222                           --argument2   => P_REPORT_DATE, sechawla 25-sep-09 8890513 : removed report_date and re sequenced following paramaters
223                           argument2   => P_START_DATE_FROM,
224                           argument3   => P_START_DATE_TO,
225                           argument4   => P_AR_INFO_YN,
226                           argument5   => P_BOOK_CLASS,
227                           argument6   => P_LEASE_PRODUCT,
228                           argument7   => P_CONTRACT_STATUS,
229                           argument8   => P_CUSTOMER_NUMBER,
230              			  argument9  => P_CUSTOMER_NAME,
231              			  argument10  => P_SIC_CODE,
232              			  argument11  => P_VENDOR_NUMBER,
233              			  argument12  => P_VENDOR_NAME,
234              			  argument13  => P_SALES_CHANNEL,
235              			  argument14  => P_GEN_ACCRUAL,
236              			  argument15  => P_END_DATE_FROM,
237              			  argument16  => P_END_DATE_TO,
238              			  argument17  => P_TERMINATE_DATE_FROM,
239              			  argument18  => P_TERMINATE_DATE_TO,
240              			  argument19  => P_DELETE_DATA_YN
241 
242                          );
243 
244 
245     write_to_log('Launching Report with Request ID '||report_request_id);
246 
247     if (report_request_id = 0) then
248 
249 
250     	write_to_log('Request submission failed. ');
251         write_to_log('Exiting with error... ');
252 
253         -- If request submission failed, exit with error
254         errbuf := fnd_message.get;
255         retcode := 2;
256     else
257         write_to_log('Report Sub-Request submitted, putting master into PAUSED mode');
258         --Set the globals to put the master into PAUSED mode
259         fnd_conc_global.set_req_globals(conc_status => 'PAUSED',
260                                      	request_data => to_char(2));
261         errbuf := 'Sub-Request submitted!';
262         retcode := 0;
263     end if;
264 
265 elsif  l_req_data is not null and l_req_data = '2' then
266     l_child_in_error := 0;
267     OPEN  parent_sts_csr( l_request_id );
268     FETCH parent_sts_csr INTO l_child_in_error;
269     CLOSE parent_sts_csr;
270 
271     write_to_log('l_child_in_error : '||l_child_in_error);
272     l_child_in_warn := 0;
273     OPEN  parent_warn_sts_csr( l_request_id );
274     FETCH parent_warn_sts_csr INTO l_child_in_warn;
275     CLOSE parent_warn_sts_csr;
276 
277     write_to_log('l_child_in_warn : '||l_child_in_warn);
278 
279     if l_child_in_error > 0 then
280         errbuf := 'Done, but with error!';
281         retcode := 2;
282         return;
283     end if;
284 
285     if l_child_in_warn > 0 then
286         errbuf := 'Done, but with warning(s)!';
287         retcode := 1;
288         return;
289     end if;
290 
291     write_to_log('Returning Successfully');
292     errbuf := 'Done!';
293     retcode := 0;
294     return;
295 
296   end if;
297 
298 IF l_req_data IS NULL THEN
299 
300 
301 
302 	write_to_log('P_OPERATING_UNIT = '||P_OPERATING_UNIT);
303 --	write_to_log('P_REPORT_DATE = '||P_REPORT_DATE); sechawla 25-sep-09 8890513
304 	write_to_log('P_DATA_SOURCE_CODE = '||P_DATA_SOURCE_CODE);
305 	write_to_log('P_REPORT_TEMPLATE_NAME ='|| P_REPORT_TEMPLATE_NAME);
306 	write_to_log('P_REPORT_LANGUAGE ='|| P_REPORT_LANGUAGE);
307 	write_to_log('P_REPORT_FORMAT ='|| P_REPORT_FORMAT);
308 	write_to_log('P_START_DATE_FROM = '||P_START_DATE_FROM);
309 	write_to_log('P_START_DATE_TO = '||P_START_DATE_TO);
310 	write_to_log('P_AR_INFO_YN = '||P_AR_INFO_YN);
311 	write_to_log('P_BOOK_CLASS = '||P_BOOK_CLASS);
312 	write_to_log('P_LEASE_PRODUCT = '||P_LEASE_PRODUCT);
313 	write_to_log('P_CONTRACT_STATUS = '||P_CONTRACT_STATUS);
314 	write_to_log('P_CUSTOMER_NUMBER = '||P_CUSTOMER_NUMBER);
315 	write_to_log('P_CUSTOMER_NAME = '||P_CUSTOMER_NAME);
316 	write_to_log('P_SIC_CODE = '||P_SIC_CODE);
317 	write_to_log('P_VENDOR_NUMBER = '||P_VENDOR_NUMBER);
318 	write_to_log('P_VENDOR_NAME = '||P_VENDOR_NAME);
319 	write_to_log('P_SALES_CHANNEL = '||P_SALES_CHANNEL);
320 	write_to_log('P_GEN_ACCRUAL = '||P_GEN_ACCRUAL);
321 	write_to_log('P_END_DATE_FROM = '||P_END_DATE_FROM);
322 	write_to_log('P_END_DATE_TO = '||P_END_DATE_TO);
323 	write_to_log('P_TERMINATE_DATE_FROM = '||P_TERMINATE_DATE_FROM);
324 	write_to_log('P_TERMINATE_DATE_TO = '||P_TERMINATE_DATE_TO);
325 	write_to_log('P_DELETE_DATA_YN '||P_DELETE_DATA_YN);
326 	write_to_log('p_num_processes = '||p_num_processes);
327 
328 
329 
330 
331 
332 --  lp_report_date := FND_DATE.CANONICAL_TO_DATE(P_REPORT_DATE);   sechawla 25-sep-09 8890513
333 
334 
335 
336   ---- Paramater validations -----
337   /* --sechawla 25-sep-09 8890513
338   IF trunc(lp_report_date) <>  trunc(sysdate) THEN
339      write_to_log('Report Date should be today''s date');
340      return;
341   END IF;
342   */
343 
344   -- If p_num_processes is 0 then no need to go through the algorithm.
345   -- p_num_processes can be 1
346   if ( nvl(p_num_processes,0) = 0 OR nvl(p_num_processes,0) < 0 )then
347     write_to_log('No workers specified');
348     return;
349   end if;
350 
351   lp_k_start_date_from := FND_DATE.CANONICAL_TO_DATE(P_START_DATE_FROM);
352   lp_k_start_date_to   := FND_DATE.CANONICAL_TO_DATE(P_START_DATE_TO);
353 
354 
355   IF P_END_DATE_FROM IS NOT NULL THEN
356      lp_k_end_date_from := FND_DATE.CANONICAL_TO_DATE(P_END_DATE_FROM);
357   END IF;
358 
359   IF P_END_DATE_TO IS NOT NULL THEN
360      lp_k_end_date_to   := FND_DATE.CANONICAL_TO_DATE(P_END_DATE_TO);
361   END IF;
362 
363   -- Select sequence for marking processes
364   select okl_opp_seq.nextval
365   into l_seq_next
366   from dual ;
367 
368   l_char_seq_num := to_char(l_seq_next);
369 
370   WRITE_TO_LOG('Sequence Number : '||l_seq_next);
371 
372   -- mark records for processing
373 
374   l_org_id := mo_global.get_current_org_id();
375   WRITE_TO_LOG('org id:: '||l_org_id);
376 
377 
378   INSERT INTO OKL_PARALLEL_PROCESSES
379     (
380      object_type, object_value, assigned_process, process_status, start_date, khr_id,
381      ORG_ID,CREATED_BY,CREATION_DATE,LAST_UPDATE_DATE,LAST_UPDATED_BY,LAST_UPDATE_LOGIN,
382      REQUEST_ID,PROGRAM_ID,PROGRAM_UPDATE_DATE
383     )
384   SELECT 'CONTRACT_FIN_EXTRACT', chr.contract_number, l_char_seq_num, 'PENDING_ASSIGNMENT', sysdate, chr.id ,
385           l_org_id,l_last_updated_by,sysdate,sysdate,l_last_updated_by,l_last_update_login,
386           l_request_id,l_program_id,sysdate
387   FROM   okc_k_headers_all_b chr,
388          OKL_K_HEADERS khr
389   WHERE  chr.id = khr.id
390   AND    chr.SCS_CODE = 'LEASE'
391   AND    chr.sts_code IN ('BANKRUPTCY_HOLD','ENTERED','BOOKED', 'COMPLETE', 'EVERGREEN', 'EXPIRED', 'INCOMPLETE',
392                           'LITIGATION_HOLD', 'NEW', 'PASSED', 'REVERSED', 'TERMINATED') --sechawla 13-jan-09 7693771
393   AND    chr.AUTHORING_ORG_ID = P_OPERATING_UNIT
394   AND    (chr.start_date IS NOT NULL AND chr.START_DATE >= lp_k_start_date_from)
395   AND    (chr.start_date IS NOT NULL AND chr.START_DATE <= lp_k_start_date_to)
396   AND    nvl(khr.DEAL_TYPE,'XXX') = nvl(P_BOOK_CLASS, nvl(khr.DEAL_TYPE,'XXX'))
397   AND    nvl(khr.pdt_id,-9999) = nvl(P_LEASE_PRODUCT,nvl(khr.pdt_id,-9999))
398   AND    chr.sts_code = nvl(P_CONTRACT_STATUS, chr.sts_code)
399   AND    ( (lp_k_end_date_from IS NULL) OR (chr.END_DATE IS NOT NULL AND chr.END_DATE >= lp_k_end_date_from) )
400   AND    ( (lp_k_end_date_to IS NULL  ) OR (chr.END_DATE IS NOT NULL AND chr.END_DATE <= lp_k_end_date_to)   )
401   AND    NOT EXISTS
402 		       (SELECT '1'
403 			    FROM OKL_PARALLEL_PROCESSES opp
404 		        WHERE chr.contract_number = opp.object_value
405 		        AND opp.object_type = 'CONTRACT_FIN_EXTRACT'
406 		        AND opp.process_status in ('PENDING_ASSIGNMENT', 'ASSIGNED'));
407 
408  l_row_count := SQL%ROWCOUNT;
409 
410  write_to_log('Number of rows inserted in OKL_PARALLEL_PROCESSES :'||l_row_count);
411 
412   IF l_row_count > 0 THEN
413       l_data_found := TRUE;
414 
415   END IF;
416 
417 
418   COMMIT;
419 
420 
421   if l_data_found then
422 
423     write_to_log('l_fetch_size : '||l_fetch_size);
424 
425 
426      i := 1;
427      l_parallel_worker_tbl.DELETE;
428      OPEN l_parallel_worker_csr(l_char_seq_num);
429      LOOP
430         l_parallel_worker_temp_tbl.DELETE;
431         FETCH l_parallel_worker_csr BULK COLLECT INTO l_parallel_worker_temp_tbl LIMIT l_fetch_size;
432 
433 
434         IF l_parallel_worker_temp_tbl.COUNT > 0 THEN
435            FOR k IN l_parallel_worker_temp_tbl.FIRST..l_parallel_worker_temp_tbl.LAST LOOP
436                l_parallel_worker_tbl(i).object_value := l_parallel_worker_temp_tbl(k).object_value;
437                l_parallel_worker_tbl(i).khr_id := l_parallel_worker_temp_tbl(k).khr_id;
438                l_parallel_worker_tbl(i).assigned_process := l_parallel_worker_temp_tbl(k).assigned_process;
439 
440                i := i + 1;
441             END LOOP;
442 
443         END IF;
444 
445         EXIT WHEN l_parallel_worker_csr%NOTFOUND;
446      END LOOP;
447      CLOSE l_parallel_worker_csr;
448 
449 	 l_total_rows :=  l_parallel_worker_tbl.count;
450 
451 	 write_to_log('l_parallel_worker_tbl.count :'||l_total_rows);
452 
453 
454      IF l_total_rows > 0 THEN
455         -- p_num_processes is > 0
456            l_this_row := 1;
457 
458            l_max_worker_used := 0;
459 
460            WHILE l_this_row <= l_total_rows LOOP
461               FOR j in 1..p_num_processes LOOP
462                   IF l_this_row <= l_total_rows THEN
463                      l_parallel_worker_tbl(l_this_row).assigned_process := l_parallel_worker_tbl(l_this_row).assigned_process||'-'||j ;
464 
465                      l_last_worker_used := j;
466 
467                      l_this_row := l_this_row + 1;
468                   ELSE
469                      EXIT;
470                   END IF;
471               END LOOP;
472 
473               if l_last_worker_used > l_max_worker_used then
474                  l_max_worker_used :=l_last_worker_used;
475               end if;
476 
477             END LOOP;
478 
479 	        write_to_log('l_max_worker_used :'||l_max_worker_used);
480 
481 	  		-- At this point, l_parallel_worker_tbl has all the contracts with an assigned process
482 	  		FOR k IN l_parallel_worker_tbl.FIRST..l_parallel_worker_tbl.LAST LOOP
483 
484 
485 				write_to_log('contract # : '||l_parallel_worker_tbl(k).object_value||': worker # '||l_parallel_worker_tbl(k).assigned_process);
486 	      		UPDATE OKL_PARALLEL_PROCESSES
487           		SET assigned_process = l_parallel_worker_tbl(k).assigned_process,
488               		process_status = 'ASSIGNED'
489 	      		WHERE object_Type = 'CONTRACT_FIN_EXTRACT'
490           		AND   object_value = l_parallel_worker_tbl(k).object_value
491           		AND   process_status = 'PENDING_ASSIGNMENT';
492 
493           		COMMIT;
494 	  		END LOOP;
495 
496 	        write_to_log('OKL_PARALLEL_PROCESSES Updated with worker assignment');
497 
498 	  		FOR j in 1..l_max_worker_used LOOP
499 
500 	      		l_req_data := fnd_conc_global.request_data;
501 
502 
503           		if (l_req_data is not null) then
504           			l_req_counter := l_req_counter + to_number(l_req_data);
505           		else
506           			l_req_counter := 1;
507           		end if;
508 
509                 -- l_req_counter = number of workers used ?
510           		write_to_log('Worker # :'||j||' l_req_data  : '||l_req_data||' l_req_counter : '||l_req_counter);
511           		if l_req_counter < (p_num_processes+1) then
512           			FND_REQUEST.set_org_id(mo_global.get_current_org_id); --MOAC- Concurrent request
513 
514 
515           			request_id := FND_REQUEST.SUBMIT_REQUEST(
516                           application => 'OKL',
517                           program     => 'OKL_CNTRCT_FIN_REP_CHILD', --short name for child conc program
518                           sub_request => TRUE,
519                           argument1   => P_OPERATING_UNIT,
520                           --argument2   => P_REPORT_DATE, --sechawla 25-sep-09 8890513
521                           argument2   => P_START_DATE_FROM,
522                           argument3   => P_START_DATE_TO,
523                           argument4   => P_AR_INFO_YN,
524                           argument5   => P_BOOK_CLASS,
525                           argument6   => P_LEASE_PRODUCT,
526                           argument7   => P_CONTRACT_STATUS,
527                           argument8   => P_CUSTOMER_NUMBER,
528              			  argument9  => P_CUSTOMER_NAME,
529              			  argument10  => P_SIC_CODE,
530              			  argument11  => P_VENDOR_NUMBER,
531              			  argument12  => P_VENDOR_NAME,
532              			  argument13  => P_SALES_CHANNEL,
533              			  argument14  => P_GEN_ACCRUAL,
534              			  argument15  => P_END_DATE_FROM,
535              			  argument16  => P_END_DATE_TO,
536              			  argument17  => P_TERMINATE_DATE_FROM,
537              			  argument18  => P_TERMINATE_DATE_TO,
538              			  argument19  => P_DELETE_DATA_YN,
539              			  argument20  => p_num_processes,
540              			  argument21  => l_seq_next||'-'||j
541                          );
542 
543 
544           			write_to_log('Launching Process '||l_seq_next||'-'||j ||' with Request ID '||request_id);
545 
546           			if (request_id = 0) then
547 
548           			    write_to_log('Request submission failed.');
549           			    write_to_log('Exiting with error... ');
550 
551           			    DELETE OKL_PARALLEL_PROCESSES
552     					WHERE   assigned_process like l_char_seq_num||'%' ;
553 
554                         l_row_count := sql%rowcount;
555                         IF l_row_count > 0 THEN
556     					   write_to_log('Deleted '||l_row_count||' rows from OKL_PARALLEL_PROCESSES.');
557     					END IF;
558 
559 					    COMMIT;
560              			-- If request submission failed, exit with error
561              			errbuf := fnd_message.get;
562              			retcode := 2;
563           			else
564           			    write_to_log('Sub-Request submitted, putting master into PAUSED mode');
565              			-- Set the globals to put the master into PAUSED mode
566              			fnd_conc_global.set_req_globals(conc_status => 'PAUSED',
567                                      					request_data => to_char(1));
568              			errbuf := 'Sub-Request submitted!';
569              			retcode := 0;
570           			end if;
571         		end if;
572 
573 
574 	  		END LOOP;
575 
576 	 END IF;  --IF l_total_rows > 0 THEN
577 
578   else  --if l_data_found then
579     write_to_log('No workers assigned due to no data found for prcocesing');
580 
581   end if;
582 end if;
583   exception
584   when others then
585     write_to_log('Unhandled Exception '||sqlcode||':'||sqlerrm);
586 
587     DELETE OKL_PARALLEL_PROCESSES
588     WHERE assigned_process like l_char_seq_num||'%' ;
589 
590     l_row_count := sql%rowcount;
591 
592     IF l_row_count > 0 THEN
593        write_to_log('Deleted '||sql%rowcount||' rows from OKL_PARALLEL_PROCESSES.');
594     END IF;
595 
596     COMMIT;
597 
598 END Process_Spawner;
599 
600 
601 
602 END OKL_CNTRCT_FIN_EXT_MASTER_PVT;