mpeinit.sas
Go to the documentation of this file.
1 /**
2  @file mpeinit.sas
3  @brief Initialisation file for Data Controller- sets SASAUTOs etc
4  @details Runs at the beginning of every service. Used to configure settings,
5  options and macro variables. Requires the staging area and DC library to be
6  preconfigured.
7 
8  <h4> SAS Macros </h4>
9  @li dc_getsettings.sas
10  @li mf_fmtdttm.sas
11  @li mf_getuser.sas
12  @li mp_abort.sas
13  @li mp_init.sas
14 
15  @param fetch= Fetch the SASjs tables. Use NO if not loading SASjs content,
16  eg for file upload.
17 
18  @version 9.3
19  @author 4GL Apps Ltd
20  @copyright 4GL Apps Ltd. This code may only be used within Data Controller
21  and may not be re-distributed or re-sold without the express permission of
22  4GL Apps Ltd.
23 **/
24 
25 
26 %macro mpeinit(fetch=YES);
27 %global mpeinit
28  mpeadmins /* group with unrestricted Meditor access */
29  mpelocapprovals /* location for landing and staging files */
30  mpelib /* location of configuration tables for DC */
31  dc_repo_users /* location of user / group metadata */
32  /* extracted in dc_getsettings */
33  dc_activation_key
34  dc_licence_key
35  dc_locale
36  dc_request_logs
37  dc_restrict_viewer
38  dc_dttmtfmt /* can be overridden in dc_getsettings */
39  _debug /* automatic variable when provided in URL */
40  sasjs_mdebug /* used to show extra info when _debug is enabled */
41  ;
42 
43 %if &mpeinit=1 %then %return;
44 %else %let mpeinit=1;
45 %mp_abort(iftrue= (&syscc ne 0)
46  ,mac=&_program
47  ,msg=%str(Problem on service startup (&syswarningtext &syserrortext))
48 )
49 
50 %mp_init()
51 
52 %if &fetch=YES %then %do;
53  %webout(FETCH)
54 %end;
55 
56 %global _CLIENTNAME;
57 %mp_abort(iftrue= (&_CLIENTNAME=SAS Enterprise Guide)
58  ,mac=&_program..sas
59  ,msg=%str(Data Controller is a web app and should not be executed from EG)
60 )
61 
62 options urlencoding=utf8 nobomfile lrecl=32767;
63 
64 %let perf=%sysfunc(datetime());
65 %put perfdiff: 0;
66 
67 %let dc_locale=SYSTEM; /* default if not set */
68 
69 /**
70  * E8601DT26.6 has widest database support - but not all SAS flavours can
71  * handle it. Override in the settings STP if needed.
72  */
73 data _null_;
74  dc_dttmtfmt='"%sysfunc(datetime(),'!!"%mf_fmtdttm()"!!')"dt';
75  call symputx('dc_dttmtfmt',dc_dttmtfmt);
76  put dc_dttmtfmt=;
77 run;
78 
79 %put &=dc_dttmtfmt;
80 
81 %mp_abort(iftrue= (&syscc ne 0)
82  ,mac=&_program
83  ,msg=%str(syscc=&syscc prior to dc_getsettings)
84 )
85 
86 %dc_getsettings()
87 
88 %mp_abort(iftrue= (&syscc ne 0)
89  ,mac=&_program
90  ,msg=%str(syscc=&syscc after dc_getsettings)
91 )
92 
93 data _null_;
94  set &DC_LIBREF..mpe_config(where=(
95  var_scope="DC"
96  and &dc_dttmtfmt lt tx_to
97  and var_active=1
98  ));
99  call symputx(var_name,var_value,'G');
100  putlog var_name "=" var_value;
101 run;
102 
103 %let mpelib=&dc_libref;
104 %let mpeadmins=&dc_admin_group;
105 %let mpelocapprovals=&dc_staging_area;
106 %let dc_repo_users=&dc_repo_users;
107 
108 %if &dc_locale ne SYSTEM %then %do;
109  options locale=&dc_locale;
110 %end;
111 
112 %mp_abort(iftrue= (&syscc ne 0)
113  ,mac=&_program..sas
114  ,msg=%str(Problem during compilation or with STP precode (&syswarningtext))
115 )
116 
117 %if "&_debug"="2477" or "&_debug"="fields,log,trace" or "&_debug"="131"
118 %then %do;
119  %let sasjs_mdebug=1;
120 %end;
121 
122 %mend mpeinit;