1923: FROM bsc_kpi_analysis_groups
1924: WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1925:
1926: DELETE
1927: FROM bsc_kpi_analysis_options_b
1928: WHERE indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
1929:
1930: DELETE
1931: FROM bsc_kpi_analysis_options_tl
5201:
5202: --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 7');
5203:
5204: -- show All the analysis options.
5205: update BSC_KPI_ANALYSIS_OPTIONS_B
5206: set USER_LEVEL1 = USER_LEVEL0
5207: where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5208:
5209: --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Master_Kpi Flag 10');
5465:
5466: --DBMS_OUTPUT.PUT_LINE(' BSC_KPI_PVT.Create_Shared_Kpi - Flag 11');
5467:
5468: -- show All the analysis options.
5469: update BSC_KPI_ANALYSIS_OPTIONS_B
5470: set USER_LEVEL1 = USER_LEVEL0
5471: where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id;
5472:
5473: -- Fix issue in bug 3248729
5789: -- default if it is the Master KPI, if it is not the Master KPI, then reselect the
5790: -- default from the Master.
5791: select count(*)
5792: into l_count
5793: from BSC_KPI_ANALYSIS_OPTIONS_B
5794: where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5795: and analysis_group_id = 0
5796: and user_level1 = 1;
5797:
5806: if ((l_share_flag = 1) and (l_proto_flag <> BSC_KPI_PUB.DELETE_KPI_FLAG)) then
5807:
5808: -- Second step is to set the default option (1) by selecting the first displayed
5809: -- option. At this point all displayed options are flagged with 2.
5810: update BSC_KPI_ANALYSIS_OPTIONS_B
5811: set user_level1 = 1
5812: where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5813: and analysis_group_id = 0
5814: and option_id = (select option_id
5811: set user_level1 = 1
5812: where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5813: and analysis_group_id = 0
5814: and option_id = (select option_id
5815: from BSC_KPI_ANALYSIS_OPTIONS_B
5816: where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5817: and user_level1 = 2
5818: and rownum < 2);
5819:
5819:
5820: -- store the default option.
5821: select option_id
5822: into l_def_option
5823: from BSC_KPI_ANALYSIS_OPTIONS_B
5824: where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5825: and analysis_group_id = 0
5826: and user_level1 = 1;
5827:
5835:
5836: FOR SrcInd IN c_Select_Indicator LOOP
5837: l_shared_kpi := SrcInd.INDICATOR;
5838:
5839: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
5840: SET USER_LEVEL1 = 2
5841: WHERE INDICATOR = l_shared_kpi
5842: AND ANALYSIS_GROUP_ID = 0
5843: AND USER_LEVEL1 = 1;
5842: AND ANALYSIS_GROUP_ID = 0
5843: AND USER_LEVEL1 = 1;
5844:
5845: -- then set the default option.
5846: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
5847: SET USER_LEVEL1 = 1
5848: WHERE INDICATOR = l_shared_kpi
5849: AND ANALYSIS_GROUP_ID = 0
5850: AND OPTION_ID = L_DEF_OPTION;
5870: from BSC_KPI_ANALYSIS_GROUPS
5871: where indicator = l_shared_kpi
5872: and analysis_group_id = 0;
5873:
5874: update BSC_KPI_ANALYSIS_OPTIONS_B
5875: set user_level1 = 1
5876: where indicator = l_Bsc_Kpi_Entity_Rec.Bsc_Kpi_id
5877: and analysis_group_id = 0
5878: and option_id = l_def_option;
5950: l_count NUMBER := 0;
5951:
5952: CURSOR c_old_option_id IS
5953: SELECT Option_Id, Parent_Option_Id, Grandparent_Option_Id
5954: FROM BSC_KPI_ANALYSIS_OPTIONS_B
5955: WHERE Indicator = p_Kpi_Id
5956: AND Analysis_Group_ID = p_group_Id
5957: AND User_Level0 = 1;
5958: BEGIN
5976:
5977: IF (l_Dependency_Flag = 0) THEN -- for indenpendent
5978:
5979: IF (l_old_option_id <> p_option_Id) THEN
5980: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
5981: SET User_Level0 = 1
5982: , User_Level1 = 1
5983: WHERE Indicator = p_Kpi_Id
5984: AND Analysis_Group_Id = p_group_Id
5989: WHERE Indicator = p_Kpi_Id
5990: AND Analysis_Group_Id = p_group_Id;
5991:
5992: -- change previous default option id back to normal
5993: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
5994: SET User_Level0 = 2
5995: , User_Level1 = 2
5996: WHERE Indicator = p_Kpi_Id
5997: AND Analysis_Group_Id = p_group_Id
6003: IF (p_group_Id = 0) THEN
6004:
6005: IF (l_old_option_id <> p_option_Id) THEN
6006:
6007: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6008: SET User_Level0 = 1
6009: , User_Level1 = 1
6010: WHERE Indicator = p_Kpi_Id
6011: AND Analysis_Group_Id = p_group_Id
6016: WHERE Indicator = p_Kpi_Id
6017: AND Analysis_Group_Id = p_group_Id;
6018:
6019: -- change previous default option id back to normal
6020: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6021: SET User_Level0 = 2
6022: , User_Level1 = 2
6023: WHERE Indicator = p_Kpi_Id
6024: AND Analysis_Group_Id = p_group_Id
6028: ELSIF (p_group_Id = 1) THEN
6029:
6030: IF (l_old_option_id <> p_option_Id ) OR (l_old_parent_option_Id <> p_Parent_Option_Id) THEN
6031:
6032: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6033: SET User_Level0 = 1
6034: , User_Level1 = 1
6035: WHERE Indicator = p_Kpi_Id
6036: AND Analysis_Group_Id = p_group_Id
6042: WHERE Indicator = p_Kpi_Id
6043: AND Analysis_Group_Id = p_group_Id;
6044:
6045: -- change previous default option id back to normal
6046: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6047: SET User_Level0 = 2
6048: , User_Level1 = 2
6049: WHERE Indicator = p_Kpi_Id
6050: AND Analysis_Group_Id = p_group_Id
6056:
6057: IF (l_old_option_id <> p_option_Id ) OR (l_old_parent_option_Id <> p_Parent_Option_Id)
6058: OR (l_old_grandparent_option_Id <> p_Grand_Parent_Option_Id) THEN
6059:
6060: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6061: SET User_Level0 = 1
6062: , User_Level1 = 1
6063: WHERE Indicator = p_Kpi_Id
6064: AND Analysis_Group_Id = p_group_Id
6071: WHERE Indicator = p_Kpi_Id
6072: AND Analysis_Group_Id = p_group_Id;
6073:
6074: -- change previous default option id back to normal
6075: UPDATE BSC_KPI_ANALYSIS_OPTIONS_B
6076: SET User_Level0 = 2
6077: , User_Level1 = 2
6078: WHERE Indicator = p_Kpi_Id
6079: AND Analysis_Group_Id = p_group_Id
6139: where indicator = l_source_kpi
6140: and analysis_group_id = 0;
6141:
6142: -- Set this default option for the display flag
6143: update BSC_KPI_ANALYSIS_OPTIONS_B
6144: set user_level1 = 1
6145: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6146: and analysis_group_id = 0
6147: and option_id = l_default_option;
6159:
6160: -- If there is no dependency apply This flag without filtering on parent id.
6161: if l_dependency1_flag <> 1 then
6162:
6163: update BSC_KPI_ANALYSIS_OPTIONS_B
6164: set user_level1 = 1
6165: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6166: and analysis_group_id = 1
6167: and option_id = l_default_option;
6173: from BSC_KPI_ANALYSIS_GROUPS
6174: where indicator = l_source_kpi
6175: and analysis_group_id = 0;
6176:
6177: update BSC_KPI_ANALYSIS_OPTIONS_B
6178: set user_level1 = 1
6179: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6180: and analysis_group_id = 1
6181: and option_id = l_default_option
6196:
6197: -- if there is no dependency between groups 1 and 0, and 2 and 1 apply flag
6198: if l_dependency1_flag <> 1 and l_dependency2_flag <> 1 then
6199:
6200: update BSC_KPI_ANALYSIS_OPTIONS_B
6201: set user_level1 = 1
6202: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6203: and analysis_group_id = 2
6204: and option_id = l_default_option;
6210: from BSC_KPI_ANALYSIS_GROUPS
6211: where indicator = l_source_kpi
6212: and analysis_group_id = 1;
6213:
6214: update BSC_KPI_ANALYSIS_OPTIONS_B
6215: set user_level1 = 1
6216: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6217: and analysis_group_id = 2
6218: and option_id = l_default_option
6222:
6223: -- If there is no dependency flag between 2 an 1 then do not filter.
6224: if l_dependency2_flag <> 1 then
6225:
6226: update BSC_KPI_ANALYSIS_OPTIONS_B
6227: set user_level1 = 1
6228: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6229: and analysis_group_id = 2
6230: and option_id = l_default_option;
6242: from BSC_KPI_ANALYSIS_GROUPS
6243: where indicator = l_source_kpi
6244: and analysis_group_id = 0;
6245:
6246: update BSC_KPI_ANALYSIS_OPTIONS_B
6247: set user_level1 = 1
6248: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6249: and analysis_group_id = 2
6250: and option_id = l_default_option
6350: --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag = ' || p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag);
6351:
6352:
6353: -- Update the Analysis Option Set the option visible
6354: update BSC_KPI_ANALYSIS_OPTIONS_B
6355: set user_level1 = user_level0
6356: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6357: and analysis_group_id = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6358: and option_id = l_option_id
6465: --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - l_grandparent_option_id = ' || l_grandparent_option_id);
6466: --DBMS_OUTPUT.PUT_LINE('--BSC_KPI_PVT.Assign_Analysis_Option - p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag = ' || p_Bsc_kpi_Entity_Rec.Bsc_Dependency_Flag);
6467:
6468: -- Update the Analysis Option to hide the option
6469: update BSC_KPI_ANALYSIS_OPTIONS_B
6470: set user_level1 = 0
6471: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6472: and analysis_group_id = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6473: and option_id = l_option_id
6480:
6481: -- count the option visible under the parent
6482: select count(option_id)
6483: into l_count
6484: from BSC_KPI_ANALYSIS_OPTIONS_B
6485: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6486: and analysis_group_id = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6487: and parent_option_id = l_parent_option_id
6488: and grandparent_option_id = l_grandparent_option_id
6602:
6603: -- see if the option is selected
6604: Select count(indicator)
6605: into l_count
6606: from BSC_KPI_ANALYSIS_OPTIONS_B
6607: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6608: and analysis_group_id = p_Bsc_kpi_Entity_Rec.Bsc_kpi_Group_Id
6609: and option_id = l_option_id
6610: and parent_option_id = l_parent_option_id
6754:
6755: -- Count the option which one depending of the current one
6756: select count(option_id)
6757: into l_count_child_options
6758: from BSC_KPI_ANALYSIS_OPTIONS_B
6759: where indicator = p_Bsc_Kpi_Entity_Rec.Bsc_Kpi_Id
6760: and analysis_group_id = l_child_analysis_Group
6761: and parent_option_id = l_option_id
6762: and grandparent_option_id = l_parent_option_id;