× 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.



I'm not clear on exactly what you are trying to do but when i need to
sort an array that containsother elements, I create an array element
that contains the key field and the element pointer.

D sortfld ds
D keyfld 1 3
D ArrElem 4 6s 0

D KeyArray s 6 dim(20)
D array1 s 3 dim(20)
D array2 s 3 dim(20)

Load array
C add 1 x
C eval array1(x) = field1
C eval array2(x) = field2
C eval keyfld = field3
C eval ArrElem = x
C eval KeyArray2(x) = sortfld

Sort array
C sorta KeyArray

Process array
C do x y
C eval sortfld = KeyArray(y)
C eval field1 = array1(ArrElem)
C eval field2 = array2(ArrElem)
C eval field3 = Keyfld



On Tue, Mar 15, 2011 at 11:38 AM, Willie J. Moore <WJMoore@xxxxxxxxxxxx> wrote:
I have an array with multiple fields. I need to sort the array on one field (alot1).
Here is my array definition, load and print code.
I have tried using the SORTA on 'a lot', but get a Decimal data error.

D prtfields       DS
D allfields               1    320    DIM(10)
D  acoat1                        3a   overlay(allfields:*next)
D  awgt                          9s 3 overlay(allfields:*next)
D  alot1                         5s 0 overlay(allfields:*next)
D  alot2                         5s 0 overlay(allfields:*next)
D  abarcod                      10s 0 overlay(allfields:*next)

C* Build array.
C*
C                   add       1             x
C                   move      coat1         acoat1(x)
C                   move      wgt            wgt(x)
C                   move      lot1            alot1(x)
C                   move      lot2            alot2(x)
C                   move      barcod       abarcod(x)

C* Print report
C     X           DOUEQ     0
C                   move      abarcod(x)    barcod
C                   move      awgt(x)       wgt
C                   move      acoat1(x)     coat1
C                   move      alot1(x)      lot1
C                   move      alot2(x)      lot2
C                   SUB       1             X
C                   EXCEPT    DETAIL
C                   ENDDO

Any help would be appreciated.

William Moore
California Fine Wire
805-489-5144
wjmoore@xxxxxxxxxxxx

--
This is the RPG programming on the IBM i / System i (RPG400-L) mailing list
To post a message email: RPG400-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/rpg400-l
or email: RPG400-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/rpg400-l.



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.