Forum Stats

  • 3,854,962 Users
  • 2,264,441 Discussions
  • 7,905,847 Comments

Discussions

FDMEE: Unable to capture successful Import status Flag in afterimport script

Ishti
Ishti Member Posts: 41 Red Ribbon
edited Sep 8, 2015 8:23PM in Financial Data Management

Hello Experts,

I am facing an issue in capturing successful import in FDMEE.

I have the requirement to send email notification on successful import and unsuccessful import mentioning the status.

I have tried using the variables:

1.      Set objProcessStatus = objFDMAPI.API.MaintenanceMgr.fProcessStatus(strLoc,strCat,strPer,strRulID)

         objProcessStatus.blnImp

The value of objProcessStatus.blnImp is always returned as "False" no matter what is the status of the import ( Successful & Unsuccessful both cases)

2. I have tried with objProcessStatus.lngStatus,

     Here also the value returned is always '0' irrespective of the status of the import.

3. I have tried capturing the "PROCESSIMP" from TLOGPROCESS and the value of PROCESSIMP always remains 0 even on successful import.

While the Fish turns Orange on Import indicating a successfull import.

Need help in an effective way to capture the status flag of successful import.

Code Sample I am using to capture the Status:

Dim lngStateCheck

Dim objProcessStatus

Dim stat

strLoc = objFDMAPI.API.State.LocName

strLocKey = objFDMAPI.API.State.LocKey

strCat = objFDMAPI.API.State.CatName

strCatKey = objFDMAPI.API.State.CatKey

strPer = objFDMAPI.API.State.PeriodKey

strRulID= objFDMAPI.API.State.RuleID

  WScript.Echo "Location Key " & strLocKey

  WScript.Echo "Rule ID " & strRulID

  WScript.Echo "Partition Key " & strLocKey

  WScript.Echo "Period " & strPeriodKey

' Set Object Process Status Flag

Set objProcessStatus = objFDMAPI.API.MaintenanceMgr.fProcessStatus(strLoc,strCat,strPer,strRulID)

Set FSO = CreateObject("Scripting.FileSystemObject")

Set writefile = FSO.OpenTextFile("E:\FDMEE\data\scripts\debug.txt",8)

writefile.writeline "I am Here and my value is"

writefile.writeline objProcessStatus.blnImp

writefile.writeline objProcessStatus.lngStatus

writefile.close

'Destroy Objects

objFDMAPI.Dispose

Set objFDMAPI = Nothing

********************************

Log File Entry of PROCESSIMP: ( The following Query is from the log file stating that PROCESSIMP is updated as 0)

2015-09-01 11:15:08,008 DEBUG [AIF]:

        UPDATE TLOGPROCESS

        SET PROCESSENDTIME = CURRENT_TIMESTAMP

        ,PROCESSSTATUS = 0

          ,PROCESSIMP = 0

          ,PROCESSVAL = 0

          ,PROCESSEXP = 0

          ,PROCESSENTLOAD = 0

          ,PROCESSENTVAL = 0

          ,BLNWCDIRTY = 0

          ,BLNLOGICDIRTY = 0

          ,BLNVALDIRTY = 0

          ,PROCESSIMPNOTE = NULL

          ,PROCESSVALNOTE = NULL

          ,PROCESSEXPNOTE = NULL

          ,PROCESSENTLOADNOTE = NULL

          ,PROCESSENTVALNOTE = NULL

        WHERE PARTITIONKEY = 37 AND CATKEY = 1 AND PERIODKEY = '2017-01-31' AND RULE_ID = 56

Tagged:
IshtiSH_INT

Best Answer

  • Ishti
    Ishti Member Posts: 41 Red Ribbon
    edited Sep 7, 2015 10:34PM Answer ✓

    I have tried printing the values of IMPSTATUS in both afterimport & befValidate script.

    The value for AfterImport is =0

    While that in BefValidate =1

    This proves that the value of the status flag for IMPSTATUS is changed after the script afterimport is run.

    Thanks for your time and help.

«1

