RPG/400 Help

FREE (Deactivate a Program)

*---------*---------------*-----------------*----------------*---------------*
|   CODE  |    FACTOR 1   |     FACTOR 2    |     RESULT     |  INDICATORS   |
|         |               |                 |      FIELD     |               |
*---------*---------------*-----------------*----------------*---------------*
| FREE    |               | Program name    |                |    _ ER _     |
*---------*---------------*-----------------*----------------*---------------*

The FREE operation removes a program from the list of activated programs, frees static storage, and ensures program initialization (first cycle processing) the next time the program is called. It does not close files or unlock data areas.

Factor 2 contains the name of the program to be deactivated. It must contain the name of a field, named constant, literal, or array element that contains the name of the program to be deactivated. The entry in factor 2 must be character data; it can include a qualified name such as LIB/PGM. The name preceding the slash is the library that contains the program to be freed from the activated program list. Specify only the program name if you want to search the library list. The RPG/400 language uses the program name exactly as specified in the literal, field, or array element to determine the program to be called. (Lowercase characters are not shifted to uppercase, and a name enclosed in quotation marks (for example 'ABC') always includes the quotation marks as part of the name of the program to be freed.) *LIBL and *CURLIB are not supported (for example, '*LIBL/PROG').

You can specify any valid resulting indicator in positions 56 and 57 to be set on if FREE is not completed successfully. No error occurs if the program to be freed is not active (for example, the program does not exist).

See the CALL (Call a Program) operation for details on how program references are grouped.

Note:
Issuing a FREE operation and then a CALL operation to the same program reopens the program's files and may use additional temporary storage. Repeatedly issuing FREE and CALL operations to a program, without closing the program's files in between, may use enough temporary storage to degrade the system's performance, and ultimately cause an AS/400 machine check. This problem can be avoided if the files have shared open data paths SHARE(*YES). However, using SHARE(*YES) can cause other problems. Read the section on "Sharing an Open Data Path" in the RPG/400* User's Guide for complete details.

Figure "CALL/FREE Operations" shows the FREE operation being used with the CALL operation.

FREE Example

Figure 30. CALL/FREE Operations

*...1....+....2....+....3....+....4....+....5....+....6....+....7...
CL0N01N02N03Factor1+++OpcdeFactor2+++ResultLenDHHiLoEqComments++++++
C*
C*  When the CALL operation is processed, the data in the result
C*  fields of the parameter list can be accessed by PROGA.  The
C*  parameter list ends when the first calculation operation other
C*  than a PARM operation is encountered.
C                     CALL 'PROGA'
C                     PARM          FLDA    30
C                     PARM          FLDB    30
C                     PARM          FLDC    50
C*
C*  When the FREE operation is processed, PROGA is removed from the
C*  list of activated programs.  Removing it from the list ensures
C*  a fresh copy of all fields in PROGA the next time the program is
C*  called.  Indicator 55 is set on if the FREE operation is not
C*  completed successfully.
C*
C                     FREE 'PROGA'                55  55 = NO SUCCESS


[ Top of Page | Previous Page | Next Page | Table of Contents ]