Production Ready Macros for SAS Application Developers
https://github.com/sasjs/core
mm_updatestpservertype.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Updates a type 2 stored process to run on STP or WKS context
4 @details Only works on Type 2 (9.3 compatible) STPs
5
6 Usage:
7
8 %mm_updatestpservertype(target=/some/meta/path/myStoredProcess
9 ,type=WKS)
10
11
12 @param target= full path to the STP being deleted
13 @param type= Either WKS or STP depending on whether Workspace or
14 Stored Process type required
15
16 @version 9.4
17 @author Allan Bowe
18
19**/
20
21%macro mm_updatestpservertype(
22 target=
23 ,type=
24)/*/STORE SOURCE*/;
25
26/**
27 * Check STP does exist
28 */
29%local cmtype;
30data _null_;
31 length type uri $256;
32 rc=metadata_pathobj("","&target",'StoredProcess',type,uri);
33 call symputx('cmtype',type,'l');
34 call symputx('stpuri',uri,'l');
35run;
36%if &cmtype ne ClassifierMap %then %do;
37 %put %str(WARN)ING: No Stored Process found at ⌖
38 %return;
39%end;
40
41%local newtype;
42%if &type=WKS %then %let newtype=Wks;
43%else %let newtype=Sps;
44
45%local result;
46%let result=NOT FOUND;
47data _null_;
48 length uri name value $256;
49 n=1;
50 do while(metadata_getnasn("&stpuri","Notes",n,uri)>0);
51 n+1;
52 rc=metadata_getattr(uri,"Name",name);
53 if name='Stored Process' then do;
54 rc = METADATA_SETATTR(uri,'StoredText'
55 ,'<?xml version="1.0" encoding="UTF-8"?>'
56 !!'<StoredProcess><ServerContext LogicalServerType="'!!"&newtype"
57 !!'" OtherAllowed="false"/><ResultCapabilities Package="false" '
58 !!' Streaming="true"/><OutputParameters/></StoredProcess>');
59 if rc=0 then call symputx('result','SUCCESS');
60 stop;
61 end;
62 end;
63run;
64%if &result=SUCCESS %then %put NOTE: SUCCESS: STP &target changed to &type type;
65%else %put %str(ERR)OR: Issue with &sysmacroname;
66
67%mend mm_updatestpservertype;