Discussions
Categories
- 17.9K All Categories
- 3.4K Industry Applications
- 3.3K Intelligent Advisor
- 63 Insurance
- 536.4K On-Premises Infrastructure
- 138.3K Analytics Software
- 38.6K Application Development Software
- 5.8K Cloud Platform
- 109.5K Database Software
- 17.5K Enterprise Manager
- 8.8K Hardware
- 71.1K Infrastructure Software
- 105.3K Integration
- 41.6K Security Software
FDMEE: Unable to capture successful Import status Flag in afterimport script

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
Best 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.
Answers
-
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"]
-
Can you help me with the API initialization part using Jython, as I cannot find any examples in admin guide for API initialization.
-
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"]))
-
As Simon suggests, forget about VB for your scripts :-)
-
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
-
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
-
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()
-
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.
-
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
-
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