195 pts.
 coding with load array
i5, RPG
Hi, Thsi si stiffen.Im a RPG developer I5.Im doing some coding practicing for giving training my students. Can anybody tell me how to read a record from the file with load an array of size with error condition

Software/Hardware used:
ASKED: July 29, 2008  1:02 PM
UPDATED: July 30, 2008  1:55 PM

Answer Wiki:
Hi, Can you make it a little clearer what you want to do? Regards, Martin Gilbert.
Last Wiki Answer Submitted:  July 29, 2008  1:04 pm  by  Gilly400   23,625 pts.
All Answer Wiki Contributors:  Gilly400   23,625 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _


 

The question itself is not so clear but let’s give some tips about the subject.

If you want to read records from a file and handle error condition, the extensor (e) is the best choice. Also, and Indicator number in the LO column (middle one) allow us to do the same. With the extensor code we can use the Built-in function %Error. For example:

Read(e) File1
If %Error
Leave
Endif

For loading an array from a file data you have to code yourself as there is not an automatic procedure nor instruction to do it. There is a prerun-time array wich is based on a program described file.

You have to keep in mind that Arrays have limits of entries, 32767 records is around the max capacity. If you’re loading an array from a file you must avoid the out of subscript error by overflowing the limit.

 150 pts.

 

With some creative data structure array definitions, you could have an array loaded automatically as a record is read from a file. You could create an external data structure based on the physical file definition, and define that structure into an array.

For a start, here are two good articles about the modern capabilities of data structures in RPG IV.
http://search400.techtarget.com/tip/0,289483,sid3_gci1208954,00.html
http://search400.techtarget.com/tip/1,289483,sid3_gci902821,00.html

Also, Version 6.1 of IBM i (formerly known as OS/400 / i5/OS) has removed the array element limit.

 4,275 pts.