You are here: LANSA for i User Guide > 2. Fields > 2 16 System Variables

2.16 System Variables

A system variable is a name that is assigned to a commonly used (and often variable) piece of information.

For instance, the current date is a commonly used piece of information that varies every day. It could be assigned the system variable name *TODAYS_DATE.

Once this is created, you can use this system variable name in many places within LANSA:

The extensive use of system variables in validation rules has many advantages:

For instance, if a field named DATDUE is to be validated so that it can only be the current date. The required validation rule could be done in any of these ways:

Many system variables are provided with the shipped version of LANSA. However, the primary use of system variables is to aid in accessing your own company's information. You might create some system variables defined to match your company's specific requirements such as these:

System Variable

Description

Type

Len

Dec

*PERIOD

Current financial period

N

4

0

*LASTPERIOD

Last financial period

N

4

0

*NEXTPERIOD

Next financial period

N

4

0

*BEGINMONTH

Date of first day of current month

N

6

0

*ENDMONTH

Date of last day of current month

N

6

0

*SYDOFFICE

Sydney office name and address code

A

7

 

*MEBOFFICE

Melbourne office name and address code

A

7

 

*COMPANY

Company number for use in G/Ledger

A

2

 

 

Note that the system variables listed above are not supplied with LANSA. They are suggestions for creating your own system variables.

When a system variable is defined to LANSA, a name, description, method of derivation, type and length must be specified.

The method of derivation indicates when the system variable is to be derived or evaluated. It can be specified as STATIC or DYNAMIC.

In addition, the name of a LANSA function or 3GL program that will "evaluate" the system variable must also be specified. It is this function/ program that is important because it provides the "intelligence" required to decide what is the correct value to place in the system variable.

For information about the evaluation programs, refer to System Variable Evaluation Programs in the Visual LANSA Developer Guide.