Is there a way to create temporary tables?

Is there a way to create temporary tables on the fly for use on custom reports or forms? The reason I ask is because it would be useful to preprocess and group data from many different tables into a single form for reporting and analysis functions.

If you mean creating a table a defining fields etc. at run time then the answer is no. But what you can do is define a global record variable for an existing table then on the properties define it as temporary. You can then put whatever data you like in there without it being written to the database. With a bit of thought, you can work up a generic table design that you only ever use for sorting. Alternatively, you get lazy and find something vaguely suitable in the existing tables and use it for something other than its intended use. Goes against the programming guidelines but sometimes expediency rules. For example, I recently used a temporary sales comment table as a log book for a dataport run. Setup a report with the comments as a temporary table and function that could be passed some data that it then put in the temp table. The dataport defines the report as a global and calls the function with text that I want to print. At the end of the dataport, run the report and out comes all the text from the temp table. Cheers, John

Thanks, I was hoping there might be an easier way. I suppose we could create a generic sorting table with say 10 numeric, 10 text, 10 date fields etc and write a field mapper to make the code readable - which will probably require another table!

It is in fact a very easy way. The only trick is to find a suiteable existing table. If you need e.g. a temporary table with a code PK a text-field and a couple of decimal values you could use the item table (T27). Of course it looks quite funny in the code if you missue fields like minimum quantity and the like to sumarize internally an amount but it works fine. ------- With best regards from Switzerland Marcus Fabian

Roy, If you want it that way, there’s nothing wrong with creating a special table for this purpose. But as the possibilities of using/naming fields from code are quite limited, you will probably better off by using a temporary copy of the table which contains the specific data. You may want to have a look at the JIT Sort (Just in Time sorting) example on the Hermida website (www.hermida.com/navision) for some ideas on using temp tables. John

Just for information: You can create a table in Navision, even outside the customers license area, and still use this as a temporary table in other objects. As long as you don’t store any data in it you are fine. Don’t know if it is a “feature” of Navision or something that is done on purpose. Soren Nielsen, moderator Integration/Developer NOLUG