Subfile sort

475 pts.
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.
  • filuphaze
    I am using ILE on an iseries.
    475 pointsBadges:
  • The Most-Watched IT Questions: March 8, 2011 - ITKE Community Blog
    [...] 8. Do you have any suggestions for a member who’s trying to sort subfiles in a subfile program? [...]
    0 pointsBadges:
  • 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:
  • 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.
    11,175 pointsBadges:
  • 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:

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.

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


Share this item with your network: