日次データ統合の自動化

このシナリオでは、データ統合を定期的に自動化するサンプル・スクリプトの使用方法を調べます。

データ統合関連のアクティビティを自動化する次のようなスクリプトが含まれるバッチ(.bat)またはシェル(.sh)ファイルを作成します。後述するWindows用のサンプル・スクリプトでは次のアクティビティを完了することで毎日のアプリケーション・データ統合を自動化します。

  • 指定したURL、ユーザー名およびパスワード・ファイルを使用して環境にサインインします。
  • 存在する場合はDailyPlanDataを削除します。
  • DailyPlanDataをサービスにアップロードします。
  • プラン・タイプPlan1でビジネス・ルールClear Plan Targetsを実行します。
  • ジョブ名LoadDailyPlanを使用してデータをインポートします。
  • ビジネス・ルールBalance Sheet - Planを実行します。
  • ビジネス・ルールAllocate Plan Targetsを実行します。
  • 存在する場合はDailyTarget.zipを削除します。
  • ジョブ名ExportDailyTargetを使用してデータをDailyTarget.zipにエクスポートします。
  • DailyTarget.zipをサーバーにダウンロードしてタイムスタンプを付加します。
  • 環境からサインアウトします。

注:

このスクリプトを再利用する場合は、必ずurl、userおよびpasswordfileパラメータの値を変更してください。さらに、dataimportfilename、dataexportfilename、importdatajobname、exportdatajobname、br_clear、br_calculatebalancesheetおよびbr_allocatetargetパラメータの値を要件に合うように変更できます

Windowsタスク・スケジューラを使用してスクリプトをスケジュールする方法の詳細は、スクリプトの実行の自動化を参照してください。

automateDailyIntegration.batスクリプトの内容

@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 passwordfile=examplePassword.epw

rem Executing EPM Automate commands
CD /D %~dp0
call epmautomate login %user% %passwordfile% %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%