SlideShare uma empresa Scribd logo
1 de 50
Become Jythonic
Best Practices for FDMEE Scripts
Francisco Amores
Infratects
 The following is intended for information purposes
only on behalf of Infratects, and may not be
incorporated into any contract. It is not a commitment
to deliver any services or functionality, and should not
be relied upon in making purchasing decisions. This
provides no warranties with respect to the offerings
described within. The development, release, and
timing of any features or functionality described for
Oracle’s products remains at the sole discretion of
Oracle. Any third-party names, trademarks and
copyrights contained in this document are the
property of their respective owners
Safe Harbour
 Say hello to Jython
 Coding standards – PEP8
 Best practices when…
 Best practices for FDMEE scripts
 Highlights
 Q&A
Agenda
DEEP EXPERTISE
HOSTING
CLOUD
DESIGN
CONFIGURATION
INSTALLATION
STRESS TESTING
UPGRADES
MIGRATIONS
PATCHING
INTEGRATION
SUPPORT
TRAINING
INFRASTRUCTURE
FOLLOW THE SUN
SUPPORT
40+CONSULTANTS
15+ YEARS
EXPERIENCE
5 DATA
CENTERS
NA EMEA APAC
DEDICATED
MANAGED SERVICES
& SUPPPORT
TEAM
FOCUSED
15
IN BUSINESS
YEARS INFRATECTS FI
INFRATECTS UK
INFRATECTS NL2000
INFRATECTS AUS2008
2009
2012
INFRATECTS US2014
INFRATECTS SP2012
WWW.INFRATECTS.COM
● Data Integration Leader
● +9 years focused on Data
Integration
● Link between functional
and technical people
● FDMEE Blogger
● fishing with FDMEE
● FDMEE Trainer
● Active member of OTN Next challenge
August-2015
CCC Mont Blanc
100KM
+6000m
Goals
What I don’t pretend What I do pretend
● You change all your
scripts after this
session
● You get bored and
leave the room 
● You take best practices
into account
● Loose your fear of
Jython
● You enjoy 
JYTHONEER OR JYTHONIST?
Say hello to Jython
 Python implementation for JVM
 Functional + object-oriented
 Elegant syntax for clearer scripts
 Key fundamentals
● Code Indentation
● No need to declare types
● Indexes start at 0
● Slicing notation
● Seamless integration with Java
What is Jython?
+
_______
 Windows and penguin are both happy
 Easy to learn and code
 Code reusing
 VB Script is obsolete
 JAVA APIs across EPM products
 Jython 2.5.1
Why Jython in FDMEE?
 VB syntax = 'Oh God!'
 Jython syntax = 'My Goodness!‘
 Simpler and clearer solutions
 No begin/end tags
 Functions are always defined as def (no Sub)
 More robust and flexible error handling
Key differentiators with VB Script
 Idiomatic Jython
● Common scripting idioms
● May not be obvious to newcomers
 How do I get Jythonista?
What is Jythonic?
1. Get it working at all
2. Get it working regularly
3. Reuse code and design for reuse
4. Starting to write idiomatic Jython
 Just an example
What is Jythonic?
CODING STANDARDS – PEP8
15
“Programs must be written for people to read,
and only incidentally for machines to execute”
—Abelson & Sussman,
Structure and Interpretation of Computer Programs
 Scripts easy to read
 Python Enhancement Proposal
 Must-read: coding standards (PEP8)
Coding Style
Object Convention
Functions, methods, modules joined_lower, camelCase
Constants joined_lower or ALL_CAPS
Global variable names joined_lower
Variable names camelCase
Naming convention
 No hard tabs (never mix)
 Indentation level  4 spaces
 Space after “,” (lists, dicts, args, tuples)
 Space around assignment and comparisons
Indentation and whitespaces
Hanging indent
• No args in 1st line
• Additional indent for args
Implied line
• Vertical Align with opening
delimiter
 Line length < 80 chars (73 for
comments)
 Align elements of continuation
