Array and Types of Array in RPG AS400

Array and Types of Array in RPG AS400
Array and Types of Array in RPG AS400,array,types of array,compile time array,pre-runtime array,runtime array,DIM() keyword,CTDATA() keyword,PERRCD() keyword,array related op-code,look-up,sorta,xfoot,introduction,about,what is,create,make
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.

  • Run-Time Array
  • Compile-Time Array
  • PreRun-Time Array
  • Run-Time Array

    It is loaded by the RPG program when it's in a RUNNING state.

    Run-Time Array in RPG AS400

    Compile-Time Array

    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

    PreRun-Time Array

    It is loaded from the Array file when the program starts executing.

    PreRun-Time Array in RPG AS400

    Related Post

    Post a Comment

    © AS400 and SQL Tricks. All rights reserved. Developed by Jago Desain