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 mm_updatestpservertype.sas
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  <h4> Dependencies </h4>
12 
13  @param target= full path to the STP being deleted
14  @param type= Either WKS or STP depending on whether Workspace or Stored Process
15  type required
16 
17  @version 9.4
18  @author Allan Bowe
19 
20 **/
21 
22 %macro mm_updatestpservertype(
23  target=
24  ,type=
25 )/*/STORE SOURCE*/;
26 
27 /**
28  * Check STP does exist
29  */
30 %local cmtype;
31 data _null_;
32  length type uri $256;
33  rc=metadata_pathobj("","&target",'StoredProcess',type,uri);
34  call symputx('cmtype',type,'l');
35  call symputx('stpuri',uri,'l');
36 run;
37 %if &cmtype ne ClassifierMap %then %do;
38  %put WARNING: No Stored Process found at &target;
39  %return;
40 %end;
41 
42 %local newtype;
43 %if &type=WKS %then %let newtype=Wks;
44 %else %let newtype=Sps;
45 
46 %local result;
47 %let result=NOT FOUND;
48 data _null_;
49  length uri name value $256;
50  n=1;
51  do while(metadata_getnasn("&stpuri","Notes",n,uri)>0);
52  n+1;
53  rc=metadata_getattr(uri,"Name",name);
54  if name='Stored Process' then do;
55  rc = METADATA_SETATTR(uri,'StoredText','<?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;
63 run;
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;