The system function sysLib.bytes returns the number of bytes in a named area of memory.
result = sysLib.bytes(myItem);
Related reference
Primitive types
SQL record internals
The system function sysLib.calculateChkDigitMod10 places a modulus-10 check digit in a character item that begins with a series of integers.
This item has 4 digits and is either of type SMALLINT or is of a type BIN, with no decimal places.
You can use sysLib.calculateChkDigitMod10 in a function-invocation statement.
In the following example, myInput is an item of type CHAR and contains the value 1734289; myLength is an item of type SMALLINT and contains the value 7; and myResult is an item of type SMALLINT:
sysLib.verifyChkDigitMod10 (myInput, myLength, myResult);
An algorithm is used to derive the modulus-10 check digit, and in all cases the number at the check-digit position is not considered. The algorithm is described in relation to the example values:
8 x 2 = 16 4 x 2 = 8 7 x 2 = 14
1 + 6 + 8 + 1 + 4 + 1 + 3 + 2 = 26
30 - 26 = 4
If the subtraction yields 10, the check digit is 0.
In this example, the original characters in myInput become these:
1734284
The system function sysLib.calculateChkDigitMod11 places a modulus-11 check digit in a character item that begins with a series of integers.
This item has 4 digits and is either of type SMALLINT or is of a type BIN, with no decimal places.
You can use sysLib.calculateChkDigitMod11 in a function-invocation statement.
In the following example, myInput is an item of type CHAR and contains the value 56621869; myLength is an item of type SMALLINT and contains the value 8; and myResult is an item of type SMALLINT:
sysLib.verifyChkDigitMod (myInput, myLength, myResult);
An algorithm is used to derive the modulus-11 check digit, and in all cases the number at the check-digit position is not considered. The algorithm is described in relation to the example values:
6 x 2 = 12 8 x 3 = 24 1 x 4 = 4 2 x 5 = 10 6 x 6 = 36 6 x 7 = 42 5 x 2 = 10
(12 + 24 + 4 + 10 + 36 + 42 + 10) / 11 = 138 / 11 = 12 remainder 6
11 - 6 = 5
If the remainder is 0 or 1, the check digit is 0.
In this example, the original characters in myInput become these:
56621865
The system function sysLib.clearScreen clears the screen, as is useful before the program issues a converse statement in a text application.
Related reference
converse
System words in alphabetical order
The system function sysLib.fieldInputLength returns the number of characters that the user typed in the input field when the text form was last presented. That number does not include leading or trailing blanks or nulls.
If the field is at its originally defined state, the function returns a length of 0. For example, if the field contains the value property and it has not been modified during execution in any way, then the length is calculated as 0. The set form initial statement resets the field to its originally defined state. If the field is not at its originally defined state, then the length is calculated based on what was displayed or entered on the last converse statement.
Related reference
System words in alphabetical order
The system function sysLib.getVAGSysType identifies the target system in which the program is running. The function is supported (at development time) if the program property VAGCompatibility is selected or (at generation time) if the build descriptor option VAGCompatibility is set to yes.
If the generated output is a Java wrapper, sysLib.getVAGSysType is not available. Otherwise, the function returns the character value that would have been returned by the VisualAge Generator EZESYS special function word. If the current system was not supported by VisualAge Generator, the function returns the uppercase, string equivalent of the code returned by sysVar.systemType.
sysLib.getVAGSysType returns the VisualAge Generator
equivalent of the value in sysVar.systemType.
Value in sysVar.systemType | Value returned by sysLib.getVAGSysType |
---|---|
AIX | "AIX" |
DEBUG | "ITF" |
ISERIESC | "OS400" |
ISERIESJ | "OS400" |
LINUX | "LINUX" |
USS | "OS390" |
WIN | "WINNT" |
The value returned by sysLib.getVAGSysType can be used only as a character string; you cannot use the returned value with the operands is or not in a logical expression, as you can with sysVar.systemType:
// valid ONLY for sysVar.systemType if sysVar.systemType is AIX call myProgram; end
The only place that sysLib.getVAGSysType can be used is as the source in an assignment or move statement.
The characteristics of sysLib.getVAGSysType are as follows:
It is recommended that you use sysVar.systemType instead of sysLib.getVAGSysType.
The value of sysLib.getVAGSysType does not affect what code is validated at generation time. For example, the following add statement is validated even if you are generating for Windows:
mySystem CHAR(8); mySystem = sysLib.getVAGSysType(); if (mySystem = "AIX") add myRecord; end
To avoid validating code that will never run in the target system, move the statements that you do not want to validate to a second program; then, let the original program call the new program conditionally:
mySystem CHAR(8); mySystem = sysLib.getVAGSysType(); if (mySystem = "AIX") call myAddProgram myRecord; end
An alternative way to solve the problem is available, but only if you use sysVar.systemType instead of sysLib.getVAGSysType; for details, see eliminateSystemDependentCode.
Related reference
eliminateSystemDependentCode
sysVar.systemType
The system function sysLib.maximumSize returns the maximum number of rows that can be in a dynamic array of data items or records; specifically, the function returns the value of the array property maxSize.
The item to which the value is returned must be of type INT or the following equivalent: type BIN with length 9 and no decimal places.
The array name may be qualified by a package name, a library name, or both
An error occurs if you reference an item or record that is not a dynamic array.
Related reference
Arrays
System words in alphabetical order
The system function sysLib.pageEject advances print-form output to the top of the next page, as is useful before the program issues a print statement.
For other details on printing, see Print forms.
Related concepts
Print forms
Related reference
print
System words in alphabetical order
The system function sysLib.setLocale is used in page handlers. The function sets the Java locale, which determines these aspects of run-time behavior:
You might present a list of languages on a Web page, for example, and set the Java locale based on the user's selection. The new Java locale is in use until one of the following occurs:
In the cases mentioned, the next Web page reverts (by default) to the Java locale specified in the browser.
If the user submits a form or clicks a link that opens a new window, the Java locale in the original window is unaffected by the locale in the new window.
sysLib.setLocale conforms to the JDK 1.1 and 1.2 API documentation for class java.util.Locale. See ISO 639 for language codes and ISO 3166 for country codes.
Related concepts
PageHandler part
The system function sysLib.setRemoteUser sets the userid and password that are used on calls to remote programs from Java programs.
When the linkage option part, callLink element, property remoteComType is CICSJ2C, CICSECI, or JAVA400 on a remote call, authorization is based on the values (if non-blank) that are passed to sysLib.setRemoteUser. If a value is blank or not specified, it is sought in a properties file named csouidpwd.properties. Within the csouidpwd.properties file, the values of the CSOUID and CSOPWD properties are used for the username and password. If neither approach is used, EGL run-time makes the call without a username and password.
One way to provide the user ID and password is for your program to issue Java access functions that display a dialog box to prompt the user for the information.
Related concepts
Java access functions
Related reference
remoteComType in callLink element
System words in alphabetical order
The system function sysLib.size returns the number of rows in the specified data table or the number of elements in the specified array. The array may be a structure-item array, a static array of data items or records, or a dynamic array of data items or records.
The item to which the value is returned must be of type INT or the following equivalent: type BIN with length 9 and no decimal places.
If the array name (arrayName) is in a substructured element of another array, the returned value is the number of occurrences for the structure item itself, not the total number of occurrences in the containing structure (see Examples section).
The array name may be qualified by a package name, a library name, or both
An error occurs if you reference an item or record that is not an array.
This example uses the value returned by sysLib.size to control a loop:
// Calculate the sum of an array of numbers sum = 0; i = 1; myArraySize = sysLib.size(myArray); while (i <= myArraySize) sum = myArray[i] + sum; i = i + 1; end
Next, consider the following record part:
Record myRecordPart 10 siTop CHAR(40)[3]; 20 siNext CHAR(20)[2]; end
Given that you create a record based on myRecordPart, you can use sysLib.size(siNext) to determine the occurs value for the subordinate array:
// Sets count to 2 count = sysLib.size(myRecord.siTop.siNext);
Related reference
Arrays
System words in alphabetical order
The system function sysLib.startTransaction invokes a main program asynchronously, associates that program with a printer or terminal device, and passes a record. If the receiving program is generated by EGL, the record is used to initialize the input record; if the receiver is produced by VisualAge Generator, the record is used to initialize the working storage.
This function is not supported in programs that are generated as iSeries COBOL programs.
The default behavior of this function is to start a program that resides in the same Java package. To change that behavior, specify an asynchLink element in the linkage options part that is used to generate the invoking program.
A Java program can transfer only to another Java program on the same machine.
For COBOL programs, EGL Server for iSeries provides support for sysLib.startTransaction by way of two command language (CL) programs:
Related reference
asynchLink element
sysVar.errorCode
sysVar.printerAssociation
transfer
The system function sysLib.verifyChkDigitMod10 verifies a modulus-10 check digit in a character item that begins with a series of integers.
This item has 4 digits and is either of type SMALLINT or is of a type BIN, with no decimal places.
You can use sysLib.verifyChkDigitMod10 in a function-invocation statement; or as an item validator in a text form.
In the following example, myInput is an item of type CHAR and contains the value 1734284; myLength is an item of type SMALLINT and contains the value 7; and myResult is an item of type SMALLINT:
sysLib.verifyChkDigitMod10 (myInput, myLength, myResult);
An algorithm is used to derive the modulus-10 check digit, and in all cases the number at the check-digit position is not considered; but when the algorithm is complete, the calculated value is compared with the number at the check-digit position.
The algorithm is described in relation to the example values:
8 x 2 = 16 4 x 2 = 8 7 x 2 = 14
1 + 6 + 8 + 1 + 4 + 1 + 3 + 2 = 26
30 - 26 = 4
If the subtraction yields 10, the check digit is 0.
In this example, the calculated check digit matches the value in the check-digit position, and the value of myResult is 0.
Related reference
Validation properties
The system function sysLib.verifyChkDigitMod11 verifies a modulus-11 check digit in a character item that begins with a series of integers.
This item has 4 digits and is either of type SMALLINT or is of a type BIN, with no decimal places.
You can use sysLib.verifyChkDigitMod11 in a function-invocation statement; or as an item validator in a text form.
In the following example, myInput is an item of type CHAR and contains the value 56621869; myLength is an item of type SMALLINT and contains the value 8; and myResult is an item of type SMALLINT:
sysLib.verifyChkDigitMod11 (myInput, myLength, myResult);
An algorithm is used to derive the modulus-11 check digit, and in all cases the number at the check-digit position is not considered; but when the algorithm is complete, the calculated value is compared with the number at the check-digit position. The algorithm is described in relation to the example values:
6 x 2 = 12 8 x 3 = 24 1 x 4 = 4 2 x 5 = 10 6 x 6 = 36 6 x 7 = 42 5 x 2 = 10
(12 + 24 + 4 + 10 + 36 + 42 + 10) / 11 = 138 / 11 = 12 remainder 6
11 - 6 = 5
If the remainder is 0 or 1, the check digit is 0.
In this example, the calculated check digit matches the value in the check-digit position, and the value of myResult is 0.
Related reference
Validation properties
The system function sysLib.wait suspends execution for the specified number of seconds.
You can use sysLib.wait when two asynchronously running programs need to communicate through a record in a shared file or database. One program might need to suspend processing until the other program updates the information in the shared record.
Example
sysLib.wait(15); // waits for 15 seconds
Related reference
System words in alphabetical order
The system variable sysVar.arrayIndex contains a number:
You can use sysVar.arrayIndex as any of these:
The characteristics of sysVar.arrayIndex are as follows:
Assume that the record myRecord is based on the following part:
Record mySerialRecPart serialRecord: fileName = "myFile" end 10 zipCodeArray CHA(9)[100]; 10 cityStateArray CHA(30)[100]; end
Furthermore, assume that the arrays are initialized with zip codes and city-and-state combinations.
The following code sets the variable currentCityState to the city and state that corresponds to the specified zip code:
currentZipCode = "27540"; if (currentZipCode in myRecord.zipCodeArray) currentCityState = myRecord.cityStateArray[sysVar.arrayIndex]; end
After the if statement, sysVar.arrayIndex contains the index of the first zipCodeArray element that contains the value of "27540". If "27540" is not found in zipCodeArray, the value of sysVar.arrayIndex is 0.
Related concepts
Segmentation in text applications
Related reference
Arrays
in
Logical expressions
The system variable sysVar.eventKey identifies the key that the user pressed to return a form to an EGL text program. The value is reset each time that the program runs the converse statement.
If the EGL code has no input form, the initial value of sysVar.eventKey is ENTER.
The following values are valid (whether uppercase, lowercase, or a combination):
You can use sysVar.eventKey as an operand in an if or while statement.
The characteristics of this system variable are as follows:
sysVar.eventKey is not valid in a batch program.
The comparison operator for sysVar.eventKey is either is or not, as in this example:
if (sysVar.eventKey IS PF3) exit program(0); end
Related reference
Logical expressions
The system variable sysVar.printerAssociation allows you to specify, at run time, the output destination when you print a print form.
You can use this variable in any of these ways:
Characteristics of sysVar.printerAssociation are as follows:
sysVar.printerAssociation is initialized to the system resource name specified during generation or for debugging. If a program passes control to another program, the value of sysVar.printerAssociation is set to the default value for the receiving program.
Even when multiple print jobs are allowed for a given print form, the close statement closes only the file related to the current value of sysVar.printerAssociation.
For Java output, you set sysVar.printerAssociation to a two-part string with an intervening colon:
jobID:destination
You can use different jobs to promote a different kind of output or a different ordering of output, depending on the flow of events in your code. Consider the following sequence of EGL statements, for example:
sysVar.printerAssociation = "job1"; print form1; sysVar.printerAssociation = "job2"; print form2; sysVar.printerAssociation = "job1"; print form3;
When the program ends, two print jobs are created:
The string destination is optional and is ignored if the print job is still open. The following statements apply if the string is absent:
The following statements apply to the setting of destination when you are generating for Windows 2000/NT/XP:
vgj.ra.myFile.systemName=printer vgj.ra.myFile.fileType=spool
The following statements apply to the setting of destination when you are generating for UNIX:
In relation to iSeries COBOL, set the system variable sysVar.printerAssociation to the value of a fileName property in the resource associations part that is used at generation time. The file type must be of type SEQ and not of type SPOOL.
Multiple print jobs are not supported for COBOL programs that are generated for iSeries, and when sysVar.printerAssociation is set, the EGL run time closes the old file (to complete the previous output of data); uses the iSeries command OVRPRTF to override the file name; and opens the new file.
Prior to its use, the value in sysVar.printerAssociation is folded to uppercase; but the value in the system variable itself remains unchanged. The value of sysVar.printerAssociation tests true when compared against a lowercase version if the system variable was initialized with a lowercase version.
The value set in sysVar.printerAssociation is propagated from the call level and changed to all the subordinate call levels. The value is not propagated, however if the program opened the file previously.
The system variable sysVar.remoteSystemID contains the system name for the location of a remote program. This variable does not support dynamic definition of programs, but does support dynamic selection from a predefined set of locations.
sysVar.remoteSystemID is initialized to blanks and must be set before doing any call that requires use of this variable.
If you generate a COBOL program, any value in sysVar.remoteSystemID is folded to uppercase. Regardless of the target language, however, any comparison of sysVar.remoteSystemID and a character string is case-sensitive and is based on the value assigned to the variable. The comparison in the following code resolves to false, for example:
sysVar.remoteSystemID = "myWin"; // resolves to false if (sysVar.remoteSystemID = "MYWIN") record1.resourceAssociation = "myCorp.txt"; end
You can use sysVar.remoteSystemID in most places where an item is allowed: as the target or source in an assignment statement, as a value passed to a system function, as an item in a logical expression, or as the argument in a return statement.
The characteristics of sysVar.remoteSystemID are as follows:
The value of sysVar.remoteSystemID provides access of the remote program only if the linkage options part, callLink element, property location is set to PROGRAMCONTROLLED. For details on the meaning of sysVar.remoteSystemID for remote programs, see the description of system name in location in callLink element.
Platform | Compatibility considerations |
---|---|
iSeries COBOL | Not supported |
sysVar.remoteSystemID = "myWIN"; // resolves to true if (sysVar.remoteSystemID = "myWIN") record1.resourceAssociation = "myCorp.txt"; end
Related concepts
Linkage options part
Related tasks
Editing the asynchLink element of a linkage options part
Editing the callLink element of a linkage options part
Related reference
asynchLink element
location in callLink element
sysLib.startTransaction
transferToProgram element
The system variable sysVar.segmentedMode is used in a text application to change the effect of the converse statement, but the variable is ignored for this purpose in called programs. For background information, see Segmentation.
Values of sysVar.segmentedMode are as follows:
The default value is 0 for non-segmented programs and 1 for segmented programs. The variable is reset to the default after the converse statement runs.
You can use this variable in any of these ways:
Characteristics of sysVar.segmentedMode are as follows:
Related concepts
Segmentation in text applications
Related reference
System words in alphabetical order
In Web applications, the system variable sysVar.sessionID contains an ID that is specific to the Web application server session. You can use the sysVar.sessionID value as a key value to access file or database information shared between programs.
Outside of Web applications, the following statements apply:
You can use sysVar.sessionID in these ways:
The characteristics of sysVar.sessionID are as follows:
sysVar.sessionID is initialized from the Java Virtual Machine system property user.name; and if the property cannot be retrieved, sysVar.sessionID is blank.
In relation to COBOL code for iSeries, sysVar.sessionID is the logon user ID and equivalent to the sysVar.userID.
myItem = sysVar.sessionID;
Related reference
sysVar.terminalID
sysVar.userID
The system variable sysVar.systemType identifies the target system in which the program is running. If the generated output is a Java wrapper, sysVar.systemType is not available. Otherwise, the valid values are as follows:
You can use sysVar.systemType in these ways:
The characteristics of sysVar.systemType are as follows:
Use sysVar.systemType instead of sysLib.getVAGSysType.
The value of sysVar.systemType does not affect what code is validated at generation time. For example, the following add statement is validated even if you are generating for Windows:
if (sysVar.systemType IS AIX) add myRecord; end
To avoid validating code that will never run in the target system, take either of the following actions:
if (sysVar.systemType IS AIX) call myAddProgram myRecord; end
if (sysVar.systemType is WIN) call myAddProgram myRecord; end
Related reference
eliminateSystemDependentCode
sysLib.getVAGSysType
In relation to COBOL code on iSeries, sysVar.terminalID is initialized to blanks; and if the code is interactive, the variable is reset to the terminal device name received from a query of the attributes of the active job.
In relation to Java code, sysVar.terminalID (like sysVar.sessionID) is initialized from the Java Virtual Machine system property user.name, and if the property cannot be retrieved, sysVar.terminalID is blank.
You can use sysVar.terminalID in these ways:
The characteristics of sysVar.terminalID are as follows:
myItem10 = sysVar.terminalID;
Thevariable is not used; but if the program was invoked by a transfer statement of the form transfer to program, the variable contains the name of the transferring program.
You can use this variable in any of these ways:
Characteristics of sysVar.transactionID are as follows:
Related concepts
Segmentation in text applications
Related reference
The system variable sysVar.transferName allows you to specify, at run time, the name of the program or transaction to which you want to transfer.
You can use this variable in any of these ways:
Characteristics of sysVar.transferName are as follows:
Related reference
System words in alphabetical order
transfer
The system variable sysVar.userID contains a user identifier in environments where one is available.
You can use sysVar.userID in these ways:
The characteristics of sysVar.userID are as follows:
sysVar.userID is initialized from the Java Virtual Machine system property user.name; and if the property cannot be retrieved, sysVar.userID is blank.
In relation to COBOL code for iSeries, sysVar.userID contains the user ID specified at sign-on.
myItem = sysVar.userID;
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.