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**/
22
23%macro mm_getstpinfo(pgm
24 ,outds=work.mm_getstpinfo
25 ,mDebug=0
26);
27
28%local mD;
29%if &mDebug=1 %then %let mD=;
30%else %let mD=%str(*);
31%&mD.put Executing &sysmacroname..sas;
32%&mD.put _local_;
33
34data &outds;
35 length type stp_uri tsuri servercontext value $200
36 StoredProcessConfiguration $1000 sourcecode_first32k $32767;
37 keep path stp_uri sourcecode_first32k StoredProcessConfiguration
38 servercontext;
39 call missing (of _all_);
40 path="&pgm(StoredProcess)";
41 /* first, find the STP ID */
42 if metadata_pathobj("",path,"StoredProcess",type,stp_uri)>0 then do;
43 /* get attributes */
44 cnt=1;
45 do while (metadata_getnasn(stp_uri,"Notes",cnt,tsuri)>0);
46 rc1=metadata_getattr(tsuri,"Name",value);
47 &mD.put tsuri= value=;
48 if value="SourceCode" then do;
49 rc2=metadata_getattr(tsuri,"StoredText",sourcecode_first32k);
50 end;
51 else if value="Stored Process" then do;
52 rc3=metadata_getattr(tsuri,"StoredText",StoredProcessConfiguration);
53 end;
54 cnt+1;
55 end;
56 /* get context (should only be one) */
57 rc4=metadata_getnasn(stp_uri,"ComputeLocations",1,tsuri);
58 rc5=metadata_getattr(tsuri,"Name",servercontext);
59 end;
60 else do;
61 put 'ERR' +(-1) "OR: could not find " path;
62 put (_all_)(=);
63 end;
64 &md.put (_all_)(=);
65run;
66
67%mend mm_getstpinfo ;