IBM Books

Administration and Programming Guide for OS/400

Defining the Scope of a Variable in a Transaction

You can decide what scope you want a variable to have in a transaction by specifying the scope as an attribute of the %DEFINE statement. You can specify

transaction scope
The variable scope is for the entire transaction.

single invocation scope
The variable scope is for a single Net.Data invocation.

To specify transaction scope for a variable:

Specify the attribute STATIC to indicate that the variable has transaction scope, meaning the value of the variable is saved across all invocations in a transaction. STATIC is the default for persistent macros. For example:

@dtw_static()
%define(static) var1 = "val1"

To specify single invocation scope for a variable:

Specify the attribute TRANSIENT to indicate that the variable has single invocation scope, meaning the value of the variable will be re-initialized on each invocation. TRANSIENT is the default for non-persistent macros. For example:

@dtw_static()
%define(transient) var1 = "val1"

In a persistent macro:


[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]