getapprovals.sas
Go to the documentation of this file.
1 /**
2  @file getapprovals.sas
3  @brief Returns a list of staged data items that need to be approved
4  @details
5 
6  <h4> SAS Macros </h4>
7  @li mpe_getgroups.sas
8  @li mp_abort.sas
9  @li mf_getuser.sas
10 
11  @version 9.2
12  @author 4GL Apps Ltd
13  @copyright 4GL Apps Ltd. This code may only be used within Data Controller
14  and may not be re-distributed or re-sold without the express permission of
15  4GL Apps Ltd.
16 
17 **/
18 
19 %mpeinit()
20 
21 /* determine users group membership */
22 %let user=%mf_getuser();
23 %mpe_getgroups(user=&user,outds=work.groups)
24 
25 PROC FORMAT;
26  picture yymmddhhmmss other='%0Y-%0m-%0d %0H:%0M:%0S' (datatype=datetime);
27 RUN;
28 
29 proc sql noprint;
30 create table out1 (rename=(SUBMITTED_ON_DTTM1=SUBMITTED_ON_DTTM)) as
31  select table_id
32  ,submit_status_cd as REVIEW_STATUS_ID
33  ,SUBMITTED_BY_NM
34  ,cats(base_lib,'.',base_ds) as base_table
35  ,put(submitted_on_dttm,yymmddhhmmss.) as SUBMITTED_ON_DTTM1
36  ,submitted_on_dttm as SUBMITTED_ON_DTTM2
37  ,submitted_reason_txt
38  ,num_of_approvals_required
39  ,num_of_approvals_remaining
40  ,base_lib as libref
41  ,base_ds as dsn
42  from &mpelib..mpe_submit (where=(submit_status_cd='SUBMITTED'))
43  /* filter out any submits for which approval is already made */
44  where table_id not in (
45  select table_id from &mpelib..mpe_review where submitted_by_nm="&user"
46  );
47 
48 %macro getapprovals();
49  %local admin_check;
50  select count(*) into: admin_check
51  from groups
52  where groupname="&mpeadmins"
53  or groupname in (
54  select sas_group from &mpelib..mpe_security
55  where libref='*ALL*'
56  and &dc_dttmtfmt. lt tx_to
57  and access_level in ('APPROVE')
58  );
59  %if &admin_check >0 %then %do;
60  create table fromSAS as
61  select distinct * from out1
62  order by SUBMITTED_ON_DTTM2 desc;
63  %end;
64  %else %do;
65  create table fromSAS as
66  select distinct a.*
67  from out1 a
68  inner join &mpelib..mpe_security b
69  on a.libref=b.libref
70  and (a.dsn=b.dsn or b.dsn='*ALL*')
71  and &dc_dttmtfmt. lt b.tx_to
72  and b.ACCESS_LEVEL ='APPROVE'
73  and b.SAS_GROUP in (select groupname from work.groups)
74  order by SUBMITTED_ON_DTTM2 desc;
75  %end;
76 %mend getapprovals;
77 %getapprovals()
78 
79 %mp_abort(iftrue= (&syscc ne 0)
80  ,mac=&_program..sas
81  ,msg=%str(syscc=&syscc)
82 )
83 
84 %webout(OPEN)
85 %webout(OBJ,fromSAS)
86 %webout(CLOSE)
87 
88 
89 %mpeterm()