EPM統合エージェント・スクリプト例

次のスクリプト例は、為替レートを提供し、Oracle Enterprise Performance Management Cloudの「データ交換」セクションに定義された統合によって処理可能なフォーマットでデータのアップロードを準備する外部APIを呼び出す方法を示します。EPM Cloudの設定ステップでは、エージェント・インスタンスを統合データ・ソースとして使用し、EPMアプリケーションをターゲットとして使用します。このスクリプトは例としてのみ提供されており、障害に対する保証はされず、ユーザーはこのスクリプトに関連する質問や問題についてOracleサポートにサービス・リクエストを提出できません。

''' 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))