| Getting the System Name and
Workstation ID with a System Variable |
Accessing, reviewing, and logging the Machine
Name that is performing a particular task is often very important. For
the Server, this is the System Name and for a client, it is the
Workstation ID. On the iSeries, this can be retrieved using the Retrieve
Network Attribute, RTVNETA, command to get the SYSNAME Attribute.
On Windows, it is available in the Registry under "HKEY_LOCAL_MACHINE"
Registry Root, "SYSTEM\CURRENTCONTROLSET\CONTROL\COMPUTERNAME\COMPUTERNAME"
Registry Key, and "ComputerName" Registry Key.
To make this information more readily
accessible from within a LANSA program, we suggest that you create a
LANSA System Variable to retrieve this information. To do this, you will
need to do 3 things:
Create the LANSA System Variable
Create the System Variable Evaluation Function
Create the CL program on the iSeries to retrieve the System Name Network Attribute
Refer to the following sections for information
and Code for all three of these steps.
LANSA System Variable

LANSA System Variable Function Code Snippet
(The code below is a Snippet from Surround's Machine Information System
Variable evaluator):
*
=======================================================
* Copyright .....: (C) Surround
Technologies, LLC, 2003
* Process .......: FWSYVRP01
* Function ......: FWSVMI1
* Type ..........: System Variable
Evaluator
*
* Created by ....: LEE
* Created on ....: 10/23/01 at
16:24:35
* Description ...: Machine
Information
*
=======================================================
* Function Control Options
FUNCTION OPTIONS(*DIRECT *DBOPTIMIZE
*NOMESSAGES *HEAVYUSAGE *MLOPTIMISE *ALP_SYSTEM_VARIABLE)
*
* Condition definitions
DEF_COND NAME(*AS400) COND('(*CPUTYPE
= AS400)')
DEF_COND NAME(*NEVERTRUE)
COND('(NEVER = TRUE)')
*
*
*
=======================================================
* Tag: Program Mainline : FWSVMI1
*
=======================================================
* <<<<<<<<<<<<<<<< Initializations
>>>>>>>>>>>>>>>>
*
*
* Tag: <<<<<<<<<<<<<< Main Logic
>>>>>>>>>>>>>>>>
CASE OF_FIELD(#SYSVAR$NM)
WHEN VALUE_IS('= ''*UD_FW_SYSTEM_NAME''')
* System Name
IF COND(*AS400)
CALL PGM(STRTVSYSVL) PARM('SYSNAME ' #SYSVAR$AV) EXIT_USED(ER1)
MENU_USED(ER1) IF_ERROR(ER1)
USE BUILTIN(LEFT) WITH_ARGS(#SYSVAR$AV) TO_GET(#SYSVAR$AV)
ELSE
* For PC's, extract details from registry
CHANGE FIELD(#FW_DOCPT) TO('SYSTEM\CURRENTCONTROLSET\CONTROL\COMPUTERNAME\COMPUTERNAME')
USE BUILTIN(GET_REGISTRY_VALUE) WITH_ARGS('HKEY_LOCAL_MACHINE' #FW_DOCPT
'ComputerName') TO_GET(#SYSVAR$AV #IO$STS)
USE BUILTIN(LEFT) WITH_ARGS(#SYSVAR$AV) TO_GET(#SYSVAR$AV)
ENDIF
*
OTHERWISE
ABORT MSGTXT('Machine information system variable evaluator invalidly
invoked.')
ENDCASE
*
IF COND(*NEVERTRUE)
ER1: * Error Retrieving Machine Information
CHANGE FIELD(#SYSVAR$AV) TO('''Error''')
ENDIF
*
RETURN
*
=======================================================
* Tag: End Program Mainline :
FWSVMI1
*
=======================================================
CL Program Code Snippet (The code below is a
Snippet from Surround's Machine Information System Variable evaluator):
/*
================================================================
*/
/* Copyright ....: (C) Surround
Technologies, LLC 1999 - 2003 */
/*
PO Box 47
*/
/*
Scotch Plains, NJ 07076
*/
/*
(908) 490-1235
*/
/*
http://www.surroundtech.com
*/
/*
*/
/*
================================================================
*/
/* Program.......: STRTVSYSVL
*/
/* Created by ...: Lee Paul
*/
/* Created on ...: October 24,
2001
*/
/* Description ..: Retrieve a
System Value and put onto Exch List */
/*
================================================================
*/
/* This program is used as an
interface to LANSA System Variables */
/* to Retrieve System Values.
*/
/*
*/
/* Incoming Parameters:
*/
/* &SYSVALNM -
Name of System Value to Retrieve
*/
/*
*/
/* Outgoing Parameters
*/
/* &RTNVAL -
System Value
*/
/*
*/
/*
================================================================
*/
/* Program Definition
*/
/*
================================================================
*/
PGM PARM(&SYSVALNM &RTNVAL)
/*
================================================================
*/
/* Declare Program Variables &
Files
*/
/*
================================================================
*/
DCL VAR(&SYSVALNM) TYPE(*CHAR)
LEN(10)
DCL VAR(&RTNVAL)
TYPE(*CHAR) LEN(256)
DCL VAR(&SYSNAME)
TYPE(*CHAR) LEN(8)
/*
================================================================
*/
/* Program Mainline
*/
/*
================================================================
*/
/* Retrieve the Network Attribute
*/
IF COND(&SYSVALNM *EQ SYSNAME) THEN(DO)
RTVNETA SYSNAME(&SYSNAME)
MONMSG (CPF0000 MCH0000)
CHGVAR VAR(&RTNVAL) VALUE(&SYSNAME)
GOTO CMDLBL(ENDPGM)
ENDDO
ENDPGM:
RETURN
ENDPGM
/*
================================================================
*/
/* End of Program
*/
/*
================================================================
*/
Envision VL Accelerator Developers:
You're in luck, No coding
needed! We did it for you. Refer to the Developers Guide for the "Client
and Server Job Information Interface" and the properties:
uClientSystemName and
uServerSystemName.
This information is also available through the VL Accelerator LANSA
System Variable, *UD_FW_SYSTEM_NAME.

|