Previous Topic: GETLIKE function variable output:Next Topic: Debugging Guidelines


Sample Coding Statements

The following generic syntax demonstrates the most common usage of the OPSVASRV() function. The automation creates, updates, obtains, and deletes the CCS Sysplex Variable Service variables.

Create basic sysplex variables using the CREATE function:

/*--------------------------------------------------------------------*/
/* Create basic variable named GLVPLXT0.VARTEST.1 with desired        */
/* value using the NAME and DATAVAL keywords. This variable can then  */
/* be accessed by any OPS/MVS system that is also running with the    */

/* CCS CAVARSRV component active.                                     */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
setvar = OPSVASRV("CREATE NAME(GLVPLXT0.VARTEST.1)",
                  "DATAVAL('Specify contents of the variable here')")

/*--------------------------------------------------------------------*
/* Use simple variables that will identify the name of the variable   *
/* and its value, using the NAME and DATAVAR keywords. This is useful *
/* if the variable value is lengthy and/or contains mixed quotation   *
/* marks or any other special characters.                             *
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7* 
varname = 'GLVPLXT0.VARTEST.2'
varval  = 'Specify the contents of the variable here'
setvar  = OPSVASRV("CREATE NAME("varname") DATAVAL('"varval"')") 

Update a basic string variable:

/*--------------------------------------------------------------------*/
/* Update a basic string variable named GLVPLXT0.VARTEST.1 with       */
/* desired value. Variable will be automatically created if it does   */
/* not exist.                                                         */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
varname = 'GLVPLXT0.VARTEST.1'                                          
varval  = 'Contents of the variable value'                              
update  = OPSVASRV("UPDATE NAME("varname") DATAVAR(varval)")            

Obtain and manipulate basic sysplex variables with the GET and the GETLIKE functions:

/*--------------------------------------------------------------------*/
/* Use simple variables that will identify the name of the variable   */
/* to be obtained. If desired, this can be hardcoded directly in the  */
/* NAME keyword. These simple statements will obtain a previously     */
/* created sysplex variable called GLVPLXT0.VARTEST.1 and its value   */
/* will be returned to the variable that invoked the function (getvar)*/
/* Simply SAY the contents of this variable.                          */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
varname = 'GLVPLXT0.VARTEST.1'                                          
getvar   = OPSVASRV("GET NAME('"varname"')")                            
say '****The value of sysplex variable 'varname'='getvar

/*--------------------------------------------------------------------*/
/* Obtain and manipulate a mask of variables. Assuming the sysplex    */
/* variables exist named:GLVPLXT0.IPLDATA.SYSA,GLVPLXT0.IPLDATA.SYSB, */
/* GLVPLXT0.IPLDATA.SYSC, etc the following code would obtain and loop*/
/* through each variable.                                             */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
varnamemask = 'GLVPLXT0.IPLDATA*'
getvar   = OPSVASRV("GETLIKE NAME('"varnamemask"')")
say '****Total number of variables with mask= 'vasrv_name.0
do v = 1 to vasrv_name.0
 say 'Variable name='vasrv_name.v
 say 'Value of var ='vasrv_value.v
end

/*--------------------------------------------------------------------*/
/* Obtain and manipulate a mask of variables and request variable     */
/* metadata so that the group name, create date, and create time can  */
/* be manipulated in addition to the variable names and values.       */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
varnamemask = 'GLVPLXT0.VARX*
getvar   = OPSVASRV("GETLIKE NAME('"varnamemask"')",
                    "OPTIONS(STATS)")
do v = 1 to vasrv_name.0
 groupname  = WORD(vasrv_info.v,3)
 createdate = WORD(vasrv_info.v,11)
 createtime = WORD(vasrv_info.v,12)
 say '**Variable name='vasrv_name.v
 say '         Value ='vasrv_value.v
 say '         Group ='groupname
 say '         CDATE ='createdate
 say '         CTIME ='createtime
end

Obtain and manipulate a large variable mask that exceeds the GETLIKE constraints:

/*--------------------------------------------------------------------*/
/* Assuming you have a very large mask of plex variables that you     */
/* need to manipulate that exceed GETLIKE storage constraints, use    */
/* the GETNEXT function to loop through and process each variable.    */
/* The first GETNEXT will obtain the first variable in the mask, and  */
/* also set the pointer or TOKEN that will be used in the subsequent  */
/* GETNEXT that is done within a loop. At the end of the variable list*/
/* a non vasrv_rc will be returned to end the loop.                   */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
varcnt = 1
varnamemask = 'GLVPLXT0.VARDG*'
firstvarval = OPSVASRV("GETNEXT NAME("varnamemask")")
say 'Value of variable #1 in mask='firstvarval
do while vasrv_rc = 0
  varcnt = varcnt + 1
  nextvarval = OPSVASRV("GETNEXT NAME("varnamemask")",
               "TOKEN("vasrv_token")")
  if vasrv_rc = 0 then,
          say 'Value of variable' vasrv_name'='nextvarval
end

Create, increment, decrement, and obtain counter variables with the INCR or DECR functions or both:

/*--------------------------------------------------------------------*/
/* Create a counter type variable that will be used within the INCR   */
/* and/or DECR functions to automatically increment/decrement the     */
/* value. Set value to initial value (zero),and use required          */
/* DATATYPE(SIGNED32) keyword.                                        */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
setvar = OPSVASRV("CREATE NAME(GLVPLXT0.ABENDCNTR)",
                  "DATAVAL(0)",
                  "DATATYPE(SIGNED32)")

/*--------------------------------------------------------------------*/
/* Add some value to the counter variable using the INCR function.    */
/* This sample code will add 1 to a variable called GLVPXT0.ABENDCNTR */
/* Simply change INCR to DECR if you are decrementing the value.      */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
varname = 'GLVPLXT0.ABENDCNTR'
add12var = OPSVASRV("INCR NAME("varname")",
                    "DATAVAL(1)")

/*--------------------------------------------------------------------*/
/* Obtain a counter variable that was incremented/decremented with    */
/* the INCR/DECR functions. Wrap the REXX C2D() function around the   */
/* the internally stored binary value to view the decimal format.     */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
varname = 'GLVPLXT0.ABENDCNTR'
getvar   = OPSVASRV("GET NAME('"varname"')")
say '****The value of counter variable 'varname'='C2D(getvar) 

Delete sysplex variables:

/*--------------------------------------------------------------------*
/* These simple statements will delete a single variable called       *
/* GLVPLXT0.VARTEST.1, thus making it non-existant to any automation  *
/* executing on any system in the sysplex.                            *
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*
varname = 'GLVPLXT0.VARTEST.1'
delvar  = OPSVASRV('DELETE NAME('varname')')

/*--------------------------------------------------------------------*
/* Delete a mask variables.                                           *
*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*
varnamemask = 'GLVPLXT0.IPLINFO*'
delvars     = OPSVASRV("DELLIKE NAME('"varnamemask"')")

/*--------------------------------------------------------------------*/
/* Purge all sysplex variables within the CCS CAVARSRV component.     */
/* !!WARNING!! Use this function with caution as sysplex variables    */
/* are not checkpointed in any copy of the CCS CAVARSRV component.Thus*/
/* a PURGE will cause all applications running on all OPS/MVS regions */
/* to no longer have access to any sysplex variable.                  */
/*--+----1----+----2----+----3----+----4----+----5----+----6----+----7*/
purgeall  = OPSVASRV('PURGE')