Arrays in PeopleSoft

Your rating: None Average: 3.4 (5 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 4 weeks 12 hours ago. Offline
Joined: 08/02/2010
Posts: 78
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.

Post new comment

The content of this field is kept private and will not be shown publicly.
CAPTCHA
The question below is to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image.