4 Replies Latest reply on Sep 18, 2012 7:13 PM by Amit R

# PeopleCode Array Object Structure Question If support such structure

Hi All,

I would like to create a complicated 2-dimension (or 3-dimension ? :-P) Array to be shared for usage during AE program. There prompts error when I tested it. I'm not sure if this kind of Array sturcture is supported or not by PeopleSoft. Please help to give a confirmation or advice on this point.

Here's the Array structure I want:
{("AAA", "BBB", {("CCC", 1, 2), ("DDD", 2, 3), ("EEE", 3, 4)}), ("AAA", "ZZZ", {("CCC", 2, 3), ("DDD", 1, 1)}), ...}

Detail breakdown as following:
{
--- Array Item 1 --> {"*AAA*", "*BBB*", {
--- Array Item 1 --- Element 3 Array Item 1 --> {"*CCC*", *1*, *2*},
--- Array Item 1 --- Element 3 Array Item 2 --> {"*DDD*", *2*, *3*},
--- Array Item 1 --- Element 3 Array Item 3 --> {"*EEE*", *3*, *4*}}},
--- Array Item 2 --> {"*AAA*", "*ZZZ*", {
--- Array Item 2 --- Element 3 Array Item 1 --> {"*CCC*", *2*, *3*},
--- Array Item 2 --- Element 3 Array Item 2 --> {"*DDD*", *1*, *1*}}}

I'm using the following PeopleCode to create the array:

Global Array of Array of Any &Array;
*&Array = CreateArrayRept(CreateArrayAny("", "", CreateArrayRept(CreateArrayAny("", 0, 0), 0)), 0);*

Using the following similar code to populate the array:
*&ArrayTmpL1 = CreateArrayAny("SAMPLE3", 1, 1);* or CreateArrayRept(CreateArrayAny("SAMPLE3", 1, 1), 1); -- Sorry my bad memo, forget if CreateArrayRept is nested or not, I will check it tomorrow.
*&ArrayTmpL0 = CreateArrayAny("SAMPLE1", "SAMPLE2", &ArrayTmpL1);*
*&Array.Push(&ArrayTmpL0);*

When I validate the Array item:
For &i = 1 To &Array.Len
MessageBox for &Array[&i][1] --> Value showed such as SAMPLE1
MessageBox for &Array[&i][2] --> Value showed such as SAMPLE2
MessageBox for &Array[&i][3].Len --> Error the Element 3 is not a valid Array
MessageBox for &Array[&i][3] --> Value is "SAMPLE3", This is NOT what i want.
End-For;

Is there anyone can help to confirm that if the Array object support such structure or not? I will also do some test tomorrow if this can fix, but it would be appreciated if anyone previously encountered such situation.

As of a backup solution, if this is not possible, I've to change the Array to a single 2-dimenstion array like CreateRept(CreateArrayAny("", "", "", 0, 0), 0).

Thanks,

Saxon SI
• ###### 1. Re: PeopleCode Array Object Structure Question If support such structure
Hi,

Although it is very exciting and changing to create 3 dimensional arrays, you should really not go beyond 2 dimensions.
This is to complex to maintain and unreadable.

But to prove your point, here is a peice of code for a 3 dimensional array
``````Local array of array of array of string &aArray;

&aArray = CreateArrayRept(CreateArrayRept(CreateArrayRept("", 0), 0), 0);

&aArray.Push(CreateArray(CreateArray("AAA", "BBB"), CreateArray(CreateArray("CCC", "1", "*2*"), CreateArray("DDD", "2", "*2*"), CreateArray("EEE", "3", "*2*"))));
&aArray.Push(CreateArray(CreateArray("AAA", "ZZZ"), CreateArray(CreateArray("CCC", "2", "*3*"), CreateArray("DDD", "2", "*2*"))));``````
• ###### 2. Re: PeopleCode Array Object Structure Question If support such structure

Yeah, it's not good use array beyond 2-Dimension. The reason is that, I write almost the program and function, then when test it throw the array element not recognize the correct type. Thus I want to try the minimum efforts to fix the program. If we can have an array item combined with 3 elements, first 2 is string type and the last element is 2-Dimension Array, then it will be good for me to modify the program. Otherwise I have to change all the logic as this occurrs in multiple place. I should had ONLY using the simple array like (string, string, string, number, number) at the first time wrote the program, then I can avoid such issue. Ooops...

In your example, you're using all array object in the very first level:
&array = ((array("", ""), array(array("", 1, 2), ... array("", 2, 3))), ... );

So the following format is not valid in PeopleSoft right?
&array = (("", "", array(array("", 1, 2), ... array("", 2, 3))), ... );

Thanks,

Saxon SI
• ###### 3. Re: PeopleCode Array Object Structure Question If support such structure
An array of any can hold anything. That is why you can make multidimensional arrays. The array doesn't really need to know that it is holding an array of arrays. It is just holding an array of something, and it really doesn't care what that "something" is. Once you start getting deep, though, unless the internals are really random and the item at each index has no special meaning, then you are probably better off creating a object and collection hierarchy/relationship in app classes.
• ###### 4. Re: PeopleCode Array Object Structure Question If support such structure
I would have tried to create some kind of rowset structure, instead of relying on such a complicated array structure.