此案例探討使用範例指令碼,以定期自動化資料整合。
建立包含類似下列項目之指令碼的批次 (.bat) 或殼層 (.sh) 檔案以自動執行資料整合相關活動。下列 Windows 範例指令碼會完成以下活動,自動執行每日應用程式資料整合:
DailyPlanData 存在則將其刪除。DailyPlanData 上傳至服務。Plan1 上執行商業規則 Clear Plan Targets。LoadDailyPlan 匯入資料。Balance Sheet - Plan。Allocate Plan Targets。DailyTarget.zip 存在,則將其刪除。ExportDailyTarget 將資料匯出至 DailyTarget.zip。DailyTarget.zip 下載至您的伺服器並附加時間戳記。註:
若要針對您的用途改寫此指令碼,請確定修改 SET url 和 SET user 參數的值。此外,您可以修改 dataimportfilename、dataexportfilename、importdatajobname、exportdatajobname、br_clear、br_calculatebalancesheet 及 br_allocatetarget 參數的值,以符合的需求
請參閱自動執行指令碼以取得使用 Windows 工作排程器排程執行指令碼的相關資訊。
@echo off
rem Sample Script to demonstrate daily data integration with
rem Cloud EPM application.
rem This script uploads Plan data, clears target numbers,
rem runs a business rule to calculate balance sheet data, and
rem recalculates target numbers on the Vision demo application
rem Please update these parameters
SET url=https://example.oraclecloud.com
SET user=serviceAdmin
SET dataimportfilename=DailyPlanData.csv
SET dataexportfilename=DailyTarget
SET importdatajobname=LoadDailyPlan
SET exportdatajobname=ExportDailyTarget
SET br_clear=Clear Plan Targets
SET br_calculatebalancesheet=Balance Sheet - Plan
SET br_allocatetarget=Allocate Plan Targets
SET password=%1
rem Executing EPM Automate commands
CD /D %~dp0
call epmautomate login %user% %password% %url%
IF %ERRORLEVEL% NEQ 0 goto :ERROR
for /f %%i in ('call epmautomate listfiles') do if %%i==%dataimportfilename% (call epmautomate deletefile %%i)
IF %ERRORLEVEL% NEQ 0 goto :ERROR
call epmautomate uploadfile %dataimportfilename%
IF %ERRORLEVEL% NEQ 0 goto :ERROR
call epmautomate runbusinessrule "%br_clear%"
IF %ERRORLEVEL% NEQ 0 goto :ERROR
call epmautomate importdata "%importdatajobname%"
IF %ERRORLEVEL% NEQ 0 goto :ERROR
call epmautomate runbusinessrule "%br_calculatebalancesheet%"
IF %ERRORLEVEL% NEQ 0 goto :ERROR
call epmautomate runbusinessrule "%br_allocatetarget%" "TargetVersion=Baseline"
IF %ERRORLEVEL% NEQ 0 goto :ERROR
for /f %%i in ('call epmautomate listfiles') do if %%i=="%dataexportfilename%.zip" (call epmautomate deletefile %%i)
IF %ERRORLEVEL% NEQ 0 goto :ERROR
call epmautomate exportdata %exportdatajobname% "%dataexportfilename%.zip"
IF %ERRORLEVEL% NEQ 0 goto :ERROR
call epmautomate downloadfile "%dataexportfilename%.zip"
IF %ERRORLEVEL% NEQ 0 goto :ERROR
rem Section to rename the file
Set Timestamp=%date:~4,2%_%date:~7,2%_%date:~10,4%_%time:~1,1%%time:~3,2%%
ren "%dataexportfilename%.zip" "%dataexportfilename%_%Timestamp%.zip"
call epmautomate logout
IF %ERRORLEVEL% NEQ 0 goto :ERROR
:EOF
echo Scheduled Task Completed successfully
exit /b %errorlevel%
:ERROR
echo Failed with error #%errorlevel%.
exit /b %errorlevel%