Hi!
Now I am about to show you how create a CSV file in Ax 2012 R3.
First of all, we need to create an instance of the class CommaTextIo, a Container, and the reference to the #File macro.
01 static void CreateCSV(Args _args)
02 {
03 CommaTextIo file;
04 Container line;
05 InventTable inventTable;
06 #File
07
08 file = new CommaTextIo("c:\\users\\jarizmendi\\aCSVFile.csv", #io_write);
09 if (!file || file.status() != IO_Status::Ok)
10 {
11 throw error("File cannot be opened.");
12 }
13
14 while select * from inventTable
15 {
16 line = [inventTable.ItemId, inventTable.ItemName];
17 file.writeExp(line);
18 }
19 info("It works!!.");
20 }
Then, we need to create the CSV file in a specified directory, and finally, we need to write the data as lines 14 to 18 show.
I hope it helps!!
No comments:
Post a Comment