Question

  Asked: Jun 12 2008   7:15 PM GMT
  Asked by: JAC


How to define two dimensional arrays in RPGILE


AS/400, 2D arrays, RPG ILE, RPGILE, RPG

I need to create an array that contains a code (2,0) and hrs worked (5,2) for that code.

something like

01 2.3 4.3 5.6 7.0 8.0
02 5.0 6.0 7.0 7.0 6.5

I will then take this array and load a subfile to display on a screen.

Thanks,

John

Subscribe to Alerts! Get questions and answers delivered to your Inbox.


E-mail me updates on this question



   SUBSCRIBE

hidden modal window

Answer Wiki (Improve, edit or add to this answer)


 RATE THIS ANSWER
0
Click to Vote:
  •   0
  •  0



I assume you have finite limits for these arrays - that is, for each code entry, there is a fixed (or maximum) number of hours worked entries?

Usually, I would do this as two arrays - the first would be code (say, 50 entries), and the second hours worked.

If there are never more than 10 hours worked entries for any code, then the hours worked array will be 10 * 50 entries.

Entries 1 to 10 will be reserved for the code value in the code array element 1.
Entries 11 to 20 will be reserved for the code value in the code array element 2...

...and so on.

You can see that for any code entry you can use arithmetic to get the start element number for the matching list of elements in the hours worked array.

You can 'hide' the code you write to manipulate the arrays, by using procedures to write to and read from the arrays. Then in the body of your code you can use the procedure calls and pass parameters to identify what you want to write and what you want to read.

This is a very simple, even crude, way of looking at your problem, but for most purposes it will work. If your requirements are more sophisticated, please describe them more fully and I'll come back with some refinements!

Regards,

Sloopy
  • AddThis Social Bookmark Button

Browse more Questions and Answers on AS/400 and Development.

Looking for relevant AS/400 Whitepapers? Visit the Search400.com Research Library.


Discuss This Answer


You must be logged-in to discuss a question. Log-in/Register