Focal Point Banner
Community Center Education Summit Technical Support User Groups
Let's Get Social!

Facebook Twitter LinkedIn YouTube
Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to read a dynamic file from FTP server
Go
New
Search
Notify
Tools
Reply
  
[SOLVED] How to read a dynamic file from FTP server
 Login/Join
 
Silver Member
posted
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
 
Posts: 34 | Location: Kearney, Nebraska | Registered: December 14, 2011Reply With QuoteReport This Post
Expert
posted 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 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.06 on Windows Svr 2008 R2  
WebFOCUS App Studio 8.2.06 standalone on Windows 10 
 
Posts: 5601 | Location: United Kingdom | Registered: April 08, 2004Reply With QuoteReport This Post
Silver Member
posted 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 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
 
Posts: 34 | Location: Kearney, Nebraska | Registered: December 14, 2011Reply With QuoteReport This Post
Platinum Member
posted 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

-READFILE FNAME

-TYPE &FILENAME


WebFOCUS 8.0.09
 
Posts: 236 | Location: Melbourne, Australia | Registered: February 07, 2007Reply With QuoteReport This Post
  Powered by Social Strata  
 

Focal Point    Focal Point Forums  Hop To Forum Categories  WebFOCUS/FOCUS Forum on Focal Point     [SOLVED] How to read a dynamic file from FTP server

Copyright © 1996-2018 Information Builders, leaders in enterprise business intelligence.