Information about deployment directories (name and path) is created directly within the script via a DATA step and a 'datalines' statement.
1 Code Block
OPTIONS
Explanation : This block configures system options to establish a connection to the SAS metadata server. It specifies the host, port, user credentials, repository (Foundation), and connection protocol (BRIDGE).
Explanation : Defines a macro variable 'appcontext' for the context name. Then, a DATA step creates the 'depdirs' table in memory. This table contains two columns, 'Name' and 'Path', which are populated via the 'datalines' statement with the list of deployment directories to be created.
Copied!
/* Define the context to attach the deployment directories. */
%let appcontext = SASApp;
/* Create a dataset with each deployment directory name and path. */
data depdirs;
length Name Path $ 255;
input Name Path;
datalines;
DeploymentDir1 /tmp/depdir1
DeploymentDir2 /tmp/depdir2
;;
run;
1
/* Define the context to attach the deployment directories. */
2
%let appcontext = SASApp;
3
4
/* Create a dataset with each deployment directory name and path. */
5
DATA depdirs;
6
LENGTH Name Path $ 255;
7
INPUT Name Path;
8
DATALINES;
9
DeploymentDir1 /tmp/depdir1
10
DeploymentDir2 /tmp/depdir2
11
;;
12
RUN;
3 Code Block
DATA STEP
Explanation : This DATA _null_ step (which does not produce an output table) manages the main logic. It starts by resolving the application context's URI via 'metadata_resolve'. If the context is found, it reads the 'depdirs' table line by line. For each line, it uses 'metadata_newobj' to create a new 'Directory' object and 'metadata_setattr' to define its attributes, notably the path ('DirectoryName').
Copied!
data _null_;
/* Initialize variables. */
length type id appuri diruri $ 255;
call missing (of _character_);
/* Define query for context. */
appobj = "omsobj:ServerContext? @Name='&appcontext'";
/* Check for the existence of the context. */
rc=metadata_resolve(appobj,type,id);
/* If the context doesn't exist, throw an error and end the program. */
if rc ne 1 then do;
put "ERROR: A single context named &appcontext not found.";
stop;
end;
/* Read in the data set of deployment directories. */
set depdirs;
/* For each one, create the directory object as a child of the context */
/* defined above. */
rc=metadata_newobj("Directory",diruri,Name,"Foundation",appobj,"DataPackages");
/* Add the attribute defining the path. */
rc=metadata_setattr(diruri,"DirectoryName",Path);
/* Add some required attributes. */
rc=metadata_setattr(diruri,"UsageVersion","0");
rc=metadata_setattr(diruri,"IsRelative","0");
run;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
Copyright Info : Author: Greg Wootton Date: 14JUN2019
« Programmatically adding deployment directories is an advanced administration technique that ensures consistency across your server contexts (such as SASApp). By using metadata interface functions rather than the manual GUI, you eliminate human entry errors and enable the industrial deployment of technical folder structures across multi-tier environments. »
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.