Fetching Daily Exchange Rates from xml feed provided by Turkish National Bank
Yalcin Kumbasar 270006B8DE Visits (2839)
I will present you a simple Jython script to fetch daily exchange rates using the xml feed provided by Turkish National Bank via the following url:
Figure 1 - Caption of Web Page for Exchange Rates
Let me show the partial page source which will present the xml structure clearly:
Figure 2 - Caption of Source xml for Exchange Rates
Now, I want to show a screenshot for the Exchange Rates application of Maximo which also shows the result of our development.
Figure 3 - Exchange Rates Application of Maximo
In Figure 3, you can see exchange rates from EURO to Turkish Lira (TL or TRY) and US Dollar to Turkish Lira for today. One can compare these rates to the values provided by national bank and figure out that these values are Banknote Selling rates.
First, we add a system property for defining the URL provided from Turkish National Bank.
Figure 4 - System Properties Application showing the URL Property
Then, we create an Automation Script with action type of launch point. It works on ORGANIZATION object. The script loads the xml document from the url defined in property and then stores currency codes and banknote selling rates of each currency element as a pair of a python dictionary. Lastly, we select the currencies we want to save from the dictionary and add them to Maximo EXCHANGE table.
# Action to Fetch Exchange Rates and Save to Maximo from java.net import URL from java.text import DateFormat, SimpleDateFormat from java.util import Date, Properties from javax.xml.parsers import DocumentBuilder, Docu
Code 1 - Jython Script for Action
Finally, the action for the code piece above is substituted in an escalation which runs automatically on daily basis in order to fetch the exchange rates and save them to Maximo database. Do not forget to tick "Repeat?" check box for the escalation point.
Figure 5 - Escalation for Exchange Rates Action in Maximo
All in all, this implementation is a practice of parsing an xml document provided via a url. One can alter the code piece due to their specific needs for other urls and currencies.