the way navision filters

Hey, just a question for understanding: i’ve written a little codeunit which copies records from one table to another. The filter is set to two fields, where they’re part of a secondary key i’ve choosen before the filtering is done. Before the copy starts i’ve opened a dialog window which shows me the current value of the filtered fields. One of them is a simple counter. I expected to see the counter counting up and it does so… but not only one time. It looks as if this part of the codeunit is done multiple times. But this can’t be, because i do a “rec.insert” without using the result of the insert. If there would be inserted a record twice the codeunit should crash (what it didn’t). So how does navision (we use native database version DE2.5) do the filter and why does it run through the records more than one time ?!.. thanks in advance STEFAN

Well, maybe you should post some code to this forum. That would be more understandable than the explanations and we could help you on finding the error.

Hey Beaver, okay, here’s the complete code. The way it works (should work… :wink: ): At first i filter on a table with the different carriers (Table ICC). The i filter the table with the Calls (ICAnrufe) for this carrier and copy the found records into table ICAC. Field “Laufnr” ist the primary key of table ICAnrufe. Every new call gets a new “Laufnr” (a simple counter). The records in the table are stored by date and time (of course by Laufnr, but every new call gets a higher Laufnr the the call before). As the date and time are part of the primary key “Carrier OUT” i expected to get the records in the range Carriername, date, time. If the records are selected by this range my message window (variabnle “Fenster”) should show a Laufnr which is counting up, until a new carrier is selected. But it doesn’t. It counts up, and the begins with the lowest number again. But obviously it doesn’t fail, because in the meantime it is selecting the 10th carrier (of eleven). Here’s the code: //******* starting of code ****** __Fenster.OPEN('Laufnummer #1#######\' + _______________'Carrier OUT #2#######'); __ICAnrufe.RESET; __ICAnrufe.SETCURRENTKEY("Carrier OUT"); __ICC.RESET; __ICC.SETRANGE("Kunden Nr", '1000088'); __IF ICC.FIND('-') THEN REPEAT ____WITH ICAnrufe DO BEGIN ______SETRANGE("Carrier OUT", ICC."Carrier ID"); ______SETRANGE("Carrier Zone OUT", ''); ______IF FIND('-') THEN REPEAT ________Fenster.UPDATE(1, Laufnr); ________Fenster.UPDATE(2, "Carrier OUT"); ________ICAC.TRANSFERFIELDS(ICAnrufe); ________ICAC.INSERT; ______UNTIL NEXT = 0; ____END; __UNTIL ICC.NEXT = 0; __Fenster.CLOSE; //***** end of code ***** [i]stefan, use the [ code] … [ /code] tags instead of the ____

Hi Stefan, How many Records of Table ICC belong to Customer 1000088? Is there more than one (You use REPEAT - UNTIL)? If there is more than one, your counter begins with one for every set of records in Table ICAnrufe, doesn’t it? Greetings, Frank

By setting ICAnrufe.RESET; __ICAnrufe.SETCURRENTKEY(“Carrier OUT”); you set the sorting to “Carrier OUT” (plus subsequent fields in this key, plus LaufNr (primary key at the end. so now your recs are sorted by Carrier OUT. then you loop through the table. For Carrier A there might be the LaufNr 1,47,59,101 and for Carrier B 2,59,87 105. then your window would show “1,47,59,101,2,59,87,105” because first Carrier A is looped through and then Carrier B.

@Frank: in ICC are about 20 Carrier. 11 of them belong to Customer 1000088. Of course it has to begin with 1 if as new carrier is selcted. In my case it begins with one WITHIN the selected carrier. So if the windows shows Carrier X field Laufnr is counting up and when it reaches the end it begins again with Laufnr 1. That’s what it makes me wonder. @Beaver: “Laufnr” is an id. Calls are put into table ICAnrufe by date and time, so if a new call in added it has a newer date and time and a higher Laufnr… but you gave me the correct direction… sometimes eyes are closed by tomatoes ! In the secondary key there is one more field between field “Carrier OUT” and “date”. So it is sorted by this field too and hence it counts up more than one time (so much times as there are different entries in this “forgotten” field)… Sorry that i wasted your time because i didn’t watch the keys enough… :frowning: STEFAN