EGL Reference Guide for iSeries

Library part in EGL source format

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:



Syntax diagram for a library part

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:

All are optional:

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 ]