Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
I am using a tFileOutputDelimited component for a output process.
I am using an external context values file to parameterize the values.
Context value file data example:
PATH_TGT==//mydoc/share/
In the tFileOutputDelimited File Name I am also using " "XXX_"+TalendDate.formatDate("yyyyMMdd",TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM"))) + ".txt"" to get the date in the name of the file.
So the file output file name is like: XXX_20191210.txt
My function is working in the working good inside the talend.
But if i put the TalendDate.formatDate("yyyyMMdd",TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM"))) in a context variable I am having error.
Context value file data example:
PATH_TGT==//mydoc/share/
TGT==TalendDate.formatDate("yyyyMMdd",TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM")))
Calling the TGT context in inside tFileOutputDelimited file name : "xxx_" +context.TGT + + ".txt"
Error:
statistics] connecting to socket on port 3753
[statistics] connected
Exception in component tFileOutputDelimited_1 (t_Att_FILE)
java.io.FileNotFoundException: \\my\ "_" +TalendDate.formatDate("yyyyMMdd",TalendDate.getLastDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM"))) + ".txt" (The filename, directory name, or volume label syntax is incorrect)
at java.io.FileOutputStream.open0(Native Method)
at java.io.FileOutputStream.open(Unknown Source)
I know the TalendDate is a builtin function so is it possible to assign the TalendDate function as a context variable?
It considers TalendDate.formatDate("yyyyMMdd",TalendDate.getFirstDayOfMonth(TalendDate.addDate(TalendDate.getCurrentDate(),-1,"MM"))) as a variable value, you can't use any function in the value field.
You cannot use expressions in context variable inputs. It looks a bit like an expression because you can put quotes around it but this is an illusion. All it does is take off any leading or trailing quotes and treat everything else as a literal string.