DBA Data[Home] [Help]

PACKAGE BODY: APPS.XDP_PERF_BM_PKG

Source


1 PACKAGE BODY XDP_PERF_BM_PKG AS
2 /* $Header: XDPPERFB.pls 120.2 2005/07/07 02:06:06 appldev ship $ */
3 
4 /***********************************************************************************
5 Name	:	SendOrder
6 Purpose	:	This Procedure will be called from UI as a driver concurrent program.
7 		This will in turn make another call to a concurrent program(SubmitOrder)
8 		that will actually send the request via FND_REQUEST.SUBMIT_REQUEST.
9 INPUT	:
10 		order_number_prefix	Order Number Prefix to be Generated.
11 		number_of_orders	Number of Orders to be Generated per process.
12 		number_of_lineitems	Number of LineItems per Order.
13 		number_of_process	Number of Parallel Process(threads) to run.
14 		service_name		Performance Test Service Name to execute.
15 OUTPUT	:
16 		ERRBUF			Error Text
17 		RETCODE			Return Code
18 ***********************************************************************************/
19 
20 PROCEDURE SendOrder(
21 	errbuf			OUT NOCOPY	varchar2,
22 	retcode			OUT NOCOPY	number,
23 	order_number_prefix	IN	varchar2,
24 	number_of_orders	IN	number DEFAULT 1,
25 	number_of_lineitems	IN	number DEFAULT 1,
26 	number_of_process	IN	number DEFAULT 1,
27         organization_id         IN      number ,
28 	inventory_item_id	IN	number,
29         action_code             IN      varchar2)
30 IS
31   e_OrderPrefixException	exception;
32   req_id			number;
33   p_errbuf			varchar2(512);
34   msg_out			varchar2(512);
35   print_option_set 		boolean;
36 
37 BEGIN
38 
39   req_id := null;
40   p_errbuf	:= null;
41   errbuf	:= null;
42   retcode	:= 0;
43   msg_out	:= null;
44   print_option_set := FALSE;
45 
46 
47   FOR i in 1..number_of_process LOOP
48 
49     FND_FILE.put_line(FND_FILE.LOG ,'Spawning Process # '||i||' Of '||number_of_process);
50 
51     -- Need to set print option since print is set upon definition of concurrent program
52     -- on the UI.
53 
54     print_option_set := FND_REQUEST.SET_PRINT_OPTIONS(
55 			null,
56 			null,
57                         null,
58                         TRUE,
59                         'N');
60 
61     IF print_option_set THEN
62 	FND_FILE.put_line(FND_FILE.LOG ,'Print Options Set ...');
63     ELSE
64 	FND_FILE.put_line(FND_FILE.LOG ,'ERROR in setting Print Options ...');
65 	errbuf := substr(fnd_message.get, 1, 240);
66 	FND_FILE.put_line(FND_FILE.LOG ,'ERR MSG: '||errbuf);
67     END IF;
68 
69 	req_id := FND_REQUEST.SUBMIT_REQUEST(
70 			'XDP',
71 			'XDP_PERF_BM_PROG',
72 			'SFM Performance Benchmark Bulk Order Submission Program',
73 			null,
74 			FALSE,
75 			order_number_prefix,
76 			number_of_orders,
77 			number_of_lineitems,
78 			i,
79                         organization_id,
80 			inventory_item_id ,
81                         action_code);
82 
83 	FND_FILE.put_line(FND_FILE.LOG, 'Request ID: '||req_id);
84 
85 	IF req_id = 0 THEN
86 	  FND_FILE.put_line(FND_FILE.LOG ,'Error on SUBMIT_REQUEST for process #'||i);
87 	  p_errbuf := substr(fnd_message.get, 1, 240);
88 	  FND_FILE.put_line(FND_FILE.LOG, 'ERR MSG: '||errbuf);
89 	  --EXIT;
90 	END IF;
91 
92   END LOOP;
93 
94 EXCEPTION
95 	WHEN  e_OrderPrefixException THEN
96 		errbuf := 'Order Prefix given already exists';
97 		retcode := -1;
98   	WHEN OTHERS THEN
99     		FND_MESSAGE.SET_NAME('XDP', 'XDP_API_WHEN_OTHERS');
100     		FND_MESSAGE.SET_TOKEN('API_NAME', 'XDP_PERF_BM_PKG.SENDORDER');
101     		FND_MESSAGE.SET_TOKEN('ERROR_STRING', SQLERRM);
102     		errbuf := FND_MESSAGE.GET;
103     		retcode := -1;
104 
105 END SendOrder;
106 
107 /***********************************************************************************
108 Name	:	SubmitOrder
109 Purpose	:	This is a concurrent Program called by the driver concurrent program(SendOrder).
110 		This Procedure will  call XDP_INTERFACES.PROCESS_ORDER.
111 INPUT	:
112 		p_order_number_prefix	Order Number Prefix to be Generated.
113 		p_number_of_orders	Number of Orders to be Generated per process.
114 		p_number_of_lineitems	Number of LineItems per Order.
115 		p_service_name		Performance Test Service Name to execute.
116 OUTPUT	:
117 		ERRBUF			Error Text
118 		RETCODE			Return Code
119 ***********************************************************************************/
120 
121 PROCEDURE SubmitOrder(
122 	errbuf			OUT NOCOPY	VARCHAR2,
123 	retcode			OUT NOCOPY	NUMBER,
124 	p_order_number_prefix	IN	VARCHAR2,
125 	p_number_of_orders	IN	NUMBER DEFAULT 1,
126 	p_number_of_lineitems	IN	NUMBER DEFAULT 1,
127 	-- Need this as part of unique order NUMBER PREFIX
128 	p_process_number	IN	NUMBER DEFAULT 1,
129         p_organization_id       IN      NUMBER,
130 	p_inventory_item_id	IN	NUMBER,
131         p_action_code             IN      varchar2)
132 
133 IS
134   sdp_order_id        	        number;
135   return_code         	        number;
136   p_external_id		        varchar2(40);
137   p_action	      	        varchar2(30);
138 
139   -- Needed for                 XDP_INTERFACES_PUB call
140   msg_count		        number;
141   msg_data		        varchar2(2000);
142   return_status		        varchar2(1);
143   --
144   parm_count		        number;
145   time_start		        number;
146   time_end		        number;
147   time_elapsed		        number;
148   total_time		        number;
149   error_count		        number;
150   resultout           	        varchar2(512);
151   search_prefix			varchar2(40);
152   search_rec			varchar2(5);
153   ParameterName  		varchar2(30);
154   ParameterValue	        varchar2(40);
155   l_service_name                varchar2(80);
156 
157  l_msg_count                    NUMBER;
158  l_return_status                varchar2(20);
159  l_err_code                     varchar2(20);
160  l_msg_list                     varchar2(20);
161  l_error_message                VARCHAR(512);
162 
163   r_order_header      	        XDP_TYPES.SERVICE_ORDER_HEADER     ;
164   l_oparm_list        	        XDP_TYPES.SERVICE_ORDER_PARAM_LIST ;
165   l_line_list         	        XDP_TYPES.SERVICE_ORDER_LINE_LIST  ;
166   l_lparm_list        	        XDP_TYPES.SERVICE_LINE_PARAM_LIST  ;
167 
168   -- To be used for XDP_INTERFACES_PUB.Process_Order
169   l_api_version                 CONSTANT NUMBER := 11.5;
170 
171   e_organization_id_null        exception;
172   e_OrderPrefixException	exception;
173   e_SubmitOrderException	exception;
174   e_ActionCodeException		exception;
175 
176   cursor cCheckUniquePrefix(p_prefix varchar2) IS
177 	select	null
178 	from	xdp_order_headers xoh
179 	where
180 		xoh.external_order_number like (p_prefix)
181 		and xoh.external_order_version = '1'
182 		and xoh.order_type = 'BENCHMARK'
183 	;
184 
185   cursor cGetActionCode(p_organization_id IN NUMBER,
186                         p_inventory_item_id IN VARCHAR2) IS
187          SELECT sva.action_code
188            FROM xdp_service_val_acts sva
189           WHERE sva.organization_id       = p_organization_id
190             AND sva.inventory_item_id     = p_inventory_item_id  ;
191 
192   cursor c_get_service_name (p_organization_id IN NUMBER,
193                            p_inventory_item_id IN  NUMBER) IS
194          SELECT concatenated_segments  service_name
195            FROM mtl_system_items_vl  msi
196           WHERE msi.organization_id       = p_organization_id
197             AND msi.inventory_item_id     = p_inventory_item_id  ;
198 
199 BEGIN
200 
201   errbuf 	:= 'NO ERRORS';
202   retcode 	:= 0;
203   error_count	:= 0;
204   total_time      := 0;
205 
206   p_external_id := 'XDPPERFBM_'||p_order_number_prefix||'_'||to_char(p_process_number)||'_';
207   search_prefix :=  p_external_id || '%';
208 
209 
210   IF cCheckUniquePrefix%ISOPEN THEN
211 	close cCheckUniquePrefix;
212   END IF;
213   open cCheckUniquePrefix(search_prefix);
214   fetch cCheckUniquePrefix into search_rec;
215 
216   IF cCheckUniquePrefix%FOUND THEN
217 	close cCheckUniquePrefix;
218 	errbuf := 'Order Prefix given already exists';
219 	RAISE e_SubmitOrderException;
220   END IF;
221 
222   IF cCheckUniquePrefix%ISOPEN THEN
223 	close cCheckUniquePrefix;
224   END IF;
225 
226   r_order_header.required_fulfillment_date 	:= sysdate;
227   r_order_header.due_date		        := sysdate + 1;
228   r_order_header.jeopardy_enabled_flag	        := 'Y';
229   r_order_header.order_type		        := 'BENCHMARK';
230   r_order_header.order_version		        := '1';
231   r_order_header.execution_mode 		:= 'ASYNC';
232 
233   IF cGetActionCode%ISOPEN THEN
234 	close cGetActionCode;
235   END IF;
236 
237   for c_get_service_name_rec IN c_get_service_name (p_organization_id,
238                                                     p_inventory_item_id )
239       loop
240          l_service_name := c_get_service_name_rec.service_name ;
241       end loop ;
242 
243   parm_count := 1;
244 
245   FOR i in 1..p_number_of_lineitems LOOP
246 
247     l_line_list(i).line_number                := i;
248     l_line_list(i).inventory_item_id          := p_inventory_item_id;
249     l_line_list(i).service_item_name          := l_service_name;
250     l_line_list(i).action_code	              := p_action_code;
251     l_line_list(1).organization_id            := p_organization_id;
252     l_line_list(1).fulfillment_required_flag := 'Y';
253     l_line_list(1).ib_source                  := 'NONE';
254     l_line_list(1).site_use_id                := NULL;
255 
256 
257     FOR j in 1..10 LOOP -- There are 10 defined parameters for this WorkItem .
258 
259     -- Parameter names/values hard-coded because these are referenced from the publish
260     -- test message.
261 	IF j = 1 THEN
262 	  ParameterName	        := 'SUBSCRIPTION_TN';
263 	  ParameterValue	:= '650-633-5000';
264 	ELSIF j = 2 THEN
265 	  ParameterName	        := 'CUSTOMER_NAME';
266 	  ParameterValue	:= 'Johnny Smith';
267 	ELSIF j = 3 THEN
268 	  ParameterName	:= 'ADDRESS_LINE1';
269 	  ParameterValue	:= '600 Oracle Parkway';
270 	ELSIF j = 4 THEN
271 	  ParameterName	:= 'ADDRESS_LINE2';
272 	  ParameterValue	:= '6th Floor';
273 	ELSIF j = 5 THEN
274 	  ParameterName	:= 'CITY';
275 	  ParameterValue	:= 'Redwood Shores';
276 	ELSIF j = 6 THEN
277 	  ParameterName	:= 'ZIP_CODE';
278 	  ParameterValue	:= '94565';
279 	ELSIF j = 7 THEN
280 	  ParameterName	:= 'SERVICE_TYPE';
281 	  ParameterValue	:= 'ISDN Line';
282 	ELSIF j = 8 THEN
283 	  ParameterName	:= 'STATUS';
284 	  ParameterValue	:= 'WORKING';
285 	ELSIF j = 9 THEN
286 	  ParameterName	:= 'CUSTOMER_TYPE';
287 	  ParameterValue	:= 'RESIDENTIAL';
288 	ELSE
289 	  ParameterName	:= 'FEATURE_TYPE';
290 	  ParameterValue	:= 'Custom Calling Feature';
291 	END IF;
292 
293     	l_lparm_list(parm_count).line_number	:= i;
294 	l_lparm_list(parm_count).parameter_name := ParameterName;
295 	l_lparm_list(parm_count).parameter_value := ParameterValue;
296 
297 
298 	parm_count := parm_count + 1;
299     END LOOP;
300 
301   END LOOP;
302 
303   FOR i in 1..p_number_of_orders LOOP
304     r_order_header.order_number := p_external_id || to_char(i);
305 
306     time_start := dbms_utility.get_time;
307 
308  XDP_INTERFACES_PUB.PROCESS_ORDER(11,
309                                   l_msg_list,
310                                   FND_API.G_FALSE,
311                                   FND_API.G_VALID_LEVEL_FULL,
312                                   return_status,
313                                   msg_count,
314                                   msg_data,
315                                   l_err_code,
316                                   r_order_header,
317                                   l_oparm_list,
318                                   l_line_list,
319                                   l_lparm_list,
320                                   sdp_order_id);
321 
322     time_end := dbms_utility.get_time;
323     time_elapsed := time_end - time_start ;
324 
325     -- Gather timed stats only for successful orders.
326     IF (return_status <> FND_API.G_RET_STS_ERROR) THEN
327       total_time := total_time + time_elapsed;
328 
329       IF (i = 1) THEN
330 	FND_FILE.put_line(FND_FILE.LOG, 'Start Order ID	: '||sdp_order_id|| '	Order Number : '
331 		||r_order_header.order_number);
332       ELSIF (i = p_number_of_orders) THEN
333 	FND_FILE.put_line(FND_FILE.LOG, 'End Order ID	: '||sdp_order_id|| '	Order Number : '
334 		||r_order_header.order_number);
335       END IF;
336 
337     ELSE
338       error_count := error_count +1;
339       FND_FILE.put_line(FND_FILE.LOG, 'SFM Order ID	: '||sdp_order_id|| '	Order Number : '
340 			||r_order_header.order_number||' Return Code : '||return_status||
341 			' Error Desc : '||msg_data);
342 
343     END IF;
344 
345   END LOOP;
346 
347   IF (p_number_of_orders = error_count) THEN
348     errbuf := 'No Orders Successfully Submitted';
349     retcode := -1;
350 
351   ELSE
352     XDP_PERF_BM_PKG.PrintSubmitOrderStat(resultout,
353 			 return_code,
354 			 p_number_of_orders,
355 			 error_count,
356 	    	         total_time);
357 
358     IF (return_code <> 0) THEN
359       errbuf := resultout;
360       retcode := return_code;
361     END IF;
362 
363   END IF;
364 
365 
366 EXCEPTION
367   WHEN  e_SubmitOrderException THEN
368 	retcode := -1;
369   WHEN OTHERS THEN
370     FND_MESSAGE.SET_NAME('XDP', 'XDP_API_WHEN_OTHERS');
371     FND_MESSAGE.SET_TOKEN('API_NAME', 'XDP_PERF_BM_PKG.SUBMITORDER');
372     FND_MESSAGE.SET_TOKEN('ERROR_STRING', SQLERRM);
373     errbuf := FND_MESSAGE.GET;
374     retcode := -1;
375 
376 END SubmitOrder ;
377 
378 /***********************************************************************************
379 Name	:	PrintSubmitOrderStat
380 Purpose	:	This Procedure prints timed statistics of processed orders.
381 INPUT	:
382 		p_total_orders
383 		p_total_time_elapsed
384 OUTPUT	:
385 		ERRBUF
386 		RETCODE
387 ***********************************************************************************/
388 
389 PROCEDURE PrintSubmitOrderStat(
390 		    errbuf			OUT NOCOPY	varchar2,
391 		    retcode			OUT NOCOPY	number,
392 		    p_total_orders		IN	number,
393 		    p_error_count		IN	number,
394 		    p_total_time_elapsed	IN	number)
395 IS
396 
397  average	float(10) := 0;
398 
399 BEGIN
400 
401 errbuf := null;
402 retcode := 0;
403 
404   average := p_total_orders / (p_total_time_elapsed / 100);
405   FND_FILE.put_line(FND_FILE.OUTPUT,'These Figures Represent Orders Successfully Sent to the Process Orders Queue.');
406   FND_FILE.put_line(FND_FILE.OUTPUT,'=============================================================================');
407   FND_FILE.put_line(FND_FILE.OUTPUT,'Total Number of Orders Requested			: '
408 		|| p_total_orders);
409   FND_FILE.put_line(FND_FILE.OUTPUT,'Total Number of Successful Orders Processed	: '
410 		|| to_number(p_total_orders - p_error_count));
411   FND_FILE.put_line(FND_FILE.OUTPUT,'Total Elapsed Time (Successful Orders)		: '
412 		|| p_total_time_elapsed / 100 ||' seconds');
413   FND_FILE.put_line(FND_FILE.OUTPUT,'Average						: '||average||' Orders per Second.');
414   FND_FILE.put_line(FND_FILE.OUTPUT,'==============================================================');
415   FND_FILE.put_line(FND_FILE.OUTPUT,'Total Number of Orders in Error			: ' || p_error_count);
416   FND_FILE.put_line(FND_FILE.OUTPUT,'==============================================================');
417 
418 EXCEPTION
419   WHEN OTHERS THEN
420     FND_MESSAGE.SET_NAME('XDP', 'XDP_API_WHEN_OTHERS');
421     FND_MESSAGE.SET_TOKEN('API_NAME', 'XDP_PERF_BM_PKG.PRINTSUBMITORDERSTAT');
422     FND_MESSAGE.SET_TOKEN('ERROR_STRING', SQLERRM);
423     errbuf := FND_MESSAGE.GET;
424     retcode := -1;
425 
426 END PrintSubmitOrderStat;
427 
431 Purpose	:	This Procedure is a concurrent program that will generate stats for
428 
429 /***********************************************************************************
430 Name	:	GetReport
432 		performance benchmark.
433 INPUT	:
434 		order prefix	-- Unique Service Order Prefix
435 OUTPUT	:
436 		ERRBUF
437 		RETCODE
438 ***********************************************************************************/
439 PROCEDURE GetReport(
440 		    errbuf		OUT NOCOPY	varchar2,
441 		    retcode		OUT NOCOPY	number,
442 		    order_prefix	IN	varchar2)
443 IS
444   e_OrderPrefixException	exception;
445   p_total_processed_orders	number;
446   p_total_completed_orders	number;
447   p_completed_orders_ave	number;
448   p_total_orders_ave		number;
449   p_errbuf			varchar2(150);
450   p_retcode			number;
451   p_order_prefix		varchar2(20);
452   p_total_order_elapse_time	number;
453   --p_total_completed_elapse_time	number;
454   p_total_completed_elapse_time	float(15);
455   all_ave			float(15);
456   comp_ave			float(15);
457 
458 BEGIN
459 
460   IF (order_prefix is NULL) THEN
461 	RAISE e_OrderPrefixException;
462   END IF;
463 
464   p_order_prefix := UPPER(order_prefix);
465 
466   GetFlowthroughStat(order_number_prefix	=> p_order_prefix,
467 		     total_processed_orders	=> p_total_processed_orders,
468 		     total_completed_orders	=> p_total_completed_orders,
469 		     total_order_elapse_time	=> p_total_order_elapse_time,
470 	 	     total_completed_elapse_time=> p_total_completed_elapse_time,
471 		     errbuf			=> p_errbuf,
472 		     retcode			=> p_retcode);
473 
474 
475   IF p_retcode = 0 THEN
476 
477     comp_ave  := p_total_completed_orders/p_total_completed_elapse_time;
478     --all_ave := p_total_completed_orders/p_total_order_elapse_time;
479     all_ave := p_total_order_elapse_time / p_total_completed_orders;
480 
481     IF (p_total_completed_orders <> p_total_processed_orders) THEN
482       FND_FILE.put_line(FND_FILE.OUTPUT,'These are Partial Thoroughput Stats. Some orders '||
483       'with Prefix '||p_order_prefix||' Not yet Successfully Completed.');
484     ELSE
485       FND_FILE.put_line(FND_FILE.OUTPUT,'These are Complete Thoroughput Stats. All Test '||
486       'Orders with Prefix XDPPERFBM_'||p_order_prefix||' Successfully Completed.');
487     END IF;
488     FND_FILE.put_line(FND_FILE.OUTPUT,'============================================================================================');
489 
490     FND_FILE.put_line(FND_FILE.OUTPUT,'Total Processed Orders		:	'||p_total_processed_orders);
491     FND_FILE.put_line(FND_FILE.OUTPUT,'Total Completed Orders		:	'||p_total_completed_orders);
492     FND_FILE.put_line(FND_FILE.OUTPUT,'Total Process Duration		:	'
493 				||p_total_completed_elapse_time||' seconds');
494     FND_FILE.put_line(FND_FILE.OUTPUT,'Order Throughput');
495     FND_FILE.put_line(FND_FILE.OUTPUT,'		Orders Per Second	:	'||comp_ave);
496     FND_FILE.put_line(FND_FILE.OUTPUT,'		Orders Per Hour		:	'||comp_ave * 3600);
497     FND_FILE.put_line(FND_FILE.OUTPUT,'		Orders Per Day		:	'||comp_ave * 86400);
498 
499     FND_FILE.put_line(FND_FILE.OUTPUT,'Average Order Completion Rate.(Based on Individual Process Time)');
500     FND_FILE.put_line(FND_FILE.OUTPUT,'		Seconds Per Order:	'||all_ave);
501 
502   ELSE
503     errbuf := p_errbuf;
504     retcode := p_retcode;
505   END IF;
506 
507 EXCEPTION
508   WHEN  e_OrderPrefixException THEN
509 	errbuf := 'Order Prefix Not Found';
510 	retcode := -1;
511   WHEN OTHERS THEN
512     FND_MESSAGE.SET_NAME('XDP', 'XDP_API_WHEN_OTHERS');
513     FND_MESSAGE.SET_TOKEN('API_NAME', 'XDP_PERF_BM_PKG.GETREPORT');
514     FND_MESSAGE.SET_TOKEN('ERROR_STRING', SQLERRM);
515     errbuf := FND_MESSAGE.GET;
516     retcode := -1;
517 END GetReport;
518 
519 /***********************************************************************************
520 Name	:	GetFlowthroughStat
521 Purpose	:	This Procedure prints timed statistics of processed orders.
522 INPUT	:
523 		order_number_prefix	-- Unique Service Order Prefix
524 OUTPUT	:
525 		total_processed_orders
526 		total_completed_orders
527 		total_order_elapse_time		-- taken for each order(excludes lags)
528 		total_completed_elapse_time	-- including lags between orders
529 		ERRBUF
530 		RETCODE
531 ***********************************************************************************/
532 
533 PROCEDURE GetFlowthroughStat(
534 			     order_number_prefix		IN	varchar2,
535 			     total_processed_orders		OUT NOCOPY	number,
536 			     total_completed_orders		OUT NOCOPY	number,
537 			     total_order_elapse_time		OUT NOCOPY	number,
538 	 		     total_completed_elapse_time	OUT NOCOPY	number,
539 			     errbuf				OUT NOCOPY	varchar2,
540 			     retcode				OUT NOCOPY	number)
541 IS
542 	cursor orders_all(OrderPrefix varchar2) is
543 		select	SUM(XOH.COMPLETION_DATE - XOH.PROVISIONING_DATE) ElapseTime,
544 			count(*) OrderCount
545 		from	xdp_order_headers XOH
546 		where	XOH.EXTERNAL_ORDER_NUMBER like (OrderPrefix)
547 			AND XOH.status_code = 'SUCCESS'
548 			AND XOH.EXTERNAL_ORDER_VERSION = '1'
549 			AND XOH.ORDER_TYPE = 'BENCHMARK'
550 		;
551 
552 	cursor orders_complete(OrderPrefix varchar2) is
553 		select	min(XOH.provisioning_date) ProvDate,
554 			max(XOH.completion_date) CompDate
555 		from	xdp_order_headers XOH
556 		where	XOH.EXTERNAL_ORDER_NUMBER like (OrderPrefix)
557 			AND XOH.status_code = 'SUCCESS'
558 			AND XOH.EXTERNAL_ORDER_VERSION = '1'
559 			AND XOH.ORDER_TYPE = 'BENCHMARK'
560 		;
561 
562 	AllOrdersRec			orders_all%ROWTYPE;
563 	CompOrdersRec			orders_complete%ROWTYPE;
564 	search_prefix			varchar2(40);
565 	order_elapse_time		number;		-- in seconds
566   	e_OrderPrefixException		exception;
567 
568 BEGIN
569 
570   errbuf			:= null;
571   retcode			:= 0;
572   total_completed_elapse_time	:= 0;
573   total_order_elapse_time	:= 0;
574   order_elapse_time		:= 0;
575   total_completed_orders	:= 0;
576   total_processed_orders	:= 0;
577 
578   search_prefix := 'XDPPERFBM_' || order_number_prefix||'_%';
579 
580   SELECT count(*) INTO total_processed_orders
581   FROM	xdp_order_headers h
582   WHERE
583 	h.external_order_number like search_prefix
584 	and h.external_order_version = '1'
585 	and h.order_type = 'BENCHMARK';
586 
587   IF (total_processed_orders = 0) THEN
588 	errbuf := 'No Orders Found with Prefix '|| order_number_prefix;
589 	RAISE e_OrderPrefixException;
590   END IF;
591 
592   IF orders_all%ISOPEN THEN
593 	close orders_all;
594   END IF;
595 
596   open orders_all(search_prefix) ;
597   fetch orders_all into AllOrdersRec;
598 
599   IF orders_all%NOTFOUND THEN
600 	errbuf := 'No Completed Orders Found for Prefix '|| order_number_prefix;
601 	RAISE e_OrderPrefixException;
602   END IF;
603 
604   total_order_elapse_time := AllOrdersRec.ElapseTime * 86400;
605   total_completed_orders := AllOrdersRec.OrderCount;
606 
607   IF orders_all%ISOPEN THEN
608 	close orders_all;
609   END IF;
610 
611 
612   IF orders_complete%ISOPEN THEN
613 	close orders_complete;
614   END IF;
615 
616   open orders_complete(search_prefix) ;
617     fetch orders_complete into CompOrdersRec;
618     -- Got to check for CompOrdersRec.ProvDate since min/max returns null row when no record found
619     IF (orders_complete%NOTFOUND OR CompOrdersRec.ProvDate IS NULL  AND CompOrdersRec.CompDate IS NULL) THEN
620 	-- No orders completed, no use in getting stats!
621 	errbuf := 'No Completed Orders Found for Prefix '|| order_number_prefix;
622 	RAISE e_OrderPrefixException;
623     ELSE
624         total_completed_elapse_time := (CompOrdersRec.CompDate - CompOrdersRec.ProvDate)*86400;
625     END IF;
626 
627   IF orders_complete%ISOPEN THEN
628 	close orders_complete;
629   END IF;
630 
631 EXCEPTION
632   WHEN  e_OrderPrefixException THEN
633 	retcode := -1;
634   WHEN OTHERS THEN
635     FND_MESSAGE.SET_NAME('XDP', 'XDP_API_WHEN_OTHERS');
636     FND_MESSAGE.SET_TOKEN('API_NAME', 'XDP_PERF_BM_PKG.GETFLOWTHROUGHSTAT');
637     FND_MESSAGE.SET_TOKEN('ERROR_STRING', SQLERRM);
638     errbuf := FND_MESSAGE.GET;
639     retcode := -1;
640 
641 END GetFlowthroughStat;
642 
643 END XDP_PERF_BM_PKG;
644