Dear All,
Let say we have the Gen. Journal line table with Document No. as current key and I would like to read the first record of every document No. What should I do?
For ex. let say we have three records 111 and two records 222. The current key is document No. I would like to read the first document 111 and after that the first document of 222. Can this be done?
0
Comments
while you are looping you check
if (perviousDocNo <> '') and (perviousDocNo <> "Document No.") then begin
perviousDocNo := "Document No.";
end;
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
I don't think there is something cleaner (I'm guessing you mean something simpler)
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
For Native you could optimize it like this: But never do this on SQL :-)
Peter
1. Would there be any side-effect if you use just one xx instead of xx & xx2 then apply 2. Would applying SETRANGE multiple times slow the iteration down a little? At least slower than looping through the filtered records once like what ara2n suggested?
Scott
Scott
You still haven't mentioned if you were coding for Native, SQL or Both.
But I guess you are using SQL, but please confirm.
For SQL you should go for the suggestion by ara2n. Otherwise the SQL server has to make a new execution plan for each Next, which would kill the performance.
Peter
We actually use Native DB.
I don't quite understand your suggestion about using two variables. Please try modifying my code and show it.
Peter
<insert your code here> :?: :?:
what is exactly my code ?
example i have 4 records EEEE 5 records FFFF and 3 records GGGG the result in the form must be 1 eeee 1 ffff and 1 GGGG ?
But since you need to read a table and "group" it by one or more fields I would guess you would like to do something with each of these "groups". So whatever you would like to do with the "group" should be put in this section.
But I have to repeat: Do never do like this on a SQL server...
Peter
IF FIND('-') THEN REPEAT //i'm using temp table
Sorttemp.INIT;
Sorttemp.COPY(Rec);
Sorttemp.INSERT;
UNTIL NEXT=0;
Sorttemp.SETFILTER(Code, :?: :?: :?: :?: ); //what i need to put there to filter one of a kind
RIS Plus, LLC
Peter
check this please :roll:
Then you will have to store the records in a Temp table, and then show the temp table on the form. If you are using NAV5 or later you can use the SourceTableTemporary property. For older versions you could override the OnFind and OnNext triggers like form 344.
My suggestion would be something like this: But never do this on SQL :-)
Peter
RIS Plus, LLC
Writing code is not always the solution to a problem. Many times I fix problems simply by removing code.
In most cases where you need to find a complex code solution to a problem, maybe you need to take a step back and redesign the logic of what you are doing.
most likely you are just doing this all wrong. Maybe you need a Header table and consider your existing table as a lines table.
Either way, I don't think that this is a programming problem.
Peter
can you help me do this without temp table
Did you read my reply, or just chose to ignore it?
Kine solutions seams to work?