Create a table in runtime

I have a question: Is it possible to create a new (temporarily) table with C/AL code? Thanx Joep Admiraal

creat a new table from code is not possible as far as I know. But if is was possible, I don’t think this is what you want to do. Just mis-use an other table. Find one in Navision you can use, make a record variable based on this table, make is Temp and very important… Give is a very good name!!! Don’t name it TempItem is you are not using it to store item data.

Thanx for your reply.


Just mis-use an other table.

That’s not a handy solution in my case (I think) I’m sending records from a dataport to a report. Only the records I’m sending need 2 extra fields. So I thougt let’s create a temporarily table which contains all the fields I need to import and copy a record from that table to the report.

Could explain me what you want to do here?

I have a function in a report wich has a record(Customer) parameter. In a dataport I want to call this function with the imported customer fields as parameter. The above works fine. The problem is that I get two extra fields during the import. I need to send those two fields to the function in the report. At the moment I use something like this: Function(RecCustomer, Var1, Var2) This is allright for the moment but when I have about 10 extra fields it would be nice if I could create a temporarily table with all the customer fields and the extra fields I need and use this table as parameter for the function. Hope this makes sense :slight_smile: Greetz Joep Admiraal

What you doing with the extra imported values (var1, var2) in that function?

They give extra information about the imported customer. In the function I generate import error’s on the report. The kind of error sometimes depend on the two extra variables.

Could not help this solution ? 1. Add own field “Add. Informations” in Customer record - data type BLOB. 2. In dataport after import “No.” in OnAfterFormatField create OUTSTREAM object for “Add. Informations”: Customer.“Add. Informations”.CREATEOUTSTREAM(ostAddInformation); ostAddInformation is global variable of data type - Outstream 3. For each additional information use ostAddInformation.WRITE or ostAddInformation.WRITETEXT 4. Call report 5. In report function create INSTREAM object for “Add. Informations”: RecCustomer.“Add. Informations”.CREATEINSTREAM(istAddInformation); 6. Use EOS and READ(or READTEXT) For more information check help for INSTREAM and OUTSTREAM object

That could be a solution… Only I forgot to tell you that I may not adjust the Customer table :slight_smile: Thanx Joep

Maybe you could pass the info in an array (of text)?

And can you create own table ? If you can, create table f.e. “Customer Add. Info” with 2 fields: “No.” - (PK) Integer, “Additional Cust. Information” data type BLOB. Then make small changes to example above. Exchange Customer.“Add. Informations” for “Customer Add. Info”.“Additional Cust. Information” and your function in dataport could looks something like this Function (recCustomer, recAddCustInfo)

I could create a new table and I could pass the info as an array but I want to know if it is possible to create a temperarily table with C/AL code. I allready solved my problem but I’m just interesting in the posibility to create tables at run-time. I found the table “2000000041 - Field” and I can add records to that table but those fields are put directly into the table. I could offcourse create the table that way and remove it when I’m done but that’s not a great solution either.

I cant understand why you won’t create a new table. As far as I see you will get pretty far with a temporary table. Remember - you don’t need to add the temporary table to the customers license. They are free of charge… as long as you use them temporarily.

Hey Joep, It sounds to me that you are stuck in the old “but I can do it in VB, why not in Navision”. Navision is not VB. Well in VB, there is no native function to post an Invoice, in Navision there is. So should Microsoft include Codeunit 80 as a standard feature of VB? Please jsut do it the Navision way, rather than beating your head against the wall with no purpose.

If you ignore David’s advice, which I shouldn’t, you could use the C/FRONT ocx from within Navision and create your table on the same database that way + plus clean it up as needed etc. It’s very round-about, but I’ve seen it done before.