Maximo Open Forum

 View Only
  • 1.  Automation Script error writing to S3 bucket in AWS (Red Hat) environment

    Posted 10 hours ago

    I am having an issue with automation script.  It used to work fine on Prim in Maximo 7.6.1.3.  The script creates an AWARD memo (BIRT report) and attach it to Work order and saves it in DOCLINK folder.

    Now in MAS9, it's giving error writing to S3 folders in AWSs environment, any help or guidance will be great, I am new to AWS- Red Hat arena.

    here is script:

    from psdi.server import MXServer

    from com.ibm.tivoli.maximo.report.birt.admin import ReportAdminServiceRemote

    from com.ibm.tivoli.maximo.report.birt.runtime import ReportParameterData

    from java.text import SimpleDateFormat

    from psdi.mbo import MboConstants

    from psdi.util.logging import MXLoggerFactory

    # var_rptname = ''

    #userinfo = mbo.getUserInfo()

    #para = ReportParameterData()

    def getDoclinksDir(myDocType):

        doctypesMboSet = MXServer.getMXServer().getMboSet("DOCTYPES", mbo.getUserInfo())

        doctypesMboSet.setWhere("DOCTYPE = " + "'" + myDocType + "'")

        doctypesMboSet.reset()

        doctypesMbo = doctypesMboSet.moveFirst();

        return doctypesMbo.getString("DEFAULTFILEPATH")

       

    def generateReport():

        if mbo.getString("STATUS") == 'APPR' and not mbo.isNull("glaccount") :

            sdf = SimpleDateFormat("yyyyMMddhhmmss")

            maximo= MXServer.getMXServer()

            userinfo = mbo.getUserInfo()

            para = ReportParameterData()

            var_rptname = ''

            var_filename ='AwardMemo'

            var_wonum = mbo.getString("WONUM")

            filepath = getDoclinksDir("AwardMemo")

            newType ='SentAward'

            var_rptname = 'FMS_PROJECT_Award_Memo.rptdesign'

            xdoclinksMboSet = mbo.getMboSet("PROJECTAWARDLINKS")

            # Relationship to DOCLINKS

            # (ownertable='WORKORDER' and ownerid=:workorderid  and doctype='InspMemo')

            filename2 = var_filename+ "-"+var_wonum+"-"+ sdf.format(maximo.getDate())

            filename3 = filepath + "/" + filename2 + ".pdf"

            para.addParameter("wonum", var_wonum)

            reportService = MXServer.getMXServer().lookup("BIRTREPORT")

            outputReport = reportService.runReport(userinfo, var_rptname, "WOTRACK", para, filename2, "pdf")

            report_file = open(filename3,"wb")

    #        report_file.write(outputReport)

    #        report_file.flush()

    #        report_file.close()

        # change the previous awardmemo to a diff doctype so that on the communication template only

        # the latest memo will be sent - template sends all Image folder

         

            docl = xdoclinksMboSet.moveFirst()

            if docl is not None:

                var_DOCTYPE = newType

            else:

                var_DOCTYPE = var_filename

           

            doclinksMboSet = mbo.getMboSet("DOCLINKS")

            doclinksMbo = doclinksMboSet.add()

            doclinksMbo.setValue("URLTYPE", "FILE")

            doclinksMbo.setValue("URLNAME", filename3)

            doclinksMbo.setValue("NEWURLNAME", filename3)

            doclinksMbo.setValue("DOCTYPE", var_DOCTYPE)

            doclinksMbo.setValue("ADDINFO", True)

            doclinksMbo.setValue("DOCUMENT", var_filename)

            doclinksMbo.setValue("DESCRIPTION", filename2)

            doclinksMboSet.save()

           

            clMbo =  mbo.createComm()

            clMbo.setValue('TEMPLATEID', 'PROJAWARD')

            try:

                clMbo.sendMessage()

            except:

                clMbo.setValue("ISSENDFAIL", True, mbo.NOACCESSCHECK)

    if (mbo.getString("STATUS") == 'APPR') and mbo.getString("WORKTYPE") == 'PROJECT':

        generateReport()


    #MaximoApplicationSuite

    ------------------------------
    Hardev Bal
    Navitas
    ------------------------------


  • 2.  RE: Automation Script error writing to S3 bucket in AWS (Red Hat) environment

    Posted 5 hours ago
    Edited by Steven Shull 5 hours ago

    There's a generic framework for attachment handling that will simplify your experience. Add the following import

    from com.ibm.tivoli.maximo.oslc.provider import AttachmentStorage

    And then after you call doclinksMbo = doclinksMboSet.add() do the following

    docStore=AttachmentStorage.getInstance()
    newFileName=docStore.getAttachmentQualifiedName(doclinksMbo,filename2)
    docStore.createAttachment(newFileName,outputReport,"application/pdf")

    Note: filename3 and filepath would go away as well as getDoclinksDir method. DOCTYPES are now metadata only meaning it doesn't change the folder structure for new attachments. On the NEWURLNAME and URLNAME you would set the value to newFileName



    ------------------------------
    Steven Shull
    Naviam
    ------------------------------



Newest Episode
Ep. 4 | System Properties in IBM Maximo

Watch Steven Shull walk through practical IBM Maximo system properties that can improve usability, query behavior, attachment handling, and the overall Maximo user experience.

MORE by Naviam Episode 4 cover
Watch Episode 4
Also available: Ep. 3 | Work Order Role-Based Application