45: l_currency VARCHAR2(3200) ; -- Currency
46: l_gp_currency VARCHAR2(15); --Global Primary Currency
47: l_gs_currency VARCHAR2(15); --Global Secondary Curr
48:
49: --FND Logging
50: l_full_path VARCHAR2(50);
51: gaflog_value VARCHAR2(10);
52:
53:
52:
53:
54: BEGIN
55:
56: --FND Logging
57: l_full_path := 'ibw.plsql.ibwbcusb.get_cust_acquis_trend_sql';
58: --Profile is : FND: Debug Log Enabled and FND: Debug Log Level for Log Level
59: gaflog_value := fnd_profile.value('AFLOG_ENABLED');
60:
59: gaflog_value := fnd_profile.value('AFLOG_ENABLED');
60:
61: --Fetch all the Parameters into the Local Variables.
62:
63: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
64: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
65: END IF;
66:
67: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
60:
61: --Fetch all the Parameters into the Local Variables.
62:
63: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
64: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
65: END IF;
66:
67: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
68: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
63: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
64: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
65: END IF;
66:
67: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
68: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
69: END IF;
70:
71: IBW_BI_UTL_PVT.GET_PAGE_PARAMETERS
64: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
65: END IF;
66:
67: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
68: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
69: END IF;
70:
71: IBW_BI_UTL_PVT.GET_PAGE_PARAMETERS
72: (
84: X_CUST_CLASS => l_cust_class,
85: X_CUST => l_cust --Not Wanted
86: );
87:
88: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
89: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
90: END IF;
91:
92: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
85: X_CUST => l_cust --Not Wanted
86: );
87:
88: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
89: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
90: END IF;
91:
92: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
93: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust || ' l_currency : ' || l_currency || ' l_period_type : ' || l_period_type );
88: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
89: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
90: END IF;
91:
92: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
93: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust || ' l_currency : ' || l_currency || ' l_period_type : ' || l_period_type );
94: END IF;
95:
96: --Initializing section starts
89: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
90: END IF;
91:
92: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
93: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust || ' l_currency : ' || l_currency || ' l_period_type : ' || l_period_type );
94: END IF;
95:
96: --Initializing section starts
97: l_gp_currency := '''FII_GLOBAL1''' ;
112: l_from := ' IBW_VISIT_CUST_TIME_MV CUSTACQUIS_MV' ||
113: ' ,FII_TIME_RPT_STRUCT_V CAL' ||
114: ' ,FII_PARTY_MKT_CLASS CUST_CLASS_MAP'; -- This is a mapping table between customer classification and customers ( party_id )
115:
116: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
117: fnd_log.string(fnd_log.level_statement,l_full_path,'l_from : ' || l_from );
118: END IF;
119:
120: -- Initialising where clause based for time dimension
113: ' ,FII_TIME_RPT_STRUCT_V CAL' ||
114: ' ,FII_PARTY_MKT_CLASS CUST_CLASS_MAP'; -- This is a mapping table between customer classification and customers ( party_id )
115:
116: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
117: fnd_log.string(fnd_log.level_statement,l_full_path,'l_from : ' || l_from );
118: END IF;
119:
120: -- Initialising where clause based for time dimension
121:
125: CUSTACQUIS_MV.period_type_id = cal.period_type_id AND
126: bitand(cal.record_type_id, &BIS_NESTED_PATTERN) = cal.record_type_id AND
127: cal.CALENDAR_ID = -1 ';
128:
129: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
130: fnd_log.string(fnd_log.level_statement,l_full_path,'l_where : ' || l_where );
131: END IF;
132:
133: -- Initialising where clause based on the parameter selection
126: bitand(cal.record_type_id, &BIS_NESTED_PATTERN) = cal.record_type_id AND
127: cal.CALENDAR_ID = -1 ';
128:
129: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
130: fnd_log.string(fnd_log.level_statement,l_full_path,'l_where : ' || l_where );
131: END IF;
132:
133: -- Initialising where clause based on the parameter selection
134: -- The site where clause is kept in a seperate variable because New Web Customers through
154: ' AND CUSTACQUIS_MV.CUSTOMER_ID = CUST_CLASS_MAP.PARTY_ID '||
155: ' AND CUST_CLASS_MAP.class_code = CUSTCLASS.ID ';
156: END IF;
157:
158: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
159: fnd_log.string(fnd_log.level_statement,l_full_path,' l_from : ' || l_from || ' l_where : ' || l_where ||' l_site_from : '|| l_site_from ||' l_site_where : '|| l_site_where);
160: END IF;
161:
162: -- Initialising the outer select clause. For any ratios divide by zero issue is also handled
155: ' AND CUST_CLASS_MAP.class_code = CUSTCLASS.ID ';
156: END IF;
157:
158: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
159: fnd_log.string(fnd_log.level_statement,l_full_path,' l_from : ' || l_from || ' l_where : ' || l_where ||' l_site_from : '|| l_site_from ||' l_site_where : '|| l_site_where);
160: END IF;
161:
162: -- Initialising the outer select clause. For any ratios divide by zero issue is also handled
163:
184: SUM(WEB_CUST_ALL) WEB_CUST_ALL,
185: SUM(BOOKED_AMOUNT_C) BOOKED_AMOUNT_C,
186: SUM(BOOKED_ORDERS_C) BOOKED_ORDERS_C ';
187:
188: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
189: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_select : ' || l_outer_select );
190: END IF;
191:
192: -- Initialising the outer where clause
185: SUM(BOOKED_AMOUNT_C) BOOKED_AMOUNT_C,
186: SUM(BOOKED_ORDERS_C) BOOKED_ORDERS_C ';
187:
188: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
189: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_select : ' || l_outer_select );
190: END IF;
191:
192: -- Initialising the outer where clause
193:
193:
194: l_outer_where := ' time_dim.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE AND &BIS_CURRENT_ASOF_DATE AND
195: time_dim.start_date = s.start_date(+) ';
196:
197: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
198: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_where : ' || l_outer_where );
199: END IF;
200:
201: /*************************************************************************/
194: l_outer_where := ' time_dim.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE AND &BIS_CURRENT_ASOF_DATE AND
195: time_dim.start_date = s.start_date(+) ';
196:
197: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
198: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_where : ' || l_outer_where );
199: END IF;
200:
201: /*************************************************************************/
202: /* IBW_VAL1 : Web Registrations */
325: WHERE '|| l_outer_where ||
326: 'ORDER BY time_dim.start_date';
327:
328:
329: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
330: fnd_log.string(fnd_log.level_statement,l_full_path,'l_custom_sql : ' || l_custom_sql );
331: END IF;
332:
333: x_custom_sql := l_custom_sql;
326: 'ORDER BY time_dim.start_date';
327:
328:
329: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
330: fnd_log.string(fnd_log.level_statement,l_full_path,'l_custom_sql : ' || l_custom_sql );
331: END IF;
332:
333: x_custom_sql := l_custom_sql;
334:
354: l_custom_rec.attribute_data_type := BIS_PMV_PARAMETERS_PUB.VARCHAR2_BIND;
355: x_custom_output.EXTEND;
356: x_custom_output(3) := l_custom_rec;
357:
358: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
359: fnd_log.string(fnd_log.level_statement,l_full_path,'END');
360: END IF;
361:
362: EXCEPTION
355: x_custom_output.EXTEND;
356: x_custom_output(3) := l_custom_rec;
357:
358: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
359: fnd_log.string(fnd_log.level_statement,l_full_path,'END');
360: END IF;
361:
362: EXCEPTION
363: WHEN OTHERS THEN
360: END IF;
361:
362: EXCEPTION
363: WHEN OTHERS THEN
364: if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
365: fnd_log.string(fnd_log.level_unexpected,l_full_path,SQLERRM);
366: end if;
367:
368: END GET_CUST_ACQUIS_TREND_SQL;
361:
362: EXCEPTION
363: WHEN OTHERS THEN
364: if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
365: fnd_log.string(fnd_log.level_unexpected,l_full_path,SQLERRM);
366: end if;
367:
368: END GET_CUST_ACQUIS_TREND_SQL;
369:
412: l_currency VARCHAR2(3200) ; -- Currency
413: l_gp_currency VARCHAR2(15); --Global Primary Currency
414: l_gs_currency VARCHAR2(15); --Global Secondary Curr
415:
416: --FND Logging
417: l_full_path VARCHAR2(50);
418: gaflog_value VARCHAR2(10);
419:
420:
419:
420:
421: BEGIN
422:
423: --FND Logging
424: l_full_path := 'ibw.plsql.ibwbcusb.get_cust_acty_trend_sql';
425: --Profile is : FND: Debug Log Enabled and FND: Debug Log Level for Log Level
426: gaflog_value := fnd_profile.value('AFLOG_ENABLED');
427:
426: gaflog_value := fnd_profile.value('AFLOG_ENABLED');
427:
428: --Fetch all the Parameters into the Local Variables.
429:
430: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
431: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
432: END IF;
433:
434: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
427:
428: --Fetch all the Parameters into the Local Variables.
429:
430: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
431: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
432: END IF;
433:
434: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
435: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
430: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
431: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
432: END IF;
433:
434: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
435: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
436: END IF;
437:
438: IBW_BI_UTL_PVT.GET_PAGE_PARAMETERS
431: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
432: END IF;
433:
434: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
435: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
436: END IF;
437:
438: IBW_BI_UTL_PVT.GET_PAGE_PARAMETERS
439: (
451: X_CUST_CLASS => l_cust_class,
452: X_CUST => l_cust
453: );
454:
455: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
456: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
457: END IF;
458:
459: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
452: X_CUST => l_cust
453: );
454:
455: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
456: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
457: END IF;
458:
459: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
460: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust ||' l_cust_class : '|| l_cust_class || ' l_currency : ' || l_currency || ' l_period_type : ' || l_period_type );
455: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
456: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
457: END IF;
458:
459: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
460: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust ||' l_cust_class : '|| l_cust_class || ' l_currency : ' || l_currency || ' l_period_type : ' || l_period_type );
461: END IF;
462:
463: --Initializing section starts
456: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
457: END IF;
458:
459: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
460: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust ||' l_cust_class : '|| l_cust_class || ' l_currency : ' || l_currency || ' l_period_type : ' || l_period_type );
461: END IF;
462:
463: --Initializing section starts
464:
478: l_from := ' IBW_VISIT_CUST_TIME_MV CUSTACQUIS_MV' ||
479: ' ,FII_TIME_RPT_STRUCT_V CAL' ||
480: ' ,FII_PARTY_MKT_CLASS CUST_CLASS_MAP'; -- This is a mapping table between customer classification and customers ( party_id )
481:
482: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
483: fnd_log.string(fnd_log.level_statement,l_full_path,'l_from : ' || l_from );
484: END IF;
485:
486: -- Initialising where clause based for time dimension
479: ' ,FII_TIME_RPT_STRUCT_V CAL' ||
480: ' ,FII_PARTY_MKT_CLASS CUST_CLASS_MAP'; -- This is a mapping table between customer classification and customers ( party_id )
481:
482: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
483: fnd_log.string(fnd_log.level_statement,l_full_path,'l_from : ' || l_from );
484: END IF;
485:
486: -- Initialising where clause based for time dimension
487:
491: CUSTACQUIS_MV.period_type_id = cal.period_type_id AND
492: bitand(cal.record_type_id, &BIS_NESTED_PATTERN) = cal.record_type_id AND
493: cal.CALENDAR_ID = -1 ';
494:
495: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
496: fnd_log.string(fnd_log.level_statement,l_full_path,'l_where : ' || l_where);
497: END IF;
498:
499: -- Initialising where clause based on the parameter selection
492: bitand(cal.record_type_id, &BIS_NESTED_PATTERN) = cal.record_type_id AND
493: cal.CALENDAR_ID = -1 ';
494:
495: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
496: fnd_log.string(fnd_log.level_statement,l_full_path,'l_where : ' || l_where);
497: END IF;
498:
499: -- Initialising where clause based on the parameter selection
500: -- The site where clause is kept in a seperate variable because Total Booked Orders Amount
529: l_where := l_where ||
530: ' AND CUSTACQUIS_MV.CUSTOMER_ID = CUST.ID ';
531: END IF;
532:
533: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
534: fnd_log.string(fnd_log.level_statement,l_full_path,' l_from : ' || l_from || ' l_where : ' || l_where ||' l_site_from : '|| l_site_from ||' l_site_where : '|| l_site_where);
535: END IF;
536:
537: -- Initialising the outer select clause
530: ' AND CUSTACQUIS_MV.CUSTOMER_ID = CUST.ID ';
531: END IF;
532:
533: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
534: fnd_log.string(fnd_log.level_statement,l_full_path,' l_from : ' || l_from || ' l_where : ' || l_where ||' l_site_from : '|| l_site_from ||' l_site_where : '|| l_site_where);
535: END IF;
536:
537: -- Initialising the outer select clause
538:
579: SUM(P_BOOKED_ORDERS) P_BOOKED_ORDERS, --4727078 Issue#21
580: SUM(P_BOOKED_ORDERS_ALL) P_BOOKED_ORDERS_ALL --4727078 Issue#21
581: ';
582:
583: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
584: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_select : ' || l_outer_select);
585: END IF;
586:
587: -- Initialising the outer where clause
580: SUM(P_BOOKED_ORDERS_ALL) P_BOOKED_ORDERS_ALL --4727078 Issue#21
581: ';
582:
583: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
584: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_select : ' || l_outer_select);
585: END IF;
586:
587: -- Initialising the outer where clause
588:
588:
589: l_outer_where := ' time_dim.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE AND &BIS_CURRENT_ASOF_DATE AND
590: time_dim.start_date = s.start_date(+) ';
591:
592: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
593: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_where : ' || l_outer_where);
594: END IF;
595:
596: /*************************************************************************/
589: l_outer_where := ' time_dim.start_date BETWEEN &BIS_CURRENT_REPORT_START_DATE AND &BIS_CURRENT_ASOF_DATE AND
590: time_dim.start_date = s.start_date(+) ';
591:
592: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
593: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_where : ' || l_outer_where);
594: END IF;
595:
596: /*************************************************************************/
597: /* IBW_VAL1 : Visits */
759: WHERE '|| l_outer_where ||
760: 'ORDER BY time_dim.start_date';
761:
762:
763: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
764: fnd_log.string(fnd_log.level_statement,l_full_path,'l_custom_sql : ' || l_custom_sql );
765: END IF;
766:
767: x_custom_sql := l_custom_sql;
760: 'ORDER BY time_dim.start_date';
761:
762:
763: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
764: fnd_log.string(fnd_log.level_statement,l_full_path,'l_custom_sql : ' || l_custom_sql );
765: END IF;
766:
767: x_custom_sql := l_custom_sql;
768:
788: l_custom_rec.attribute_data_type := BIS_PMV_PARAMETERS_PUB.VARCHAR2_BIND;
789: x_custom_output.EXTEND;
790: x_custom_output(3) := l_custom_rec;
791:
792: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
793: fnd_log.string(fnd_log.level_statement,l_full_path,'END');
794: END IF;
795:
796: EXCEPTION
789: x_custom_output.EXTEND;
790: x_custom_output(3) := l_custom_rec;
791:
792: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
793: fnd_log.string(fnd_log.level_statement,l_full_path,'END');
794: END IF;
795:
796: EXCEPTION
797: WHEN OTHERS THEN
794: END IF;
795:
796: EXCEPTION
797: WHEN OTHERS THEN
798: if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
799: fnd_log.string(fnd_log.level_unexpected,l_full_path,SQLERRM);
800: end if;
801:
802: END GET_CUST_ACTY_TREND_SQL;
795:
796: EXCEPTION
797: WHEN OTHERS THEN
798: if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
799: fnd_log.string(fnd_log.level_unexpected,l_full_path,SQLERRM);
800: end if;
801:
802: END GET_CUST_ACTY_TREND_SQL;
803:
853: l_currency VARCHAR2(3200) ; -- Currency
854: l_gp_currency VARCHAR2(15); --Global Primary Currency
855: l_gs_currency VARCHAR2(15); --Global Secondary Curr
856:
857: --FND Logging
858: l_full_path VARCHAR2(50);
859: gaflog_value VARCHAR2(10);
860:
861:
860:
861:
862: BEGIN
863:
864: --FND Logging
865: l_full_path := 'ibw.plsql.ibwbcusb.get_cust_acty_sql';
866: --Profile is : FND: Debug Log Enabled and FND: Debug Log Level for Log Level
867: gaflog_value := fnd_profile.value('AFLOG_ENABLED');
868:
867: gaflog_value := fnd_profile.value('AFLOG_ENABLED');
868:
869: --Fetch all the Parameters into the Local Variables.
870:
871: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
872: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
873: END IF;
874:
875: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
868:
869: --Fetch all the Parameters into the Local Variables.
870:
871: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
872: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
873: END IF;
874:
875: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
876: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
871: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
872: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
873: END IF;
874:
875: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
876: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
877: END IF;
878:
879: IBW_BI_UTL_PVT.GET_PAGE_PARAMETERS
872: fnd_log.string(fnd_log.level_statement,l_full_path,'BEGIN');
873: END IF;
874:
875: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
876: fnd_log.string(fnd_log.level_procedure,l_full_path,'Before the Call to UTL Package');
877: END IF;
878:
879: IBW_BI_UTL_PVT.GET_PAGE_PARAMETERS
880: (
892: X_CUST_CLASS => l_cust_class,
893: X_CUST => l_cust
894: );
895:
896: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
897: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
898: END IF;
899:
900: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
893: X_CUST => l_cust
894: );
895:
896: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
897: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
898: END IF;
899:
900: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
901: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust ||' l_cust_class : '|| l_cust_class || ' l_currency : ' || l_currency || ' l_view_by : ' || l_view_by );
896: IF gaflog_value ='Y' AND (fnd_log.level_procedure >= fnd_log.g_current_runtime_level) THEN
897: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
898: END IF;
899:
900: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
901: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust ||' l_cust_class : '|| l_cust_class || ' l_currency : ' || l_currency || ' l_view_by : ' || l_view_by );
902: END IF;
903:
904: --Initializing section starts
897: fnd_log.string(fnd_log.level_procedure,l_full_path,'After the Call to UTL Package');
898: END IF;
899:
900: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
901: fnd_log.string(fnd_log.level_statement,l_full_path,'l_site : ' || l_site ||' l_cust : '|| l_cust ||' l_cust_class : '|| l_cust_class || ' l_currency : ' || l_currency || ' l_view_by : ' || l_view_by );
902: END IF;
903:
904: --Initializing section starts
905:
926: l_from := ' IBW_VISIT_CUST_TIME_MV CUSTACTY_MV' ||
927: ' ,FII_TIME_RPT_STRUCT_V CAL' ||
928: ' ,FII_PARTY_MKT_CLASS CUST_CLASS_MAP'; -- This is a mapping table between customer classification and customers ( party_id )
929:
930: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
931: fnd_log.string(fnd_log.level_statement,l_full_path,'l_from : ' || l_from );
932: END IF;
933:
934: -- Initialising where clause based for time dimension
927: ' ,FII_TIME_RPT_STRUCT_V CAL' ||
928: ' ,FII_PARTY_MKT_CLASS CUST_CLASS_MAP'; -- This is a mapping table between customer classification and customers ( party_id )
929:
930: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
931: fnd_log.string(fnd_log.level_statement,l_full_path,'l_from : ' || l_from );
932: END IF;
933:
934: -- Initialising where clause based for time dimension
935:
938: ' AND BITAND(CAL.RECORD_TYPE_ID,&BIS_NESTED_PATTERN)= CAL.RECORD_TYPE_ID '||
939: ' AND CUSTACTY_MV.TIME_ID = CAL.TIME_ID ' ||
940: ' AND CAL.CALENDAR_ID = -1 ';
941:
942: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
943: fnd_log.string(fnd_log.level_statement,l_full_path,'l_where : ' || l_where );
944: END IF;
945:
946: l_where_all := l_where;
939: ' AND CUSTACTY_MV.TIME_ID = CAL.TIME_ID ' ||
940: ' AND CAL.CALENDAR_ID = -1 ';
941:
942: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
943: fnd_log.string(fnd_log.level_statement,l_full_path,'l_where : ' || l_where );
944: END IF;
945:
946: l_where_all := l_where;
947:
944: END IF;
945:
946: l_where_all := l_where;
947:
948: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
949: fnd_log.string(fnd_log.level_statement,l_full_path,'l_where_all : ' || l_where_all );
950: END IF;
951:
952: --The Outer Select statement is recorded in this variable.
945:
946: l_where_all := l_where;
947:
948: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
949: fnd_log.string(fnd_log.level_statement,l_full_path,'l_where_all : ' || l_where_all );
950: END IF;
951:
952: --The Outer Select statement is recorded in this variable.
953: -- IBW_G_TOT9 : Grand total for Total Web Orders Amount is non additive across site
1001: SUM(NVL(TOTAL_ORDER_INQUIRIES,0)) over () IBW_G_TOT10,
1002: SUM(NVL(TOTAL_INVOICE_INQUIRIES,0)) over () IBW_G_TOT11,
1003: SUM(NVL(TOTAL_PAYMENT_INQUIRIES,0)) over () IBW_G_TOT12 ';
1004:
1005: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1006: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_select : ' || l_outer_select );
1007: END IF;
1008:
1009: --The middle Select statement is recorded in this variable.
1002: SUM(NVL(TOTAL_INVOICE_INQUIRIES,0)) over () IBW_G_TOT11,
1003: SUM(NVL(TOTAL_PAYMENT_INQUIRIES,0)) over () IBW_G_TOT12 ';
1004:
1005: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1006: fnd_log.string(fnd_log.level_statement,l_full_path,'l_outer_select : ' || l_outer_select );
1007: END IF;
1008:
1009: --The middle Select statement is recorded in this variable.
1010:
1037: OR NVL(SUM(TOTAL_ORDER_INQUIRIES),0) > 0
1038: OR NVL(SUM(TOTAL_INVOICE_INQUIRIES),0) > 0
1039: OR NVL(SUM(TOTAL_PAYMENT_INQUIRIES),0) > 0 ';
1040:
1041: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1042: fnd_log.string(fnd_log.level_statement,l_full_path,'l_middle_select : ' || l_middle_select );
1043: END IF;
1044:
1045: --The Inner Select statement is recorded in this variable.
1038: OR NVL(SUM(TOTAL_INVOICE_INQUIRIES),0) > 0
1039: OR NVL(SUM(TOTAL_PAYMENT_INQUIRIES),0) > 0 ';
1040:
1041: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1042: fnd_log.string(fnd_log.level_statement,l_full_path,'l_middle_select : ' || l_middle_select );
1043: END IF;
1044:
1045: --The Inner Select statement is recorded in this variable.
1046: -- The select clause fetches Visits,Carts,A Leads,Cart Conversion,Booked Orders,Assisted Orders,Booked Orders Amount,Order Status,Invoice,Payment
1056: SUM(TOTAL_ORDER_INQUIRIES) TOTAL_ORDER_INQUIRIES,
1057: SUM(TOTAL_INVOICE_INQUIRIES) TOTAL_INVOICE_INQUIRIES,
1058: SUM(TOTAL_PAYMENT_INQUIRIES) TOTAL_PAYMENT_INQUIRIES ';
1059:
1060: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1061: fnd_log.string(fnd_log.level_statement,l_full_path,'l_inner_select : ' || l_inner_select );
1062: END IF;
1063:
1064:
1057: SUM(TOTAL_INVOICE_INQUIRIES) TOTAL_INVOICE_INQUIRIES,
1058: SUM(TOTAL_PAYMENT_INQUIRIES) TOTAL_PAYMENT_INQUIRIES ';
1059:
1060: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1061: fnd_log.string(fnd_log.level_statement,l_full_path,'l_inner_select : ' || l_inner_select );
1062: END IF;
1063:
1064:
1065:
1077: NULL TOTAL_ORDER_INQUIRIES,
1078: NULL TOTAL_INVOICE_INQUIRIES,
1079: NULL TOTAL_PAYMENT_INQUIRIES ';
1080:
1081: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1082: fnd_log.string(fnd_log.level_statement,l_full_path,'l_inner_select_all : ' || l_inner_select_all );
1083: END IF;
1084:
1085: -- Initialising where clause based on the view by parameter
1078: NULL TOTAL_INVOICE_INQUIRIES,
1079: NULL TOTAL_PAYMENT_INQUIRIES ';
1080:
1081: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1082: fnd_log.string(fnd_log.level_statement,l_full_path,'l_inner_select_all : ' || l_inner_select_all );
1083: END IF;
1084:
1085: -- Initialising where clause based on the view by parameter
1086: -- Since these two measures Total Booked Orders Amount,Total Booked Orders are not dependent on site dimension
1182: END IF;
1183:
1184: l_middle_group_by := ' VIEW_BY,VIEW_BY_ID ';
1185:
1186: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1187: fnd_log.string(fnd_log.level_statement,l_full_path,'l_inner_select : ' || l_inner_select ||
1188: 'l_inner_select_all : ' || l_inner_select_all || 'l_from : ' || l_from || 'l_where : ' ||
1189: l_where || 'l_from_all : ' || l_from_all || 'l_where_all : ' || l_where_all || 'l_inner_group_by : '
1190: || l_inner_select_all || 'l_middle_group_by : ' || l_middle_group_by );
1183:
1184: l_middle_group_by := ' VIEW_BY,VIEW_BY_ID ';
1185:
1186: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1187: fnd_log.string(fnd_log.level_statement,l_full_path,'l_inner_select : ' || l_inner_select ||
1188: 'l_inner_select_all : ' || l_inner_select_all || 'l_from : ' || l_from || 'l_where : ' ||
1189: l_where || 'l_from_all : ' || l_from_all || 'l_where_all : ' || l_where_all || 'l_inner_group_by : '
1190: || l_inner_select_all || 'l_middle_group_by : ' || l_middle_group_by );
1191: END IF;
1231: ' HAVING ' || l_having ||
1232: ' ) ' ||
1233: ' &ORDER_BY_CLAUSE ';
1234:
1235: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1236: fnd_log.string(fnd_log.level_statement,l_full_path,'l_custom_sql : ' || l_custom_sql );
1237: END IF;
1238:
1239: x_custom_sql := l_custom_sql;
1232: ' ) ' ||
1233: ' &ORDER_BY_CLAUSE ';
1234:
1235: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1236: fnd_log.string(fnd_log.level_statement,l_full_path,'l_custom_sql : ' || l_custom_sql );
1237: END IF;
1238:
1239: x_custom_sql := l_custom_sql;
1240:
1260: l_custom_rec.attribute_data_type := BIS_PMV_PARAMETERS_PUB.VARCHAR2_BIND;
1261: x_custom_output.EXTEND;
1262: x_custom_output(3) := l_custom_rec;
1263:
1264: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1265: fnd_log.string(fnd_log.level_statement,l_full_path,'END');
1266: END IF;
1267:
1268: EXCEPTION
1261: x_custom_output.EXTEND;
1262: x_custom_output(3) := l_custom_rec;
1263:
1264: IF gaflog_value ='Y' AND (fnd_log.level_statement >= fnd_log.g_current_runtime_level) THEN
1265: fnd_log.string(fnd_log.level_statement,l_full_path,'END');
1266: END IF;
1267:
1268: EXCEPTION
1269: WHEN OTHERS THEN
1266: END IF;
1267:
1268: EXCEPTION
1269: WHEN OTHERS THEN
1270: if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
1271: fnd_log.string(fnd_log.level_unexpected,l_full_path,SQLERRM);
1272: end if;
1273:
1274: END GET_CUST_ACTY_SQL;
1267:
1268: EXCEPTION
1269: WHEN OTHERS THEN
1270: if (fnd_log.level_unexpected >= fnd_log.g_current_runtime_level) then
1271: fnd_log.string(fnd_log.level_unexpected,l_full_path,SQLERRM);
1272: end if;
1273:
1274: END GET_CUST_ACTY_SQL;
1275: