3GL Programs

Visual LANSA

3GL Programs

This program can be very easily expanded to return the values for the 2 system variables named *SYDN and *MELB because they have the same type and length:

C           *ENTRY    PLIST

C                     PARM           SYSVAR 20

C                     PARM           VALUE   7

C*

C           SYSVAR    IFEQ '*SYDN'

C                     MOVEL'SYD0386' VALUE

C                     ELSE

C                     MOVEL'MEB2307' VALUE

C                     END

C*

C                     RETRN

 

In addition this program could be modified to return values for system variables that have different types and lengths like *SYDN, *MELB, *PERIOD and *COMPANY:

IVALUE       DS

I                                        1   7 OFFICE

I                                    P   1   30PERIOD

I                                        1   2 COMPNY

C*

C           *ENTRY    PLIST

C                     PARM           SYSVAR 20

C                     PARM           VALUE

C*

C           SYSVAR    IFEQ '*SYDN'

C                     MOVEL'SYD0386' OFFICE

C                     ELSE

C           SYSVAR    IFEQ '*MELB'

C                     MOVEL'MEB2307' OFFICE

C                     ELSE

C           SYSVAR    IFEQ '*PERIOD'

C                     Z-ADD8701      PERIOD

C                     ELSE

C           SYSVAR    IFEQ '*COMPANY'

C                     MOVEL'05'      COMPNY

C                     END

C                     END

C                     END

C                     END

C*

C                     RETRN

 

In addition, this program could be modified to return values for system variables that have different types and lengths such as *SYDN, *MELB, *PERIOD and *COMPANY:

In all cases the returned values are generated from moves of numeric or alphanumeric literals that are "hard-coded" into the system variable evaluation program. In reality this is not usually the case. The returned values are most often derived from data areas or database files. The extension of the logic demonstrated above to access data areas or database files is fairly easy to imagine.

Smart System Variables

Some system variable evaluation programs are provided with the shipped version of LANSA. These are:

M@SYSDTA - Retrieve portion of an alphanumeric data area

M@SYSNUM- Get the next number from a data area

M@SYSDTA can be used to retrieve data from predefined alphanumeric data areas on your system.

M@SYSNUM can be used to generate the next number from a value that is stored in a data area. This can be returned as either an alpha or numeric value.

These shipped programs can be used as the system variable evaluation program for user defined system variables that follow a defined naming convention. This convention is shown below.

Example 1

For M@SYSDTA use the following naming convention:

*DTAssslllxxxxxxxxxx

where

Sss

Starting position in data area

lll

The length to retrieve (limited to 256 characters)

Xxxxxxxxxx

The data area name

  

Note:

  • The data area must exist in the library list.
  • Data area name cannot be *LDA (Local Data Area) or *GDA (Group Job Data Area).
  • Method of derivation should be STATIC for system variables using this evaluation program.

Example of Use (#1)

Retrieve the company name from data area COMPDETL. The company is in position 32 and is 25 characters long.

STEP 1 - Define System Variable

STEP 2 - Use in a LANSA Function

Example 2

For M@SYSNUM use the following naming conventions . . .

For alphanumeric results

*AUTOALPnnxxxxxxxxxx

For numeric results

*AUTONUMnnxxxxxxxxxx

where nn = is length to retrieve and  xxxxxxxxxx = the data area name.

Note:  

  • Data area name cannot be *LDA (Local Data Area) or *GDA (Group Job Data Area).
  • If data area cannot be allocated / found, it will be created with name xxxxxxxxxx of type *DEC and length nn (limited to 15 digits), and initialized to 0.
  • The xxxxxxxxxx part of system variable name must be unique.
  • Method of derivation should be DYNAMIC for system variables using this evaluation program.

Example of Use (#2)

Retrieve the next available order number. Used order numbers are stored in a data area called ORDNO. This data area is defined as decimal 5 with 0 decimal places. The order number should be returned as alphanumeric with length 5.

STEP 1 - Define System Variable

STEP 2 - Use in a LANSA Function