Loading...
Searching...
No Matches
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 mp_abort.sas
12 @li mp_init.sas
13
14 @param fetch= Fetch the SASjs tables. Use NO if not loading SASjs content,
15 eg for file upload.
16
17 @version 9.3
18 @author 4GL Apps Ltd
19 @copyright 4GL Apps Ltd. This code may only be used within Data Controller
20 and may not be re-distributed or re-sold without the express permission of
21 4GL Apps Ltd.
22**/
23
24
25%macro mpeinit(fetch=YES);
26%global mpeinit
27 mpeadmins /* group with unrestricted Meditor access */
28 mpelocapprovals /* location for landing and staging files */
29 mpelib /* location of configuration tables for DC */
30 dc_repo_users /* location of user / group metadata */
31 /* extracted in dc_getsettings */
32 dc_activation_key
33 dc_licence_key
34 dc_locale
35 dc_request_logs
36 dc_restrict_viewer
37 dc_dttmtfmt /* can be overridden in dc_getsettings */
38 _debug /* automatic variable when provided in URL */
39 sasjs_mdebug /* used to show extra info when _debug is enabled */
40 sqlrc /* avoid errors when using DI jobs in HOOK scripts */
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
62options 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 */
73data _null_;
74 dc_dttmtfmt='"%sysfunc(datetime(),'!!"%mf_fmtdttm()"!!')"dt';
75 call symputx('dc_dttmtfmt',dc_dttmtfmt);
76 put dc_dttmtfmt=;
77run;
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
93data _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;
101run;
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/* `_debug` is 131 by default, but the adapter sends 128 on the Viya WEB JES
118 * path when runAsTask is enabled (see WebJobExecutor.getRequestParams), and
119 * 128 also arrives when a `log` debug value is requested. All of them mean
120 * "debug on" - so all of them enable the extra logging below. */
121%if "&_debug"="2477" or "&_debug"="fields,log,trace" or "&_debug"="131"
122 or "&_debug"="128"
123%then %do;
124 %let sasjs_mdebug=1;
125%end;
126
127%if "&sasjs_mdebug"="1" %then %do;
128 %if %sysfunc(exist(work.browser_url_vars)) %then %do;
129 data _null_;
130 length name value $1024;
131 set work.browser_url_vars;
132 putlog "NOTE: &sysmacroname: work.browser_url_vars:";
133 putlog name= value=;
134 run;
135 %end;
136 %else %put NOTE: &sysmacroname: no work.browser_url_vars on this request;
137 %if %sysfunc(exist(work.browser_info)) %then %do;
138 data _null_;
139 set work.browser_info;
140 putlog "NOTE: &sysmacroname: work.browser_info:";
141 putlog (_all_)(=);
142 run;
143 %end;
144 %else %put NOTE: &sysmacroname: no work.browser_info on this request;
145%end;
146
147%mend mpeinit;