Loading...
Searching...
No Matches
getdiffs.sas
Go to the documentation of this file.
1/**
2 @file getdiffs.sas
3 @brief Retrieves the diff file for viewing
4 @details
5
6 <h4> SAS Macros </h4>
7 @li mpe_getvars.sas
8 @li mpe_accesscheck.sas
9 @li mf_getattrn.sas
10 @li mf_getuser.sas
11 @li mp_abort.sas
12 @li mp_binarycopy.sas
13 @li mp_streamfile.sas
14 @li mp_validatecol.sas
15
16 @version 9.2
17 @author 4GL Apps Ltd
18 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
19 and may not be re-distributed or re-sold without the express permission of
20 4GL Apps Ltd.
21
22**/
23
24%mpeinit()
25%mpe_getvars(BrowserParams, BrowserParams);
26
27/**
28 * Validate inputs before they reach executable code. libds is passed to
29 * the access check (which interpolates it into SQL) and table is used in
30 * the staging file path, so both must be well formed before use. Values
31 * are re-read with symget (never re-resolved) and validated in a data
32 * step so no macro content in the request can execute.
33 */
34%let is_libds=0;
35%let is_table=0;
36%let is_csv=0;
37data _null_;
38 length _libds $64 _table $64 _csv $128;
39 _libds=symget('libds');
40 _table=symget('table');
41 _csv=coalescec(symget('stp_diffs_csv'),'tempDiffs.csv');
42 %mp_validatecol(_libds,LIBDS,is_libds)
43 %mp_validatecol(_table,ISNAME,is_table)
44 /* the diffs csv filename must stay inside the staging directory */
45 if findc(_csv,'/\')>0 or index(_csv,'..')>0 then do;
46 is_csv=0;
47 putlog 'ERR' 'OR: Invalid stp_diffs_csv:' _csv;
48 end;
49 else is_csv=1;
50 if is_libds=0 then putlog 'ERR' 'OR: Invalid libds:' _libds;
51 if is_table=0 then putlog 'ERR' 'OR: Invalid table:' _table;
52 call symputx('is_libds',is_libds,'l');
53 call symputx('is_table',is_table,'l');
54 call symputx('is_csv',is_csv,'l');
55 if is_libds=1 then call symputx('libds',_libds,'g');
56 if is_table=1 then call symputx('table',_table,'g');
57 if is_csv=1 then call symputx('stp_diffs_csv',_csv,'g');
58run;
59
60%mp_abort(iftrue= (&is_libds ne 1)
61 ,mac=&_program..sas
62 ,msg=%str(Invalid libds)
63)
64%mp_abort(iftrue= (&is_table ne 1)
65 ,mac=&_program..sas
66 ,msg=%str(Invalid table)
67)
68%mp_abort(iftrue= (&is_csv ne 1)
69 ,mac=&_program..sas
70 ,msg=%str(Invalid stp_diffs_csv)
71)
72
73/* security checks */
74%let user=%mf_getuser();
75%mpe_accesscheck(&libds,outds=authEDIT,user=&user,access_level=EDIT)
76%mpe_accesscheck(&libds,outds=authAPP,user=&user,access_level=APPROVE)
77
78%macro mpestp_diffs();
79 %if %mf_getattrn(work.authEDIT,NLOBS)=0 & %mf_getattrn(work.authAPP,NLOBS)=0
80 %then %do;
81 %mp_abort(msg=%str(
82 &user not authorised to download diffs data for &stp_table)
83 ,mac=mpestp_diffs.sas);
84 %return;
85 %end;
86
87 %mp_abort(iftrue= (&syscc ne 0)
88 ,mac=&_program..sas
89 ,msg=%str(syscc=&syscc)
90 )
91
92 /* stream diffs csv to client */
93 %mp_streamfile(contenttype=EXCEL
94 ,inloc=%str(&mpelocapprovals/&TABLE/&STP_DIFFS_CSV)
95 ,outname=&STP_DIFFS_CSV
96 )
97
98%mend mpestp_diffs;
99%mpestp_diffs()
100
101
102%mpeterm()