|Array and Types of Array in RPG AS400|
Introduction to Arrays
The array is a collection of elements of the same data type and length. We generally use the DIM keyword to define an array in the RPG program. We can refer to a specific array element by its position and array name in itself refers to all its elements in an RPG program.
Array name must be unique in the RPG program and array index must be numeric with zero decimal positions.
At run time, if the RPG program tried to use array index ARR(Idx) as zero, negative or greater than the number of elements defined in the DIM keyword then the error occurs at run time.
Types of Arrays
There are three types of arrays.
It is loaded by the RPG program when it's in a RUNNING state.Run-Time Array in RPG AS400
It is loaded when the RPG program gets created. Whatever data present in the compile-time array will not be changed until and unless the data is changed by the RPG programmer and the program object gets recreated.Compile-Time Array in RPG AS400
Using PERRCD keyword in Compile-Time Array in RPG AS400
It is loaded from the Array file when the program starts executing.PreRun-Time Array in RPG AS400
Post a Comment