Focal Point
[SOLVED] How to read a dynamic file from FTP server

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/2737084196

August 15, 2019, 05:53 PM
Venkat-
[SOLVED] How to read a dynamic file from FTP server
Greetings!

Please see code snippet below. This is what I'm trying to accomplish. I receive one dynamic .csv file every night from an external batch process. It basically places them on FTP server with a date and timestamp on it, something like this: "7_APP_INPROGRESS_20190815010206.csv", then next day "7_APP_INPROGRESS_20190816030107.csv", then following day "7_APP_INPROGRESS_20190817020403.csv", ect...So, I'm trying to figure out how to read a dynamic csv date/timestamp file via WF FILEDEF command.

For example, "7_APP_INPROGRESS_" name part would always stay the same and it never changes, but next portion "20190815" (8 digit-date) changes every night, then last piece "010206" (6 digit-timestamp) changes every night and won't be consistent. And, here is the challenge that I run into. If I do a FILEDEF to look for &FILENAME*.csv, it doesn't appear to be working/reading file correctly. Is there anything that I need to tweak here? Please advise.

 SET EMPTYREPORT=ON

-SET &FILENAME = 7_APP_INPROGRESS_|&YYMD|;

APP MAP TESTING D:\FOCUS\MFD

APP PREPENDPATH TESTING

FILEDEF TESTING DISK D:\FOCUS\in\&FILENAME*.csv

TABLE FILE TESTING
PRINT *
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS HLD_TEST_1
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
TYPE=REPORT,
     COLUMN=N41,
     WRAP=6.000000,
$
ENDSTYLE
END 

This message has been edited. Last edited by: Venkat-,


product release:8203
o/s: windows 10
expected o/p formats: HTML,EXCEL,PDF
August 16, 2019, 03:00 AM
Tony A
If there is only one file for that date then the following might work for you.

Essentially, copy the file(s) into a known (temporary) filename and FILEDEF that.

SET EMPTYREPORT=ON

-SET &FILENAME = 7_APP_INPROGRESS_|&YYMD|;
-SET &CONCAT = 'COPY D:\FOCUS\in\&FILENAME*.csv testing.csv';
-SET &RETCD  = SYSTEM(&CONCAT.LENGTH, &CONCAT.QUOTEDSTRING, 'D4');

APP MAP TESTING D:\FOCUS\MFD

APP PREPENDPATH TESTING

FILEDEF TESTING DISK testing.csv

TABLE FILE TESTING
PRINT *
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS HLD_TEST_1
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
TYPE=REPORT,
     COLUMN=N41,
     WRAP=6.000000,
$
ENDSTYLE
END


T



In FOCUS
since 1986
WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
August 16, 2019, 12:08 PM
Venkat-
Thanks Tony, really appreciate your help! I tried your script, but ran into an error message indicating unrecognized command on line &FILENAME*.csv. I then realized to switch it with DOS command and that worked!!! Below is the final revised script for your reference and thanks again:


SET EMPTYREPORT=ON

-SET &FILENAME = 7_APP_INPROGRESS_|&YYMD|;
DOS COPY D:\FOCUS\in\&FILENAME*.csv D:\FOCUS\in\testing.csv;

APP MAP TESTING D:\FOCUS\MFD

APP PREPENDPATH TESTING

FILEDEF TESTING DISK D:\FOCUS\in\testing.csv

TABLE FILE TESTING
PRINT *
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE HOLD AS HLD_TEST_1
ON TABLE SET HTMLCSS ON
ON TABLE SET STYLE *
     INCLUDE = IBFS:/EDA/EDASERVE/_EDAHOME/ETC/endeflt.sty,
$
TYPE=REPORT,
     COLUMN=N41,
     WRAP=6.000000,
$
ENDSTYLE
END  



product release:8203
o/s: windows 10
expected o/p formats: HTML,EXCEL,PDF
August 17, 2019, 08:13 AM
StuBouyer
Since you are using APP MAP already you can also use APP QUERY and get the full name of the file

APP QUERY TESTING HOLD

TABLE FILE FOCAPPQ
PRINT FILENAME
WHERE FILENAME LIKE '7_APP_INPROGRESS_%'
ON TABLE HOLD AS FNAME FORMAT ALPHA
END

-READFILE FNAME

-TYPE &FILENAME


WebFOCUS 8.2.03 (8.2.06 in testing)