Loading...
Searching...
No Matches
rejection.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Removes a staged data package from approval screen
4 @details
5
6 <h4> SAS Macros </h4>
7 @li mf_getuser.sas
8 @li mf_getvarlist.sas
9 @li mf_verifymacvars.sas
10 @li mp_abort.sas
11 @li mp_lockanytable.sas
12 @li mpe_accesscheck.sas
13 @li mpe_alerts.sas
14 @li mpe_getvars.sas
15 @li removecolsfromwork.sas
16
17 <h4> Service Outputs </h4>
18 <h5> fromsas </h5>
19
20 @li TABLE_ID
21 @li SUBMITTED_REASON_TXT
22 @li RESPONSE
23
24 @version 9.2
25 @author 4GL Apps Ltd
26 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
27 and may not be re-distributed or re-sold without the express permission of
28 4GL Apps Ltd.
29
30**/
31%global STP_ACTION TABLE STP_REASON;
32%mpeinit()
33
34%mpe_getvars(BrowserParams, BrowserParams)
35
36PROC FORMAT;
37 picture yymmddhhmmss other='%0Y-%0m-%0d %0H:%0M:%0S' (datatype=datetime);
38RUN;
39
40/* get current status and base table */
41data _null_;
42 set &mpelib..mpe_submit(where=(TABLE_ID="&TABLE"));
43 call symputx('BASE_TABLE',cats(base_lib,'.',base_ds));
44 call symputx('submit_status_cd',submit_status_cd);
45run;
46
47%mp_abort(
48 iftrue=(%mf_verifymacvars(base_table)=0)
49 ,mac=&_program
50 ,msg=%str(Missing: base_table)
51)
52
53%mp_abort(
54 iftrue=(%quote(&submit_status_cd)=%quote(REJECTED))
55 ,mac=&_program
56 ,msg=%str(&table is already rejected!)
57)
58
59%mp_abort(iftrue= (&syscc ge 4)
60 ,mac=&_program
61 ,msg=%str(Issue on setup)
62)
63
64/**
65 * determine if user is authorised to reject table
66 */
67%let user=%mf_getuser();
68%global authcheck; %let authcheck=0;
69%mpe_accesscheck(&base_table,outds=authAPP,user=&user,access_level=APPROVE)
70%let authcheck=%mf_getattrn(work.authAPP,NLOBS);
71
72%mp_abort(iftrue= (&authcheck=0)
73 ,mac=&_program..sas
74 ,msg=%str(User &user does not have APPROVE rights on &base_table and is not
75 in the &mpeadmins group)
76)
77
78/* update the control table to show table as rejected (and why) */
79%let now=%sysfunc(datetime());
80data work.reject;
81 if 0 then set &mpelib..mpe_review;
82 TABLE_ID="&table";
83 BASE_TABLE="&base_table";
84 REVIEW_STATUS_ID="REJECTED";
85 REVIEWED_BY_NM="&user";
86 REVIEWED_ON_DTTM=&now;
87 REVIEW_REASON_TXT=symget('STP_REASON');
88run;
89
90%mp_lockanytable(LOCK,
91 lib=&mpelib,ds=mpe_review,ref=%str(&table rejection),
92 ctl_ds=&mpelib..mpe_lockanytable
93)
94proc append base=&mpelib..mpe_review data=work.reject;
95run;
96%mp_lockanytable(UNLOCK,
97 lib=&mpelib,ds=mpe_review,
98 ctl_ds=&mpelib..mpe_lockanytable
99)
100
101%mp_lockanytable(LOCK,
102 lib=&mpelib,ds=mpe_submit,ref=%str(&table rejection),
103 ctl_ds=&mpelib..mpe_lockanytable
104)
105proc sql;
106update &mpelib..mpe_submit
107 set submit_status_cd='REJECTED',
108 num_of_approvals_remaining=0,
109 reviewed_by_nm="&user",
110 reviewed_on_dttm=&now
111 where table_id="&table";
112%mp_lockanytable(UNLOCK,
113 lib=&mpelib,ds=mpe_submit,
114 ctl_ds=&mpelib..mpe_lockanytable
115)
116
117
118%mp_abort(iftrue= (&syscc ne 0)
119 ,mac=&_program..sas
120 ,msg=%str(syscc=&syscc AFTER update...)
121)
122
123%mpe_alerts(alert_event=REJECTED
124 , alert_lib=%scan(&BASE_TABLE,1,.)
125 , alert_ds=%scan(&BASE_TABLE,2,.)
126 , dsid=&TABLE
127)
128
129data fromSAS;
130 RESPONSE='SUCCESS!';
131 set REJECT;
132run;
133
134%removecolsfromwork(___TMP___MD5)
135
136%webout(OPEN)
137%webout(OBJ,fromSAS)
138%webout(CLOSE)
139
140
141%mpeterm()