Assign a Row Number

Manturo

New Member
Greetings - I would like to assign a row number to a query result list based on the descending order of inventory value. Here is my code:

[FONT=r_ansi][FONT=r_ansi]for each icsw no-lock where (cono = 1)
BY qtyonhand * avgcost DESCENDING:
if qtyonhand * avgcost >= 1500 then do:
disp whse prod countfl qtyonhand qtyonhand * avgcost label 'item value'
with width 420.
end.
end.

What is the best function for this? My Progress Language Reference is not clear on this.

Thanks for your help!
:confused:
[/FONT]
[/FONT]
 
I don't think there is a built-in way to do this. Can't you just define a variable, then increment and display it each time thru the loop?
 
Thanks. That worked. I'm new to Progress so concepts are "sticking" as I'm coming from the rudiments of T-SQL.
 
Re: Assign a Row Number - One more refinement

I modified my code as follows:
[FONT=r_ansi][FONT=r_ansi]def var cnt as int.
for each icsw exclusive-lock where (cono = 1 and whse = '')
BY (qtyonhand * avgcost) DESCENDING:
cnt = cnt + 1.
assign countfl = no.
if qtyonhand * avgcost >= 1500 then do:
assign binloc1 = string(cnt).
disp whse prod cnt binloc1 countfl qtyonhand qtyonhand * avgcost label
'item value'
with width 420.
end.
end.
However, how would I assign the row numbers by whse? Meaning that I would want the cnt var to be restarted per whse. I run this program manually per whse to get what I want but is there a way to do it in one shot? I am clueless. And thanks for your help.
[/FONT]
[/FONT]
 
Look up break by and first-of and related functions. That should allow you to break up the output by warehouse, put in warehouse headers, add a warehouse total, number within warehouse, etc., etc.
 
Back
Top