How to sort Alternate Array?

185 pts.
Tags:
Array
AS/400 Load Testing
Load testing
RPGLE
Arr1       s        10 A Dim(4)   Perrcd(2)  Fromfile(abc)

Arr2       s         2  0  Dim(4) Alt(arr1)

Now , I have load records From file to that array then i want to show these record in reverse Order How i can do this?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Arr1 can be sorted ascending or descending with the SORTA op-code, but the alternate array Arr2 shouldn’t change. From the ILE RPG Language Reference, <a href=”http://publib.boulder.ibm.com/infocenter/iseries/v5r4/index.jsp?topic=%2Fbooks_web%2Fc0925086749.htm”>SORTA (Sort an Array)</a> page:<ul>
<li>If the array is defined as a compile-time or prerun-time array with data in alternating form, <i>the alternate array is not sorted</i>.</li>
</ul>
I wouldn’t use a run-time array like this if I need to sort it in an order different from how it loaded. Either define the arrays as data structure subfields where the data structure itself is dimensioned and load it yourself from the file, or let your run-time arrays load as they are now and copy them into a data structure array.

After you have them in a data structure array, then you can sort the array using SORTA or any other method you choose.

I suppose you could change from Fromfile(abc) to a different file. Perhaps create a LF that presents the records in descending order.

Almost forgot… If the array is loaded in ascending order and you need to display it descending, just start from the bottom (the highest index) and work through to the top (lowest index).

Tom

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following