For one of my month end close processes, I need to update various applications with the appropriate varibles that depict things like:
1. Current Month
2. Forecast Month
3. Current Year
4. PriorYear
5.Actuals Start Month
etc etc
Obviously, the year values are only performed in the fall for budget season (October is usually when companies begin there FY17 budget) and then in December for annual roll forward.
I currently have a process where I update a text file each month and then it's scheduled on the last day of each month to propogate changes to the necessary applications:
Here is a piece of a text file I update:
Code: Select all
GENJBAPP,Fin_Plan,ActMonth,Oct
GENJBAPP,Fin_Plan,BudYear,FY17
GENJBAPP,Fin_Plan,CurrMonth,Nov
GENJBAPP,Fin_Plan,CurrYear,FY16
GENJBAPP,Fin_Plan,CurrYear1,FY17
GENJBAPP,Fin_Plan,CurrYear2,FY18
GENJBAPP,Fin_Plan,FcstMonth,Nov
GENJBAPP,Fin_Plan,PriorMonth,Sep
GENJBAPP,Fin_Plan,PriorYear,FY15
The format is as follows:
Application,Database,Substitution Variable,Value
And here is the code I use to perform the updates:
Code: Select all
echo ********************************************************>>%logfile%
echo Update Substition Variables >>%logfile%
echo ********************************************************>>%logfile%
>> %maxllogfile% (
FOR /f "eol=; tokens=1,2,3,4 delims=, " %%i in (Update_Subvars.txt) do (
::-- Spool most recent values to text file for records --::
ECHO %%i,%%j,%%k,%%l; >> %date:~-4,4%%date:~-10,2%%date:~-7,2%_%timestamp%_Updated_Subvars.txt
CALL %STARTMAXL% %MAINFOLDER%%MAXLSCRIPTPATH%Update_Subvars.mxl %ESSB_USER% %ESSB_PSWD% %ESSB_SRVR% %%i %%j %%k %%l
)
)
My question is, is there an easy way to grab token 4 of Update_Subvars.txt and run it through a process to understand current value, current system date, and then perform the necessary find and replaces on Update_Subvars.txt?
I'm playing around with some thing like:
Code: Select all
SET CURR_MONTH=%Date:~4,2%
SET CURR_YEAR=%Date:~10,4%
SET CM=%CURR_MONTH%
SET CY=%CURR_YEAR%
CALL :FND_RPLC Jan Feb
CALL :FND_RPLC Feb Mar
CALL :FND_RPLC Mar Apr
CALL :FND_RPLC Apr May
CALL :FND_RPLC May Jun
CALL :FND_RPLC Jun Jul
CALL :FND_RPLC Jul Aug
CALL :FND_RPLC Aug Sep
CALL :FND_RPLC Sep Oct
CALL :FND_RPLC Oct Nov
CALL :FND_RPLC Dec Jan
CALL :FND_RPLC Jan Feb
IF %CM%==12 (
CALL :FND_RPLC FY15 FY16
CALL :FND_RPLC FY16 FY17
CALL :FND_RPLC FY17 FY18
CALL :FND_RPLC FY18 FY19
)
GOTO SKIP
:FND_RPLC
setlocal enableextensions disabledelayedexpansion
set SRC_STRNG=%1
set RPLC_STRNG=%2
set FILE_PATH=%CD%\
set "FILE=%FILE_PATH%Update_Subvars.txt"
for /f "delims=" %%i in ('type "%FILE%" ^& break ^> "%FILE%" ') do (
set "line=%%i"
setlocal enabledelayedexpansion
set "line=!line:%SRC_STRNG%=%RPLC_STRNG%!"
>>"%FILE%" echo !line!
endlocal
)
GOTO :EOF
But it's pretty barbaric and not sure if its the right approach. Essentially, I need a process to grab column 4 and roll forward 1 month all values except for FY-- strings. FY-- string should be rolled forward ONLY in December. I can perform the intraday year Budget roll forward manually.
Thank you for any and all help!