Dynamic Sort Sequence

Chris Kelleher

Administrator
Staff member
Yo PEGmeisters,

Is there a way to dynamically change sort sequence in a for each stmt?
Such as:

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
case caps(input frame f-in t-sort-seq):
when "D" then T_BY_PHRASE = "by vendor.pay-lst-yr descending".
when "B" then T_BY_PHRASE = "by vendor.vend-num".
otherwise T_BY_PHRASE = "by vendaddr.name".
end. /* case */

for each vendor no-lock where
{lib/rangcond.i &file=symix.vendor &field=vend-num &type=ch
&low=""~~001""},
symvend.vendaddr of vendor no-lock
{&T_BY_PHRASE}
on endkey undo, leave:
[/code]

The above code snippet will compile but does not work, it sorts by vend-num
(primary index) no matter what the value of T_BY_PHRASE is.

Can this be done in progress?

cheers
Chas. E. Lehnert
CPFP IS Mgr
616 847 1890 (v)
616 847 3109 (f)
 

Chris Kelleher

Administrator
Staff member
Yes,

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
define query q-vendor for vendor.

case .... :

when "D" then open query q-vendor .....
when "B" then open query q-vendor ....
end case.

repeat:

get next q-vendor.

end.
[/code]

Patrick T. Gordon
Senior Software Engineer
Software Services
Symix Computer Systems, Inc.
Columbus, OH 43231
Phone: 614/523-7000
Fax: 614/895-1195
 
Top