FDMEE Scripts sample


The scope of this post is to provide some samples of common scripts that may be used in FDM Enterprise Edition for use in customizations. (FDM version – 11.1.2.3)

Example #1

Question:

Trying to use the Process Status property in scripts to generate email alerts based on the failure/success of the events. How can this be done?

Answer:

The fdmContext does return the correct status. The fdmcontext gets initialized at the start of the process and the status is not available. You can use the following to get the status. The following prints the status to a log file.

stat = fdmAPI.getProcessStates(fdmContext[“LOADID”])
fdmAPI.logInfo(str(stat[“IMPSTATUS”]))
fdmAPI.logInfo(str(stat[“EXPSTATUS”]))

Example #2
Question:

Conditional statements do not recognize any value for a variable that has not been set.
Answer:

Initialize the variable before doing any conditional statements against the variable.

site = “”

site = fdmRow.getString(“UD5”)

if (site[0:1] == “A”):
fdmResult = “SITETEST”
elif (site == “”):
fdmResult = “No_Site”
else:
fdmResult = “[” + site + “]”

Example #3

Is there a way I can make the BefImport event wait or the Import step wait until a batch completes? So the import step should start only after a data file is generated?

p = subprocess.Popen(command)

retcode = p.wait()

This would be using if you try to run a O/S Script form Jyton.

Example #4

This script replaces the ‘ and , characters in a description field so that the amount can be returned.

def FixAmt(strfield, strrec):

cleanrec = strrec.replace(“‘”, “”)

qstart = strrec.find( ‘”‘ )

if qstart > 0:

qend = strrec.rfind(‘”‘, qstart)

ndesc = strrec[qstart+1:qend].replace(“‘”, “”).replace(“,”, “”)

cleanrec = strrec[0:qstart]+ndesc+strrec[qend+1:]

seg = cleanrec.split(“,”)

return seg[2]

Example #5

Customer wants to run a calc script to perform an Essbase extract, and then load the extract file with FDMEE.

1)Create a batch file (.bat) that performs the extract from Essbase.

2)Then you call the batch file from the BefImport event script.

import os

import subprocess

import shutil

os.chdir(“D:\temp\\BatchFiles”)

command = “D:\temp\BatchFiles\helloworld.bat > helloworld.out”

p = subprocess.Popen(command)

retcode = p.wait()

3)Then you would load helloworld.out using FDMEE

Example #6

After Import Event Script Used to update data imported from a adapter based source system, such as SAP.

updateStmt = “””UPDATE TDATASEG_T
SET
ENTITY =
CASE
WHEN UD5 IN (‘1801’ , ‘1018’ , ‘1255’ , ‘1256’ , ‘1257’ , ‘0460’ , ‘0469’ , ‘1100’ , ‘4100’ , ‘4274’ , ‘9100’ , ‘9150’ , ‘9274’ , ‘0458’ , ‘4150’ , ‘1481’ , ‘1482’ , ‘1488’ , ‘1492’ , ‘1494’ , ‘1637’) THEN UD5||’.’||UD6
ELSE UD7
END,
UD3=
CASE
WHEN SUBSTR(ACCOUNT, 1, 1) IN (‘6’, ‘7’) AND UD6 IS NULL THEN ‘910000’
WHEN SUBSTR(ACCOUNT, 1, 1) IN (‘6’, ‘7’) THEN UD6
ELSE ‘[None]’
END
WHERE LOADID = ? “””
params = [ fdmContext[“LOADID”] ]
updateCount = fdmAPI.executeDML(updateStmt, params, True)

Example #7

Using classic FDM to load, this script can remove the zero balance values.
Set the “Enable Event Script Execution” option to Yes in the Application Setting
Create a AftImport event script with the following code:

delStmt = “””
DELETE FROM tdataseg_t
WHERE loadid = ?
AND amount = 0
“””
params = [ fdmContext[“LOADID”] ]
delCount = fdmAPI.executeDML(delStmt, params, True)

Thanks,
~KKT~

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s