How to Create s CSV file in C/AL programming

SreenivasanSreenivasan Member Posts: 3
Hi,

I am try to write a script which should dynamically fetch the TableName and the fileds and value of the Tables.And these data has to written in csv File.

And i am very very new to Navision i have lot and lot of questions in creating the script.

1.How can i find the TableName dynamically.
2.How can i get the Fields in the Table.
3.How can i get the Field Values in the Table.
4.How can i write in a csv file .

Comments

  • lubostlubost Member Posts: 632
    Your question is very complex, but some things can be written shortly:
    1. There exist variable type named RecordRef which can point to record in any table (see help or manual)
    2. There exist variable type named FieldRef which can point to eny field in any table (see help or manual)

    3. You must "only" create the loop thru all records and all fields in desired table and write values (use FORMAT function) to file (f.OPEN, f.Write, f.CLOSE)
  • Captain_DX4Captain_DX4 Member Posts: 230
    Dude! A lot of what you are requesting is covered in the Application Designer's Guide, which resides on your Navision installation CD in the Documents folder. I would suggest you crack that open for a while. It is the primer for up-and-coming developers.
    Kristopher Webb
    Microsoft Dynamics NAV Developer
  • SreenivasanSreenivasan Member Posts: 3
    Hi Lubost,

    Thankyou very much for your valuable inputs,as said by you i have tried by using the Recordref and the fieldref but still am facing the issue.

    I am giving code C\AL code written by be me i request you to suggest me for further move.

    Script:
    ======
    SourceName := xRec.TABLENAME;
    FiledSet.OPEN(15); //Filedset is Recordref
    currTblFieldCount := FiledSet.FIELDCOUNT; //currTblFieldCount is an Integer
    idx := 1;
    viewno := 1;
    WHILE idx <> currTblFieldCount DO BEGIN
    IF FiledSet.FIELDEXIST(viewno) THEN BEGIN
    currField := FiledSet.FIELD(viewno);
    MESSAGE('%1',viewno);
    MESSAGE('%1',currField.NAME()); //currFiled is the Fieldref
    MESSAGE('%1',currField.VALUE());
    idx := idx +1;
    END;
    viewno := viewno +1;
    END;
Sign In or Register to comment.