Metadata API Class _ADD_METADATA_ 17
Parameters
Parameter Type Description
i_api Class specifies the passed instance of METAAPI.CLASS. See “Using the
Metadata API Class” on page 14.
l_rc
N specifies the return codes for the method. A nonzero code indicates
failure and means that l_rc is an error list identifier. For the error
list format, see “Error Codes” on page 14.
l_meta L specifies the passed metadata property list for the object that is to
be added. For the general format of this list, see “Metadata
Property List” on page 14.
Details
l_meta
specifies the passed metadata property list for the object that is to be added.
To create a new instance of a particular type, the ID value in l_meta should be
resposid.typeid. If an instance ID is passed, it is ignored and replaced with a new
instance ID upon successful addition to the repository.
Not all metadata types (type IDs) can be added. The documentation for each
metadata type indicates whether it can be added or not. _ADD_METADATA_ will
return an error of any type that cannot be added.
Using _ADD_METADATA_
Be sure to check the return code of a write method call. A nonzero return indicates that
a failure has occurred while trying to write to the metadata. If a nonzero return code is
returned, none of the changes that are indicated by this method call will be made.
Example: Add a New Detail Table
l_meta=makelist();
/*
* Set which group to add this new table to.
*/
l_groups=makelist();
l_group=makelist();
l_groups=insertl(l_groups,l_group,-1);
l_group=insertc(l_group,group_id,-1,’ID’);
l_meta=insertl(l_meta,l_groups,-1,’GROUP’);
/*
* Use the same repository id as the group.
*/
18 _ADD_METADATA_ Chapter 2
repos_id=scan(group_id,1,’.’);
new_type=repos_id||’.WHDETAIL’;
l_meta=insertc(l_meta,new_type,-1,’ID’);
/*
* Set the name for the display.
*/
l_meta=insertc(l_meta,
’NEW TABLE’,-1,’NAME’);
/*
* Set the desc for the display.
*/
l_meta=insertc(l_meta,’New table added
through API’,-1,’DESC’);
/*
* Set an icon for the display.
*/
l_meta=insertc(l_meta,
’SASHELP.I0808.ADD.IMAGE’,-1,’ICON’);
/*
* Define a column. The COLUMNS property
* contains a sublist per column.
*/
l_cols=makelist();
l_col=makelist();
l_cols=insertl(l_cols,l_col,-1);
l_meta=insertl(l_meta,l_cols,-1,’COLUMNS’);
col_id=repos_id||’.’||’WHCOLUMN’;
l_col=insertc(l_col,col_id,-1,’ID’);
l_col=insertc(l_col,’CUSTOMER’,-1,’NAME’);
l_col=insertc(l_col,’Name of Customer’,-1,
’DESC’);
l_col=insertc(l_col,’C’,-1,’TYPE’);
l_col=insertn(l_col,75,-1,’LENGTH’);
/*
* Add any additional properties
*:
*:
*/
Metadata API Class _CLEAR_SECONDARY_REPOSITORY_ 19
/*
* Add the table.
*/
call send(i_api,’_ADD_METADATA_’,l_rc,l_meta);
if l_rc = 0 then do;
put ’Table Added successfully’;
end; /* if */
else do;
msg=getnitemc(l_rc,’MSG’,1,1,’ERROR:
_ADD_METADATA_ FAILED’);
put msg;
list_rc=dellist(l_rc);
end; /* else */
l_meta=dellist(l_meta,’Y’);
See Also
_DELETE_METADATA_, _UPDATE_METADATA_
_CLEAR_SECONDARY_REPOSITORY_
Detaches from a secondary repository
Category: Repository Methods
Syntax
CALL SEND(i_api, ’_CLEAR_SECONDARY_REPOSITORY_’, l_rc, repos_id);
20 _DELETE_METADATA_ Chapter 2
Parameters
Parameter Type Description
i_api
Class specifies the passed instance of METAAPI.CLASS. See “Using the
Metadata API Class” on page 14.
l_rc
N specifies the return codes for the method. A nonzero code indicates
failure and means that l_rc is an error list identifier. For the error
list format, see “Error Codes” on page 14.
repos_id
C specifies the passed repository ID that specifies the repository that
is to be detached from. For details about the repos_id parameter,
see “Identifying Metadata” on page 7.
Using _CLEAR_SECONDARY_REPOSITORY_
When you only want to be attached to the primary repository, use the
_CLEAR_SECONDARY_REPOSITORY_ method to detach from any secondary
repositories.
Use the _GET_METADATA_ method to return the list of possible secondary
repositories. Specify the REPOSITORIES property in the
l_meta list, and use the
returned metadata identifier from the _SET_PRIMARY_REPOSITORY_ method. See
the code examples under _SET_PRIMARY_REPOSITORY_ and
_SET_SECONDARY_REPOSITORY_ .
Example: Detach from a Secondary Repository
/* sec_repos_id is the REPOSID of the secondary repository that is
* to be detached from.
*/
call send(i_api, ’_SET_SECONDARY_REPOSITORY_’, l_rc, sec_repos_id);
See Also
_GET_METADATA_
_SET_SECONDARY_REPOSITORY_
_SET_PRIMARY_REPOSITORY_
_DELETE_METADATA_
Deletes specified metadata from a repository
Category: Write Methods
Syntax
CALL SEND(i_api, ’_DELETE_METADATA_’, l_rc, l_meta);
Metadata API Class _DELETE_METADATA_ 21
Parameters
Parameter Type Description
i_api Class specifies the passed instance of METAAPI.CLASS. See “Using the
Metadata API Class” on page 14.
l_rc
N specifies the return codes for the method. A nonzero code indicates
failure and means that l_rc is an error list identifier. For the error
list format, see “Error Codes” on page 14.
l_meta L specifies the passed metadata property list for the object that is to
be deleted. For the general format of this list, see “Metadata
Property List” on page 14.
Using _DELETE_METADATA
The object whose ID is included in the l_meta list will be deleted. Where appropriate,
the metadata API will enforce metadata integrity by deleting all other metadata that is
associated with the object that is being deleted.
CAUTION:
The _DELETE_METADATA_ method is destructive. Its changes cannot be reversed. When
you use this method in an application, verify the delete request before you issue the
method call.
Be sure to check the return code of a write method call. A nonzero return indicates
that a failure has occurred while trying to write to the metadata. If a nonzero return
code is returned, none of the changes that are indicated by this method call will be
made.
Example: Delete Column Definitions
/*
* Delete all the current column
* definitions for the passed id.
*/
l_meta=makelist();
l_meta=insertc(l_meta,selected_id,-1,’ID’);
/*
* Get all of the columns.
*/
l_meta=insertl(l_meta,0,-1,’COLUMNS’);
call send(i_api,’_GET_METADATA_’,l_rc,l_meta);
/*
* Continue if zero return code
* (removed for brevity of example)
*: