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