Skip to Content

How to get latest file using wait_for_file() function

Hi All,

I am facing issue using wait_for_file function, my requirement is in my source file path C:\FTP\PROD_20150314.csv  & PROD_20150314.csv two files having same name with different time factor. When I start  job want to take only one file that is latest one need to be process. How to set this option in wait_for_file function. currently I am using this pattern.

Substitution Param:


$$Filepath = ‘C:\FTP’

$$Filename = ‘PRODUCT_*.csv’  (i.e. PRODUCT_20150314.csv)



$PATH  ='[$$Filepath]’;

$Filename = ‘[$$Filename]’;

wait_for_file(‘[$PATH]’\\'[$Filename]’, 0, 0, 1, $filestat);

$filestat = replace_substr($filestat,’/’,’\\’);

What changes is required to get latest file from the path.

Thanks in Advance…!!!!



You must be Logged on to comment or reply to a post.
  • Hi,

    You can apply following logic.

    First get all the file name into single table using wait for file function.

    Now after getting all the file names onto single table;apply rank according to descending order of timestamp of file.

    now in script, you can write logic to get file having maximum timestamp.

    Var:= Select filename from table where rank=1;

    Now in BODS , you can get file with the help of Var as file name;

    I think you got the solution.