Using Temporary tables in Reports

I need to prnt a report that is a little complex. Th eonly way that I can think of doing it is to insert ecords in a temporary table and then run the report by passing the record of the temp table to the report. I have created a process-only report(Report 1) in which I accept the filter from user and then write into a temp table(global of type record and temporary flag set to ‘Yes’) the records that I process and then in the OnPostDataItem trigger of the report I run modally another report(Report 2) to which I pass the temporary table record as a parameter. The Dataitem of Report 2 and the global for temp table record are ponting to the same table in the data base. But I get the following error when procesing is completed in Reoprt 1 and Report is called. Report 2 does not have a Dataitem that uses the table (Table 50019 Job BOM Cutting List) specified in the function SetTableView. Table 50019 is the source table for the data item in both report 1 and Report 2. Can someone gve an idea why this happens? Thanks. Pari.

Well the first problem you will have once the error is resolved is that the temporary table you built can not really be passed. When a report is called, all you are really passing is a copy of the filters applied to that table variable not an actual record. I would suggest that you modify report 1 to not only accumulate the information in the temporary table but, also produce the output. If you get a count of the records in the temporary table you could add a dataitem to the report from the Integer table. Set the range from 1 to the number of records in the temporary table. After that, it should be simple to add the fields to the integer body section referencing them like: Temptable.Fieldname. You’ll also have to add a little code to the integer OnAfterGetRecord table to parse the temporary table…In fact if you want you could actually create an arrary of records in which case you would reference them like TempTable[1].FieldName. Bill Benefiel Manager of Information Systems Overhead Door Company (317) 842-7444 ext 117 Edited by - wbenefiel on 2001 Oct 30 14:40:59

Hi A temporary table can be passed from one report to another. If you create a function in report 1 with the the temptableVar as a parameter and check the Var option. From Report 2 you call Report1.Function(temptableVar).

You can also pass temp tables using REPORT.RUN(1234,TempTable); Then your report is run on the tempory table. Paul Baxter

Hi I also need to call a report with a Temp-table as argument, but my experience is that Paul Baxters suggestion,Temptabel) doesn’t work? I’m running Attain 3.01b. My setup is: I have created a temporary version of T39 with som new lines that I don’t want created in the real version of T39. Now I wan’t to call a report with T39_Temp as argument - and,Temp_T39) doesn’t work - any suggestions?

Hi Jensthomsen On the form containing the temp table you will need to define the report you want to run as a Variable. eg. Rep1234 Report “Report 1234” Then use code something like this to run the report CLEAR(Rep1234); Rep1234.SetTempt39(Temp_t39); Rep1234.RUNMODAL; On the Report you will have created a Function ‘SetTempt39’ passing Temp-t39 through as a Parameter. and created another Variable for Table 39 eg Temp-t39-2 Record “Purchase Line” Temporary SetTempt39(VAR Temp-t39 : Record "purchase Line") IF Tmp-t39.FIND('-') THEN REPEAT Temp-t39-2 := Temp-t39; Temp-t39-2.Insert; UNTIL Temp-t39.Next = 0; Then Design the report on Temp-t39-2.

Hej Stephen Thanks, that helped me a bit further. I have designed the report according to your instructions: Created a function with a temp rec as argument. But I can’t use the temp_table as dataitem in the report…I.e the report now knows the temp_table but how do I put it onto the sections? I don’t know if this make sense at all…

Hi Sorry i should of mentioned. You Need to Use the Integer table as the DataItem. On the OnPreDataItem trigger SETRANGE(Number,1,TmpRec.COUNT); OnAfterGetRecord IF Number = 1 THEN TmpRec.Find('-') ELSE IF TmpRec.NEXT = 0 THEN CurrReport.BREAK; If its any help Look at Reps 111,311 or 711 Top 10 lists they use Integer and temptables in this way.

Hi Stephen Perfect! Thanks! This forum is just great!


Originally posted by jensthomsen
… This forum is just great!

What he said :slight_smile: