1
0
mirror of https://github.com/sasjs/core.git synced 2026-03-09 20:48:10 +00:00

feat: new mx_createjob macro and associated test

This commit is contained in:
allan
2026-02-09 00:51:30 +00:00
parent 641966eed8
commit c1f1fcdebf
6 changed files with 141 additions and 34 deletions

View File

@@ -1,6 +0,0 @@
FROM gitpod/workspace-full
RUN sudo apt-get update \
&& sudo apt-get install -y doxygen \
&& sudo apt-get install -y graphviz \
&& sudo rm -rf /var/lib/apt/lists/*

View File

@@ -1,27 +0,0 @@
tasks:
- init: npm install -g npm
- command: npm i
- command: npm i -g @sasjs/cli
image:
file: .gitpod.dockerfile
vscode:
extensions:
- sasjs.sasjs-for-vscode
github:
prebuilds:
# enable for the master/default branch (defaults to true)
master: true
# enable for all branches in this repo (defaults to false)
branches: false
# enable for pull requests coming from this repo (defaults to true)
pullRequests: true
# enable for pull requests coming from forks (defaults to false)
pullRequestsFromForks: true
# add a "Review in Gitpod" button as a comment to pull requests (defaults to true)
addComment: true
# add a "Review in Gitpod" button to pull requests (defaults to false)
addBadge: false
# add a label once the prebuild is ready to pull requests (defaults to false)
addLabel: prebuilt-in-gitpod

View File

@@ -1,6 +1,5 @@
all.sas all.sas
build.py build.py
.gitpod*
tests/ tests/
sasjs/ sasjs/
.github/ .github/

View File

@@ -0,0 +1,27 @@
/**
@file
@brief Testing mx_createjob.sas macro
Be sure to run <code>%let mcTestAppLoc=/Public/temp/macrocore;</code> when
running in Studio
<h4> SAS Macros </h4>
@li mx_createjob.sas
@li mp_assert.sas
**/
filename ft15f001 temp;
parmcards4;
data example1;
set sashelp.class;
run;
%put Job executed successfully;
;;;;
%mx_createjob(path=&mcTestAppLoc/jobs,name=testjob,replace=YES)
%mp_assert(
iftrue=(&syscc=0),
desc=No errors after job creation,
outds=work.test_results
)

111
xplatform/mx_createjob.sas Normal file
View File

@@ -0,0 +1,111 @@
/**
@file mx_createjob.sas
@brief Create a job in SAS 9, Viya or SASjs
@details Creates a Stored Process in SAS 9, a Job Execution Service in SAS
Viya, or a Stored Program on SASjs Server - depending on the executing
environment.
Usage:
%* compile macros ;
filename mc url "https://raw.githubusercontent.com/sasjs/core/main/all.sas";
%inc mc;
%* write some code;
filename ft15f001 temp;
parmcards4;
data example1;
set sashelp.class;
run;
;;;;
%* create the job;
%mx_createjob(path=/Public/app/jobs,name=myjob,replace=YES)
<h4> SAS Macros </h4>
@li mf_getplatform.sas
@li mm_createstp.sas
@li ms_createfile.sas
@li mv_createjob.sas
@param [in,out] path= The full folder path where the job will be created
@param [in,out] name= Job name. Avoid spaces.
@param [in] desc= The description of the job (optional)
@param [in] precode= Space separated list of filerefs, pointing to the code
that needs to be attached to the beginning of the job (optional)
@param [in] code= (ft15f001) Space seperated fileref(s) of the actual code to
be added
@param [in] replace= (YES) Select YES to replace any existing job in that
location
@param [in] mDebug= (0) set to 1 to show debug messages in the log
@author Allan Bowe
<h4> Related Macros </h4>
@li mx_createjob.test.sas
@li mx_createwebservice.sas
**/
%macro mx_createjob(path=HOME
,name=initJob
,precode=
,code=ft15f001
,desc=This job was created by the mx_createjob macro
,replace=YES
,mdebug=0
)/*/STORE SOURCE*/;
%if &syscc ge 4 %then %do;
%put syscc=&syscc - &sysmacroname will not execute in this state;
%return;
%end;
/* combine precode and code into a single file */
%local tempref x fref freflist;
%let tempref=%mf_getuniquefileref();
%local work tmpfile;
%let work=%sysfunc(pathname(work));
%let tmpfile=&tempref..sas;
filename &tempref "&work/&tmpfile";
%let freflist=&precode &code ;
%do x=1 %to %sysfunc(countw(&freflist));
%let fref=%scan(&freflist,&x);
%put &sysmacroname: adding &fref;
data _null_;
file &tempref lrecl=3000 termstr=crlf mod;
infile &fref lrecl=3000;
input;
put _infile_;
run;
%end;
%local platform; %let platform=%mf_getplatform();
%if &platform=SASVIYA %then %do;
%if "&path"="HOME" %then %let path=/Users/&sysuserid/My Folder;
%mv_createjob(path=&path
,name=&name
,code=&tempref
,desc=&desc
,replace=&replace
)
%end;
%else %if &platform=SASJS %then %do;
%if "&path"="HOME" %then %let path=/Users/&_sasjs_username/My Folder;
%ms_createfile(&path/&name..sas
,inref=&tempref
,mdebug=&mdebug
)
%end;
%else %do;
%if "&path"="HOME" %then %let path=/User Folders/&_METAPERSON/My Folder;
%mm_createstp(stpname=&name
,filename=&tmpfile
,directory=&work
,tree=&path
,stpdesc=&desc
,mDebug=&mdebug
)
%end;
filename &tempref clear;
%mend mx_createjob;

View File

@@ -48,6 +48,9 @@ Usage:
@author Allan Bowe @author Allan Bowe
<h4> Related Macros </h4>
@li mx_createjob.sas
**/ **/
%macro mx_createwebservice(path=HOME %macro mx_createwebservice(path=HOME