Group by Duplicates

Phillip

Member
I need to runoff values and group by duplicates to create an htm document. For example, a typical runoff would look like this:

Order Number: 5610
Tracking Number: 654654654

Order Number: 5610
Tracking Number: 987987987

Order Number: 5612
Tracking Number: 321321321

(Obviously in spreadsheet form) What I want to do is group them by order number so that I can get a runoff like this (comma would be next column):

Order Number: 5610
Tracking Number: 654654654, 987987987

Order Number: 5612
Tracking Number: 321321321

How can I get this? Right now my "for each" statement looks like this:

for each tracknum where tracknum.ord-num begins "w" and tracknum.s-date = TODAY:

this sorts it out by tracking numbers that are web orders and shipped out today. Thanks in advance
 
Code:
def var lv-TrackNum as character no-undo. 
for each tracknum 
  where tracknum.ord-num begins "w" 
  and tracknum.s-date = TODAY
  break by tracknum.ord-num:
  if first-of(tracknum.ord-num) then 
    lv-TrackNum = tracknum.tracknum. 
  else 
    lv-TrackNum = lv-TrackNum + ", " + tracknum.tracknum. 
end.

Not syntax checked, but it'll give you the right idea.
 
Code:
def var lv-TrackNum as character no-undo.
for each tracknum
  where tracknum.ord-num begins "w"
  and tracknum.s-date = TODAY
  break by tracknum.ord-num:
  if first-of(tracknum.ord-num) then
    lv-TrackNum = tracknum.tracknum.
  else
    lv-TrackNum = lv-TrackNum + ", " + tracknum.tracknum.
end.

Not syntax checked, but it'll give you the right idea.

forgot to mention but this will work in progress 9.1 right? throwing me an error on the if first of line
 
Code:
def var lv-TrackNum as character no-undo.
for each tracknum
  where tracknum.ord-num begins "w"
  and tracknum.s-date = TODAY
  break by tracknum.ord-num:
  if first-of(tracknum.ord-num) then
    lv-TrackNum = tracknum.tracknum.
  else
    lv-TrackNum = lv-TrackNum + ", " + tracknum.tracknum.
end.

Not syntax checked, but it'll give you the right idea.
nevermind on the error. discrepancy with table references. thank you for the help
 
Code:
def var lv-TrackNum as character no-undo.
for each tracknum
  where tracknum.ord-num begins "w"
  and tracknum.s-date = TODAY
  break by tracknum.ord-num:
  if first-of(tracknum.ord-num) then
    lv-TrackNum = tracknum.tracknum.
  else
    lv-TrackNum = lv-TrackNum + ", " + tracknum.tracknum.
end.

Not syntax checked, but it'll give you the right idea.

I ran an export with it and what it does is it runs off the order number with the first tracknum then it runs off another line with the order number again and two tracknums seperated by the comma and so on. I need just the final value where, if there are 5 tracknums associated with the order, it will have 5 comma seperated tracknums.
 
Back
Top