Download - KScope14 Jython Scripting
![Page 1: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/1.jpg)
Jython Scripting in FDMEEIt's Not That Scary
Tony Scalese
Edgewater Ranzal
![Page 2: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/2.jpg)
FocusServicesPeopleMethodologyCustomersPartnership
15 Years700+ clients
1000+ projects
About Edgewater Ranzal
![Page 3: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/3.jpg)
We offer a full spectrum of EPM/BI ServicesDashboards & Scorecards, Financial Analytics & Reporting, Operational
Analytics, What-if Analysis, Query & Reporting, Visual Exploration
Financial performance, Legal, Segment & Mgmt Reporting, Financial
Close HFM Optimization, Performance Lab
SOX Compliance Support
Strategic Finance, Planning, Budgeting, Forecasting, Workforce Planning, Capital Planning, Project Financial Planning
Data Integration, Financial DataManagement, Data Warehousing, Master Data Management &DRM,
ETL Services, Automation
Project/Program Mgmt, EPM Road Maps, Application Reviews, Business Requirements, Process Change, Documentation
Installation, Upgrades, Migration, System
Monitoring, Backup and Recovery, Disaster
Recovery, Load Testing, Hardware Sizing, Exalytics
Benchmarking
Consolidation
BusinessIntelligence
EnterprisePlanning
Infrastructure
Training &Support Services
ProjectManagement
DataServices
Costing & Profitability
Mgmt
Support Services – Infrastructure & Application Support Contracts
Key Teach Course Delivery: Planning, Essbase, Financial Reporting, Smart View, HPCM, HFM,
FDM, DRM, OBIEECustom Training Delivery: Process & Reporting
HPCM Standard & Detailed Models, Waterfall Allocations, Activity Based Costing, Customer, Product & LOB Profitability
![Page 4: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/4.jpg)
Jython Overview Configuring Eclipse FDMEE Scripting Configuration
Agenda
![Page 5: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/5.jpg)
Why Jython and not VBScript?● Jython is the strategic direction
of Oracle development● Jython is platform independent● The API supporting Jython
scripting will continue to be enhanced
● Jython error handling is more elegant and robust
Let’s Get It Out of the Way
![Page 6: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/6.jpg)
Python programming language written in JAVA Syntax is more sensitive than VBScript Variable data type is critical; declaration is
implicit Comment characters: # or ‘’’<comment block>’’’ import statement allows easy reuse of code Far more robust error handling Familiarize yourself with camelCase Not that different than VBScript
Jython Basics
![Page 7: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/7.jpg)
Import JAVA classesimport java.sql as sql
Utilize Try...Excepttry:
Code to execute
except:
Error handling
Script Format
![Page 8: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/8.jpg)
Sys, Traceback: Can be used to get detailed error information including line in script producing error
Java.sql: Used to interact with remote databases
Smtplib: Used for email generation
Commonly Used JAVA Classes
![Page 9: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/9.jpg)
Method Functionality
count(Substring,[Start],[End]) Number of times substring occurs
endswith(Suffix,[Start],[End]) Boolean result; does string end with suffix
find(substring,[Start],[End]) Returns position where substring is found
isdigit() Boolean result; is string all numbers
isspace() Boolean result; is string all spaces
lower() Puts still in all lower case, similar to lcase
replace(old,new,[count]) Replaces text in string
split([separator],[max split]) Returns a list, string is divided by separator
startswith(prefix,[Start],[End]) Boolean result; does string start with prefix
strip([characters]) Removes specified character(s) from string
upper() Puts still in all upper case, similar to ucase
zfill(width) Returns numeric string filled left with zeros
Jython String Manipulation
![Page 10: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/10.jpg)
Jython VBScript
If Then if x == 100:elif x == 200:else:
If x = 100 thenElseif x = 200 thenElseEnd if
Case No native statement; utilize dictionary or If Then statements
Select Case x Case 100 Case 200 Case ElseEnd Select
Jython Statements
![Page 11: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/11.jpg)
Jython VBScript
Do Loop while x<100: Do something x += 1
Do while x < 100 Do something x = x+1Loop
For Loop for x in range(100): Do something
For x = 0 to 100 Do somethingNext
Jython Iteration
![Page 12: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/12.jpg)
Jython VBScript
List lListName = [‘Elem1’,’Elem2’,’Elem3’]
for elem in lListName: print elem
aArrayName = Array(“Elem1”,”Elem2”,”Elem3”)
For each strElem in aArrayName msgbox strElemNext
Dictionary dictName = {}dictName[‘Tony Scalese’] = 36dictName[‘Opal Alapat’] = 39
for sKey,sItem in dictName.iteritems(): print sKey + ‘\’s age is ‘ + str(sItem)
Set dictName = CreateObject(“Scripting.Dictionary”)
dictName.Add “Tony Scalese”, 36dictName.Add “Opal Alapat”, 39
For each strKey in dictName.Keys msgbox strKey & “’s age is “ & dictName.Item(strKey)Next
Jython Mapping Data Type
![Page 13: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/13.jpg)
Jython Overview Configuring Eclipse FDMEE Scripting Configuration
Agenda
![Page 14: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/14.jpg)
If a JRE is not installed, be sure to install the 64 bit JRE (install using defaults)● http://
www.oracle.com/technetwork/java/javase/downloads/jre7-downloads-1880261.html
JAVA Runtime Environment (JRE)
![Page 15: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/15.jpg)
Download Jython 2.5.1 from http://www.jython.org/downloads.html● Do not use a more up to date version!
Jython Download
![Page 16: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/16.jpg)
Select English Next Accept the EULA Next Select Standard Next Leave the default C:\Jython2.5.1 directory Next May be prompted that the directory is created,
click OK and Next again Leave Current as JAVA home directory Next Click Next on the Summary tab, install will begin Click Next on the ReadMe and then Finish
Jython Install
![Page 17: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/17.jpg)
Confirm the C:\jython2.5.1 directory exists Confirm jython.jar file exists
Jython Install Confirmation
![Page 18: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/18.jpg)
Download Eclipse Standard from http://www.eclipse.org/downloads/
Download Eclipse
![Page 19: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/19.jpg)
Extract the download to the C:\ directory Open the C:\Eclipse folder and launch
eclipse.exe
Extract Eclipse
![Page 20: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/20.jpg)
Specify a default workspace
Workspace
![Page 21: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/21.jpg)
Expand General Editors and click Text Editors
Change the options:● Display tab width: 2● Insert spaces for tabs:
Checked● Show Print Margin:
Checked● Show Line Numbers:
Checked
Configure Eclipse General Options
![Page 22: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/22.jpg)
Select Windows Preferences Expand Install/Update Click Available Software Sites Click Add Name: PyDev Location: http://pydev.org/updates/ Click OK
Install PyDev
![Page 23: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/23.jpg)
PyDev Install
![Page 24: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/24.jpg)
Select Help Install New Software Click PyDev from the Work With drop down Check PyDev Click Next Click Next Accept the EULA and click Finish
PyDev Install
![Page 25: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/25.jpg)
Put a check next to the certificate
Click OK Click Yes to restart Eclipse
after the install
PyDev Install
![Page 26: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/26.jpg)
Windows Preferences Expand PyDev and click Editor Change tab length to 2
Set PyDev Options
![Page 27: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/27.jpg)
Interpreter – Jython Click New
● Interpreter Name: Jython2.5.1● Browse and select Jython.jar from C: drive
Click OK
Set PyDev Interpreter
![Page 28: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/28.jpg)
When prompted, leave defaults and click OK
Set PyDev Interpreter
![Page 29: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/29.jpg)
Close the Welcome Screen Right click the Package Explorer New Project
Creating a Project
![Page 30: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/30.jpg)
Expand PyDev and select PyDev Project Click Next
Creating a Project
![Page 31: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/31.jpg)
Name the Project Change the project type to Jython Click Finish Click Yes when prompted
Creating a Project
![Page 32: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/32.jpg)
Right click the Project Select New Folder
● Name the folder src● Repeat and create as lib
Organize Code
![Page 33: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/33.jpg)
Right click lib folder and select Import Expand General and select File System
Import JAR Files
![Page 34: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/34.jpg)
From Directory: lib directory of FDM● %hyperion_home%\Products\FinancialDataQuality\
lib Check the aif-apis.jar Click Finish
Import FDMEE JAR
![Page 35: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/35.jpg)
Right click the project (ER_FDMEE) Select Properties Click PyDev – PYTHONPATH Click Add jar/zip/egg Expand the project and click the lib folder
Update Python Path
![Page 36: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/36.jpg)
Add new PyDev module● Right click src folder● New PyDev module
Creating Modules
![Page 37: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/37.jpg)
Specify a name Click Finish When prompted for a template, select Module
main and click OK
Creating Modules
![Page 38: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/38.jpg)
Add print “hello” Run the script
● Run as Jython Run hello shows in the
console window when successful
Testing Module
![Page 39: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/39.jpg)
Add the following text to the module:● import com.hyperion.aif.scripting.API as API
Save the module Type API(). on a new line. A list of available methods will display
Testing FDMEE API Usage
![Page 40: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/40.jpg)
Jython Overview Configuring Eclipse FDMEE Scripting Configuration
Agenda
![Page 41: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/41.jpg)
The equivalent of Import – Data Pump scripts in FDM Classic Import Integration scripts have been replaced by the Open
Interface adaptor and the BefImport event script Import scripts are used to manipulate data during the import
process Execute during an import process when assigned to the
import format used by the location and data load rule Every line in the data file is evaluated Avoid the temptation to overuse import scripts
● Parsing strings that cannot be parsed by an import format● Temporary variables storing header information● Mapping data should be done in maps, not import scripts
Import Scripts
![Page 42: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/42.jpg)
Define the script name● def ScriptName (strfield,strrecord):
Write script actions● aField = split(strrecord,”-”)● sCostCenter = aField[1]
Return result to function● return sCostCenter
Import Script SyntaxNotice the
colon at the end
![Page 43: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/43.jpg)
def EBS_CostCenter(strField, strRecord):
sCC = strField
if strField.count(“.”) > 0:
aSegments = strField.split(‘.’)
sCC = aSegments[2]
return sCC
Sample Import Script
Notice the colon at the
end
![Page 44: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/44.jpg)
No longer limited to 5 Declare a variable before the function Designate the variable as global
strDept = “”
def Nvision_Entity(strfield,strrecord):
if strrecord[1:5] == “Dept:”:
global strDept
strDept = strrecord[6:9]
return strfield
Temporary Variables (RES.pVarTempx)
![Page 45: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/45.jpg)
Simply return temporary variable in “assign” script
def Nvision_C1(strfield,strrecord):
return strDept
Using Temporary Variables
![Page 46: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/46.jpg)
Similar in concept to varValues Be careful of overuse due to performance
impacts Enter #SCRIPT to activate script section of
maps fdmRow.getString(“FieldName”) fdmResult = “Mapped_Result”
Mapping Scripts
![Page 47: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/47.jpg)
Execute during defined events within the application
Fewer than FDM Classic, notably StartUp, POVChanged
Scope needs to be well defined to ensure process only executes when needed
No need to declare function● def BefImport(): Not needed
Event Scripts
![Page 48: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/48.jpg)
Event Description FDM Classic Equivalent
Import Executes any time the import process is executed
ImportAction, FileImport
Calculate Before & After Logic groups and maps processing
Calculate
ProcLogicGrp When logic groups are assigned ProcLogicGroup
ProcMap Executes ONCE during mapping application
ProcMap
Validate Validate workflow step Validate
ExportToDat Export workflow step ExportToDat
Load Export workflow step Load
Consolidate Export workflow step Consolidate
Check Check workflow step Check
Events – Before and After
![Page 49: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/49.jpg)
Custom scripts are used to extend the functionality of FDMEE
Custom script are organized in groups● Scripts can be assigned to multiple groups
Custom scripts are registered● Similar to Menu Maker specifying a caption● Parameters can be added to make a script more dynamic
Custom scripts can executed from web UI No need to declare function
● def ER_OutputData(): Not needed
Custom Scripts
![Page 50: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/50.jpg)
Create a group● Logical grouping that a user can select
● By Region: North America, EMEA, Asia Pacific● By Purpose: Data Exports, Budget, Actuals
Register script to group● Add parameters if applicable
Custom Script Registration
![Page 51: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/51.jpg)
Select Group Select Script & click Execute
● Specify parameters if applicable Select Execution Mode and click OK
Executing Custom Scripts
![Page 52: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/52.jpg)
Used to test code without actually impacting the data in FDMEE
4 sections:1. Initialize dev mode
2. Populate context
3. Custom code
4. Clean-up actions Once code is tested, sections 1, 2 & 4 can be
removed, handled natively by the application
Development Mode
![Page 53: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/53.jpg)
Commonly Used Occasionally Used Rarely Used
APPIDCATKEYCATNAMECHKSTATUSEXPSTATUSIMPSTATUSINBOXDIRLOADIDLOCKEYLOCNAMEOUTBOXDIRPERIODNAMEPERIODKEYPROCESSSTATUSSCRIPTSDIRVALSTATUS
EXPORTFLAGEXPORTMODEFILEDIRFILENAMEIMPORTFLAGIMPORTFORMATIMPORTMODEMULTIPERIODLOADRULEIDRULENAMESOURCENAMESOURCETYPETARGETAPPDBTARGETAPPNAME
BATCHSCRIPTDIREPMORACLEHOMEEPMORACLEINSTANCEHOME
FDM Context
Each execution includes a collection of information
![Page 54: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/54.jpg)
import java.math.BigDecimal as BigDecimal
import java.sql as sql
import com.hyperion.aif.scripting.API as API
fdmAPI = API()
conn = sql.DriverManager.getConnection("jdbc:oracle:thin:@server:port:SID", "user", "password");
conn.setAutoCommit(False)
fdmAPI.initializeDevMode(conn);
print “Connected”
Initialize Development Mode
![Page 55: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/55.jpg)
fdmContext = fdmAPI.initContext(BigDecimal(LoadID))
print “Location Name: “ + fdmContext[“LOCNAME”]
Populate Context
![Page 56: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/56.jpg)
fdmAPI.closeConnection();
Clean-up Action
![Page 57: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/57.jpg)
getPOVLocation(LoadID), Category, StartPeriod, EndPeriod: Returns key, not text
executeDML(query,param_list) getCustomScriptParameterValue(loadID,param):
Load ID is optional executeQuery(query,parameters): Returns recordset showCustomFile(FilePath): Display file showCustomMessage(message) logFatal(message), Error, Warn, Info, Debug
Useful FDM APIs
![Page 58: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/58.jpg)
The BefImport event script is used in conjunction with the Open Interface adaptor to import data from relational source
This approach replaces import integration scripts from FDM Classic
Check out Mike Casey’s presentation - Using the Open Interface Adapter in FDM Enterprise Edition 11.1.2.3 - on 6/25 from 2-3 for a deep dive into the setup
Integrating Data from Relational Sources
![Page 59: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/59.jpg)
import java.text.SimpleDateFormat as SimpleDateFormat
import java.sql as sql
strPOVPer = fdmContext["PERIODKEY"]
strYear = SimpleDateFormat("yyyy").format(strPOVPer)
lngMonth = SimpleDateFormat("MM").format(strPOVPer)
strMonth = SimpleDateFormat("MMM").format(strPOVPer)
batchName = "MatchDataLoadRuleParam"
BefImport Script Sample - Setup
![Page 60: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/60.jpg)
insertStmt = """
INSERT INTO AIF_OPEN_INTERFACE (
BATCH_NAME
,YEAR
,PERIOD
,PERIOD_NUM
,CURRENCY
,COL01
,COL02
,AMOUNT
) VALUES (
?
,?
,?
,?
,?
,?
,?
)
"""
BefImport Script Sample – Build Query
![Page 61: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/61.jpg)
#Connect to source DB
sourceConn = sql.DriverManager.getConnection("jdbc:oracle:thin:@Server:Port:SID","User","Password");
#Build SELECT statement to get data to insert
selectStmt = "Select * from table \n"
selectStmt = selectStmt + "Where 1=1 \n"
#Run the query to get the data
stmt = sourceConn.prepareStatement(selectStmt)
RS = stmt.executeQuery()
BefImport Script Sample – Run Query
![Page 62: KScope14 Jython Scripting](https://reader036.vdocuments.site/reader036/viewer/2022081412/54151b078d7f72486c8b4829/html5/thumbnails/62.jpg)
#Loop through the data and import it into the Open Interface table
while(RS.next()):
params = [ batchName, strYear,strMonth,lngMonth, "USD", RS.getString("Account"), RS.getString("Entity"), RS.getBigDecimal("Amount") ]
fdmAPI.executeDML(insertStmt, params, False)
fdmAPI.commitTransaction()
#Close the connection
RS.close()
sourceConn.close()
BefImport Script Sample – Import Data