Arrays in PeopleSoft

Your rating: None Average: 3.9 (16 votes)

Few examples to help clarify how PeopleSoft arrays work.

Local Array of Number &MYARRAY;
&MYARRAY = CreateArray(100, 200, 300); Result is [100] [200] [300]

You can assign values to the elements of the array:

Local Array of Number &MYARRAY;
&MYARRAY = CreateArrayRept(0,3); Result is [0] [0] [0]
&MYARRAY[1] = 100; Result is [100] [0] [0]
&MYARRAY[1] = 200; Result is [100] [200] [0]
&MYARRAY[1] = 300; Result is [100] [200] [300]

Use the Push method to add items to the end of the array:

Local Array of Number &MYARRAY;
&MYARRAY = CreateArray();
&MYARRAY.Push(100); Result is [100]
&MYARRAY.Push(200); Result is [100] [200]
&MYARRAY.Push(300); Result is [100] [200] [300]

Use the Unshit method to add items to the beginning of the array:

Local Array of Number &MYARRAY;
&MYARRAY = CreateArray();
&MYARRAY.Unshift(300); Result is [300]
&MYARRAY.Unshift(200); Result is [200] [300]
&MYARRAY.Unshift(100); Result is [100] [200] [300]

Please try to help out with unanswered topics on the forum. Chances are you have had the same issue/question some time in your IT career!

Comments

Have a question? Please ask it on the forum instead.
Guest's picture
Guest (not verified)
Re: Arrays in PeopleSoft

I was wondering, what was the best way to clear out an array in peoplecode during saveprechange processing so that elements can be re-evaluated each time. For example, when the value is deleted from a scroll level I want the array to be cleared and re-populated with only those values that are remaining. Thanks in advance for any help you might have.

Hari_aindian's picture
User offline. Last seen 3 years 21 weeks ago. Offline
Joined: 08/02/2010
Posts: 84
Re: Arrays in PeopleSoft

Try reinitializing the array like
If scroll row got deleted then reinitialize the array and then populate the values.

Let me know if this works for you.

Guest's picture
Guest (not verified)
Re: Arrays in PeopleSoft

How to reinitializing the array in peoplecode.

Guest's picture
Guest
Re: Arrays in PeopleSoft

Shouldn't your first example be:
&MYARRAY[1] = 100;
&MYARRAY[2] = 200;
&MYARRAY[3] = 300;

Guest's picture
Guest
Re: Arrays in PeopleSoft

LOL... "unshit".... instead of "unshift" in the line above the examples...

Guest's picture
Guest
Re: Arrays in PeopleSoft

Local Array of Number &MYARRAY;
&MYARRAY = CreateArray();

This example generates the followign error:
"Assignment left hand side of type Array of Number is not compatible with right hand side of type Array of Any. (2,47) ^ FMP"

Guest's picture
Guest
Re: Arrays in PeopleSoft

this is because &MYARRAY is of type Number
and you are instantiating it with No type

Post new comment

CAPTCHA
The question below is to prevent automated spam submissions.
8 + 7 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.