Using ctmvar with %%$CALCULATE

All questions about Control-M jobs definitions
Post Reply
User avatar
Nightwatchrenband
Nouveau
Nouveau
Posts: 28
Joined: 24 Jul 2012 12:00
Location: Long Beach, CA

Using ctmvar with %%$CALCULATE

Post by Nightwatchrenband » 14 Feb 2013 4:44

I set a variable for ODATE plus one day in tables and jobs using this in the SET tab: %%$CALCDATE %%ODATE +1
and it works just fine.
Now, I want to use it as a global var. So, the following "should" work, but doesn't. Gets message: CALCDATE: Undefined variable. Go figure?
ctmvar -action set -var "%%\ODATE1" -varexpr %%@$CALCDATE %%@ODATE +1 "
The following does not work either
ctmvar -action set -var "%%\ODATE1" -varexpr "%%$CALCDATE %%@ODATE +1 "
Any suggestions? I opened an issue with BMC, I will update if they have anything.

User avatar
fyot
Nouveau
Nouveau
Posts: 736
Joined: 26 Apr 2005 12:00
Location: PARIS
Contact:

Post by fyot » 14 Feb 2013 4:50

Hi

%%CALCDATE is not a variable but a function.

So %%@CALCDATE is not possible.
And be care full about that thing.

%%CALCDATE must only use dates having YYMMDD format.
%%$CALCDATE using CCYYMMDD format.

So if you want to calculate something using %%ODATE, you must use %%CALCDATE and in case of you want to work with century unsing %%$ODATE, function will be %%$CALCDATE

User avatar
Nightwatchrenband
Nouveau
Nouveau
Posts: 28
Joined: 24 Jul 2012 12:00
Location: Long Beach, CA

Thanks, but should work in ctmvar

Post by Nightwatchrenband » 14 Feb 2013 5:14

Thanks for the info on $CALCULATE. My command works just fine when in a Table or job, and as I understand it, the table and job just invoke ctmvar behind the scenes. It seems to me that it should work as a command for global as well.

User avatar
jstarkw
Nouveau
Nouveau
Posts: 58
Joined: 14 Jan 2010 12:00

Post by jstarkw » 14 Feb 2013 6:25

Correct me if I am wrong but you cannot execute %%CALCDATE from the command line. It is a bmc internal function.

User avatar
Nightwatchrenband
Nouveau
Nouveau
Posts: 28
Joined: 24 Jul 2012 12:00
Location: Long Beach, CA

Actually I'm not trying to execute it

Post by Nightwatchrenband » 14 Feb 2013 6:29

Think about what I am trying to do. I am not actually trying to EXECUTE the $CALCULATE. I am only trying to ASSIGN it to a global variable where it will be evaluated later when a JOB tries to use the global variable. The "@" signs indicate that the %% values are to be evaluated at execution time, NOT when the variable are created.
I think I am going to try to create the global var in a JOB, and see if that works.

User avatar
Nightwatchrenband
Nouveau
Nouveau
Posts: 28
Joined: 24 Jul 2012 12:00
Location: Long Beach, CA

WHOO HOO I figured it out

Post by Nightwatchrenband » 14 Feb 2013 9:19

It would seem that you are not entirely correct. When you think about it, what I am trying to do is put $CALCULATE into a global variable to be executed later. I am NOT trying to execute it. While it is in the global variable it is just a character string. That's all.
To test my theory, I decided to create the Global Var in an actual Job, rather than explicitly with the ctmvar command. Your suggestion of a daily job to do this is what gave me the idea. So I did the SET tab as follows
VARNAME VALUE
%%\ODATE1 %%@$CALCDATE %%@ODATE +1

And displayed the value of ODATE1 in a DOMAIL Message.

I ran the JOB and Here is what I see in my global var listing... exactly what I wanted to see.
epspubmdv-bmdadm [47] ctmvar -action list
<<<GLOBAL>>>

VAR VAREXPR
---------------------------------------- ---------------------------------
%%CyclicTime 092100
%%CyclicDate 130214
%%PDQ Q
%%pdq q
%%ecc eq2
%%ECC EQ2
%%gts gq2
%%GTS GQ2
%%scm sq2
%%SCM SQ2
%%eMailCC1
%%eMailCC2
%%eMailCC3
%%eMailTO1 CTM_ECC_DEV@ea.espon.com
%%eMailTO2
%%eMailTO3
%%eMailSubj %%@PDQ. Control-M - Failure Type:%%@JobT
%%eMailMsg00 %%@PDQ. %%@JOBNAME.-%%@ORDERID > Job-Ord
%%eMailMsg01 %%@PDQ. YYMMDD-HHMMSS : %%@ODATE.-%%@TIM
%%eMailMsg02 %%@PDQ. DataCenter : %%@DATACENTER. N
%%eMailMsg03 %%@PDQ. Application : %%@APPLIC.
%%eMailMsg04 %%@PDQ. Group : %%@APPLGROUP.
%%eMailMsg05 %%@PDQ. Owner : %%@OWNER.
%%eMailMsg06
%%eMailMsg07
%%eMailMsg08
%%eMailMsg09
%%JobType SAP
%%ODATE1 %%@$CALCDATE %%@ODATE +1

And here is the result in my eMail... My only concern is why the closing double quote disappeared.

Mail message from CONTROL-M:
"Q"
"20130215
"Q TS_JLM_eMail_GVar-0148b > Job-Orderid Ended with Errors."
"Q YYMMDD-HHMMSS : 130214-120818 => YYMMDD-HHMMSS Date-Time"
"Q DataCenter : NON-PROD NodeID: aix15a"
"Q Application : TS_JLM"
"Q Group : TS_JLM_eMail"
"Q Owner : root"
""
""
""
""
I will send BMC a bill for my consulting fee. Please feel free to use this any time.

User avatar
Nightwatchrenband
Nouveau
Nouveau
Posts: 28
Joined: 24 Jul 2012 12:00
Location: Long Beach, CA

Another way to approach this from BMC support

Post by Nightwatchrenband » 15 Feb 2013 3:39

Got this from BMC support. A good approach to this thing...
You might also want to consider using a list of variables that is accessed via the %%LIBMEMSYM variable. The %%LIBMEMSYM AutoEdit variable can be used in the AutoEdit Assignment or Do AutoEdit parameters to indicate a text file containing a list of AutoEdit assignments. This variable enables you to create a central file containing AutoEdit assignment statements that can be read by many job processing definitions. In the Control-M Parameters Guide, there is a section that describes %%LIBMEMSYM and there are some examples of how %%$CALDATE can be used in one of those members.
For example... The job processing definition might contain the following:
%%a=1
%%LIBMEMSYM=/controlm/ctm/autoedit.common1
%%PARM1=%%c
And the file /controlm/ctm/autoedit.common1 contains the following entries:
%%c=%%$CALCDATE %%ODATE +%%a
When the job is submitted for execution by Control-M, AutoEdit variables are resolved as if the AutoEdit Assignment parameter contained the following entries:
%%a=1
%%c=%%$CALCDATE %%ODATE +%%a
%%PARM1=%%c

Post Reply