Today I would like to introduce some tools that can be useful for you to learn the scripting languages of FDMEE:
- Jython
- SQL
We all have heard about Cloud and Cloud...did you know there are IDEs (Integrated Development Environment) in the Cloud?
What is that? I will try to make it simple. It's a web where you can partially test your FDMEE scripts.
Why I say partially? Because don't think you are going to copy&paste your script, click Run, and voilĂ .
But what about situations where you need to build an import script to parse data lines to get the account, or convert string to dates, or create a #SQL mapping which strips source Entity? These tools can help you to reduce time cost of implementation. Sometimes you need to run the import step 10 times to get your import script working and that makes me crazy.
I still need to say that I prefer Notepad++ to run my unit tests but Cloud IDEs are also a good tool.
Today I will show you how you can use Python Fiddle to easily test string operations for your FDMEE scripts.
Navigate to http://pythonfiddle.com/
Navigate to the site and enjoy. See what it can offer like some code snippets that may be useful for you but what I would suggest is to initially think of this site as a learning place.
Create your login
You can use your Gmail account or social network accounts:
Your first example
So I need to parse the entity code from my source file and not sure about how to do it. You could start building your script, running the import, fixing the script, running the import, see results..
Let's use the Cloud IDE for the following case:
- My source Entity looks like XXXX-YYY-PLANTN
- I want to import into FDMEE the value XXXX_PLANTN
As you can see I have divided the script in two parts:
- The function for my import script
- Split source Field and get first and third item (indexed starts at 0)
- sField.split("-") will return a list of three elements ["XXXX","YYY","PLANTN"]
- If use [n] to get the nth element
- We use "+" operator to concatenate
- Test code for sample source Entity field and source Record. I have used print to show the result in the bottom panel.
What is the objective?
- Run the script
- Fix syntax errors
- If we have unexpected result, fix the script and try again
- Everything works? Copy & Paste the function definition into your import script and run a final test with the entire source file.
In the example below we get a syntax error when we click Run: we forgot to close the string with "
Once I have fixed my script I get what I wanted: 0000_PLANT1
You can also save your script and share with other users if you wish:This can be useful if you want to save all your code snippets in case you need to reuse them. Once it is saved you can always access to your Dashboard and open your script:
Some additional notes
As always, don't forget FDMEE uses Jython so it may be that some functions or coding solutions may not be available for Jython and they are for Python. In theory you can use Python 2.5.1 based code in your Event and Custom Scripts. However as explained in previous posts, Import Scripts uses Jython 2.2.1.
Regarding SQL, let's say that you don't have access to any SQL tool and you cannot test the SQL query you are going to use either in your BefImport for Open Interface Adapter or in a mapping script. There are also Cloud IDEs for SQL like http://sqlfiddle.com. You can define your own database/tables online and import some sample data there.
Other Cloud IDEs? Sure. And it's now time for you to select your preferred one. In this site you have a good review of different ones.
Enjoy!