Greetings and salutations! I’ve run across the strangest thing today that has myself and our other programmer scratching our heads. We’ve created a report that uses a temporary table to view some data that a customer has in several tables for his “jobs”. The usage is really unimportant, I think, but this section of code is!
JLETemp.INIT;
JLETemp."Entry No." := i;
JLETemp."Job No." := "Job No.";
JLETemp."Phase Code" := PhaseCode;
IF Phases.GET(PhaseCode) THEN
JLETemp.Description := Phases.Description
ELSE
JLETemp.Description := 'No Description Available.';
JLETemp."Unit Cost" := "Amt. Posted to G/L";
JLETemp.INSERT;
i := i + 1;
This code is contained within several dataitems that read an assortment of different tables. We’ve bastardized the temporary table to store our data for the “Jobs” and “Phases”. Our problem occurs with the code above… it will not insert a new record past the first record! The first time the code is encountered, the temporary table has been cleared (DELETEALL), and the “i” variable has been set to 1 (the primary key of the table is “Entry No.”). The first pass will insert a new record. The second pass to this code, a new record is not inserted. We know the code is run because we included a MESSAGE temporarily to check. We’re running Financials US v2.00A. Regards! [b]Kristopher Webb Edited by - Kristopher on 2002 Jan 30 21:56:43
Hello Krisopher this is so evident that it escapes your eye: Try JLETemp.INIT; JLETemp.“Entry No.” := i; JLETemp.“Job No.” := “Job No.”; JLETemp.“Phase Code” := PhaseCode; IF Phases.GET(PhaseCode) THEN JLETemp.Description := Phases.Description ELSE BEGIN //!!! JLETemp.Description := ‘No Description Available.’; JLETemp.“Unit Cost” := “Amt. Posted to G/L”; JLETemp.INSERT; END //!!! i := i + 1; Pelle
Hi, I don’t know if this one helps, but try to do the JLETemp.INSERT right after filling the primary key (“Entry No.”), then fill the rest of the fields and add a JLETemp.MODIFY at the end… though it does not explain the reason for this, but debugging the whole process step by step might shed some light on the question… Saludos Nils
Check in your code if you’re using deleteall too much with that variable (or clear on it). A good way for checking this kind of problems without debugging is just using a message (’%1’,JLETemp.COUNT); after the insert routine (the auxiliar you’re using (i) is not the problem, as it will give you an error if trying to insert two records with the same key). Check clears & deleteall over the variable JLETemp Regards, Alfonso Pertierra (Spain)apertierra@teleline.es
Kristopher, Is there a chance i is getting reset to 1 somewhere in another block of code between cycles of this code? I sometimes use the same working variable name in multiple routines with the result that one routine steps on another. Dave Studebaker das@libertyforever.com Liberty Grove Software A Navision Services Partner
David, the i is not the problem: as Kristopher told, “entry No.” is the primary key on the table he’s inserting the fields. As the insert is done without being as condition (is not in the way IF (a.INSERT) then … and is done without the (TRUE) parameter, it should try to insert all records without any other verification, so if an existant record is having the same primary key will give an error instead of just not inserting the record. Another possible reason we don’t know is if there any other filters on the report that could also make the program just running to the first record and then ending the execution of the report… Regards Alfonso Pertierra (Spain)apertierra@teleline.es
Hi Kristopher, Please find out how many times your code is executing JLETemp.INSERT; Put a message(’%1’,JLETemp.count) before and after the insert statement. ( Just in case if you don’t want to go thru Debugger ) With this you will be sure of the no. of records before and after each Insert. Also you will be able to find how many times the Insert statement is getting executed within that particular code. Have you defined the JLETemp Record variable as Temporary? Regards, Satbir
Hey gang. This is getting REALLY interesting now! I’ve followed through with several of your suggestions. Nils, I tried your suggestion to put the INSERT right after setting the primary key field and the MODIFY at the end. I even put in a COMMIT for good measure. No luck. Alfonso, I exported the whole report to a Text format to double check my CLEAR and DELETE and DELETEALL calls. I have only one DELETEALL call in the OnPreDataItem of the first DataItem. I even commented it out to see if that helped. It did not. Dave, I’ve checked “i” through all the DataItems. It only gets assigned a direct value (1) in the same OnPreDataItem trigger I mentioned before. Everywhere else it gets set “i := i + 1;”. Satbir, I did try your suggestion and found something quite interesting! The count would reset back to zero after each insert. That’s when I figured that I wasn’t resetting my SETRANGE on the “PhaseCode” after each pass, and by the time I got to the end DataItem for the display purposes, I still had the filter set. So, I’ve cleared the filters between each DataItem, and I am seeing all the records now on my output. MANY MANY thanks to all who helped! I’m feeling very embarrassed now by my mistake, and I’ll go hang my head in shame after I get the stinking report finished! wink Best regards! Kristopher Webb Kelar Corporation, Canada
There’s no shame here for not knowing, otherwise we might not ask our questions. There’s no shame here for being wrong, otherwise we might not venture our answers. The only shame is in not participating and not being open minded. A wise man named Jim Hollcraft told me that a few months ago, when I felt the same as Kristopher. Dave Studebaker das@libertyforever.com Liberty Grove Software A Navision Services Partner
Originally posted by daves: There’s no shame here for not knowing, otherwise we might not ask our questions. There’s no shame here for being wrong, otherwise we might not venture our answers. The only shame is in not participating and not being open minded.
Thanks Dave. And I know that these things happen to the best of us. I just hate it when I get my weekly dose. grin Kristopher