Index: mp4/Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cfo_c.sql =================================================================== --- mp4/Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cfo_c.sql (revision 4286) +++ mp4/Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cfo_c.sql (revision 4287) @@ -10,11 +10,14 @@ -- # -- # These packages are called from modified Maximo triggers -- # -PROMPT $Header: /Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cfo_c.sql 10 26/04/06 12:00 Gc $ -DEFINE VER = '$Revision: 10 $' +PROMPT $Header: /Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cfo_c.sql 11 11/05/06 11:56 Gc $ +DEFINE VER = '$Revision: 11 $' -- # -- # $Log: /Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cfo_c.sql $ -- # +-- # 11 11/05/06 11:56 Gc +-- # 2033044 +-- # -- # 10 26/04/06 12:00 Gc -- # -- # 9 25/04/06 15:51 Gc @@ -108,6 +111,7 @@ -- # GC 03-04-06 2032078 : Added EMMWBS to p_insert/update_workorder -- # GC 03-04-06 2032989 : Added WOSEQUENCE_OLD to p_insert/update_workorder -- # GC 25-04-06 2033044 : Added generation of hierarchy pms +-- # GC 25-04-06 2033044RW : Modified obs code to only return the current pm as part of the code if the current pm has children -- #################################################### SET VERIFY OFF @@ -2053,8 +2057,9 @@ 'pm.extdate, '|| 'pm.adjnextdue, '|| 'pm.parent, '|| --- For real obs_code 'SUBSTR(SUBSTR(SYS_CONNECT_BY_PATH (pm.pmnum,''.''), 2), 1, LENGTH(SUBSTR(SYS_CONNECT_BY_PATH (pm.pmnum,''.''), 2))-1) obs_code '|| - 'SUBSTR(SUBSTR(SYS_CONNECT_BY_PATH (pm.pmnum,''.''), 2), 1, INSTR(SUBSTR(SYS_CONNECT_BY_PATH (pm.pmnum,''.''), 2), ''.'', -1)-1) obs_code '|| + -- if the pm has children then include itself in the obs code + 'DECODE(pm.haschildren, ''Y'', SUBSTR(SUBSTR(SYS_CONNECT_BY_PATH (pm.pmnum,''.''), 2), 1, LENGTH(SUBSTR(SYS_CONNECT_BY_PATH (pm.pmnum,''.''), 2))-1), '|| + 'SUBSTR(SUBSTR(SYS_CONNECT_BY_PATH (pm.pmnum,''.''), 2), 1, INSTR(SUBSTR(SYS_CONNECT_BY_PATH (pm.pmnum,''.''), 2), ''.'', -1)-1)) obs_code '|| 'FROM pm '|| 'WHERE pm.siteid = ''UKCS'' '|| 'CONNECT BY PRIOR pm.pmnum = pm.parent AND PRIOR pm.siteid = ''UKCS'' '|| @@ -2418,14 +2423,16 @@ IF bHierarchyPM THEN IF INSTR(r_new_act.obs_code, '.') > 0 THEN r_new_act.text_3 := SUBSTR(r_new_act.obs_code, INSTR(r_new_act.obs_code, '.', -1)+1); + -- if the pm haschildren the obs code will include the pm as part of the + -- code. in this case the parent will be the second last part of the obs code + IF r_new_act.text_3 = this_pm.pmnum THEN + r_new_act.text_3 := SUBSTR(r_new_act.obs_code, 1, INSTR(r_new_act.obs_code, '.', -1)-1); --- For real r_new_act.text_3 := SUBSTR(r_new_act.obs_code, 1, INSTR(r_new_act.obs_code, '.', -1)-1); --- obs_code --- IF INSTR(r_new_act.text_3, '.') > 0 THEN --- r_new_act.text_3 := SUBSTR(r_new_act.text_3, INSTR(r_new_act.text_3, '.', -1)+1); --- END IF; - - ELSIF r_new_act.obs_code IS NOT NULL THEN + IF INSTR(r_new_act.text_3, '.') > 0 THEN + r_new_act.text_3 := SUBSTR(r_new_act.text_3, INSTR(r_new_act.text_3, '.', -1)+1); + END IF; + END IF; + ELSIF r_new_act.obs_code IS NOT NULL AND r_new_act.obs_code <> this_pm.pmnum THEN r_new_act.text_3 := r_new_act.obs_code; ELSE r_new_act.text_3 := this_pm.pmnum; Index: mp4/Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cust_bp5.sql =================================================================== --- mp4/Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cust_bp5.sql (revision 4286) +++ mp4/Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cust_bp5.sql (revision 4287) @@ -7,11 +7,14 @@ -- # -- # Copyright 2002 Monitor Management Control Systems Ltd. -- # -PROMPT $Header: /Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cust_bp5.sql 5 5/04/06 11:35 Gc $ -DEFINE VER = '$Revision: 5 $' +PROMPT $Header: /Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cust_bp5.sql 6 11/05/06 11:56 Gc $ +DEFINE VER = '$Revision: 6 $' -- # -- # $Log: /Clients/BP_UKCS/Maximo_Interface5/maxmpower/process/pb_max_cust_bp5.sql $ -- # +-- # 6 11/05/06 11:56 Gc +-- # 2033044 +-- # -- # 5 5/04/06 11:35 Gc -- # 2033581 -- # @@ -61,6 +64,7 @@ -- # CAM 17-05-05 2020701 : Improved WO Hierarchy logic. -- # GC 22-12-05 2028759 : Added f_get_location -- # GC 05-04-06 2033581 : Return the bottom level from f_get_workorder_obs +-- # GC 25-04-06 2033044 : Modified f_get_workorder_obs to only return the current workorder as part of the code if the current workorder has children -- #################################################### SET VERIFY OFF @@ -88,12 +92,6 @@ AND location = p_location ORDER BY DECODE(systemid,'PRIMARY',1,2); - CURSOR get_wo_obs_count(p_siteid IN VARCHAR2, p_wonum IN VARCHAR2) IS - SELECT COUNT(*) obs_levels - FROM woancestor - WHERE siteid = p_siteid - AND wonum = p_wonum; - CURSOR get_workorder_obs(p_siteid IN VARCHAR2, p_wonum IN VARCHAR2) IS SELECT wa.ancestor code FROM woancestor wa, workorder wo @@ -231,14 +229,6 @@ s_obs t_bs_contents.code%TYPE; n_levels PLS_INTEGER; BEGIN - OPEN get_wo_obs_count(p_siteid, p_wonum); - FETCH get_wo_obs_count INTO n_levels; - CLOSE get_wo_obs_count; - - IF n_levels = 1 THEN - RETURN p_wonum; - END IF; - s_obs := NULL; FOR r_wo IN get_workorder_obs(p_siteid, p_wonum) LOOP s_obs := s_obs || r_wo.code || '.';