Dynamic File names

Dynamic file names is a quite common task and there are multiple ways of doing it

Calculations

It is possible to use calculated filenames by placing calculation inside {}

Example

This will use today date to generate the filename

C:\Data\{GetSystemDate('YYYYMMDD')}.txt

and that one will use yesterdays date

C:\Data\{DecDateS(GetSystemDate('YYYYMMDD'),'YYYYMMDD','DAY',1)}.txt
Dynamic file names

Variables

<CommonDocumentsDir>\DBSL\{GetSystemVariable('SOURCE_FILE_NAME')}.txt
<CommonDocumentsDir> is a variable and will be replaced with an actual value before execution
C:\Data\{GetVariable('<file_name>')}.txt

More complex example

This calculation will create a new file every time [F001] is changed

Dynamic Filenames
begin
if GetVariable('<file_name>')<>[F001] then // record changed
 begin
  SetVariable('<file_name>',[F001]);
  SourceChanged; // creating new file
 end;
 Result:='test';
end;

Building a complex file name

For more technologies supported by our ETL Software see Advanced ETL Processor Versions

Confused? Ask question on our ETL Forum
Last updated: September 9, 2022