× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



That could work, today, if you have V5.3 or later and use the %SUBARR() built-in
function.

Otherwise you end up with the same crap you would normally (i.e.,
blanks/zeros/empty records at the beginning of the array).
A data structure array is an array but I'm losing my memory here--I don't recall
if SORTA works on the DS. But that wouldn't matter.

If you did something like this:

     D myDS            DS                  Inz
     D arr                                 Dim(30)
     D  item                          5A   Overlay(arr)
     D  qty                           3S 0 Overlay(arr:*NEXT)
      /free
           SortA  %subarr(item:1:nlines); // Sort by item number
           SortA  %subarr(qty:1:nlines);  // Sort by quantity
      /end-free

In this example, the ARR subfield of the data structure is the array. It would
have the same number of elements in it as the Subfile's SFLSIZE keyword. 
The number of active lines in the subfile would be retained in the nLines field.
If the DS also had the BASED() keyword, you could map it to a user space with
auto-extend and have a dynamic array.

Then, sort A could be used on any of the field in the subfile, then after
sorting, you would clear/reload the subfile.

I haven't tried this, but you may also be able to do it like this:

     D myDS            DS                  Inz Qualified
     D arr                                 Dim(30)
     D  mySFL                              LikeRec(sflDtl) Overlay(arr)

To sort the subfile by field name, you should be able to do the following (again
I haven't tested this):

       Sorta   %Subarr(myds.mySFL.orddte:1:nLines);

Note that the DS is now qualified and the subfield MYSFL is based on the format
of the subfile record. Asusming the overlay(arr) thing still works, you should
be able to sort by any field in the subfile.

-Bob Cozzi
www.i5PodCast.com
Ask your manager to watch i5 TV



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of Booth Martin
Sent: Thursday, February 08, 2007 10:57 AM
To: RPG programming on the AS400 / iSeries
Subject: Re: Sort Subfile

I am curious:  why not load the subfile into an array and then do SORTA 
and reload the subfile?

Bob Cozzi wrote:
Not the subfile space.
Subfiles are such old code that nobody at IBM wants to touch it; and they
certainly don't want us playing with it either.

The way I do that is to load the subfile into a data structure array that is
based on a users pace. The user space with auto-extend allows the array to
grow
as needed (up to 16MB).

Then you can use QSORT to sort the elements of the Data Structure array.
I've written a number of articles on this topic over the years in my free
newsletter.
http://www.mcpressonline.com/mc/.2e3b409f


-Bob Cozzi
www.RPGWorld.com
May 21 to 23, 2007 - Las Vegas.



-----Original Message-----
From: rpg400-l-bounces@xxxxxxxxxxxx [mailto:rpg400-l-bounces@xxxxxxxxxxxx] On
Behalf Of Jeff Young
Sent: Thursday, February 08, 2007 10:32 AM
To: rpg400-l@xxxxxxxxxxxx
Subject: Sort Subfile

What is the best method for sorting a subfile in ILE RPG.
Can I use QSORT and somehow point to the subfile space?

Thanks,
 
Jeff Young 
Sr. Programmer Analyst
Dynax Solutions, Inc.
A wholly owned subsidiary of enherent Corp.
IBM -e(logo) server Certified Systems Exper - iSeries Technical Solutions V5R2

IBM  Certified Specialist- e(logo) server i5Series Technical Solutions
Designer
V5R3
IBM  Certified Specialist- e(logo)server i5Series Technical Solutions
Implementer V5R3


 

________________________________________________________________________________
____
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121


As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.