Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Data Structure Size Limitation

Status
Not open for further replies.

jsplice

Programmer
Jun 3, 2003
88
US
Hello all. I've run into a problem while trying to create a multi-dimensional array to hold records. I have to use an array because I want to use the SortA opcode to sort the results. From what I understand, RPG does not support actual multi-dimensional arrays. Here is the data structure I set up to hold my data:
Code:
D SflDS           DS
D  A@SflFull                           Dim(1100) Ascend Inz(*Hival)
D   A@Date                       6S 0  Overlay(A@SflFull:*Next)
D   A@PickPlan                   8S 0  Overlay(A@SflFull:*Next)
D   A@Rule                      10A    Overlay(A@SflFull:*Next)
D   A@Orders                     6S 0  Overlay(A@SflFull:*Next)
D   A@Lines                      6S 0  Overlay(A@SflFull:*Next)
D   A@Cases                      6S 0  Overlay(A@SflFull:*Next)
D   A@CuFt                       8S 0  Overlay(A@SflFull:*Next)
D   A@Weight                     8S 0  Overlay(A@SflFull:*Next)

I max out at around 1100 elements because I get the error saying that the data structure is longer than ~65500 characters. Is there another way to create this array, or am I limited to that size? An alternative would be to use a work file...
 
There use to be an rpg op code OCUR,, which appeared to me, to be an instance of setting up an mult-dimensional array, not sure what happending, when it got to RPG IV.
 
I think the trick is to create an array of data structures, with each DS containing an array. Then either use MODS (multi-occur DS) or qualified DS to simulate a multi-dimentional array.
 
You set occurrences in a MODS by using the BIF %OCCUR - it;s the free-form version of OCUR.

Feles mala! Cur cista non uteris? Stramentum novum in ea posui!

 
In RPG IV, arrays have a limit of 32767 elements.
Data structures have a limit of 65535 bytes.
Multi-occurance Data Structures have a limit of
32767 occurances.

Below is sample code using an array nested in a
multi-occurance data structure.

D DS1 DS Occurs(175)
D Array 7S 0 Dim(9000)
D inCounter S 5S 0
D outCounter S 5S 0
D SequenceNumber S 7S 0

/FREE
FOR outCounter = 1 TO 175;
%Occur(DS1) = outCounter;
FOR inCounter = 1 TO 9000;
SequenceNumber += 1;
Array(inCounter) = SequenceNumber;
ENDFOR;
ENDFOR;

%Occur(DS1) = 175;
DSPLY Array(9000); // 1,575,000
*INLR = *ON;
RETURN;
/END-FREE
 
jsplice,

As far as I understand you want to load a run-time array larger than 64Kb in storage.
1/ in the example I don't see how this array can be a multidimensional array ? A multidimensional array is an array with multi dim() statements, i.e. an array within another array. The following example illustrates this.
Code:
D Year            DS               [b]Dim(20)[/b] Qualified
D  Month                           LikeDS(Mdata) [b]Dim(12)[/b]
C                 Eval      Year(Yr).Month(Mth).Revenue = MonthTotal
2/ if the array is > 64 Kb, create a user space, load the records into the user space defining an array or a MODS over it and sort the data using the Qsort() API. With such a method, you can define an array or MODS of up to 64MegaBytes seamlessly.

Pls let us know.
 
Thanks for the help everyone. Mercury2, I see what you are saying...what I described isn't technically a multi-dimensional array; for that matter, neither is a multi-dimensioned data structure. The only true multi-dimensional arrays I've used have been in C++ and Java. I guess what I was really representing was a table of some sort. It was simply a data structure/array to hold records for a subfile.

I may try to use the OCCURS keyword on the data structure like vbMax has suggested. As of now, 1100 elements is sufficient; I'm not sure if that will be the case in the future however.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top