Written by Gary | Jul 4, 2022 5:00:00 AM
- Create an NPR Report to produce a downloaded file and add the following Footnote: AL CLOSE.UP close.up
- File and Translate your report.
- Create a Report Macro called close.up with the following code:
IF{@Not(@Z.rpt.found);
/R.HALTED;
@.on.device'="DOWNLOAD";
@Not(@Z.rpt.download.path);
%Z.rw.close.up(0),
"USER"^USR,
"PASSWORD"^PWD,
@Z.rpt.download.path^LFN,
"IP ADDRESS"^RMH,
"/FOLDERS/FILENAME"^RFN,
{LFN,"FTP://"_USR_":"_PWD_"@"_RMH_RFN}@Internet.put.file @W.return(LFN_" SENT!");
@W.return(LFN_" FAILED TO SEND!")},
@Translation.message("***** PLEASE RETRANSLATE YOUR REPORT *****")
- Replace "USER" with the user for accessing the FTP server.
Replace "PASSWORD" with the password for accessing the FTP server.
Replace "IP ADDRESS" with the IP Address of the FTP server.
Replace "/FOLDERS/FILENAME" with the name of the Remote Filename.
File and Translate your Report Macro and then Retranslate your Report.
When running your report, the close.up Macro will try to send your Downloaded file via FTP. This occurs after the End of Report message appears. You will receive a pop-up window message informing you if the file was sent or failed to be sent.
AL is a Footnote used to integrate a Report Macro into your Report. In this case, the Report Macro close.up will be integrated into your Report at the end of the Report. CLOSE.UP occurs at the end of the Report.
The Report Macro close.up makes use of an IF Statement to determine whether or not the downloaded file should be sent via FTP.
Condition: @Not(@Z.rpt.found)
If no records are found, then there is no need to send the file. @Z.rpt.found is a Global Variable (also represented by /R.FOUND) which is set up if at least one record is found. @Not is an NPR Programming Macro that returns a non-nil value if the Argument has a nil value. So if there is NOT a value for Z.rpt.found, then the IF Statement ends at that point.
Condition: /R.HALTED
If there is a value for the Global Variable /R.HALTED, then the IF Statement ends at that point. /R.HALTED is set up if the end-user chooses to halt the normal operation of the Report.
Condition: @.on.device'="DOWNLOAD"
If the Print Destination chosen is NOT EQUAL to "DOWNLOAD", then the IF Statement ends at that point. The Not Equal Operator is '=. @.on.device is a Global Variable (also represented by /.PRT) used to store the response to the Print Destination.
Condition: @Not(@Z.rpt.download.path)
The path chosen for a downloaded file is stored in the Global Variable @Z.rpt.download.path. So the IF Statement ends at this point if there is no value for @Z.rpt.download.path.
Code: %Z.rw.close.up(0)
Z.rw.close.up is an NPR Procedure used at the end of every Report. It is designed to finish the printing process. In this case, it completes the download of the report data from the Meditech server to the client.
Code: {LFN,"FTP://"_USR_":"_PWD_"@"_RMH_RFN}@Internet.put.file
@Internet.put.file is an NPR Programming Macro used to copy the contents of a Local File to a Remote File. Most NPR Programming Macros use this syntax: @NPR.Macro(ARGUMENTS)
@Internet.put.file uses this syntax: {ARGUMENTS}@Internet.put.file