Loading...
Searching...
No Matches
getlog.sas
Go to the documentation of this file.
1/**
2 @file getlog.sas
3 @brief Downloads the submission, useful if there is an error
4 @details
5
6 <h4> SAS Macros </h4>
7 @li mf_verifymacvars.sas
8 @li mf_getuser.sas
9 @li mp_abort.sas
10 @li mp_dirlist.sas
11 @li mp_streamfile.sas
12
13 @version 9.2
14 @author 4GL Apps Ltd
15 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
16 and may not be re-distributed or re-sold without the express permission of
17 4GL Apps Ltd.
18
19**/
20
21%mpeinit()
22
23%mp_abort(
24 iftrue=(%mf_verifymacvars(table)=0)
25 ,mac=&_program
26 ,msg=%str(Missing: table)
27)
28
29/* security checks */
30%let user=%mf_getuser();
31%let check_access=0;
32
33proc sql noprint;
34select count(*) into: check_access from &mpelib..mpe_loads
35 where csv_dir="&table" and user_nm="&user";
36
37%mp_abort(iftrue= (&check_access=0 )
38 ,msg=%str(&user not authorised to download audit data for &table)
39 ,mac=mpestp_getlog.sas
40)
41
42
43ods package(ProdOutput) open nopf;
44
45options notes source2 mprint;
46%mp_dirlist(outds=dirs, path=&mpelocapprovals/&TABLE)
47data _null_;
48 set dirs;
49 if scan(filename,-1,'.') not in ('sas7bdat','wpd');
50 retain str1
51 "ods package(ProdOutput) add file='&mpelocapprovals/&TABLE/";
52 retain str2 "' mimetype='text/plain' path='contents/';";
53 call execute(cats(str1,filename,str2));
54run;
55
56%let archive_path=%sysfunc(pathname(work));
57
58%mp_abort(iftrue= (&syscc ne 0)
59 ,mac=&_program..sas
60 ,msg=%str(syscc=&syscc)
61)
62ods package(ProdOutput) publish archive properties
63 (archive_name= "&table..zip" archive_path="&archive_path");
64
65ods package(ProdOutput) close;
66
67/* now serve zip file to client */
68%mp_streamfile(contenttype=ZIP
69 ,inloc=%str(&archive_path/&table..zip)
70 ,outname=&table..zip
71)
72
73%mpeterm()