56: BEGIN
57:
58:
59: -- Reset all the global variables to NULL or to the default value
60: fii_ar_util_pkg.reset_globals;
61:
62: -- Get the parameters and set the global variables
63: fii_ar_util_pkg.get_parameters(p_page_parameter_tbl);
64: l_gt_hint := ' leading(gt) cardinality(gt 1) ';
59: -- Reset all the global variables to NULL or to the default value
60: fii_ar_util_pkg.reset_globals;
61:
62: -- Get the parameters and set the global variables
63: fii_ar_util_pkg.get_parameters(p_page_parameter_tbl);
64: l_gt_hint := ' leading(gt) cardinality(gt 1) ';
65: -- Retrieve values for global variables
66: l_as_of_date := fii_ar_util_pkg.g_as_of_date;
67: l_cust_suffix := fii_ar_util_pkg.g_cust_suffix;
62: -- Get the parameters and set the global variables
63: fii_ar_util_pkg.get_parameters(p_page_parameter_tbl);
64: l_gt_hint := ' leading(gt) cardinality(gt 1) ';
65: -- Retrieve values for global variables
66: l_as_of_date := fii_ar_util_pkg.g_as_of_date;
67: l_cust_suffix := fii_ar_util_pkg.g_cust_suffix;
68: l_curr_suffix := fii_ar_util_pkg.g_curr_suffix;
69: l_collector_id := fii_ar_util_pkg.g_collector_id;
70: l_cust_id := fii_ar_util_pkg.g_party_id;
63: fii_ar_util_pkg.get_parameters(p_page_parameter_tbl);
64: l_gt_hint := ' leading(gt) cardinality(gt 1) ';
65: -- Retrieve values for global variables
66: l_as_of_date := fii_ar_util_pkg.g_as_of_date;
67: l_cust_suffix := fii_ar_util_pkg.g_cust_suffix;
68: l_curr_suffix := fii_ar_util_pkg.g_curr_suffix;
69: l_collector_id := fii_ar_util_pkg.g_collector_id;
70: l_cust_id := fii_ar_util_pkg.g_party_id;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
64: l_gt_hint := ' leading(gt) cardinality(gt 1) ';
65: -- Retrieve values for global variables
66: l_as_of_date := fii_ar_util_pkg.g_as_of_date;
67: l_cust_suffix := fii_ar_util_pkg.g_cust_suffix;
68: l_curr_suffix := fii_ar_util_pkg.g_curr_suffix;
69: l_collector_id := fii_ar_util_pkg.g_collector_id;
70: l_cust_id := fii_ar_util_pkg.g_party_id;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
72: l_itd_bitand := fii_ar_util_pkg.g_bitand_inc_todate;
65: -- Retrieve values for global variables
66: l_as_of_date := fii_ar_util_pkg.g_as_of_date;
67: l_cust_suffix := fii_ar_util_pkg.g_cust_suffix;
68: l_curr_suffix := fii_ar_util_pkg.g_curr_suffix;
69: l_collector_id := fii_ar_util_pkg.g_collector_id;
70: l_cust_id := fii_ar_util_pkg.g_party_id;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
72: l_itd_bitand := fii_ar_util_pkg.g_bitand_inc_todate;
73: l_viewby := fii_ar_util_pkg.g_view_by;
66: l_as_of_date := fii_ar_util_pkg.g_as_of_date;
67: l_cust_suffix := fii_ar_util_pkg.g_cust_suffix;
68: l_curr_suffix := fii_ar_util_pkg.g_curr_suffix;
69: l_collector_id := fii_ar_util_pkg.g_collector_id;
70: l_cust_id := fii_ar_util_pkg.g_party_id;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
72: l_itd_bitand := fii_ar_util_pkg.g_bitand_inc_todate;
73: l_viewby := fii_ar_util_pkg.g_view_by;
74: l_self_msg := fii_ar_util_pkg.g_self_msg;
67: l_cust_suffix := fii_ar_util_pkg.g_cust_suffix;
68: l_curr_suffix := fii_ar_util_pkg.g_curr_suffix;
69: l_collector_id := fii_ar_util_pkg.g_collector_id;
70: l_cust_id := fii_ar_util_pkg.g_party_id;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
72: l_itd_bitand := fii_ar_util_pkg.g_bitand_inc_todate;
73: l_viewby := fii_ar_util_pkg.g_view_by;
74: l_self_msg := fii_ar_util_pkg.g_self_msg;
75: l_hierarchical_flag := fii_ar_util_pkg.g_is_hierarchical_flag;
68: l_curr_suffix := fii_ar_util_pkg.g_curr_suffix;
69: l_collector_id := fii_ar_util_pkg.g_collector_id;
70: l_cust_id := fii_ar_util_pkg.g_party_id;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
72: l_itd_bitand := fii_ar_util_pkg.g_bitand_inc_todate;
73: l_viewby := fii_ar_util_pkg.g_view_by;
74: l_self_msg := fii_ar_util_pkg.g_self_msg;
75: l_hierarchical_flag := fii_ar_util_pkg.g_is_hierarchical_flag;
76:
69: l_collector_id := fii_ar_util_pkg.g_collector_id;
70: l_cust_id := fii_ar_util_pkg.g_party_id;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
72: l_itd_bitand := fii_ar_util_pkg.g_bitand_inc_todate;
73: l_viewby := fii_ar_util_pkg.g_view_by;
74: l_self_msg := fii_ar_util_pkg.g_self_msg;
75: l_hierarchical_flag := fii_ar_util_pkg.g_is_hierarchical_flag;
76:
77: -- Populate global temp table based on the parameters chosen
70: l_cust_id := fii_ar_util_pkg.g_party_id;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
72: l_itd_bitand := fii_ar_util_pkg.g_bitand_inc_todate;
73: l_viewby := fii_ar_util_pkg.g_view_by;
74: l_self_msg := fii_ar_util_pkg.g_self_msg;
75: l_hierarchical_flag := fii_ar_util_pkg.g_is_hierarchical_flag;
76:
77: -- Populate global temp table based on the parameters chosen
78: fii_ar_util_pkg.populate_summary_gt_tables;
71: l_cust_account_id := fii_ar_util_pkg.g_cust_account_id;
72: l_itd_bitand := fii_ar_util_pkg.g_bitand_inc_todate;
73: l_viewby := fii_ar_util_pkg.g_view_by;
74: l_self_msg := fii_ar_util_pkg.g_self_msg;
75: l_hierarchical_flag := fii_ar_util_pkg.g_is_hierarchical_flag;
76:
77: -- Populate global temp table based on the parameters chosen
78: fii_ar_util_pkg.populate_summary_gt_tables;
79:
74: l_self_msg := fii_ar_util_pkg.g_self_msg;
75: l_hierarchical_flag := fii_ar_util_pkg.g_is_hierarchical_flag;
76:
77: -- Populate global temp table based on the parameters chosen
78: fii_ar_util_pkg.populate_summary_gt_tables;
79:
80:
81: -- Find out the number of bucket ranges customized for this report
82: SELECT sum(decode(bbc.range1_low, null, 0, 1) +
176: -- 3. Aging bucket X amount will drill to Current Receivables Summary
177: -- (View by Customer Account)
178: -----------------------------------------------------------------------------
179:
180: IF (fii_ar_util_pkg.g_party_id <> '-111') THEN
181: -- Open Receivables Amount Drilldown URL
182: l_open_rec_amt_url_1 := 'pFunctionName=FII_AR_OPEN_REC_SUMMARY&VIEW_BY_NAME=VIEW_BY_ID&VIEW_BY=CUSTOMER+FII_CUSTOMER_ACCOUNTS&pParamIds=Y';
183:
184: -- Current Receivables Amount Drilldown URL
374:
375: -----------------------------------------
376: -- Construct the order by clause
377: -----------------------------------------
378: IF(instr(fii_ar_util_pkg.g_order_by, ',') <> 0) THEN
379: /*This means no particular sort column is selected in the report. So sort on
380: the default column in descending order. NVL is added to make sure the null
381: values appear last. */
382: l_order_by_clause := 'ORDER BY NVL(FII_AR_CURR_REC_AMT, -999999999) DESC';
380: the default column in descending order. NVL is added to make sure the null
381: values appear last. */
382: l_order_by_clause := 'ORDER BY NVL(FII_AR_CURR_REC_AMT, -999999999) DESC';
383:
384: ELSIF(instr(fii_ar_util_pkg.g_order_by, 'DESC') <> 0)THEN
385: /*This means a particular sort column is clicked to have descending order in which
386: case we would want all the null values to appear last in the report so add an
387: NVL to that column.*/
388: l_order_column := substr(fii_ar_util_pkg.g_order_by, 1,
384: ELSIF(instr(fii_ar_util_pkg.g_order_by, 'DESC') <> 0)THEN
385: /*This means a particular sort column is clicked to have descending order in which
386: case we would want all the null values to appear last in the report so add an
387: NVL to that column.*/
388: l_order_column := substr(fii_ar_util_pkg.g_order_by, 1,
389: instr(fii_ar_util_pkg.g_order_by, ' DESC'));
390: l_order_by_clause := 'ORDER BY NVL('||l_order_column ||', -999999999) DESC';
391: ELSE
392: /*This is the case when user has asked for an ascending order sort. Use PMV's
385: /*This means a particular sort column is clicked to have descending order in which
386: case we would want all the null values to appear last in the report so add an
387: NVL to that column.*/
388: l_order_column := substr(fii_ar_util_pkg.g_order_by, 1,
389: instr(fii_ar_util_pkg.g_order_by, ' DESC'));
390: l_order_by_clause := 'ORDER BY NVL('||l_order_column ||', -999999999) DESC';
391: ELSE
392: /*This is the case when user has asked for an ascending order sort. Use PMV's
393: order by clause*/
519: || ', NULL FII_AR_CR_BKT_AMT_DRILL_B' || i;
520: END LOOP;
521:
522: l_sqlstmt := l_sqlstmt || ' FROM (
523: SELECT /*+ INDEX(f FII_AR_NET_REC'|| fii_ar_util_pkg.g_cust_suffix ||'_mv_N1)*/
524: v.viewby VIEWBY,
525: v.viewby_code VIEWBYID,
526: sum(f.total_open_amount) FII_AR_OPEN_REC_AMT,
527: sum(f.current_open_amount) FII_AR_CURR_REC_AMT,
531: l_bucket_sql || l_cust_clause || '
532: FROM fii_ar_net_rec'||l_cust_suffix||'_mv'||l_curr_suffix||' f,
533: (SELECT /*+ no_merge '||l_gt_hint|| ' */ *
534: FROM fii_time_structures cal, '||
535: fii_ar_util_pkg.get_from_statement ||
536: ' gt WHERE cal.report_date = :ASOF_DATE
537: AND bitand(cal.record_type_id, :BITAND_INC_TODATE) = :BITAND_INC_TODATE
538: AND '|| fii_ar_util_pkg.get_where_statement || ') v
539: WHERE f.time_id = v.time_id
534: FROM fii_time_structures cal, '||
535: fii_ar_util_pkg.get_from_statement ||
536: ' gt WHERE cal.report_date = :ASOF_DATE
537: AND bitand(cal.record_type_id, :BITAND_INC_TODATE) = :BITAND_INC_TODATE
538: AND '|| fii_ar_util_pkg.get_where_statement || ') v
539: WHERE f.time_id = v.time_id
540: AND f.period_type_id = v.period_type_id
541: AND f.org_id = v.org_id
542: AND '||fii_ar_util_pkg.get_mv_where_statement||' '|| l_where_clause ||
538: AND '|| fii_ar_util_pkg.get_where_statement || ') v
539: WHERE f.time_id = v.time_id
540: AND f.period_type_id = v.period_type_id
541: AND f.org_id = v.org_id
542: AND '||fii_ar_util_pkg.get_mv_where_statement||' '|| l_where_clause ||
543: ' GROUP BY v.viewby, v.viewby_code ' || l_cust_clause || ' ) inner_view ' || l_order_by_clause;
544:
545:
546: FII_AR_UTIL_PKG.Bind_Variable(
542: AND '||fii_ar_util_pkg.get_mv_where_statement||' '|| l_where_clause ||
543: ' GROUP BY v.viewby, v.viewby_code ' || l_cust_clause || ' ) inner_view ' || l_order_by_clause;
544:
545:
546: FII_AR_UTIL_PKG.Bind_Variable(
547: p_sqlstmt => l_sqlstmt,
548: p_page_parameter_tbl => p_page_parameter_tbl,
549: p_sql_output => curr_rec_sql,
550: p_bind_output_table => curr_rec_output);