Tuesday, April 26, 2016

using array in Maximo Automation script


from psdi.util.logging import MXLogger
from psdi.util.logging import MXLoggerFactory
from psdi.mbo import MboConstants
from jarray import array

logger = MXLoggerFactory.getLogger("maximo.script");
logger.debug("==================== ATT_WO_WOPRIORITY." + launchPoint + ": START =====================")

# declaring as a set of double values
arrSubDiv = array([1,2,3,4,5,6],'d')

woPriority = mbo.getDouble("WOPRIORITY")

for i in arrSubDiv:
 if (i==woPriority):
   mbo.setFieldFlag("JUSTIFYPRIORITY",MboConstants.REQUIRED, True)
else:
   mbo.setFieldFlag("JUSTIFYPRIORITY",MboConstants.REQUIRED, False)


logger.debug("==================== ATT_WO_WOPRIORITY." + launchPoint + ": END =====================")





----------------------------------------------------------------------------
 All the messagesbelow are just forwarded messages if some one feels hurt about it please add your comments we will remove the post.Host/author is not responsible for these posts.

Tuesday, April 19, 2016

Get a list of included/excluded/Non Persistent/Persistent fields used in a Integration Object in Maximo.

Below query fetches list of records which have been used in integration object in Maximo .Here i took the example of Integration Object = MXASSET

select * from (
select distinct i.intobjectname,m.objectname,m.attributename,   'INCLUDE' as intobjfldtype from maximo.maxattribute m,maximo.MAXINTOBJCOLS i, maximo.MAXINTOBJDETAIL intobjdtl  where i.INTOBJECTNAME in ('MXASSET')
and intobjdtl.INTOBJECTNAME in ('MXASSET') and m.objectname=intobjdtl.objectname and m.attributename not in (select b.name from maximo.MAXINTOBJCOLS b where b.INTOBJECTNAME in ('MXASSET')) and m.persistent != 0
union
select distinct i.intobjectname, m.objectname,m.attributename, i.intobjfldtype from maximo.maxattribute m,maximo.MAXINTOBJCOLS i where i.INTOBJECTNAME in ('MXASSET') and i.intobjfldtype='EXCLUDE'
and m.objectname=i.objectname and m.attributename in (select  b.name from maximo.MAXINTOBJCOLS b where b.INTOBJECTNAME in ('MXASSET')  and intobjfldtype in ('EXCLUDE')) and m.persistent != 0
union
select distinct i.intobjectname, m.objectname,m.attributename, i.intobjfldtype from maximo.maxattribute m,maximo.MAXINTOBJCOLS i where i.INTOBJECTNAME in ('MXASSET') and i.intobjfldtype='NONPERSISTENT'
and m.objectname=i.objectname and m.attributename in (select  b.name from maximo.MAXINTOBJCOLS b where b.INTOBJECTNAME in ('MXASSET')  and intobjfldtype='NONPERSISTENT')) order by objectname,attributename



----------------------------------------------------------------------------
 All the messages below are just forwarded messages if some one feels hurt about it please add your comments we will remove the post.Host/author is not responsible for these posts.

Monday, April 18, 2016

Fixing LocAncestor Data integrity In Maximo


·         Take a backup of existing database table using below query
o   create table locancestor_bkp as (select * from locancestor);

·         Create a new procedure like this below and execute it.
*******************************************************************
create or replace procedure BUILD_LOCANCESTOR as

  MODULE_NAME varchar2(50) := 'LOCATIONS';
  SCRIPT_NAME varchar2(50) := 'BUILD_LOCANCESTOR.sql';
  TABLE_NAME  varchar2(50) := 'LOCANCESTOR';
  ERROR_COUNT number := 0; --Track no of errors
  REC_COUNTER number := 0; --Track no of loaded records
  R           number := 200; --Number of records to commit

  V_MAX_ID number;

  cursor LOCATIONS_CUR is
    select L.LOCATION, L.ORGID, L.SITEID, L.SYSTEMID from LOCHIERARCHY L;

  FIX_LOCATION LOCATIONS.LOCATION%type;
  FIX_SITEID   LOCATIONS.SITEID%type;
  /*These two variables are to hold the LOCATION and SITEID of the location
  for which we are building the hierarchy (the entries in LOCANCESTOR table)*/

  X_LOCATION LOCATIONS.LOCATION%type;
  X_SITEID   LOCATIONS.SITEID%type;
  /*These two variables are to hold the LOCATION and SITEID of the current location in the loop*/

  X_ANCESTOR_LOCATION LOCATIONS.LOCATION%type;
  X_ANCESTOR_SITEID   LOCATIONS.SITEID%type;
  /*These two variables are to hold the LOCATION and SITEID of the ancestor
  of the current location in the loop*/

