I have a rule which is composed of two operations and is executed each hour.
The first operation has to be executed only once after an IPL (or after each OPS startup); The second operation has to be executed at the second (and next execution of the rule).
How can I write this operation in OPS ?
)TOD 00:01,1 HOURS,,,,CATCHUPYES
)INIT
...
)PROC
....
IF "first execution" then do
/* execute first operation */
...
end
else do
/* execute second operation */
...
end
...
)TERM
...
How can I test "first execution" ?
Release : 14.0
The simplest approach would be to initialize a variable in the )INIT section of your rule. You could set a variable to YES in the )INIT section and test its value in the )PROC section. If it is set TO "YES", execute the first action and set the variable to "NO".
Using OPSINFO('PRODUCTSTATUS') allows the determination if OPS is being started.
For example:
)TOD 00:01,1 HOURS,,,,CATCHUPYES
)INIT
IF OPSINFO('PRODUCTSTATUS') = 'INIT'
THEN FIRST_EXEC = 'YES'
...
)PROC
....
IF FIRST_EXEC = 'YES' then do
/* execute first operation */
...
FIRST_EXEC = 'NO' /* not the first execution anymore */
end
else do
/* execute second operation */
end