Import and Export Concepts

ILE languages support the following types of exports and imports:
  • Weak data exports
  • Weak data imports
  • Strong data exports
  • Strong data imports
  • Strong procedure exports
  • Weak procedure exports
  • Procedure imports
An ILE module object can export procedures or data items to other modules. And an ILE module object can import (reference) procedures or data items from other modules. When using a module object on CRTSRVPGM command to create a service program, its exports optionally export from the service program. (See Export Parameter on the CRTSRVPGM Command.) The strength (strong or weak) of an export depends on the programming language. The strength determines when enough is known about an export to set its characteristics, such as the size of a data item. A strong export's characteristics are set at bind time. The strength of the exports affects symbol resolution.
  • The binder uses the characteristics of the strong export, if one or more weak exports have the same name.
  • If a weak export does not have the same name as a strong export, you cannot set its characteristics until activation time. At activation time, if multiple weak exports with the same name exist, the program uses the largest one. This is true, unless an already activated weak export with the same name has already set its characteristics.
  • At bind time, if a binding directory is used, and weak exports are found to match weak imports, they will be bound. However, the binding directory is searched only as long as there are unresolved imports to be resolved. Once all imports are resolved, the search through the binding directory entries stops. Duplicate weak exports are not flagged as duplicate variables or procedures. The order of items in the binding directory is very important.

You can export weak exports outside a program object or service program for resolution at activation time. This is opposed to strong exports that you export only outside a service program and only at bind time.

You cannot, however, export strong exports outside a program object. You can export strong procedure exports outside a service program to satisfy either of the following at bind time:
  • Imports in a program that binds the service program by reference.
  • Imports in other service programs that are bound by reference to that program.

Service programs define their public interface through binding source language.

You can make weak procedure exports part of the public interface for a service program through the binding source language. However, exporting a weak procedure export from the service program through the binding source language no longer marks it as weak. It is handled as a strong procedure export.

You can only export weak data to an activation group. You cannot make it part of the public interface that is exported from the service program through the use of binder source language. Specifying weak data in the binder source language causes the bind to fail.

Table 1 summarizes the types of imports and exports that are supported by some of the ILE languages:
Table 1. Imports and Exports Supported by ILE Languages
ILE Languages Weak Data Exports Weak Data Imports Strong Data Exports Strong Data Imports Strong Procedure Exports Weak Procedure Exports Procedure Imports
RPG IV No No Yes Yes Yes No Yes
COBOL2 Yes3 Yes3 No No Yes1 No Yes
CL No No No No Yes1 No Yes
C No No Yes Yes Yes No Yes
C++ No No Yes Yes Yes Yes Yes
Note:
  1. COBOL and CL allow only one procedure to be exported from the module.
  2. COBOL uses the weak data model. Data items that are declared as external become both weak exports and weak imports for that module.
  3. COBOL requires the NOMONOPRC option. Without this option, the lowercase letters are automatically converted to uppercase.
For information on which declarations become imports and exports for a particular language, see one of the following books: