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