Data Structure Arrays

485 pts.
Tags:
RPGLE Program
I have a "page at a time" subfile and in order to store multiple pages of options I have created arrays to store the options and the PF record RRN and Key Fields. This process Stores and reloads the options seamlessly.

It all works beautifully except that the options are executed in the order they were entered rather than in Key Field order (eg. If I enter an option on the second page and then an option on the 1st page it will execute the 2nd page option first). So, I wondered about loading the options and Key Fields into a Data Structure Array and then using SORTA against the DS to put it into the desired order. Is this feasible? Any examples would be gratefully received. I've looked in the manuals and online and can't find anything that helps me in this.

Many thanks.

RPGLE /free used.



Software/Hardware used:
V5R4M0

Answer Wiki

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

Discuss This Question: 6  Replies

 
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
  • philpl1jb
    Yes you can sort a data structure array Check out this link. http://www.itjungle.com/fhg/fhg092910-story01.html Phil
    50,425 pointsBadges:
    report
  • NeilD
    Phil, That's brilliant - thanks for the link. I wrongly assumed it was a much more complicated change from separate arrays to a DS Array. I am able to sorta on the DS and get the results I need. Neil.
    485 pointsBadges:
    report
  • NeilD
    In case anyone else is interested in how to utilize DS Arrays (or at least how I did): Below ar the old array definitions.... d a#key1 s dim(32000) like(key1) d a#key2 s dim(32000) like(key2) d a#key3 s dim(32000) like(key3) d a#opts s dim(32000) like(opt) d a#frrn s dim(32000) like(frrn) Replaced by DS Array as defined below.... d ds d Record 20 dim(32000) d a#key1 overlay(Record:*next) like(key1) d a#key2 overlay(Record:*next) like(key2) d a#key3 overlay(Record:*next) like(key3) d a#opts overlay(Record:*next) like(opt) d a#frrn overlay(Record:*next) like(frrn) d inz(0) Then : sorta Record; which put the DS into the required order. All other array loads, lookups etc remained the same. Neil.
    485 pointsBadges:
    report
  • Splat
    I've often used a subfile (never displayed) as a holding area, combined with a keyed data queue to achieve a similar outcome.
    7,425 pointsBadges:
    report
  • TomLiotta
    That's essentially what is described in Figure 355 'SORTA Operation with OVERLAY' under the SORTA (Sort an Array) op-code in the ILE RPG Reference manual. Of course, manual examples tend to be a little less illuminating. Also, the example in the manual intended to show sorting by one of the OVERLAY items rather than the entire 'Record'. But note how %SUBARR() is shown in the syntax diagram at the top. The SORTA could explicitly show the subfields that are needed for sorting. In i 7.1, this type of sort becomes better. But this is as good as it gets for V5R4 with native language sorting. Tom
    125,585 pointsBadges:
    report
  • philpl1jb
    Brilliant yes, Phil, No Susan Gantner, Brilliant, Yes
    50,425 pointsBadges:
    report

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