EPM Integration Agent 스크립트 예제

다음 스크립트 예제는 환율을 제공한 다음, Oracle Enterprise Performance Management Cloud의 데이터 교환 섹션에 정의된 통합으로 처리할 수 있는 형식으로 업로드하기 위해 데이터를 준비하는 외부 API를 호출하는 방법을 보여 줍니다. EPM Cloud의 설정 단계에서는 EPM 애플리케이션을 타겟으로 사용하는 통합의 데이터 소스로 에이전트 인스턴스를 사용합니다. 이 스크립트는 예제로만 제공되며 결함이 없다고 보증되지 않으므로, 사용자는 스크립트와 관련된 질문 또는 이슈에 대해 오라클 고객지원센터에 서비스 요청을 제출할 수 없습니다.

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