diff --git a/all.sas b/all.sas
index a2af201..f5a7f34 100644
--- a/all.sas
+++ b/all.sas
@@ -1890,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)
@@ -17726,20 +17726,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
@@ -17748,6 +17753,7 @@ filename __shake clear;
%macro mm_spkexport(metaloc=
,secureref=
+ ,excludevars=0
,outref=
,cmdoutloc=%sysfunc(pathname(work))
,cmdoutname=mmxport
@@ -17759,7 +17765,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;
@@ -17767,38 +17773,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.
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_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
+)