Beispielskript für EPM Integration Agent

Das folgende Skriptbeispiel zeigt, wie eine externe API aufgerufen wird, die Wechselkurse enthält. Anschließend werden die Daten für den Upload in einem Format vorbereitet, das mit einer im Abschnitt "Datenaustausch" in Oracle Enterprise Performance Management Cloud definierten Integration verarbeitet werden kann. Die Setupschritte in EPM Cloud verwenden eine Agent-Instanz als Datenquelle für eine Integration mit einer EPM-Anwendung als Ziel. Beachten Sie, dass dieses Skript nur als Beispiel dient und keine Garantie für Defekte gewährt wird. Benutzer dürfen keine Serviceanfrage an Oracle Support stellen, wenn sie Fragen oder Probleme im Zusammenhang mit dem Skript haben.

''' This jython script calls an external API to get exchange rates, and then generates a file which is picked up by the EPM Integration Agent '''

import json
import urllib2

''' Turn off SQL processing by AGENT '''

agentAPI.skipAction('true')

''' Set Proxy for HTTP call. Needed when connected via VPN ''' 

proxy = urllib2.ProxyHandler({'http': 'www-proxy.example.com:80' 'https': 'www-proxy.example.com:80'})
opener = urllib2.build_opener(proxy) urllib2.install_opener(opener)

''' Set up URL for rates download.  Please see the URL for additional information in regards to options. ''' 

currency = 'USD'
ratesurl = 'https://api.exchangeratesapi.io/latest?base=' + currency
fxrates = urllib2.urlopen(ratesurl)
text = json.loads(fxrates.read())
allrates = text['rates']

agentAPI.logInfo("Jython Script - RateExtract: URL - " + str(ratesurl))

''' Generate file for loading into the EPM Cloud '''

outfilename = agentContext["DATAFILENAME"]
outfile = open(outfilename, "w")

''' Generate header row '''

outfile.write("Account,Currency,Entity,From Currency,Scenario,View,Rate" + chr(10))

''' Generate a row for each rate '''

for toCur,toRate in allrates.iteritems():
    mystr = "Ending Rate" + "," + str(toCur) + "," + "FCCS_Global Assumptions" + "," + "FROM_" + str(currency) + "," + "Actual" + "," + "FCCS_Periodic" + "," + str(toRate) + chr(10)
    outfile.write(mystr)

outfile.close() 

agentAPI.logInfo("Jython Script - RateExtract: Output File Name - " + str(outfilename))