Subfile sort

475 pts.
Tags:
SQL
Subfile
I have a subfile program for updating, creating, and displaying item information the user can select from to create, view or update detail. The subfile shows item number, description, etc from my main file (i'll call itemnum1)and a vendor item number from an auxiliary file (itemnum2). My question is the users want to be able to hit a function key and have the subfile change from item number sort, to item description sort, or vendor item sort. the subfile currently is read from itemnum1 keyed on item number. Is there a way to sort the subfile without having to have multiple logicals?

Answer Wiki

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

If it is a large file, you should use logical files.
If is is a small file, by useing arrays in a data structure you can do a SORTA.
Another option is to use SQL within your program and grab the records using the ORDER BY clause.

Discuss This Question: 5  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
  • filuphaze
    I am using ILE on an iseries.
    475 pointsBadges:
    report
  • filuphaze
    [...] 8. Do you have any suggestions for a member who’s trying to sort subfiles in a subfile program? [...]
    0 pointsBadges:
    report
  • Sloopy
    The first thing is, you can't sort subfiles. You would have to clear the subfile and reload it with data in the new order. The second thing is, since this is live transactions, it's better to reload anywy to be sure of getting the most up-to-date view of the data. If you already have logical files in the right order, then use them. Otherwise you can either create them, or if that's not good practice in your place use embedded SQL as suggested by CharlieBrown. Using arrays is possible, you can have the same number of elements as the subfile maximum - 9,999 - but then the data is not current.
    2,195 pointsBadges:
    report
  • Splat
    One method would be to use a keyed data queue to sort the data. Load the subfile records to the data queue, clear the subfile, then reload the subfile from the data queue. I agree with CharlieBrown though, you'd be better served using logical files to load the subfile.
    7,455 pointsBadges:
    report
  • brettharris
    Using embedded SQL in your RPGLE is a very quick and easy way to 'sort' the subfile on demand without having to creating multiple logical files. I'm finding that embedded SQL does a lot of things well.
    40 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