How to create a new global variable in OPS/MVS?
search cancel

How to create a new global variable in OPS/MVS?

book

Article ID: 450423

calendar_today

Updated On:

Products

OPS/MVS Event Management & Automation

Issue/Introduction

You need to create a new global variable. What are the possible ways to create a variable and assign a value to it?

Environment

OPS/MVS

Resolution

Methods to Create a Global Variable

Method 1: Using Standard OPS/REXX Assignment

You can create a global variable by using a standard assignment statement with one of the recognized stems.

  • Persistent Stems: GLOBAL. or GLOBALx. (where x is 0-9). These are saved across product restarts and system IPLs.
  • Temporary Stems: GLVTEMPx. (where x is 0-9). These are lost when OPS/MVS terminates.

Example:

GLOBAL.MYVAR = "Initial Value"

The OPSVALUE function provides serialization, ensuring that asynchronous tasks do not interfere with each other.

Syntax: temp = OPSVALUE(derivedname, 'U', newvalue)

  • derivedname: The name of the variable (e.g., 'GLOBAL.MYVAR').
  • 'U': The action code for Update. It assigns newvalue to the variable. If the variable does not exist, it is created.

Example:

/* Creates or updates GLOBAL.COUNTER to 1 */
var_status = OPSVALUE('GLOBAL.COUNTER', 'U', 1)

Method 3: Using OPSVIEW (Manual Creation)

You can manually create, view, or modify global variables through the OPSVIEW interface:

  1. Enter OPSVIEW.
  2. Navigate to option 4.8 (Control Global Variables).
  3. Use the panels to define and set the value of a new variable.

Method 4: Using the OPSSETV Command Processor

You can use the OPSSETV command from a TSO environment or within a REXX program to create a variable.

Example:

"OPSSETV NAME(GLOBAL.MYVAR) VALUE(SomeValue)"