As of December 1, 2020, Focal Point is retired and repurposed as a reference repository. We value the wealth of knowledge that's been shared here over the years. You'll continue to have access to this treasure trove of knowledge, for search purposes only. Moving forward, myibi is our community platform to learn, share, and collaborate. We have the same Focal Point forum categories in myibi, so you can continue to have all new conversations there. If you need access to myibi, contact us at myibi@ibi.com and provide your corporate email address, company, and name. Connect to myibi
Focal Point    Focal Point Forums    WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to read a dynamic file from FTP server

 Go Search Notify Tools
 [SOLVED] How to read a dynamic file from FTP server
Silver Member
 posted August 15, 2019 05:53 PM
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 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

 Posts: 34 | Location: Kearney, Nebraska | Registered: December 14, 2011 IP
Expert
 posted August 16, 2019 03:00 AM Hide Post
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 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 FOCUSsince 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

 Posts: 5694 | Location: United Kingdom | Registered: April 08, 2004 IP
Silver Member
 posted August 16, 2019 12:08 PM Hide Post
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 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

 Posts: 34 | Location: Kearney, Nebraska | Registered: December 14, 2011 IP
Guru
 posted August 17, 2019 08:13 AM Hide Post
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

-TYPE &FILENAME

WebFOCUS 8.2.03 (8.2.06 in testing)

 Posts: 253 | Location: Melbourne, Australia | Registered: February 07, 2007 IP