CFRONT modifying an existing table

Hi, I’ve written a program in VB that inserts data into a user defined navision table. These tables need two control fields that if not exits the program should create. A datefield and a Boolean. I made a function that checks if these two fields already exist, if they don’t the program tries to add them to the table. I’ve added a piece of code that I use to create the extra fields in the table pointed to by TablePTR. The program runs without generating an error or warning, so every thing looks fine, but nothing has happened to the table. What am I doing wrong? I’m at a loss, so if anybody has an idea, they’re welcome!! Table_Name = cf.TableName(TablePTR) Correct1 = True Call cf.CreateTableBegin(CreateTablePTR, Table_No, Table_Name, Correct1) Field_Type = 3 Field_Class = 0 Call cf.AddTableField(CreateTablePTR, ExportFieldNo1, FieldName1, Field_Type, FLen, OptStr, Field_Class) Call cf.CreateTable(CreateTablePTR) Field_Type = 1 Call cf.AddTableField(CreateTablePTR, ExportFieldNo2, FieldName2, Field_Type, FLen, OptStr, Field_Class) Call cf.CreateTable(CreateTablePTR) Call cf.CreateTableEnd(CreateTablePTR)


Call cf.CreateTable(CreateTablePTR)

Try remove this line becouse, the table is always created. And check what every func. returns. Edited by - db on 2002 Mar 24 10:41:30

Thanks for your reaction. I have found that I’m not able to modify an exiting table. For example I am able to create a new table through C/FRONT but when I want to add a field to an existing table I get the message “Table already exists” From reading the manual I think I should be like this: (1) : CreateTableBegin (tblPTR) (2) : AddTableField (3) : CreateTable (tblPTR) (4) : CreateTableEnd (tblPTR) The error message occurs after line(3) is executed. If I leave this live out, like you suggested every thing looks fine, but nothing happens. The C/Front manual states that CreateTable must be called before the CreateTableEnd function is called because otherwise all the Add statements will be discarded. But when I call the function CreateTable (tblPTR) on a table that already exists I get an error. How should I go about adding fields to an existing table? Then there is another interesting fact, in Navision 2.01B the max. record length is 2000 bytes. When I copy a table, say table 36 (sales header) to table 90000 (temp salesheader) via VB code using C/Frony I get an error that the maximum record length is 2000 bytes, but when I go to the Navision object designer and select table 36 I am still able to add a few fields before navision starts to complain about the record length being larger then 2000 bytes. Does anybody know where this is coming from? Does C/Front use a different method then navision to calculate the record length?

Maybe they forgot add some func. I havn’t such hard task, but anyway. You can try do following trick: DeleteTable() - maybe it delete only table obj. and don’t deletes TableData … CreateTable() … Or you can tray copy data to temp table. Funny for me too About record size I think that there are compiler problems. By default compilers using 4 byte data aligment. So if you use code 20 field, compiler makes: 20 + 1 byte for terminating NULL + 1 byte for code sorting = 22 => 22/4=5.5 => 6 DWORDS => 6*4 = 24 bytes. So sizeof(code20)=24 bytes in C++ with 4 bytes aligment and maybe 22 in C/AL. Try retieve and compare field sizes.