Question
· Mar 21

Writing "DO ^ROUTINE" code

I want to write a routine [I think this is the correct Intersystems term] call STOPALLPRODUCTIONS.

I want to be able to call the routine:

DO ^STOPALLPRODUCTIONS

Routines are described here:

https://docs.intersystems.com/irislatest/csp/docbook/DocBook.UI.Page.cls...

 

The code will be something like:

zn "namespace1"

set status=##class(Ens.Director).StopProduction()

set status=##class(Ens.Director).GetProductionStatus()

WRITE "namespace1 production is ",$CASE(status,

              0:"Running",1:"Stopped",2:"Suspended",

              3:"Troubled")

zn "namespace2"

set status=##class(Ens.Director).StopProduction()

set status=##class(Ens.Director).GetProductionStatus()

WRITE "namespace2 production is ",$CASE(status,

              0:"Running",1:"Stopped",2:"Suspended",

              3:"Troubled")

 

  1. Which namespace should this code go into? I think %SYS. Is this correct?
  2. Would this code stop all my productions and print me out the production status?
  3. Would I have to put this code around my code:

STOPALLPRODUCTIONS () [PublicVariables]

{

    /* code goes here */

 }

  1. Would I put it into my DB using VS CODE like shown in the youtube videos?
Product version: IRIS 2021.1
Discussion (3)1
Log in or sign up to continue

STOPALLPRODUCTIONS
Try {
Kill array
Do ##class(%SYS.Namespace).ListAll(.array)
Set ns = ""
For {
Set ns = $Order(array(ns))
If (ns = "") Quit
Kill x
Set = $$MyFunc(ns)
Write "x = ",x,!
}
Return
Catch {
Write $ZERROR,!
}
Quit
MyFunc(ns)
Try {
Write "ns = ",ns,!
ZN ns
Set sc1 = ##class(Ens.Director).StopProduction()
Write "sc1 = ",sc1,!
Catch {
Write $ZERROR,!
}
Return ns