Hi All,

We have written a job to export to csv, able to export if ww dont include datetime in file name.

But when we include the datetime in file name unable to export.

If we include datetime in file name , "file" in the next line is coming as null.

Please  let us know how we can include datetime in the filename while exporting to CSV.

Below is the job:

public static void main(Args _args)
Commaio file;
container line;
InventTable inventTable;
LedgerJournalTable ljt;
str filname;
str datefile;
utcDateTime dateTime = DateTimeUtil::getSystemDateTime();
date dateformat;
str TodayDate;
dateformat = today();
TodayDate = date2str(dateformat,321,DateDay::Digits2,DateSeparator::Slash,DateMonth::Digits2,DateSeparator::Slash,DateYear::Digits4);
filname = @"C:\\" + TodayDate + "Error.csv";  --> able to get file name with data as "C:\\2021/08/22Error.csv"


file = new Commaio(filname , #io_write);  -->coming null if include date in filename

if( !file || file.status() != IO_Status::Ok)
throw error("File Cannot be opened");
while select ljt
line = [ljt.JournalNum];