2 16 System Variables

LANSA for i

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:

  • As a field's default value in the data dictionary.
  • In any of the 6 standard types of field validation rules.
  • Just about anywhere in the RDML components of LANSA.

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

  • The validation rules are simpler and easier to understand.
  • The validation rules are more powerful and more accurate.
  • The validation rules last longer and are easier to maintain.

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:

  • As a range of values rule. Validate DATDUE as being in range *TODAYS_DATE to *TODAYS_DATE.
  • As a list of values rule. Validate DATEDUE as being in the list *TODAYS_DATE.
  • As a simple logic rule. Validate DATDUE by evaluating the expression '#DATDUE = *TODAYS_DATE'.

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.