begin
 

  execute immediate ('TRUNCATE TABLE ' || TABLE_NAME);
  execute immediate ('ALTER TABLE ' || TABLE_NAME || ' NOLOGGING');

  --RESET_SEQUENCE(TABLE_NAME);

  for LC in LOCATIONS_CUR loop
    declare
      FIX_SYSTEMID LOCHIERARCHY.SYSTEMID%type;

    begin
      FIX_LOCATION := LC.LOCATION;
      FIX_SITEID   := LC.SITEID;
      --These two variables will be fixed all the inner loop

     

      FIX_SYSTEMID := LC.SYSTEMID;

      X_LOCATION := LC.LOCATION;
      X_SITEID   := LC.SITEID;
      --These two variables will be changed for each iteration of the inner loop

      loop
        --Inner loop to build all LOCANCESTOR entries for the current location (FIX_LOCATION, FIX_SITEID)
        REC_COUNTER := REC_COUNTER + 1;

    

        insert /*+ APPEND */
        into LOCANCESTOR
          (LOCATION, ANCESTOR, SYSTEMID, SITEID, ORGID, LOCANCESTORID)
        values
          (FIX_LOCATION, --LOCATION
           X_LOCATION, --ANCESTOR
           FIX_SYSTEMID, --SYSTEMID
           LC.SITEID, --SITEID
           LC.ORGID, --ORGID
           LOCANCESTORSEQ.NEXTVAL --LOCANCESTORID
           );

        select max(H.PARENT), max(H.SITEID)
          into X_ANCESTOR_LOCATION, X_ANCESTOR_SITEID
          from LOCHIERARCHY H
         where H.LOCATION = X_LOCATION
           and H.SITEID = X_SITEID
           and H.SYSTEMID = FIX_SYSTEMID;

        if (X_ANCESTOR_LOCATION is null) then
          /*If there is no parent of the current location,
          so it's the top level one and we have to exit the inner loop*/
          exit;
        else
          X_LOCATION := X_ANCESTOR_LOCATION;
          X_SITEID   := X_ANCESTOR_SITEID;
        end if;
      end loop; --End the inner loop

    exception
      WHEN DUP_VAL_ON_INDEX THEN
        null;
      when others then
        ERROR_COUNT := ERROR_COUNT + 1;
       
    end;

    commit;
  end loop;

  commit;

  execute immediate ('ANALYZE TABLE ' || TABLE_NAME ||
                    ' COMPUTE STATISTICS');
  execute immediate ('ALTER TABLE ' || TABLE_NAME || ' LOGGING');

  DBMS_OUTPUT.PUT_LINE(TABLE_NAME || ' errors = ' || ERROR_COUNT);

 
end BUILD_LOCANCESTOR;
/
************************************************************
---------------------------------------------------------------------------- 
All the messagesbelow are just forwarded messages if some one feels hurt about it please add your comments we will remove the post.Host/author is not responsible for these posts.

Friday, April 15, 2016

Never Give Up.. For those who don't want to give up

Once upon a time a father was very frustrated with his son because he did not seem very manly though he was already sixteen years old. The father went to see a Zen master and asked the master to help his son become a real man. The master said: "I can help you; however, you will have to leave your son at my place for three months. For the whole period, you are not allowed to come to see him. I will assure your satisfaction after the three months." As promised, the father did not come back until three month later. The master arranged a karate match to show the father the training result. When the competition was starting, the father found out that the opponent was a karate trainer. The trainer certainly made sure that he was fully prepared to win before he started to attack. On the other side, the son fell on the floor as soon as he was attacked without any resistance. However, the boy did not surrender and got up immediately after he fell. It went on like this for no fewer than twenty times. His father was embarrassed and felt pain but dared not say anything. The boy lost badly when the match was over. The master asked the father: "Don't you think your son was showing manliness?" "I felt ashamed of him! After three months' training, what kind of result is this?! He is so weak and falls to the floor as soon as he is attacked. I don't think he is manly at all." The father was very disappointed. The master said: "I am sorry that you only look at the superficial forms of failure and success. Didn't you notice that your son had courage and bravery for standing up after his falls? It is a success if the standing-ups are more than falls, which is what a real man should possesses." The father had a sudden enlightenment and thanked the master deeply, and then he took his son home. 

Enlightenment from the Story: We should not just focus on instant results when we do something. The experiences gained and the effort given are the most precious. If one's life is always smooth, he/she will not taste the final sweetness of success after many tries without giving up. The really important virtue is to remember experiences and lessons from failures and bravely move forward to the road of success after planning a new.


----------------------------------------------------------------------------

All the messagesbelow are just forwarded messages if some one feels hurt about it please add your comments we will remove the post.Host/author is not responsible for these posts.

Monday, April 11, 2016

Maximo automation script... Jython code similar to string Starts with


from psdi.util.logging import MXLogger
from psdi.util.logging import MXLoggerFactory
from psdi.mbo import MboConstants

logger = MXLoggerFactory.getLogger("maximo.script");
siteVar=str(mbo.getMboValue("SITEID"))
## Below line does action similar to starts with in string. It compares if site variable starts with KSK or not, if it doesnt start it alerts the user
if(siteVar[:len("KSK")] <> "KSK"):
 logger.debug("Site validation")
 errorgroup = "Site"
 errorkey ="Checksite"


ref : Reference Link


----------------------------------------------------------------------------
 All the messagesbelow are just forwarded messages if some one feels hurt about it please add your comments we will remove the post.Host/author is not responsible for these posts.