更新essbase 日期变量

批处理脚本内容如下

:: ********************* Set up the Day, Month, Year Variables **************************
   FOR /f "tokens=1-4 delims=- " %%a in ('date /t') do (
    set yy=%%a
    set mm=%%b
    set dd=%%c
    )
                                                                             
 set /a pr_mm=%mm%-1
 set /a pr_yy=%yy%-1

:: ***************** set up mapping table ************************
  set monthmap=00-Dec;01-Jan;02-Feb;03-Mar;04-Apr;05-May;06-Jun;07-Jul;08-Aug;09-Sep;10-Oct;11-Nov;12-Dec
::*************** set current month variable ************
 CALL SET cur_month=%%monthmap:*%mm%-=%%
 SET cur_month=%cur_month:;=&rem.%

::*************** set prior month variable **************
 CALL SET pr_month=%%monthmap:*%pr_mm%-=%%
 SET pr_month=%pr_month:;=&rem.%

echo current_month: %cur_month%
echo prior_month: %pr_month%

::*************** set current & prior year variables ***********
 set cur_yr=FY%yy:~-2%
 set pr_yr=FY%pr_yy:~-2%

echo current_year: %cur_yr%
echo prior_year: %pr_yr%

::************ set up CurrActMonth & CurrActYear variables ***************                                                                                         
 IF %cur_month% EQU Jan goto Var_Jan
 IF %dd% LSS 25 goto before25
 IF %dd% GEQ 25 goto after25
 
:Var_Jan
 IF %dd% LSS 25 goto before25_Jan
 goto after25

:before25_Jan
 SET CurrActMonth=Dec
 SET CurrActYear=%pr_yr%
 goto End
  
:before25
 SET CurrActMonth=%pr_month%
 SET CurrActYear=%cur_yr%
 goto End
  
:after25
 SET CurrActMonth=%cur_month%
 SET CurrActYear=%cur_yr%
 goto End
:End

echo CurrActMonth: %CurrActMonth%
echo CurrActYear: %CurrActYear%

:: ***************** Excute the MAXL script. if the date is 25th ***********************
 IF %dd% EQU 25 goto MAXL_update_date
 exit

REM /============ excute MAXL script. to update the Substitution Variables ======================/
:MAXL_update_date
 essmsh SubVar_CurrActMonth_Year.msh

SubVar_CurrActMonth_Year.msh

/* --------------------------------------------------------------------------
*  LOGIN AND SETUP SCRIPT. VARIABLES - &CurrActMonth and &CurrActYear
* -------------------------------------------------------------------------- */

/* NB -- user, password, and server are set up separately as Windows
  environment variables.    */
login "$ESS_USERID" "$ESS_PASSWD" on "$ESS_SERVER";

/* ---------------- SET UP SUBSTITUTION VARIALBES --------------------------- */
alter system set variable 'CurrActMonth' $CurrActMonth;
alter system set variable 'CurrActYear' $CurrActYear;

logout;
exit;

在msh文件中引用系统临时变量需要在变量前加“$”!

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/7477027/viewspace-696150/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/7477027/viewspace-696150/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值