diff --git a/all.sas b/all.sas
index dc9ab92..e600776 100644
--- a/all.sas
+++ b/all.sas
@@ -1066,7 +1066,8 @@ or %index(&pgm,/tests/testteardown)
%else %if %symexist(&metavar) %then %do;
%if %length(&&&metavar)=0 %then %let user=&sysuserid;
/* sometimes SAS will add @domain extension - remove for consistency */
- %else %let user=%scan(&&&metavar,1,@);
+ /* but be sure to quote in case of usernames with commas */
+ %else %let user=%unquote(%scan(%quote(&&&metavar),1,@));
%end;
%else %let user=&sysuserid;
@@ -1889,7 +1890,7 @@ Usage:
%goto exit_success;
%exit_err:
- %put %str(ERR)OR: &abortmsg;
+ %put &abortmsg;
%mf_abort(iftrue=(&mabort ne SOFT),
mac=mf_verifymacvars,
msg=%str(&abortmsg)
@@ -8640,13 +8641,13 @@ select distinct lowcase(memname)
@li mp_abort.sas
@li mp_cntlout.sas
@li mp_lockanytable.sas
+ @li mp_storediffs.sas
Related Macros
@li mddl_dc_difftable.sas
@li mddl_dc_locktable.sas
@li mp_loadformat.test.sas
@li mp_lockanytable.sas
- @li mp_storediffs.sas
@li mp_stackdiffs.sas
@@ -8898,7 +8899,8 @@ options ibufsize=&ibufsize;
%put &sysmacroname exit vars:;
%put _local_;
%end;
-%mend mp_loadformat;/**
+%mend mp_loadformat;
+/**
@file
@brief Mechanism for locking tables to prevent parallel modifications
@details Uses a control table to enable ANY table to be locked for updates
@@ -15089,7 +15091,8 @@ data _null_;
put ' %else %if %symexist(&metavar) %then %do; ';
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
- put ' %else %let user=%scan(&&&metavar,1,@); ';
+ put ' /* but be sure to quote in case of usernames with commas */ ';
+ put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
put ' %end; ';
put ' %else %let user=&sysuserid; ';
put ' ';
@@ -17722,20 +17725,25 @@ filename __shake clear;
SAS Macros
+ @li mf_getuniquefileref.sas
+ @li mf_getuniquename.sas
+ @li mf_isblank.sas
@li mf_loc.sas
@li mm_tree.sas
- @li mf_getuniquefileref.sas
- @li mf_isblank.sas
@li mp_abort.sas
- @param metaloc= the metadata folder to export
- @param secureref= fileref containing the username / password (should point to
- a file in a secure location). Leave blank to substitute $bash type vars.
- @param outref= fileref to which to write the command
- @param cmdoutloc= the directory to which the command will write the SPK
- (default=WORK)
- @param cmdoutname= the name of the spk / log files to create (will be
- identical just with .spk or .log extension)
+
+ @param [in] metaloc= the metadata folder to export
+ @param [in] secureref= fileref containing the username / password (should
+ point to a file in a secure location). Leave blank to substitute $bash vars.
+ @param [in] excludevars= (0) A space seperated list of macro variable names,
+ each of which contains a value that should be used to filter the output
+ objects.
+ @param [out] outref= fileref to which to write the command
+ @param [out] cmdoutloc= (%sysfunc(pathname(work))) The directory to which the
+ command will write the SPK
+ @param [out] cmdoutname= (mmxport) The name of the spk / log files to create
+ (will be identical just with .spk or .log extension)
@version 9.4
@author Allan Bowe
@@ -17744,6 +17752,7 @@ filename __shake clear;
%macro mm_spkexport(metaloc=
,secureref=
+ ,excludevars=0
,outref=
,cmdoutloc=%sysfunc(pathname(work))
,cmdoutname=mmxport
@@ -17755,7 +17764,7 @@ filename __shake clear;
%end;
/* set creds */
-%local mmxuser mmxpath;
+%local mmxuser mmxpath i var;
%let mmxuser=$1;
%let mmxpass=$2;
%if %mf_isblank(&secureref)=0 %then %do;
@@ -17763,38 +17772,47 @@ filename __shake clear;
%end;
/* setup metadata connection options */
-%local host port platform_object_path connx_string;
+%local host port platform_object_path ds;
%let host=%sysfunc(getoption(metaserver));
%let port=%sysfunc(getoption(metaport));
%let platform_object_path=%mf_loc(POF);
+%let ds=%mf_getuniquename(prefix=spkexportable);
-%let connx_string=%str(-host &host -port &port -user &mmxuser %trim(
- )-password &mmxpass);
-
-%mm_tree(root=%str(&metaloc) ,types=EXPORTABLE ,outds=exportable)
+%mm_tree(root=%str(&metaloc) ,types=EXPORTABLE ,outds=&ds)
%if %mf_isblank(&outref)=1 %then %let outref=%mf_getuniquefileref();
data _null_;
- set exportable end=last;
+ set &ds end=last;
file &outref lrecl=32767;
length str $32767;
if _n_=1 then do;
put "cd ""&platform_object_path"" \";
- put "; ./ExportPackage &connx_string -disableX11 \";
- put " -package ""&cmdoutloc/&cmdoutname..spk"" \";
+ put "; ./ExportPackage -host &host -port &port -user &mmxuser \";
+ put " -disableX11 -password &mmxpass \"
+ put " -package ""&cmdoutloc/&cmdoutname..spk"" \";
end;
+/* exclude particular patterns from the exported SPK */
+%if "&excludevars" ne "0" %then %do;
+ /* ignore top level folder else all subcontent will be exported regardless */
+ if _n_>1;
+ %do i=1 %to %sysfunc(countw(&excludevars));
+ %let var=%scan(&excludevars,&i);
+ if index(path,symget("&var")) ne 0;
+ %end;
+%end;
str=' -objects '!!cats('"',path,'/',name,"(",publictype,')" \');
put str;
if last then put " -log ""&cmdoutloc/&cmdoutname..log"" 2>&1 ";
run;
%mp_abort(iftrue= (&syscc ne 0)
- ,mac=&sysmacroname
+ ,mac=mm_spkexport
,msg=%str(syscc=&syscc)
)
-%mend mm_spkexport;/**
+%mend mm_spkexport;
+/**
@file mm_tree.sas
@brief Returns all folders / subfolder content for a particular root
@details Shows all members and SubTrees for a particular root.
@@ -20539,7 +20557,8 @@ data _null_;
put ' %else %if %symexist(&metavar) %then %do; ';
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
- put ' %else %let user=%scan(&&&metavar,1,@); ';
+ put ' /* but be sure to quote in case of usernames with commas */ ';
+ put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
put ' %end; ';
put ' %else %let user=&sysuserid; ';
put ' ';
diff --git a/base/mf_verifymacvars.sas b/base/mf_verifymacvars.sas
index ccab333..3ca00ad 100755
--- a/base/mf_verifymacvars.sas
+++ b/base/mf_verifymacvars.sas
@@ -59,7 +59,7 @@
%goto exit_success;
%exit_err:
- %put %str(ERR)OR: &abortmsg;
+ %put &abortmsg;
%mf_abort(iftrue=(&mabort ne SOFT),
mac=mf_verifymacvars,
msg=%str(&abortmsg)
diff --git a/meta/mm_createwebservice.sas b/meta/mm_createwebservice.sas
index 4b41b4f..7e54e4b 100644
--- a/meta/mm_createwebservice.sas
+++ b/meta/mm_createwebservice.sas
@@ -453,7 +453,8 @@ data _null_;
put ' %else %if %symexist(&metavar) %then %do; ';
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
- put ' %else %let user=%scan(&&&metavar,1,@); ';
+ put ' /* but be sure to quote in case of usernames with commas */ ';
+ put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
put ' %end; ';
put ' %else %let user=&sysuserid; ';
put ' ';
diff --git a/meta/mm_spkexport.sas b/meta/mm_spkexport.sas
index e51250e..7eea1e3 100644
--- a/meta/mm_spkexport.sas
+++ b/meta/mm_spkexport.sas
@@ -49,20 +49,25 @@
SAS Macros
+ @li mf_getuniquefileref.sas
+ @li mf_getuniquename.sas
+ @li mf_isblank.sas
@li mf_loc.sas
@li mm_tree.sas
- @li mf_getuniquefileref.sas
- @li mf_isblank.sas
@li mp_abort.sas
- @param metaloc= the metadata folder to export
- @param secureref= fileref containing the username / password (should point to
- a file in a secure location). Leave blank to substitute $bash type vars.
- @param outref= fileref to which to write the command
- @param cmdoutloc= the directory to which the command will write the SPK
- (default=WORK)
- @param cmdoutname= the name of the spk / log files to create (will be
- identical just with .spk or .log extension)
+
+ @param [in] metaloc= the metadata folder to export
+ @param [in] secureref= fileref containing the username / password (should
+ point to a file in a secure location). Leave blank to substitute $bash vars.
+ @param [in] excludevars= (0) A space seperated list of macro variable names,
+ each of which contains a value that should be used to filter the output
+ objects.
+ @param [out] outref= fileref to which to write the command
+ @param [out] cmdoutloc= (%sysfunc(pathname(work))) The directory to which the
+ command will write the SPK
+ @param [out] cmdoutname= (mmxport) The name of the spk / log files to create
+ (will be identical just with .spk or .log extension)
@version 9.4
@author Allan Bowe
@@ -71,6 +76,7 @@
%macro mm_spkexport(metaloc=
,secureref=
+ ,excludevars=0
,outref=
,cmdoutloc=%sysfunc(pathname(work))
,cmdoutname=mmxport
@@ -82,7 +88,7 @@
%end;
/* set creds */
-%local mmxuser mmxpath;
+%local mmxuser mmxpath i var;
%let mmxuser=$1;
%let mmxpass=$2;
%if %mf_isblank(&secureref)=0 %then %do;
@@ -90,35 +96,43 @@
%end;
/* setup metadata connection options */
-%local host port platform_object_path connx_string;
+%local host port platform_object_path ds;
%let host=%sysfunc(getoption(metaserver));
%let port=%sysfunc(getoption(metaport));
%let platform_object_path=%mf_loc(POF);
+%let ds=%mf_getuniquename(prefix=spkexportable);
-%let connx_string=%str(-host &host -port &port -user &mmxuser %trim(
- )-password &mmxpass);
-
-%mm_tree(root=%str(&metaloc) ,types=EXPORTABLE ,outds=exportable)
+%mm_tree(root=%str(&metaloc) ,types=EXPORTABLE ,outds=&ds)
%if %mf_isblank(&outref)=1 %then %let outref=%mf_getuniquefileref();
data _null_;
- set exportable end=last;
+ set &ds end=last;
file &outref lrecl=32767;
length str $32767;
if _n_=1 then do;
put "cd ""&platform_object_path"" \";
- put "; ./ExportPackage &connx_string -disableX11 \";
- put " -package ""&cmdoutloc/&cmdoutname..spk"" \";
+ put "; ./ExportPackage -host &host -port &port -user &mmxuser \";
+ put " -disableX11 -password &mmxpass \"
+ put " -package ""&cmdoutloc/&cmdoutname..spk"" \";
end;
+/* exclude particular patterns from the exported SPK */
+%if "&excludevars" ne "0" %then %do;
+ /* ignore top level folder else all subcontent will be exported regardless */
+ if _n_>1;
+ %do i=1 %to %sysfunc(countw(&excludevars));
+ %let var=%scan(&excludevars,&i);
+ if index(path,symget("&var")) ne 0;
+ %end;
+%end;
str=' -objects '!!cats('"',path,'/',name,"(",publictype,')" \');
put str;
if last then put " -log ""&cmdoutloc/&cmdoutname..log"" 2>&1 ";
run;
%mp_abort(iftrue= (&syscc ne 0)
- ,mac=&sysmacroname
+ ,mac=mm_spkexport
,msg=%str(syscc=&syscc)
)
-%mend mm_spkexport;
\ No newline at end of file
+%mend mm_spkexport;
diff --git a/tests/sas9only/mm_spkexport.test.sas b/tests/sas9only/mm_spkexport.test.sas
new file mode 100644
index 0000000..4536ea7
--- /dev/null
+++ b/tests/sas9only/mm_spkexport.test.sas
@@ -0,0 +1,41 @@
+/**
+ @file
+ @brief Testing mm_webout macro
+
+ SAS Macros
+ @li mm_spkexport.sas
+ @li mp_assert.sas
+ @li mp_as
+
+**/
+
+
+%* create sample text file as input to the macro;
+filename tmp temp;
+data _null_;
+ file tmp;
+ put '%let mmxuser="sasdemo";';
+ put '%let mmxpass="Mars321";';
+run;
+
+filename myref "%sysfunc(pathname(work))/mmxexport.sh"
+ permission='A::u::rwx,A::g::r-x,A::o::---';
+%mp_assertscope(SNAPSHOT)
+%mm_spkexport(metaloc=%str(/Shared Data)
+ ,outref=myref
+ ,secureref=tmp
+ ,cmdoutloc=%str(/tmp)
+)
+%mp_assertscope(COMPARE)
+
+data _null_;
+ infile tmp;
+ input;
+ putlog _infile_;
+ call symputx('nobs',_n_);
+run;
+
+%mp_assert(
+ iftrue=(&nobs>2),
+ desc=Check if content was created
+)
diff --git a/viya/mv_createwebservice.sas b/viya/mv_createwebservice.sas
index 16b8601..6b73e1d 100644
--- a/viya/mv_createwebservice.sas
+++ b/viya/mv_createwebservice.sas
@@ -655,7 +655,8 @@ data _null_;
put ' %else %if %symexist(&metavar) %then %do; ';
put ' %if %length(&&&metavar)=0 %then %let user=&sysuserid; ';
put ' /* sometimes SAS will add @domain extension - remove for consistency */ ';
- put ' %else %let user=%scan(&&&metavar,1,@); ';
+ put ' /* but be sure to quote in case of usernames with commas */ ';
+ put ' %else %let user=%unquote(%scan(%quote(&&&metavar),1,@)); ';
put ' %end; ';
put ' %else %let user=&sysuserid; ';
put ' ';