[Home] [Help]
751: l_cost_ctr_value := translate(l_cost_ctr_value,'''',' ');
752: get_company_sql(l_viewby, l_company_value, l_region_code, l_sql, l_agg_flag);
753: p_where_clause := p_where_clause || ' and com.child_company_id = fact.company_id ';
754: if(p_mv_set = 'APIA' or p_mv_set = 'PODA' or p_mv_set = 'PQCA' or p_mv_set = 'IDLA' or p_mv_set = 'PODCUTA') then
755: if(l_sql like '%fii_company_hierarchies%') then
756: l_in_join_rec.table_name := '(select /*+no_merge*/ a.parent_company_id, a.company_id, a.company_id child_company_id '||
757: 'from ('||l_sql||')a '||
758: 'where a.com_agg_flag = ''Y'')';
759: p_where_clause := p_where_clause || ' and fact.parent_company_id = com.parent_company_id ';
764: end if;
765: else
766: l_in_join_rec.table_name := '(select /*+no_merge*/ a.company_id, com.child_company_id, a.com_agg_flag '||
767: 'from ('||l_sql||')a, '||
768: 'fii_company_hierarchies com '||
769: 'where a.company_id = com.parent_company_id)';
770: end if;
771: l_in_join_rec.table_alias := 'com';
772: l_in_join_rec.aggregated_flag := l_agg_flag;
1903: where user_id = fnd_global.user_id
1904: and report_region_code = p_region_code;
1905:
1906: select is_leaf_flag into l_leaf_flag
1907: from fii_company_hierarchies
1908: where parent_company_id = to_number(l_top_node)
1909: and parent_company_id = child_company_id;
1910:
1911: if(l_leaf_flag = 'Y') then
1917: where company_id = l_top_node
1918: and aggregated_flag = 'N';
1919: else
1920: l_viewby_sql := 'select parent_company_id, child_company_id company_id, aggregate_next_level_flag com_agg_flag '||l_rtn||
1921: 'from fii_company_hierarchies '||l_rtn||
1922: 'where child_level = parent_level+1 '||l_rtn||
1923: 'and parent_company_id = &TOPCOMPANYID';
1924: select count(*) into l_non_agrt_nodes
1925: from fii_company_hierarchies
1921: 'from fii_company_hierarchies '||l_rtn||
1922: 'where child_level = parent_level+1 '||l_rtn||
1923: 'and parent_company_id = &TOPCOMPANYID';
1924: select count(*) into l_non_agrt_nodes
1925: from fii_company_hierarchies
1926: where child_level = parent_level + 1
1927: and parent_company_id = l_top_node
1928: and aggregate_next_level_flag = 'N';
1929: end if;
1939: and aggregated_flag = 'N';
1940: end if;
1941: else
1942: select is_leaf_flag into l_leaf_flag
1943: from fii_company_hierarchies
1944: where parent_company_id = to_number(p_company_id)
1945: and parent_company_id = child_company_id;
1946: if(l_leaf_flag = 'Y') then
1947: l_viewby_sql := 'select company_id, aggregated_flag com_agg_flag '||l_rtn||
1952: where company_id = to_number(p_company_id)
1953: and aggregated_flag = 'N';
1954: else
1955: l_viewby_sql := 'select parent_company_id, child_company_id company_id, aggregate_next_level_flag com_agg_flag '||l_rtn||
1956: 'from fii_company_hierarchies '||l_rtn||
1957: 'where child_level = parent_level+1 '||l_rtn||
1958: 'and parent_company_id = &COMPANYID';
1959: select count(*) into l_non_agrt_nodes
1960: from fii_company_hierarchies
1956: 'from fii_company_hierarchies '||l_rtn||
1957: 'where child_level = parent_level+1 '||l_rtn||
1958: 'and parent_company_id = &COMPANYID';
1959: select count(*) into l_non_agrt_nodes
1960: from fii_company_hierarchies
1961: where child_level = parent_level + 1
1962: and parent_company_id = p_company_id
1963: and aggregate_next_level_flag = 'N';
1964: end if;