Macros for SAS Application Developers
https://github.com/sasjs/core
Loading...
Searching...
No Matches
mm_getstpinfo.sas
Go to the documentation of this file.
1/**
2 @file
3 @brief Get the properties of a Stored Process
4 @details Extracts various properties and creates an output table in the
5 structure below:
6
7|STP_URI:$200.|SERVERCONTEXT:$200.|STOREDPROCESSCONFIGURATION:$1000.|SOURCECODE_FIRST32K:$32767.|PATH:$76.|
8|---|---|---|---|---|
9|`A5DN9TDQ.BH0000C8 `|`SASApp `|`<?xml version="1.0" encoding="UTF-8"?><StoredProcess><ServerContext LogicalServerType="Sps" OtherAllowed="false"/><ResultCapabilities Package="false" Streaming="true"/><OutputParameters/></StoredProcess> `|`%put first 32767 bytes of code; `|`/path/to/my/stp`|
10
11 @param [in] pgm The metadata path of the Stored Process
12 @param [out] outds= (work.mm_getstpinfo) The output table to create
13 @param [in] mdebug= (0) Set to 1 to enable DEBUG messages
14
15 <h4> Related Files </h4>
16 @li mm_getstpcode.sas
17 @li mm_getstps.sas
18 @li mm_createstp.sas
19 @li mm_deletestp.sas
20
21 @sasjslint {"maxLineLength": 292}
22**/
23
24%macro mm_getstpinfo(pgm
25 ,outds=work.mm_getstpinfo
26 ,mDebug=0
27);
28
29%local mD;
30%if &mDebug=1 %then %let mD=;
31%else %let mD=%str(*);
32%&mD.put Executing &sysmacroname..sas;
33%&mD.put _local_;
34
35data &outds;
36 length type stp_uri tsuri servercontext value $200
37 StoredProcessConfiguration $1000 sourcecode_first32k $32767;
38 keep path stp_uri sourcecode_first32k StoredProcessConfiguration
39 servercontext;
40 call missing (of _all_);
41 path="&pgm(StoredProcess)";
42 /* first, find the STP ID */
43 if metadata_pathobj("",path,"StoredProcess",type,stp_uri)>0 then do;
44 /* get attributes */
45 cnt=1;
46 do while (metadata_getnasn(stp_uri,"Notes",cnt,tsuri)>0);
47 rc1=metadata_getattr(tsuri,"Name",value);
48 &mD.put tsuri= value=;
49 if value="SourceCode" then do;
50 rc2=metadata_getattr(tsuri,"StoredText",sourcecode_first32k);
51 end;
52 else if value="Stored Process" then do;
53 rc3=metadata_getattr(tsuri,"StoredText",StoredProcessConfiguration);
54 end;
55 cnt+1;
56 end;
57 /* get context (should only be one) */
58 rc4=metadata_getnasn(stp_uri,"ComputeLocations",1,tsuri);
59 rc5=metadata_getattr(tsuri,"Name",servercontext);
60 end;
61 else do;
62 put 'ERR' +(-1) "OR: could not find " path;
63 put (_all_)(=);
64 end;
65 &md.put (_all_)(=);
66run;
67
68%mend mm_getstpinfo ;