Hi Folks -
Thanks fo rhte replies. Silly my, I didn't use DelayedExpansions, therefore it wasn't being echoed properly with the conventional methods to call a variable.
Setting the appropriate headings and encasing the variable in ! symbols did the trick.
However, I'm seeing a new issues. When I search the file for the specified string and then spool results to another files in a format used for upload, it's repeating (2) variables multiple times. Any idea why?
Here is the file I'm searching:
Code: Select all
MAXL> login admin System11admin on DIPRDHYPESS03W;
OK/INFO - 1051034 - Logging in user [admin@Native Directory].
OK/INFO - 1241001 - Logged in to Essbase.
MAXL> display variable on database "DIFIN"."DIFIN";
application database variable value
+-------------------+-------------------+-------------------+-------------------
DIFIN DIFIN PtrRM Jan
DIFIN DIFIN ThisYear FY06
DIFIN DIFIN BudYr FY16
DIFIN DIFIN CurYr FY16
DIFIN DIFIN NexYr FY17
DIFIN DIFIN NexYr2 FY18
DIFIN DIFIN NexYr3 FY19
DIFIN DIFIN NexYr4 FY20
DIFIN DIFIN NexYr5 FY21
DIFIN DIFIN PemBY FY15
DIFIN DIFIN PemCY FY16
DIFIN DIFIN PemNY FY17
DIFIN DIFIN PreYr FY15
DIFIN DIFIN PreYr2 FY14
DIFIN DIFIN PreYr3 FY13
DIFIN DIFIN PtrCY FY16
DIFIN DIFIN PtrNY FY17
DIFIN DIFIN PtrNY2 FY18
DIFIN DIFIN PtrNY3 FY19
DIFIN DIFIN PtrNY4 FY20
DIFIN DIFIN PtrNY5 FY21
DIFIN DIFIN PtrPY FY15
DIFIN DIFIN NexQtr2 Q4
DIFIN DIFIN NexQtr Q4
DIFIN DIFIN CurQtr Q3
DIFIN DIFIN FMVFXMth Dec
DIFIN DIFIN PreQtr Q2
DIFIN DIFIN PtrCM Sep
DIFIN DIFIN PtrNM2 Nov
DIFIN DIFIN PtrNM Oct
DIFIN DIFIN CurMo Oct
DIFIN DIFIN NexMo Nov
DIFIN DIFIN NexMo2 Dec
DIFIN DIFIN PemCM Oct
DIFIN DIFIN PemNM Nov
DIFIN DIFIN PreMo Sep
DIFIN DIFIN PreMo2 Aug
WARNING - 1241024 - Possible string truncation in column 3.
WARNING - 1241028 - Output column defined with warnings.
WARNING - 1241024 - Possible string truncation in column 4.
WARNING - 1241028 - Output column defined with warnings.
OK/INFO - 1241044 - Records returned: [37].
MAXL> logout;
User admin is logged out
Here is my script:
Code: Select all
@ECHO OFF
SETLOCAL ENABLEEXTENSIONS ENABLEDELAYEDEXPANSION
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::-- Script Name: Update_Subvars.cmd --::
::-- --::
::-- Description: This scripts advances and updates Essbase Subvars --::
::-- --::
::-- --::
::-- Calls: --::
::-- Called By: --::
::-- --::
::-- Parameters: Call _env.cmd to get environment variables to determine --::
::-- login info, database, application, etc. --::
::-- --::
::-- Author: --::
::-- Date: 11/28/16 --::
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
::-- Set Working Directory as Script Path --::
cd /d %~dp0
::-- Call Environment File --::
CALL \\DIPRDHYPESS03W\F$\Hyperion_Batch\Scripts\Batch\_env.cmd
::-- Set Main Intrapath Variables --::
::-- Set Process in variables below i.e EPMA_Logs\
SET PLOGPATH=Update_Subvars_Logs\
SET PERRORPATH=Update_Subvars_Errors\
SET intrapath=%ESS_SERVER%\%MAINPATH_RMT%%LOGPATH%%PLOGPATH%
SET errorintrapath=%ESS_SERVER%\%MAINPATH_RMT%%ERRORPATH%%PERRORPATH%
IF NOT EXIST %intrapath% MKDIR %intrapath%
IF NOT EXIST %errorintrapath% MKDIR %errorintrapath%
::-- Prepare Main Log and Error Files --::
FOR /f "tokens=1-2 delims=/:" %%a in ("%TIME%") do (set timestamp=%%a%%b)
FOR /f "tokens=* delims= " %%c in ("%timestamp%") do (set timestamp=%%c)
SET logfile=%intrapath%%date:~-4,4%%date:~-10,2%%date:~-7,2%_%timestamp%_%~n0.log
SET maxllogfile=%intrapath%%date:~-4,4%%date:~-10,2%%date:~-7,2%_%timestamp%_%~n0_MaxL.log
SET errorfile=%errorintrapath%%date:~-4,4%%date:~-10,2%%date:~-7,2%_%timestamp%_%~n0.log
::-- Prepare Log & Error file directories --::
FOR %%f IN ( %MAINPATH%%LOGPATH%%PLOGPATH%* ) DO ( DEL %%f )
FOR %%f IN ( %MAINPATH%%ERRORPATH%%PERRORPATH%* ) DO ( DEL %%f )
::-- Set Subvar Process Variables --::
SET FINDSTR=C:\Windows\System32\findstr.exe
SET SUBVAR_OUTPUT=%intrapath%Subvar_Output.txt
SET SUBVAR_PROC_PATH=%MAINPATH%%FILEPATH%Subvar_Maintenance\
FOR %%f IN ( %SUBVAR_PROC_PATH%* ) DO ( DEL %%f )
SET ARCHIVE_SUBVAR_PATH=%MAINPATH%%FILEPATH%Subvar_Maintenance\Updated_Subvars\%date:~-4,4%_%date:~-10,2%%date:~-7,2%\
echo ********************************************************>>%logfile%
echo %~n0 Starting at %TIME% >>%logfile%
echo ********************************************************>>%logfile%
echo ********************************************************>>%logfile%
echo Extract Valid Substition Variables for Month End >>%logfile%
echo ********************************************************>>%logfile%
CALL %STARTESSMSHPATH%ESSMSH.EXE %ESS_SERVER%\%MAINPATH_RMT%%MAXLPATH%Extract_Subvarsnew.mxl %ESSB_USER% %ESSB_PSWD% %ESSB_SRVR% %ESSB_APP% %ESSB_DB% %SUBVAR_OUTPUT%
PAUSE
FOR %%S IN (
CurMo
CurQtr
FMVFXMth
NextMo
NextMo2
NextQtr
NextQtr2
PemCM
PemNM
PreMo
PreMo2
PreQtr
CurYr
NextYr
NextYr2
NextYr3
NextYr4
NextYr5
PemCY
PemNY
PreYr
PreYr2
PreYr3
) DO (
for /f "tokens=4" %%A in ('%FINDSTR% /C:%%S "%SUBVAR_OUTPUT%" ') DO SET "SN=%%S" & SET "SV=%%A"
ECHO %ESSB_APP%,%ESSB_DB%,!SN!,!SV! >> %SUBVAR_PROC_PATH%Updated_Subvars.txt
)
pause
SET myError1=%errorlevel%
IF %myError1%==0 goto Update_Subvars
echo **********************************************************************>>%logfile%
echo Encountered Error in Extract Valid Substition Variables for Month End >>%logfile%
echo **********************************************************************>>%logfile%
goto AbnormalExit
:Update_Subvars
And then here is the generated output with multiple variables being repeated:
Code: Select all
DIFIN,DIFIN,CurMo,Oct
DIFIN,DIFIN,CurQtr,Q3
DIFIN,DIFIN,FMVFXMth,Dec
DIFIN,DIFIN,FMVFXMth,Dec
DIFIN,DIFIN,FMVFXMth,Dec
DIFIN,DIFIN,FMVFXMth,Dec
DIFIN,DIFIN,FMVFXMth,Dec
DIFIN,DIFIN,PemCM,Oct
DIFIN,DIFIN,PemNM,Nov
DIFIN,DIFIN,PreMo,Aug
DIFIN,DIFIN,PreMo2,Aug
DIFIN,DIFIN,PreQtr,Q2
DIFIN,DIFIN,CurYr,FY16
DIFIN,DIFIN,CurYr,FY16
DIFIN,DIFIN,CurYr,FY16
DIFIN,DIFIN,CurYr,FY16
DIFIN,DIFIN,CurYr,FY16
DIFIN,DIFIN,CurYr,FY16
DIFIN,DIFIN,PemCY,FY16
DIFIN,DIFIN,PemNY,FY17
DIFIN,DIFIN,PreYr,FY13
DIFIN,DIFIN,PreYr2,FY14
DIFIN,DIFIN,PreYr3,FY13
Thanks, guys!