![]() |
![]() |
Introduction to the Metadata API |
The following steps illustrate how to use the API to select and display the metadata for a particular detail table in a particular data warehouse that is created by SAS/Warehouse Administrator. For the sake of simplicity, assume that you have already attached to the relevant metadata repositories, that the metadata that you want is in the A000000E repository, and that the type ID for the SAS/Warehouse Administrator detail table is WHDETAIL.
Concatenate the DW_REPOS_ID (A000000E ) with the metadata type ID (WHDETAIL) and store them in the variable TYPE.
type=dw_repos_id||'.WHDETAIL';
Define a list (L_OBJS) to hold the results of a read operation in the next step.
l_objs=makelist();
Call the _GET_METADATA_OBJECTS_ method, which accepts the REPOSID.TYPEID that is assigned to the TYPE variable. It then loads the L_OBJS list with the instance IDs and names of WHDETAIL objects in repository A000000E .
call send(i_api,'_GET_METADATA_OBJECTS_',rc, type,l_objs);
Use the PUTLIST function to display the list in the Message Window or SASLOG.
call putlist(l_objs,'WAREHOUSE OBJECTS',2); WAREHOUSE OBJECTS ( A000000E.WHDETAIL.A000001L='Customer detail table' A000000E.WHDETAIL.A000002X='Product detail table' A000000E.WHDETAIL.A000003M='Customer detail table' A000000E.WHDETAIL.A000004H='Sales fact table' A000000E.WHDETAIL.A000005U='Oracle A000000E.WHDETAIL.A000006Q='Sybase' A000000E.WHDETAIL.A000007L='Remote Detail Table' A000000E.WHDETAIL.A000008I='Suppliers' )[421]
Search the list for the unique ID of the product detail table and pass it to _GET_METADATA_ in order to retrieve information about that table.
If you are interested in particular properties for a given metadata type, you can pass those properties to the _GET_METADATA_ method as named items. For example, in the code that follows, the LIBRARY, COLUMNS, and TABLE NAME properties for the detail table metadata type are inserted in the metadata property list (l_meta) that is passed to the _GET_METADATA_ method.
index=searchc(l_objs,'Product',1,1,'Y','Y'); id=nameitem(l_objs,index); rc=clearlist(l_meta,'Y'); l_meta=insertc(l_meta,id,-1,'ID'); l_lib=makelist(); l_meta=insertl(l_meta,l_lib,-1,'LIBRARY'); l_cols=makelist(); l_meta=insertl(l_meta,l_cols,-1,'COLUMNS'); l_meta=insertc(l_meta,' ',-1,'TABLE NAME'); call send(i_api,'_GET_METADATA_',l_rc,l_meta); rc=putlist(l_meta,'PRODUCT table',2);
The method populates these sublists with the requested information.
PRODUCT table( ID='A000000E.WHDETAIL.A000002X' LIBRARY=( ID='A0000001.WHLIBRY.A000000U' NAME='Warehouse Data Library' DESC='' )[405] COLUMNS=( ( ID='A000000E.WHCOLDTL.A0000032' NAME='PRODNUM' DESC='product number' )[575] ( ID='A000000E.WHCOLDTL.A0000034' NAME='PRODNAME' DESC='product name' )[643] ( ID='A000000E.WHCOLDTL.A0000036' NAME='PRODID' DESC='product id/abbreviation' )[619] ( ID='A000000E.WHCOLTIM.A00000FU' NAME='_LOADTM' DESC='DateTime Stamp of when row was loaded' )[621] )[407]
The API enables you to read and write many metadata objects using techniques that are similar to those used in these steps.
![]() |
![]() |
Copyright © 2012 by SAS Institute Inc., Cary, NC, USA. All rights reserved.