EGL Reference Guide for iSeries
You declare a library part in an EGL file, which is described in EGL
source format.
An example of a library part is as follows:
Library CustomerLib3
// Use declarations
Use StatusLib;
// Data Declarations
exceptionId ExceptionId ;
// Retrieve one customer for an email
// In: customer, with emailAddress set
// Out: customer, status
Function getCustomerByEmail ( customer CustomerForEmail, status int )
status = StatusLib.success;
try
get customer ;
onException
exceptionId = "getCustomerByEmail" ;
status = sqlCode ;
end
commit();
end
// Retrieve one customer for a customer ID
// In: customer, with customer ID set
// Out: customer, status
Function getCustomerByCustomerId ( customer Customer, status int )
status = StatusLib.success;
try
get customer ;
onException
exceptionId = "getCustomerByCusomerId" ;
status = sqlCode ;
end
commit();
end
// Retrieve multiple customers for an email
// In: startId
// Out: customers, status
Function getCustomersByCustomerId
( startId CustomerId, customers Customer[], status int )
status = StatusLib.success;
try
get customers usingKeys startId ;
onException
exceptionId = "getCustomerForEmail" ;
status = sqlCode ;
end
commit();
end
end
The diagram of a library part is as follows:

- Library libraryPartName ...
end
- Identifies the part as a library part and specifies the name. If
you do not set the alias property (as described later), the name of
the generated library is either libraryPartName or, if you are
generating COBOL, the first eight characters of
libraryPartName.
For other rules, see Naming conventions.
- libraryProperties
- The library properties are as follows:
- alias
- allowUnqualifiedItemReferences
- includeReferencedFunctions
- messageTablePrefix
All are optional:
- alias = alias identifies a string that is
incorporated into the names of generated output. If you do not set the
alias property, the program-part name (or a truncated version)is used
instead.
- allowUnqualifiedItemReferences = no,
allowUnqualifiedItemReferences = yes specifies whether to allow your
code to reference structure items but to exclude the name of the
container, which is the data table, record, or form that holds the
structure item. Consider the following record part, for example:
Record aRecordPart type basicRecord
10 myItem01 CHAR(5);
10 myItem02 CHAR(5);
end
The following variable is based on that part:
myRecord aRecordPart;
If you accept the default value of allowUnqualifiedItemReferences
(no), you must specify the record name when referring to myItem01,
as in this assignment:
myValue = myRecord.myItem01;
If you set the property allowUnqualifiedItemReferences to
yes, however, you can avoid specifying the record name:
myValue = myItem01;
It is recommended that you accept the default value, which promotes a best
practice. By specifying the container name, you reduces ambiguity for
people who read your code and for EGL.
EGL uses a set of rules to determine the area of memory to which a variable
name or item name refers. For details, see References to variables
and constants.
- includeReferencedFunctions = no, includeReferencedFunctions =
yes indicates whether the library contains a copy of each function that
is neither inside the library nor in a library accessed by the current
library. The default value is no, which means that you can
ignore this property if all functions that are to be part of this library are
inside the library.
If the library is using shared functions that are not in the library,
generation is possible only if you set the property
includeReferencedFunctions to yes.
- msgTablePrefix = prefix specifies the first one to
the four characters in the name of a data table that is used as a message
table. (The message table is available to forms that are output by
library functions.) The other characters in the name correspond to one
of the national language codes listed in DataTable part in EGL source
format.
- useDeclaration
- Provides easier access to a data table or library, and is needed to access
forms in a form group. For details, see Use
declaration.
- private
- Indicates that the variable, constant, or function is unavailable outside
the library. If you omit the term private, the variable,
constant, or function is available.
- dataItemName
- Name of a data item. For the rules of naming, see Naming
conventions.
- primitiveType
- The primitive type of a data item or (in relation to an array) the
primitive type of an array element.
- length
- The parameter's length or (in relation to an array) the length of an
array element. The length is an integer that represents the number of
characters or digits in the memory area referenced either by
dataItemName or (in the case of an array)
dynamicArrayName.
- decimals
- For a numeric type (BIN, DECIMAL, NUM, NUMC, or PACF), you may specify
decimals, which is an integer that represents the number of places
after the decimal point. The maximum number of decimal positions is the
smaller of two numbers: 18 or the number of digits declared as
length. The decimal point is not stored with the
data.
- dataItemPartName
- The name of a dataItem part that is visible to the program. For
details on visibility, see References to parts.
The part acts as a model of format, as described in
Typedef.
- recordName
- Name of a record. For the rules of naming, see Naming
conventions.
- recordPartName
- Name of a record part that is visible to the program. For details
on visibility, see References to parts.
The part acts as a model of format, as described in
Typedef.
- constantName literal
- Name and value of a constant. The value is either a quoted string
or a number. For the rules of naming, see Naming
conventions.
- itemProperty
- An item-specific property-and-value pair, as described inOverview of
EGL properties and overrides.
- recordProperty
- A record-specific property-and-value pair. For details on the
available properties, see the reference topic for the record type of
interest.
A basic record has no properties.
- itemName
- Name of a record item whose properties you wish to override. See
Overview of EGL properties and overrides.
- arrayName
- Name of a dynamic or static array of records or data items. If you
use this option, the other symbols to the right (dataItemPartName,
primitiveType, and so on) refer to each element of the
array.
- size
- Number of elements in the array. If you specify the number of
elements, the array is static; otherwise, the array is dynamic.
- functionPart
- A function. No parameter in the function can be of a loose
type. For details, see Function part in EGL source
format.
Related concepts
EGL projects, packages, and files
Library part
Overview of EGL properties and overrides
References to parts
References to variables and constants
Typedef
Related reference
Basic record part in EGL source format
DataTable part in EGL source format
EGL source format
Function part in EGL source format
Indexed record part in EGL source format
Input form
Input record
I/O error values
MQ record part in EGL source format
Primitive types
Relative record part in EGL source format
Serial record part in EGL source format
SQL record part in EGL source format
Use declaration
[ Top of Page | Previous Page | Next Page | Table of Contents | Index ]
(C) Copyright IBM Corporation 1992, 2005. All Rights Reserved.