Usage Note 31025: Sample code for verifying a table ID from the SAS® Metadata Server
Users sometimes need to verify that a table exists in the SAS® IT Management Solutions repository that is used by SAS® IT Resource Management. Two methods for performing this action are presented below. Use either method to verify the presence of a table (an aggregation, for example) in the SAS IT Management Solutions repository.
Note: You should ensure that you have a working backup copy of your SAS IT Resource Management data sets before attempting either of these methods.
There are several things to remember before you proceed:
- The code samples below verify the table ID and the presence of the table.
- It is best to run this code with a REGION (job card) of 500Mb or more.
- Executing this code requires the same SAS® Foundation server that you use from SAS® Data Integration Studio. Therefore, you must ensure that you have set up your Java environment correctly.
- You can submit this code from the Source Editor in SAS Data Integration Studio.
- To find the metadata ID for a table, right-click the table in SAS Data Integration Studio, select Properties, and then click the Advanced tab. The last entry in that table is Id.
Method #1:
%let metaPort = %nrquote(port_number);
%let metaServer = %nrquote(machine_name);
%let metaRepository = %nrquote(ITMS);
%let metaUser = %nrquote(Admin userid);
%let metaPassword = %nrquote(password);
/* Set metadata options */
options metaport = &metaPort
metaserver = "&metaServer"
metarepository = "&metaRepository";
%macro findTable(tableID=);
%if "&tableID" eq "" %then %goto error;
data _null_;
attrib message length=$32767;
dcl javaobj dispatch('com/sas/solutions/itms/omil/FoundationDispatcher');
dispatch.callVoidMethod('initialize',"&metaServer","&metaPort","&metaUser","&metaPassword");
dispatch.callStringMethod('getMessage',message);
put message=;
_connected=0; /* assume false */
dispatch.callIntMethod('isConnected',_connected);
if (_connected) then do;
_found=0; /* assume false */
dispatch.callIntMethod('setActiveObject',"&tableID",'PhysicalTable',_found);
dispatch.callStringMethod('getMessage',message);
put message=;
if (_found) then do;
put "NOTE: Successfully found physical table by ID=&tableID";
end;
else do;
put "ERROR: Connected OK but failed to find physical table by ID=&tableID";
end;
end;
else do;
put 'ERROR: Failed to connect, rc= ' _connected;
end;
run;
%goto endit;
%error: %put The parameter tableID= is required.;
%endit:
%mend;
%findTable(tableID=A57CX6K3.AJ000003);
Method #2:
%let metaPort = %nrquote(port_number);
%let metaServer = %nrquote(machine_name);
%let metaRepository = %nrquote(ITMS);
%let metaUser = %nrquote(userid);
%let metaPassword = %nrquote(password);
/* Set metadata options */
options metaport = &metaPort
metaserver = "&metaServer"
metarepository = "&metaRepository";
%macro findTable(tableID=);
%if "&tableID" eq "" %then %goto error;
filename output catalog "work.temp.output.source";
filename input catalog "work.temp.input.source";
data _null_;
file input;
xml= '<GetMetadata><Metadata><PhysicalTable Id="'||
trim("&tableID")||
'" Name="" Desc="" MetadataCreated="" NumRows="">
<ColumnList/>
<ObjectNote/>
</PhysicalTable>
</Metadata>
<Ns>SAS</Ns>
<Flags>1</Flags>
<Options/>
</GetMetadata>';
put xml;
run;
proc METADATA
server="&metaServer"
port=&metaPort
userid="&metaUser"
password="&metaPassword"
in=input
out=output;
run;
data _null_;
infile input length=len;
length card $32767;
input card $varying32767. len;
put _infile_;
run;
data _null_;
infile output length=len;
length card $32767;
input card $varying32767. len;
put _infile_;
run;
%goto endit;
%error: %put The parameter tableID= is required.;
%endit:
%mend;
%findTable(tableID=A57CX6K3.AJ000003);
Operating System and Release Information
SAS System | SAS IT Security Management-Server | z/OS | 9.1 TS1M3 SP4 | |
Microsoft® Windows® for 64-Bit Itanium-based Systems | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows XP 64-bit Edition | 9.1 TS1M3 SP4 | |
Microsoft® Windows® for x64 | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Advanced Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Datacenter Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Server | 9.1 TS1M3 SP4 | |
Microsoft Windows 2000 Professional | 9.1 TS1M3 SP4 | |
Microsoft Windows NT Workstation | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Datacenter Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Enterprise Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows Server 2003 Standard Edition | 9.1 TS1M3 SP4 | |
Microsoft Windows XP Professional | 9.1 TS1M3 SP4 | |
Windows Vista | 9.1 TS1M3 SP4 | |
64-bit Enabled AIX | 9.1 TS1M3 SP4 | |
64-bit Enabled HP-UX | 9.1 TS1M3 SP4 | |
64-bit Enabled Solaris | 9.1 TS1M3 SP4 | |
HP-UX IPF | 9.1 TS1M3 SP4 | |
Linux | 9.1 TS1M3 SP4 | |
Tru64 UNIX | 9.1 TS1M3 SP4 | |
*
For software releases that are not yet generally available, the Fixed
Release is the software release in which the problem is planned to be
fixed.
Date Modified: | 2012-02-10 15:17:24 |
Date Created: | 2008-01-25 11:27:59 |