I have 10 files in one directory in FTP which has to be moved to another directory in FTP. For file move process I'm using Fcopy. 
 
For all the 10files -starting of the filename is common (Report), Only the datepart and endpart of the file changes every month. I defiend datepart and endpart of the filenames to macro as the endpart of the filename are saved in table data as fname. 
 
Filename examples :
1. Report_31-10-2018_wind.xlsx
2. Report_31-10-2018_water.xlsx etc.
 
Dataset : Data
fname
wind
water
health
.
.
.
proc sql;
	select count(fname) into:n trimmed from data;
	select distinct fname into:fn1 - :fn%left(&n)
			from data;
run;
data _null_;
	 call symput ('datepart',put(intnx('month',today(),0,"b"),yymmdd10.));
run;
data _null_;
			length msg $384;
			i=filename('in',"/temp/files/Report&datepart._&&fn&n..xlsx", "DISK", "RECFM=N");
			o=filename('out',"/temp/files/backup/Report&check._&&fn&n..xlsx", "DISK", "RECFM=N");
			rc=fcopy('_in', '_out');
				if rc=0 then
			put 'Copied _in to _out.';
				else do
					msg=sysmsg();
				  put rc= msg=;
	end;
i=filename('in');
o=filename('out');
run;
This code works perfect without errors. But moves only 1 file ie., fn10 file but not rest of the files.
 
Can any advice what I'm missing here.