How to share 1 common variable across all job-steps in a chain (scheduled 4 times a day)
Emanuel Oliveira Oct 21, 2019 11:11 AMHi all,
Following the announcement in Control-M v9 new feature "named pool variables" post:
Trending in Support: Named Pool Variables in Control-M 9 Webinar Q&A
I then asked the following:
Header 1 |
---|
If a chain executes 4 times a day, where 1st job creates/sets named pool var=%%ORDERID.%%RUNCOUNT so 2nd and remaining jobsteps can reuse the same var value.
But imagine: 1st execution of chain -1st job sets named pool myvar to 123. - 2nd job fails (2nd job command line uses %%\\mypool\myvar).
2nd execution chain kicks, 1st job again sets new value for the named pool myvar. 2nd step and remaining jobs on this chain completes ok.
Now... what value will 2nd job on 1st execution sees after we rerun it? Does somehow c/m "caches" initial value so chain still sees old value, or does job pick new value set by the 2nd chain execution?
If c/m always resolves access to named pool var as it latest value, than how can we set/share 1 variable in all jobs of a chain but independent from run-execution of the chain?
Thanks, Emanuel |
Which Kindly MunKeong Lee suggested the following:
Header 1 |
---|
Hi Emanuel Accessing a named pool variable will always return the current value. To solve your issue, the name of the named pool has to be a variable. For example, if I need to differentiate the variables using order date, I can do the following: 1. Place your jobs in a SMART folder. 2. In the SMART folder, set %%POOLNAME=MYPOOL_%%ODATE. This will allow all jobs in the SMART folder to access %%POOLNAME 3. Set the value of the pool variable accordingly in 1st job: e.g. %%\\%%POOLNAME\myvar = 123 2. In 2nd job, the command will use %%\\%%POOLNAME\myvar
Regards, MK |
I then reasked more precision (how to handle the fact of multiple executions in same ODATE):
Header 1 |
---|
Hi Lee,
Thanks so much for your feedback. So you suggesting using both "named pool" (dynamic name) + SMART folder.
thanks, Emanuel |
But meanwhile BMC, emailed me suggesitng this was interesting enough and should be given more visiblity, thats why Im copy/pasting here the 3 msgs on the community website, hoping someone can help/suggest ?
Again objective is very simple really, on a simple chain of 3 job-steps,scheduled to be executed 4 times a day (2am, 8am, 2pm and 8pm) how can each have/share their own common variable ?
Seems theres 2 ways:
- SMART Folders= would each execution have its own local variables execution ? our Control-M team doenst "like devs to use SMART Folders".
- Named Pool variables(without using SMART Folder as our Control-M team doenst "like them")= using dynamic named pool ?
job-step | 2am | 8am | 2pm | 8pm |
---|---|---|---|---|
1 execute some ETL set common chain variable for 1st execution only %%COMMON_VAR= %%ORDERID | its own %%COMMON_VAR | its own %%COMMON_VAR | its own %%COMMON_VAR | its own %%COMMON_VAR |
copy_src2dest.sh %%COMMON_VAR | ||||
another.sh %%COMMON_VAR |
Thanks,
Emanuel Oliveira