Focal Point
iSM IFL for reading Environment variables

This topic can be found at:

February 09, 2012, 07:23 PM
iSM IFL for reading Environment variables

Is there an iWay function in Service Manager 6.1.2 which can retrieve the value of a Windows System Environment variable?


iSM 616
iDM 7705
iDQC 802
WF 77
Windows 2008 Server
February 10, 2012, 09:55 AM
Igor Y
I don't think there is a function, but if you change your iSM startup script to include the variable in the java properties, like -Dwindir=%windir%, you might be able to use _sreg(windir).

iWay Service Manager (6.0.1 - patch.62627)
DMC Version 7 Release 7
February 10, 2012, 01:59 PM
iWay Newbie
Hi AK,

there is no direct function, but there's a _property() iFL... If you do

C:\> set > myvars.txt

You should be able to get the values from the file.

The easiest is probably to call the service that invokes OS commands:

Run OS Shell Command Service (com.ibi.agents.XDRunCmdAgent)

The command would be "cmd /C set" to get a list of all variables under /status/cmdoutput or "cmd /C set prompt" to get the value of the PROMPT variable....

<?xml version="1.0" encoding="UTF-8" ?>
	<command>cmd /C set prompt</command>

Hope this helps!


iSM 6 on AIX,
iSM 6 on Windows 2008 Server
WebFOCUS 8.0.03 on AIX
February 14, 2012, 12:21 PM
Dan Satchell
I know nothing about Service Manager and iWay functions, but there is a WebFOCUS function, FGETENV, that is used to retrieve values from system environment variables. You could see if it works in iWay.

Syntax: How to Retrieve the Value of an Environment Variable

FGETENV(varlength, 'varname', outfieldlen, outfldformat);


varlength=Integer  - Is the length of the environment variable name.

varname=Alphanumeric  - Is the name of the environment variable.

outfieldlen=Integer  - Is the length of the field in which the environment variable's value is stored.

outfldformat=Alphanumeric  - Is the format of the field in which the environment variable's value is stored.

WebFOCUS 7.7.05
February 15, 2012, 11:06 AM
WebFOCUS / iDM function FGETENV does not work in iSM.

One comment about FGETENV function in iDM is whenever the Windows environment variable value changes, iDM server has to be restarted to load the new value. If the server is not restarted the function always retrieves the old value. Looks like this function does not call the env var directly but rather calls the variables that are loaded in memory when the server is started.

iSM 616
iDM 7705
iDQC 802
WF 77
Windows 2008 Server
February 21, 2012, 02:37 PM
I'm not sure your comment about FGETENV is quite correct; when you issue a set from a DOS prompt it's not going to affect the server running as a service or in its own DOS window.

However if you set an environment variable from withinthe running server, that would be fine. For example:

 -SET &RC= FPUTENV(9, 'IWAF_HOME', 7, 'C:\IWAF', 'I8');
-SET &IWH = FGETENV(9, 'IWAF_HOME', 20, 'A20');

February 22, 2012, 08:59 AM
Or you can just write one:

package com.ibi.funcs;
import com.ibi.edaqm.*;

public class FunctionNodeGetEnv extends FunctionNode {

	public FunctionNodeGetEnv() {
	public FunctionNodeGetEnv(String name) {
	String getTypeName() {
		return "GetEnv";
	public int getMinParms() { 
		return 1; 
	public int getMaxParms() { 
		return 1; 

	public XDNode getDesc()	{
		try {
			String info =
				"<func name='_getenv' class='string'>" +
				"<desc>Get Environment Variable value.</desc>" +
				"<parm name='string' type='string' req='yes'>Enviornment variable to return</parm>" +
			XDDocument d = new XDDocument(null,info);
			return d.getRoot();
		} catch (Exception e) {
			return null;
	private FunctionNode[] parms;
	public void optimize(XDManager manager, com.ibi.common.IXLogger logger) throws XDException	{
		parms = getParms();
	public String getXValue(XDDocument doc, com.ibi.common.ISpecRegManager srm, com.ibi.common.IXLogger logger) throws XDException	{
		/* Initialize return string */
		String eValue = null;

		/* Ensure there is 1 arguments in the function call */
		if (parms.length != 1) {
			throw new XDFunctionException("_GetEnv",1,"Function requires min 1 argument.");
		/* Retrieve the in bound arguments */
		String arg1 = parms[0].getXValue(doc, srm, logger);

		/* Get the environment variable */
			eValue = System.getenv(arg1);
		}catch (Exception e){
			throw new XDFunctionException("_GetEnv",1,"_getenv failed.");

		/* return environment variable if available */
		return (eValue == null ? " " : eValue);

package com.ibi.funcs;

public class GetEnvRegister implements com.ibi.common.IComponentRegister {
	public GetEnvRegister() {

	public void register (com.ibi.common.IComponentManager cm) {
	public void unregister (com.ibi.common.IComponentManager cm) {

Name: IXTEComponent
Register: com.ibi.funcs.GetEnvRegister



"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
February 23, 2012, 04:59 AM
I haven't tried this, but many thanks to dhagen for a top quality answer!

iWay 5.5 SMSP1 and 6.0.1 on Intel/Linux