Sorting a Report by Comments

Chris Kelleher

Administrator
Staff member
Dear Peg People,

I'm writing a report that will display basic info for a CO (easy part) but
it needs to be sorted by the text in the Comments field (hard part - for me,
at least.) The Comments field will contain special codes for our warehouse
personnel. Is it possible to sort a list by the Text in the Comment field?
Sofar I haven't been able to find a way to do it in the Progress manuals.

TIA,
Nick P.
nicholas@ix.netcom.com
 

Chris Kelleher

Administrator
Staff member
These codes will be stored in the notes.txt field, which are related to the
co by the key field. Your best bet would be a temp-table that you could
sort.

Carol Choate
Consultant
Progress DBA/Programmer
Peg Member #1998062202
 

Chris Kelleher

Administrator
Staff member
You can have a progress report sort by any field in a database by using the
BY keyword. For example:

For each co by co.any-field-you-want:

Note that if the field you select is not indexed, the report can be
PAINFULLY slow to run.

I am not sure what you mean by "comments" field. If you mean to co-text,
that would not be a good way to go. The CO text (and Item text, and all
the other text) is held in a separate table (notes) and link to the order
via a text key (co.key). To sort on this, you would need to scan through
the notes file for a hit, then scan through the CO file for a matching key
index. I would recommend using the user defined fields to hold your
special code. If you can, use charfld1, as it is indexed and will greatly
speed your report.


Good Luck!
 

Chris Kelleher

Administrator
Staff member
BREAK BY is used to do work on intermediate values within a FOR EACH loop.
for example:

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>
/*Print salesperson totals with sub-totals by sales manager*/

For each slsman BREAK BY slsman.slsmangr by slsman.salesman:

Display slsman.slsman
slsman.sales-ytd (TOTAL BY slsmangr).

End.

[/code]

If you simply wanted a list sorted by salesperson, the BY
slsman.slsman would be sufficient.
 

Chris Kelleher

Administrator
Staff member
Well, close. Break by creates a break group, creating
groups within the sort order, so you can use functions
such as first-of, first, last-of, and last, as well
as any sub-totals,etc.

<BLOCKQUOTE><font size="1" face="Arial, Verdana">code:</font><HR><pre>

for each co no-lock
break by co.slsman:

if first-of (co.slsman) then
do:
find slsman of co no-lock.
display
co.slsman
slsman.slsmangr.
end.
find custaddr of co no-lock no-error.
display
co.cust-num
co.cust-seq
custaddr.name when available custaddr
co.price with stream-io width 132.
accumulate
co.price (total by co.slsman).
if last-of(co.slsman) then
do:
underline co.price.
down 1.
display
accum total by co.slsman co.price @ co.price.
down 1.
end.

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