Dayalan Punniyamoorthy Blog

Monday, April 17, 2017

What does EPM Automate Utility offer - Part 3

After the EPM automate serious 1 & 2 let me cover downloading the latest exported file & logs related to a specific Data export job.


Currently we don’t have a specific command to download the latest exported file and when you run a export data command it prefix the job id ad the end and created the export file.

Let’s see how to download the latest file or the latest log file using EPM automate 

Batch File calling the EPM Automate Program for downloading the latest data export file and logs.

REM @echo off

echo Batch command: %0 %*
echo Batch Started at %date% %time%

REM other parameters – Change this according to your instance
SET url=https://planning-test.pbcs.us2.oraclecloud.com
SET domain=Domain
SET user=dayalan@example.com
SET password=C:\Users\DPunniamoorthy\Documents\password.epw
SET UploadFileLoc=C:/Oracle/"EPM Automate"/Files/Upload/
SET FileName=LaborMap_???
SET FileExt=dat
SET PBCSFolder=outbox

REM EPM Automate commands
echo CD /D C:\Oracle\"EPM Automate"\bin\ at %date% %time%
CD /D C:\Oracle\"EPM Automate"\bin\

REM login
echo call epmautomate login %user% %password% %url% %domain% at %date% %time%
call epmautomate login %user% %password% %url% %domain%
IF %ERRORLEVEL% NEQ 0 goto :ERROR

Call EPMAUTOMATE Listfiles > files.txt
echo EPMAUTOMATE Listfiles have created the file C:\files.txt

Set the name if the filename as needed

REM For finding the latest export file
setlocal enabledelayedexpansion
set maxfilenum=0
FOR /f "tokens=*" %%x IN ('findstr /c:"outbox/LaborMap_" files.txt') do (
  set "filename=%%~nx"
  set "filename=!filename:LaborMap_=!"
  REM  echo !filename!
  if !filename! GTR !maxfilenum! set maxfilenum=!filename!
)
echo Latest data export is: "LaborMap_%maxfilenum%.dat"

REM Download file 
echo call epmautomate downloadfile "LaborMap_%maxfilenum%.dat"
call epmautomate downloadfile outbox/LaborMap_%maxfilenum%.dat
IF %ERRORLEVEL% NEQ 0 goto :ERROR

REM For finding the latest export Log file
Set the location and the name of the log file
set maxfilenum=0
FOR /f "tokens=*" %%x IN ('findstr /c:"outbox/logs/LaborMap_" files.txt') do (
  set "filename=%%~nx"
  set "filename=!filename:LaborMap_=!"
  REM  echo !filename!
  if !filename! GTR !maxfilenum! set maxfilenum=!filename!
)
echo Latest data export is: "LaborMap_%maxfilenum%.log"

REM Download the latest log file 
echo call epmautomate downloadfile "LaborMap_%maxfilenum%.log"
call epmautomate downloadfile outbox/logs/LaborMap_%maxfilenum%.log
IF %ERRORLEVEL% NEQ 0 goto :ERROR


REM logout
echo call epmautomate logout at %date% %time%
call epmautomate logout
IF %ERRORLEVEL% NEQ 0 goto :ERROR

echo Scheduled Task Completed successfully
exit /b %errorlevel%
:ERROR

echo Failed with error #%errorlevel%.
exit /b %errorlevel%



More to come on the EPM automate topic, Happy days with Oracle PBCS!!!

1 comment:

  1. Awesome Dayalan.
    Great.I used it to download my dat file .
    Excellent.

    ReplyDelete