How to filter out files for file transfer based on part of their name (containing date)
Question and restrains:
The end user
requirement is to setup a file transfer object to transfer the latest file in
the path on a source to destination.
- The file names have the same prefix - and ends with the date it was created.
- so every day we have new files getting added to the source with the same prefix and ending with the date it was created.
- I want to pick only the file which was created on the same day and transfer it.
If you really know the date of the file creation (or the transfer is on
the same date) and you are sure the filename will contain the date.
You can use the process tab of the transaction to call the date function, which will give you current date.
Save it in a variable and format it.
:SET &DATE# = SYS_DATE("DD.MM.YYYY")
Then use the variable &DATE# and concatenate it into file name with the directory path, prefix and suffix and then paste it into the Source file field as attribute.
explained also in this community post by @Wolfgang Brueckler
FILE TRANSFER ATTRIBUTES:
:SET &FILENAME# = "Directorypath_prefix_YYYYMMDD.suffix"
:PUT_AT FT_SRC_FILE = "&FILENAME#"
This way you do not need to hard-code the source file location and file name into the FileTransfer attribute filed and can change it ad-hoc with your script
You can as well incorporate wildcards * in the mix, for example in our example path
:SET &FILENAME# =