Loading...
Searching...
No Matches
getauditfile.sas
Go to the documentation of this file.
1/**
2 @file getauditfile.sas
3 @brief Downloads a zip file containing audit info.
4 @details The staging location from the &mpelocapprovals location
5 is zipped and returned as a file download. A user can only request the
6 audit pack if they have EDIT or APPROVE rights on the target table.
7
8 <h4> SAS Macros </h4>
9 @li mf_getuser.sas
10 @li mf_verifymacvars.sas
11 @li mpe_accesscheck.sas
12 @li mp_abort.sas
13 @li mp_dirlist.sas
14 @li mf_getattrn.sas
15 @li mp_streamfile.sas
16
17
18 @version 9.2
19 @author 4GL Apps Ltd
20 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
21 and may not be re-distributed or re-sold without the express permission of
22 4GL Apps Ltd.
23
24**/
25
26%mpeinit()
27options mprint;
28
29/* security checks */
30%let user=%mf_getuser();
31
32proc sql noprint;
33select cats(base_lib,'.',base_ds) into: libds
34 from &mpelib..mpe_submit
35 where table_id="&table";
36
37%mp_abort(
38 iftrue=(%mf_verifymacvars(libds table)=0)
39 ,mac=&_program
40 ,msg=%str(Missing: libds table)
41)
42
43%mpe_accesscheck(&libds,outds=authEDIT,user=&user,access_level=EDIT);
44%mpe_accesscheck(&libds,outds=authAPP,user=&user,access_level=APPROVE);
45
46%mp_abort(
47 iftrue=(
48 %mf_getattrn(work.authEDIT,NLOBS)=0 & %mf_getattrn(work.authAPP,NLOBS)=0
49 )
50 ,mac=mpestp_audit
51 ,msg=%str(&user not authorised to download audit data for &table)
52)
53
54ods package(ProdOutput) open nopf;
55
56options notes source2 mprint;
57%let table=%unquote(&table);
58%mp_dirlist(outds=dirs, path=&mpelocapprovals/&TABLE);
59data _null_;
60 set dirs;
61 retain str1
62 "ods package(ProdOutput) add file='&mpelocapprovals/&TABLE/";
63 retain str2 "' mimetype='text/plain' path='contents/';";
64 call execute(cats(str1,filename,str2));
65run;
66
67%let archive_path=%sysfunc(pathname(work));
68
69ods package(ProdOutput) publish archive properties
70 (archive_name= "&table..zip" archive_path="&archive_path");
71
72ods package(ProdOutput) close;
73
74%mp_abort(iftrue= (&syscc ne 0)
75 ,mac=&_program..sas
76 ,msg=%nrstr(syscc=&syscc)
77)
78
79/* now serve zip file to client */
80%mp_streamfile(contenttype=ZIP
81 ,inloc=%str(&archive_path/&table..zip)
82 ,outname=&table..zip
83)
84
85%mpeterm()