lines
● After binary operator
● Vertically below open
delimiter (), [], {}
Long lines and continuations
 No need to use break lines
 Log messages SQL queries using the fdmAPI
Triple quotes for long strings
Comments and Documentation strings
● # Comment = Why and how the code works
● Block Comments
● Inline Comments
● Doc String = How to use
Please
keep them
up to date
Where do you write your scripts?
 Who are you?
● IT  Eclipse (PyDev), Netbean, Emacs, etc.
● Business  Notepad++, others
 Making your way to Jythonista easier
● IDE/Editor integration with PEP8
● Pylint (Python formatting code evaluation utility)
● PEP8 plugin for Notepad++
 PEP8 online checker (http://pep8online.com/)
Don’t be scared and try it at home
BEST PRACTICES WHEN…
24
Using loops and conditional statements
 What are my data structures?
● for iterates thru a collection/iterable/generator
● while loops until a condition is false
 List of triggers better than long conditions
● all and any functions
 True and False (type bool)
 Intrinsic truth values
Evaluating conditions
False True
False (== 0) True (==1)
“” (empty string) Any string but “” (“ “, “x”…)
0, 0.0 Any number but 0 (1, 0.2, -2…)
[], (), {}, set () Any non-empty container ([‘Loc’], [‘’]…)
None Almost any object that’s not explicitly False
Importing java libraries or modules
 Separate lines unless from same module
 Top of the script/function (after comments)
 Aliases
 Absolute imports preferred (x.y.z)
 from package import func1, func2
 Add path for custom modules to sys.path
Handling errors with try-catch
 EAFP Vs. LBYL
 Specify the exceptions to
catch
 Limit code for the try
 Module traceback (stack
traces)
 sys.exc_info (exception +
msg)
Working with numbers and dates
 Preferably use java.math.BigDecimal
 Cast int(), long(), float()
 Module datetime or java class
java.text.SimpleDateFormat
Working with strings
 Delimited by “ or ‘
 Use built-in functions when possible
 String formatting %s (no casting)
Working with strings
Working paths and files IO
 Paths
● Use fdmContext[“OUTBOXDIR”] and similar
● Use os module functions
● os.path.join(path1, path2…)
● Raw strings for hard-coded paths r’E:f1.log’
 Module codecs
 Enumerate if you need line number
Working with dictionaries
 Dictionaries are great
 Dictionary[key]  value
 Natural replacement of
select case (VB)
 Complex data structures will look simple
 Custom error library (localization)
Working with Dictionaries
Working with SQL
 FDMEE DB
● Get API functions when possible
● Commit after DML (fdmAPI.commitTransaction())
● Close result sets (fdmAPI.closeResultSet(rs))
● No need to open/close the SQL connection
 Remote DB
● Use java.sql (or specific DB modules)
● Open SQL connection (or dblinks, synonym, remote
query…)
● Commit, close ResultSet, close connection
Working with SQL
 Use parametrized SQL (avoid injection attacks)
IT’S NOT ALL BEING
JYTHONIC
Best Practices for FDMEE Scripts
37
Migrating old VB Scripts
 Line by Line = FAILURE
 Clean up mess
 Avoid mixing technologies
 JAVA API ≠ FDM VB API
 FDM VB API ≠ FDMEE
VB API
 This is a good start
(raspberry)
Script Language
Import Jython
Event Jython/VB
Custom Jython/VB
Mapping Jython/SQL
Drill-Thru JavaScript
Logic Accounts Jython
Check Rules Jython
 Object with context properties
 Not all properties available in all scripts
 Not all documented
Object fdmContext[“<PROPERTY NAME>”]
The JAVA API
 Young API
 fdmAPI.function(params)
 fdmContext > fdmAPI > SQL Query
 SQL query better than nothing 
 Write your own API (modules, aif-custom.jar)
Some examples Description
executeDML Insert, Update SQLs
executeQuery Select SQL
showCustomMessage/File Shows messages/files to end users
getCustomScriptParameters Parameters from custom scripts
Event scripts
 Actions Bef/Aft workflow steps
 FDM Classic events > FDMEE events
 Different scripts per target app 
 def EventName
 Select the right one
● When do you want to do what?
● TDATASEG or TDATASEG_T?
Example: Inserting new records
 No API available
 TDATASEG_T preferred over TDATASEG
 DATAKEY (MSSQL)
● Identity in TDATASEG_T but not in TDATASEG
● Insert into TDATASEG_T (datakey is generated)
 DATAKEY (Oracle)
● Uses a sequence
● TDATASEG_DATAKEY_S.NEXTVAL
Mapping scripts
 New API (replacing old varValues)
 Update multiple TDATASEG_T columns at
once
 Multi-dimension better than script
 #SQL preferred  1 update in one shot
Writing in the FDMEE process log
 Add debugging code to your scripts
● Disable in Production (log level < 5)
● Use the FDMEE process log to learn 
 Use API functions to log messages
API function Use Log Level
logFatal(msg) Fatal error occurs All
logError(msg) Error occurs >=2
logWarn(msg) Warning condition occurs >=3
logInfo(msg) Informational message >=4
logDebug(msg) Debug message 5
Error handling in Import Scripts
 Scripts evaluated before being executed
 Lines skipped if there are evaluation errors
Hard to find the error
Why?
Better capture
the exception
Error handling in Event scripts
 Errors shown in aif-WebApp.log
 Use try-except to control errors
● Log the error in the FDMEE process log
Working the workflow status - Set
 No published API available to set status
 Update table AIF_PROCESS_DETAILS if needed
● Undocumented API fdmAPI.updateProcessDetails
 Raise exception or sys.exit(“errmsg”)
 Can use a dictionary for error messages
Highlights
 Keep your scripts simple
 Make it working before being Jythonic
 Configure your IDE/Editor for PEP8
 Don’t forget adding comments
 Don’t reinvent the wheel… Google is your BF 
 Use the Java API
 Understand the product inside out (log level 5)
 Focus on Jython 2.5.1 (for now)
Call for papers is now open. Registration
opens May 2015.
Announcing
Infratects Top Gun US 2015
A technical conference with a focus on
Oracle Hyperion EPM
www.infratects.com/topgun
Friday, September 18, 2015
Hilton Granite Park Hotel
Dallas, Texas
 You can always contact me
Email: francisco.amores@infratects.com
Mobile: +34674209000
LinkedIn: http://lnkd.in/dgpfvMW
Twitter: @akafdmee
Blog: http://akafdmee.blogspot.com
 Join LinkedIn Group Oracle|Hyperion FDMEE
Q&A
Become Jythonic in FDMEE (KSCOPE15)

Mais conteúdo relacionado

Mais procurados

What would happen if i did...in hfm (part 2)
What would happen if i did...in hfm (part 2)What would happen if i did...in hfm (part 2)
What would happen if i did...in hfm (part 2)
Alithya
 
Finit solutions getting the most out of hfm - intercompany matching and eli...
Finit solutions   getting the most out of hfm - intercompany matching and eli...Finit solutions   getting the most out of hfm - intercompany matching and eli...
Finit solutions getting the most out of hfm - intercompany matching and eli...
finitsolutions
 
Finit solutions getting the most out of hfm - web data forms tips and tricks
Finit solutions   getting the most out of hfm - web data forms tips and tricksFinit solutions   getting the most out of hfm - web data forms tips and tricks
Finit solutions getting the most out of hfm - web data forms tips and tricks
finitsolutions
 
KSCope 2013 - Balance Sheet Reporting - Design Consideration - KSCope Format
KSCope 2013 - Balance Sheet Reporting - Design Consideration - KSCope FormatKSCope 2013 - Balance Sheet Reporting - Design Consideration - KSCope Format
KSCope 2013 - Balance Sheet Reporting - Design Consideration - KSCope Format
Alexandre SERAN
 
Finit - Creative Solutions for FX Analysis in HFM
Finit - Creative Solutions for FX Analysis in HFM Finit - Creative Solutions for FX Analysis in HFM
Finit - Creative Solutions for FX Analysis in HFM
finitsolutions
 

Mais procurados (20)

Currency Translation in HFM
Currency Translation in HFMCurrency Translation in HFM
Currency Translation in HFM
 
Hyperion EPM APIs - Added value from HFM, Workspace, FDM, Smartview, and Shar...
Hyperion EPM APIs - Added value from HFM, Workspace, FDM, Smartview, and Shar...Hyperion EPM APIs - Added value from HFM, Workspace, FDM, Smartview, and Shar...
Hyperion EPM APIs - Added value from HFM, Workspace, FDM, Smartview, and Shar...
 
FDMEE versus Cloud Data Management - The Real Story
FDMEE versus Cloud Data Management - The Real StoryFDMEE versus Cloud Data Management - The Real Story
FDMEE versus Cloud Data Management - The Real Story
 
HFM-Implementation
HFM-ImplementationHFM-Implementation
HFM-Implementation
 
What would happen if i did...in hfm (part 2)
What would happen if i did...in hfm (part 2)What would happen if i did...in hfm (part 2)
What would happen if i did...in hfm (part 2)
 
HFM vs Essbase BSO: A Comparative Anatomy
HFM vs Essbase BSO: A Comparative AnatomyHFM vs Essbase BSO: A Comparative Anatomy
HFM vs Essbase BSO: A Comparative Anatomy
 
FDMEE script examples
FDMEE script examplesFDMEE script examples
FDMEE script examples
 
FDMEE script examples
FDMEE script examplesFDMEE script examples
FDMEE script examples
 
Finit solutions getting the most out of hfm - intercompany matching and eli...
Finit solutions   getting the most out of hfm - intercompany matching and eli...Finit solutions   getting the most out of hfm - intercompany matching and eli...
Finit solutions getting the most out of hfm - intercompany matching and eli...
 
Finit solutions getting the most out of hfm - web data forms tips and tricks
Finit solutions   getting the most out of hfm - web data forms tips and tricksFinit solutions   getting the most out of hfm - web data forms tips and tricks
Finit solutions getting the most out of hfm - web data forms tips and tricks
 
KSCope 2013 - Balance Sheet Reporting - Design Consideration - KSCope Format
KSCope 2013 - Balance Sheet Reporting - Design Consideration - KSCope FormatKSCope 2013 - Balance Sheet Reporting - Design Consideration - KSCope Format
KSCope 2013 - Balance Sheet Reporting - Design Consideration - KSCope Format
 
HFM Extended Analytics
HFM Extended AnalyticsHFM Extended Analytics
HFM Extended Analytics
 
FDMEE Taking Source Filters to the Next Level
FDMEE Taking Source Filters to the Next LevelFDMEE Taking Source Filters to the Next Level
FDMEE Taking Source Filters to the Next Level
 
Data-Driven Rules in HFM
Data-Driven Rules in HFMData-Driven Rules in HFM
Data-Driven Rules in HFM
 
Hfm to Financial Consolidation and Close Cloud
Hfm to Financial Consolidation and Close CloudHfm to Financial Consolidation and Close Cloud
Hfm to Financial Consolidation and Close Cloud
 
Understanding HFM System Tables
Understanding HFM System TablesUnderstanding HFM System Tables
Understanding HFM System Tables
 
HFM Business Rule Writing Tips and Techniques
HFM Business Rule Writing Tips and TechniquesHFM Business Rule Writing Tips and Techniques
HFM Business Rule Writing Tips and Techniques
 
Finit - Creative Solutions for FX Analysis in HFM
Finit - Creative Solutions for FX Analysis in HFM Finit - Creative Solutions for FX Analysis in HFM
Finit - Creative Solutions for FX Analysis in HFM
 
Finit solutions getting the most out of hfm process management and phased sub...
Finit solutions getting the most out of hfm process management and phased sub...Finit solutions getting the most out of hfm process management and phased sub...
Finit solutions getting the most out of hfm process management and phased sub...
 
FDMEE Tutorial - Part 1
FDMEE Tutorial - Part 1FDMEE Tutorial - Part 1
FDMEE Tutorial - Part 1
 

Destaque

Destaque (10)

What Would Happen If I...? FDMEE Edition
What Would Happen If I...? FDMEE EditionWhat Would Happen If I...? FDMEE Edition
What Would Happen If I...? FDMEE Edition
 
Taking Your FDM Application to the Next Level with Advanced Scripting
Taking Your FDM Application to the Next Level with Advanced ScriptingTaking Your FDM Application to the Next Level with Advanced Scripting
Taking Your FDM Application to the Next Level with Advanced Scripting
 
FDM to FDMEE migration utility
FDM to FDMEE migration utilityFDM to FDMEE migration utility
FDM to FDMEE migration utility
 
KScope14 FDMEE Multiproduct
KScope14 FDMEE MultiproductKScope14 FDMEE Multiproduct
KScope14 FDMEE Multiproduct
 
Cycling Off FDM Classic on Steroids and Taking a Dose of FDMEE HGH
Cycling Off FDM Classic on Steroids and Taking a Dose of FDMEE HGHCycling Off FDM Classic on Steroids and Taking a Dose of FDMEE HGH
Cycling Off FDM Classic on Steroids and Taking a Dose of FDMEE HGH
 
Getting the Most Out of EPM: A deep dive into Account Reconciliation Manager
Getting the Most Out of EPM: A deep dive into Account Reconciliation ManagerGetting the Most Out of EPM: A deep dive into Account Reconciliation Manager
Getting the Most Out of EPM: A deep dive into Account Reconciliation Manager
 
Migration Approaches for FDMEE
Migration Approaches for FDMEEMigration Approaches for FDMEE
Migration Approaches for FDMEE
 
How Finance is driving growth in the Digital Age via OpenText
How Finance is driving growth in the Digital Age via OpenTextHow Finance is driving growth in the Digital Age via OpenText
How Finance is driving growth in the Digital Age via OpenText
 
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtapADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
 
Migration 101 Webinar: FDM to FDMEE
Migration 101 Webinar: FDM to FDMEEMigration 101 Webinar: FDM to FDMEE
Migration 101 Webinar: FDM to FDMEE
 

Semelhante a Become Jythonic in FDMEE (KSCOPE15)

C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
Hammad Rajjoub
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principles
Edorian
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi
Spiffy
 
...and thus your forms automagically disappeared
...and thus your forms automagically disappeared...and thus your forms automagically disappeared
...and thus your forms automagically disappeared
Luc Bors
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings
10n Software, LLC
 

Semelhante a Become Jythonic in FDMEE (KSCOPE15) (20)

Intro To AOP
Intro To AOPIntro To AOP
Intro To AOP
 
XPDays Ukraine: Legacy
XPDays Ukraine: LegacyXPDays Ukraine: Legacy
XPDays Ukraine: Legacy
 
The pragmatic programmer
The pragmatic programmerThe pragmatic programmer
The pragmatic programmer
 
Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"Viktor Turskyi "Effective NodeJS Application Development"
Viktor Turskyi "Effective NodeJS Application Development"
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2C:\Fakepath\Combating Software Entropy 2
C:\Fakepath\Combating Software Entropy 2
 
Getting started with karate dsl
Getting started with karate dslGetting started with karate dsl
Getting started with karate dsl
 
How do we do it
How do we do itHow do we do it
How do we do it
 
Save time by applying clean code principles
Save time by applying clean code principlesSave time by applying clean code principles
Save time by applying clean code principles
 
.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi.NET 4 Demystified - Sandeep Joshi
.NET 4 Demystified - Sandeep Joshi
 
API automation with JMeter + Bamboo CI
API automation with JMeter + Bamboo CIAPI automation with JMeter + Bamboo CI
API automation with JMeter + Bamboo CI
 
SDL BeGlobal The SDL Platform for Automated Translation
SDL BeGlobal The SDL Platform for Automated TranslationSDL BeGlobal The SDL Platform for Automated Translation
SDL BeGlobal The SDL Platform for Automated Translation
 
...and thus your forms automagically disappeared
...and thus your forms automagically disappeared...and thus your forms automagically disappeared
...and thus your forms automagically disappeared
 
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven PignataroJoomla! Day Chicago 2011 Presentation - Steven Pignataro
Joomla! Day Chicago 2011 Presentation - Steven Pignataro
 
IDE and Toolset For Magento Development
IDE and Toolset For Magento DevelopmentIDE and Toolset For Magento Development
IDE and Toolset For Magento Development
 
Logic programming in python
Logic programming in pythonLogic programming in python
Logic programming in python
 
So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...So You Just Inherited a $Legacy Application...
So You Just Inherited a $Legacy Application...
 
Code Quality Practice and Tools
Code Quality Practice and ToolsCode Quality Practice and Tools
Code Quality Practice and Tools
 
Slides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetingsSlides from LAX & DEN usergroup meetings
Slides from LAX & DEN usergroup meetings
 
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and DevelopersKatalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and Developers
 

Último

Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Último (20)

Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 

Become Jythonic in FDMEE (KSCOPE15)

  • 1.
  • 2. Become Jythonic Best Practices for FDMEE Scripts Francisco Amores Infratects
  • 3.  The following is intended for information purposes only on behalf of Infratects, and may not be incorporated into any contract. It is not a commitment to deliver any services or functionality, and should not be relied upon in making purchasing decisions. This provides no warranties with respect to the offerings described within. The development, release, and timing of any features or functionality described for Oracle’s products remains at the sole discretion of Oracle. Any third-party names, trademarks and copyrights contained in this document are the property of their respective owners Safe Harbour
  • 4.  Say hello to Jython  Coding standards – PEP8  Best practices when…  Best practices for FDMEE scripts  Highlights  Q&A Agenda
  • 5. DEEP EXPERTISE HOSTING CLOUD DESIGN CONFIGURATION INSTALLATION STRESS TESTING UPGRADES MIGRATIONS PATCHING INTEGRATION SUPPORT TRAINING INFRASTRUCTURE FOLLOW THE SUN SUPPORT 40+CONSULTANTS 15+ YEARS EXPERIENCE 5 DATA CENTERS NA EMEA APAC DEDICATED MANAGED SERVICES & SUPPPORT TEAM FOCUSED 15 IN BUSINESS YEARS INFRATECTS FI INFRATECTS UK INFRATECTS NL2000 INFRATECTS AUS2008 2009 2012 INFRATECTS US2014 INFRATECTS SP2012 WWW.INFRATECTS.COM
  • 6. ● Data Integration Leader ● +9 years focused on Data Integration ● Link between functional and technical people ● FDMEE Blogger ● fishing with FDMEE ● FDMEE Trainer ● Active member of OTN Next challenge August-2015 CCC Mont Blanc 100KM +6000m
  • 7. Goals What I don’t pretend What I do pretend ● You change all your scripts after this session ● You get bored and leave the room  ● You take best practices into account ● Loose your fear of Jython ● You enjoy 
  • 8. JYTHONEER OR JYTHONIST? Say hello to Jython
  • 9.  Python implementation for JVM  Functional + object-oriented  Elegant syntax for clearer scripts  Key fundamentals ● Code Indentation ● No need to declare types ● Indexes start at 0 ● Slicing notation ● Seamless integration with Java What is Jython? + _______
  • 10.  Windows and penguin are both happy  Easy to learn and code  Code reusing  VB Script is obsolete  JAVA APIs across EPM products  Jython 2.5.1 Why Jython in FDMEE?
  • 11.  VB syntax = 'Oh God!'  Jython syntax = 'My Goodness!‘  Simpler and clearer solutions  No begin/end tags  Functions are always defined as def (no Sub)  More robust and flexible error handling Key differentiators with VB Script
  • 12.  Idiomatic Jython ● Common scripting idioms ● May not be obvious to newcomers  How do I get Jythonista? What is Jythonic? 1. Get it working at all 2. Get it working regularly 3. Reuse code and design for reuse 4. Starting to write idiomatic Jython
  • 13.  Just an example What is Jythonic?
  • 14. CODING STANDARDS – PEP8 15 “Programs must be written for people to read, and only incidentally for machines to execute” —Abelson & Sussman, Structure and Interpretation of Computer Programs
  • 15.  Scripts easy to read  Python Enhancement Proposal  Must-read: coding standards (PEP8) Coding Style
  • 16. Object Convention Functions, methods, modules joined_lower, camelCase Constants joined_lower or ALL_CAPS Global variable names joined_lower Variable names camelCase Naming convention
  • 17.  No hard tabs (never mix)  Indentation level  4 spaces  Space after “,” (lists, dicts, args, tuples)  Space around assignment and comparisons Indentation and whitespaces Hanging indent • No args in 1st line • Additional indent for args Implied line • Vertical Align with opening delimiter
  • 18.  Line length < 80 chars (73 for comments)  Align elements of continuation lines ● After binary operator ● Vertically below open delimiter (), [], {} Long lines and continuations
  • 19.  No need to use break lines  Log messages SQL queries using the fdmAPI Triple quotes for long strings
  • 20. Comments and Documentation strings ● # Comment = Why and how the code works ● Block Comments ● Inline Comments ● Doc String = How to use Please keep them up to date
  • 21. Where do you write your scripts?  Who are you? ● IT  Eclipse (PyDev), Netbean, Emacs, etc. ● Business  Notepad++, others  Making your way to Jythonista easier ● IDE/Editor integration with PEP8 ● Pylint (Python formatting code evaluation utility) ● PEP8 plugin for Notepad++
  • 22.  PEP8 online checker (http://pep8online.com/) Don’t be scared and try it at home
  • 24. Using loops and conditional statements  What are my data structures? ● for iterates thru a collection/iterable/generator ● while loops until a condition is false  List of triggers better than long conditions ● all and any functions
  • 25.  True and False (type bool)  Intrinsic truth values Evaluating conditions False True False (== 0) True (==1) “” (empty string) Any string but “” (“ “, “x”…) 0, 0.0 Any number but 0 (1, 0.2, -2…) [], (), {}, set () Any non-empty container ([‘Loc’], [‘’]…) None Almost any object that’s not explicitly False
  • 26. Importing java libraries or modules  Separate lines unless from same module  Top of the script/function (after comments)  Aliases  Absolute imports preferred (x.y.z)  from package import func1, func2  Add path for custom modules to sys.path
  • 27. Handling errors with try-catch  EAFP Vs. LBYL  Specify the exceptions to catch  Limit code for the try  Module traceback (stack traces)  sys.exc_info (exception + msg)
  • 28. Working with numbers and dates  Preferably use java.math.BigDecimal  Cast int(), long(), float()  Module datetime or java class java.text.SimpleDateFormat
  • 29. Working with strings  Delimited by “ or ‘  Use built-in functions when possible
  • 30.  String formatting %s (no casting) Working with strings
  • 31. Working paths and files IO  Paths ● Use fdmContext[“OUTBOXDIR”] and similar ● Use os module functions ● os.path.join(path1, path2…) ● Raw strings for hard-coded paths r’E:f1.log’  Module codecs  Enumerate if you need line number
  • 32. Working with dictionaries  Dictionaries are great  Dictionary[key]  value  Natural replacement of select case (VB)
  • 33.  Complex data structures will look simple  Custom error library (localization) Working with Dictionaries
  • 34. Working with SQL  FDMEE DB ● Get API functions when possible ● Commit after DML (fdmAPI.commitTransaction()) ● Close result sets (fdmAPI.closeResultSet(rs)) ● No need to open/close the SQL connection  Remote DB ● Use java.sql (or specific DB modules) ● Open SQL connection (or dblinks, synonym, remote query…) ● Commit, close ResultSet, close connection
  • 35. Working with SQL  Use parametrized SQL (avoid injection attacks)
  • 36. IT’S NOT ALL BEING JYTHONIC Best Practices for FDMEE Scripts 37
  • 37. Migrating old VB Scripts  Line by Line = FAILURE  Clean up mess  Avoid mixing technologies  JAVA API ≠ FDM VB API  FDM VB API ≠ FDMEE VB API  This is a good start (raspberry) Script Language Import Jython Event Jython/VB Custom Jython/VB Mapping Jython/SQL Drill-Thru JavaScript Logic Accounts Jython Check Rules Jython
  • 38.  Object with context properties  Not all properties available in all scripts  Not all documented Object fdmContext[“<PROPERTY NAME>”]
  • 39. The JAVA API  Young API  fdmAPI.function(params)  fdmContext > fdmAPI > SQL Query  SQL query better than nothing   Write your own API (modules, aif-custom.jar) Some examples Description executeDML Insert, Update SQLs executeQuery Select SQL showCustomMessage/File Shows messages/files to end users getCustomScriptParameters Parameters from custom scripts
  • 40. Event scripts  Actions Bef/Aft workflow steps  FDM Classic events > FDMEE events  Different scripts per target app   def EventName  Select the right one ● When do you want to do what? ● TDATASEG or TDATASEG_T?
  • 41. Example: Inserting new records  No API available  TDATASEG_T preferred over TDATASEG  DATAKEY (MSSQL) ● Identity in TDATASEG_T but not in TDATASEG ● Insert into TDATASEG_T (datakey is generated)  DATAKEY (Oracle) ● Uses a sequence ● TDATASEG_DATAKEY_S.NEXTVAL
  • 42. Mapping scripts  New API (replacing old varValues)  Update multiple TDATASEG_T columns at once  Multi-dimension better than script  #SQL preferred  1 update in one shot
  • 43. Writing in the FDMEE process log  Add debugging code to your scripts ● Disable in Production (log level < 5) ● Use the FDMEE process log to learn   Use API functions to log messages API function Use Log Level logFatal(msg) Fatal error occurs All logError(msg) Error occurs >=2 logWarn(msg) Warning condition occurs >=3 logInfo(msg) Informational message >=4 logDebug(msg) Debug message 5
  • 44. Error handling in Import Scripts  Scripts evaluated before being executed  Lines skipped if there are evaluation errors Hard to find the error Why? Better capture the exception
  • 45. Error handling in Event scripts  Errors shown in aif-WebApp.log  Use try-except to control errors ● Log the error in the FDMEE process log
  • 46. Working the workflow status - Set  No published API available to set status  Update table AIF_PROCESS_DETAILS if needed ● Undocumented API fdmAPI.updateProcessDetails  Raise exception or sys.exit(“errmsg”)  Can use a dictionary for error messages
  • 47. Highlights  Keep your scripts simple  Make it working before being Jythonic  Configure your IDE/Editor for PEP8  Don’t forget adding comments  Don’t reinvent the wheel… Google is your BF   Use the Java API  Understand the product inside out (log level 5)  Focus on Jython 2.5.1 (for now)
  • 48. Call for papers is now open. Registration opens May 2015. Announcing Infratects Top Gun US 2015 A technical conference with a focus on Oracle Hyperion EPM www.infratects.com/topgun Friday, September 18, 2015 Hilton Granite Park Hotel Dallas, Texas
  • 49.  You can always contact me Email: francisco.amores@infratects.com Mobile: +34674209000 LinkedIn: http://lnkd.in/dgpfvMW Twitter: @akafdmee Blog: http://akafdmee.blogspot.com  Join LinkedIn Group Oracle|Hyperion FDMEE Q&A