Quantcast
Channel: NAV/Navision Classic Client — mibuso.com
Viewing all articles
Browse latest Browse all 2239

DISTINCT rows in a table based in conditions

$
0
0
Hello! I'm creating a chart based on data stored in a table with tables 5772 and 5773 as source of these data. I want Picks and Put-Away lines based on his header (per User). So I created a code to do it but it's not efficient and decreases NAV's performance.


// Works only for Put-Away - approximately 341 lines in the table
l_RecWhseActHdr.RESET;
l_RecWhseActHdr.SETRANGE(Type,l_RecWhseActHdr.Type::"Put-away");
l_RecWhseActHdr.SETFILTER("Assigned User ID",'<>%1','');
IF l_RecWhseActHdr.FINDSET THEN BEGIN
REPEAT
l_RecWhseActLines.RESET;
l_RecWhseActLines.SETRANGE("Activity Type",l_RecWhseActHdr.Type);
l_RecWhseActLines.SETRANGE("No.",l_RecWhseActHdr."No.");
IF l_RecWhseActLines.FINDSET THEN BEGIN
l_RecData.INIT;
REPEAT
l_RecData.Date := WORKDATE;
l_RecData.Time := TIME;
l_RecData.PutAwayCount += 1;
UNTIL l_RecWhseActLines.NEXT = 0;
END;
l_RecData.User := l_RecWhseActHdr."Assigned User ID";
l_RecData.INSERT(TRUE);
UNTIL l_RecWhseActHdr.NEXT = 0;
END;

If I do the same code for Picks the estimated number of lines would be 750000...
Here's an exemple of what the table (l_RecData) shows (not the real data):

USER - PutAwayCount
1 4
1 4
1 7
2 10

Here's what I want:

USER - PutAwayCount
1 15
2 10

I want the User to be unique and his fields summed like in SQL.

I tried to do this with a Query and worked for Picks or Put-Aways, not both. Because I needed two COUNT columns for the chart to show by user.

Viewing all articles
Browse latest Browse all 2239

Trending Articles