Answers

  • SH_INT
    SH_INT Member Posts: 3,192 Bronze Crown
    edited Sep 2, 2015 9:16AM

    My advice would be to dump VB and use Jython for all your scripting - It really isn't that scary, much more powerful and portable (yada, yadya) and it will be around long after VB is finally killed off completely, which it will be, and you will have to convert all of your scripts anyway. In Jython getting the import status is as simple as fdmContext["IMPSTATUS"]

    Ishti
  • Ishti
    Ishti Member Posts: 41 Red Ribbon
    edited Sep 3, 2015 3:46AM

    Can you help me with the API initialization part using Jython, as I cannot find any examples in admin guide for API initialization.

  • SH_INT
    SH_INT Member Posts: 3,192 Bronze Crown
    edited Sep 3, 2015 4:16AM

    If you writing this in FDMEE event scripts then there is no need to initalize the API as it is done for you, just reference it. Plenty of examples in the admin guide.

    As an amendment to my previous post to get the import status you will need 2 lines of code:

    status = fdmAPI.getProcessStates(fdmContext["LOADID"])

    fdmAPI.logInfo(str(status["IMPSTATUS"]))

    Ishti
  • Francisco Amores
    Francisco Amores Member Posts: 1,694 Bronze Crown
    edited Sep 3, 2015 7:02AM

    As Simon suggests, forget about VB for your scripts :-)

  • Ishti
    Ishti Member Posts: 41 Red Ribbon
    edited Sep 4, 2015 4:34PM

    Hello Experts,

    I tried with the following script.

    import smtplib

    sender = "[email protected]"

    receivers = "[email protected]"

    messagep = "This is a pass e-mail message."

    messagef = "This is a fail e-mail message."

    try:

      smtpServer = xxxx.SMTP("xxxxxx",11)

      smtpServer.starttls()

      print "Successfully sent email"

      smtpServer.quit()

    except Exception, e:

      print "Error: unable to send email: " + str(e)

    status = fdmAPI.getProcessStates(fdmContext["LOADID"])

    if str(status["IMPSTATUS"]) == 1:

      smtpServer.sendmail(sender, receivers, messagep)

    else:

      smtpServer.sendmail(sender, receivers, messagef)

    #******************************************************************************

    Getting the following Error:

    Error in CommData.postImportData

    Traceback (most recent call last):

      File "<string>", line 4600, in postImportData

      File "<string>", line 485, in executeScript

      File "E:\FDMEE/data/scripts/event/AftImport.py", line 20, in <module>

        smtpServer.sendmail(sender, receivers, messagef)

      File "__pyclasspath__/smtplib.py", line 676, in sendmail

      File "__pyclasspath__/smtplib.py", line 397, in ehlo

      File "__pyclasspath__/smtplib.py", line 333, in putcmd

      File "__pyclasspath__/smtplib.py", line 325, in send

    SMTPServerDisconnected: please run connect() first

    Appreciate your help !

    Thanks,

    Ishti

  • Ishti
    Ishti Member Posts: 41 Red Ribbon
    edited Sep 4, 2015 4:36PM

    Also,

    I have tried with the following,

    outfilename = fdmContext["INBOXDIR"]+"/Ishti.txt"

    outfile = open(outfilename, "w")

    status = fdmAPI.getProcessStates(fdmContext["LOADID"])

    if str(status["IMPSTATUS"]) == 1:

      outfile.write("Import Pass")

    else:

      outfile.write("Import Fail") 

    outfile.close()

    I always get the output as Import Fail irrespective of the status of the import ( Pass or Fail)

    Is there anything that I am missing or applying incorrectly in the code?

    Thanks,

    Ishti

  • Payal Kapoor
    Payal Kapoor Member Posts: 36
    edited Sep 7, 2015 5:03AM

    You are missing a few lines in your email script :

    1. Import these modules :

    from email.mime.text import MIMEText

    from email.MIMEBase import MIMEBase

    from email import Encoders

    2. Put quotes when checking for the status as you have converted it to string :

    if str(status["IMPSTATUS"]) == "1"


    3. You are saying "quit" in the try block above and then calling sendmail below. You can omit "starttls" as well. something like -


    sender = "[email protected]"

    receivers = "[email protected]"

    messagep = "This is a pass e-mail message."

    messagef = "This is a fail e-mail message."

    smtpServer = smtplib.SMTP('<<email server name>>')


    status = fdmAPI.getProcessStates(fdmContext["LOADID"])

    if str(status["IMPSTATUS"]) == "1":

      smtpServer.sendmail(sender, receivers, messagep)

    else:

    smtpServer.sendmail(sender, receivers, messagef)


    smtpServer.quit()


    Ishti
  • Ishti
    Ishti Member Posts: 41 Red Ribbon
    edited Sep 7, 2015 9:00AM

    Hello Payal,

    Thanks for the reply.

    I managed to get the email work properly, but still facing problem with the value of IMPSTATUS.

    My code works fine for aftervalidate

    outfilename = fdmContext["INBOXDIR"]+"/Ishti.txt"

    outfile = open(outfilename, "w")

    status = fdmAPI.getProcessStates(fdmContext["LOADID"])

    if str(status["IMPSTATUS"]) == 1:

      outfile.write("Import Pass")

    else:

      outfile.write("Import Fail") 

    outfile.close()

    While in afterimport it always prints "Import Fail" even when the import is successful.

    Thanks,

    Ishti.

  • SH_INT
    SH_INT Member Posts: 3,192 Bronze Crown
    edited Sep 7, 2015 9:45AM

    As has already been pointed out str(status["IMPSTATUS"]) is returning a string, therefore if str(status["IMPSTATUS"]) == 1: will always evaluate to false as you are trying to compare a string with a number. Change it to if str(status["IMPSTATUS"]) == "1": and you should get the desired result

    Ishti
  • Ishti
    Ishti Member Posts: 41 Red Ribbon
    edited Sep 7, 2015 11:02AM

    Hi,

    Tried Again,

    outfilename = fdmContext["INBOXDIR"]+"/Ishti.txt"

    outfile = open(outfilename, "w")

    status = fdmAPI.getProcessStates(fdmContext["LOADID"])

    if str(status["IMPSTATUS"]) == "1":

      outfile.write("Import Pass")

    else:

      outfile.write("Import Fail") 

    outfile.close()

    Output in the Text File:Import Fail

    Even though I had a successful Import.

    Thanks,

    Ishti

This discussion has been closed.