Arrays concepts

Arrays

1. What do you mean by Tables?
List of data stored in main memory is called tables. We can refer tables with 'TAB' as starting letters. [Suppose, Product Master table is TABPROD and City Names is TABCITY]

2. What are the types of tables?
Compile time and Pre-run time tables.

3.  What is a compile-time table?
A table whose information is hard coded in the program source.

4.  What is a pre-execution table?
A table whose data comes from an external file.

5. What is the max. no. element in an array?
           9999

6. How can you define Multiple Dimension Array in RPG?
            We cannot define a Multiple Dimension Array in RPG.

7. Is it possible to insert a record in a table, while the table in open in 'P' mode?
Yes. It is possible to insert a record by using 'O' spec.

8.  How is data accessed from a table?
By LOKUP operation.

9. Can we use tables in RPG4/ILERPG?
No. Tables are available in RPG3 only.

10. What are the keywords needed in Pre-run time table?
DIM, FROMTABLE and PF name.
The PF should be opened in 'T' mode.

11. What do you mean by array and mention its types of arrays?
Set of similar attribute elements is known as array. There are three types of array are referring here.
Compile time, Run time and Pre-run time array.

12. Explain Multi Dimensional Array.
We are achieving multi dimensional array by using OCCUR clause. It is similar elements of same data types and attribute size are repeating many times can be performed by OCCUR clause.

13. Explain. Compile time array and Run time array.

Compile time array
Run time array
Values are stored during the compile time. So the values are constant.
Values are stored during the run time. So the values are dynamic.
Three keywords DIM, CTDATA, PERRCD are used to declare
Only DIM keyword enough.

14. What are the keywords used in array declarations?
Compile time array      - DIM, CTDATA, and PERRCD
Run time array                        - DIM
Pre-run time array       - DIM, FROMFILE and PF should be opened in T mode

15. What are the array related keywords?
SORTA           : used to Sort the array in ascending
LOOKUP       : used to find an element in the array we can specify indicator and it    will                                      set on if the element is found.
XFOOT          : used to sum the elements of a numeric array
MOVEA         : used to move set of elements of another array into your array.

16. How can you copy element of one array into another in one statement?
          ADD opcode will add all elements of one array into another.

17. Is it possible to write an array element into a PF?
Yes. It is possible to write the pre-run time array elements to a pf. For that the mode of pf opening is 'C' [Combined] and the DIM, FROMFILE and TOFILE keywords have to be used.
           If no executable statements after 'C' spec, we can declare the elements after 'C' spec.   
          Otherwise, we can declare the elements after 'O' spec.

18. What is the diff between tables and array?
                       Table                                                  Array
1. Indexing is impossible                  Indexing method is possible
2. Cross-reference is impossible       Cross-reference is possible

19. How many arrays can be declared in RPG?
            200

No comments