Back to Resources
Blog 2019-01-29 2 min read Kevin Petri

MODGEN and the erwin Script Client API

An overview of the erwin Script Client API and its use in automating data warehouse models with MODGEN.

heureka developed the MODGEN add-in for erwin to automate transformations in data warehouses. The version described at the time could generate a Data Vault model from a staging model. The erwin Script Client API (SCAPI) was indispensable to its development.

SCAPI is an extensive interface. It allows applications to create, open, and modify objects within a model, including tables, columns, and user-defined properties (UDPs).

Access Levels

The API distinguishes several access levels. At the standard SCD_SL_M0 level, applications can create, read, and write tables and columns. Simple properties can also be created and modified there.

Access to metadata and the ability to modify or delete UDPs require a session with elevated privileges at the SCD_SL_M1 level.

Persistence Units and Property Bags

Alongside persistence units, SCAPI provides property bags. They represent the properties of an object. In addition to a name and value, they contain useful flags. These indicate, for example, whether a value is null or scalar and whether a property is read-only.

Class and interface model of the erwin Script Client API

The SCAPI model connects persistence units, ModelObjects, collections, and properties.

ModelObject and ModelObjects

The most frequently used class is ModelObject. Tables and columns are examples of this class and can be accessed through the standard SCD_SL_M0 level.

ModelObjects, in the plural, is a collection of ModelObject instances. It contains an enumerator that supports iteration. The NewEnum property references the IEnumVARIANT interface, whose Next(), Skip(), Reset(), and Clone() methods control the iteration sequence.

A ModelObject also has a Properties property. The collection can be iterated in full or used to address one specific property.

Changes and Transactions

Changes to ModelObjects can be applied directly to the model. A transaction is opened before the objects are retrieved and committed after the required changes. Committing writes every change to the affected objects back to the corresponding erwin model.

Each object is classified by four identifiers:

  • SC_OBJID identifies the specific object.
  • SC_CLSID assigns the object to a class.
  • SC_MODELTYPEID represents the model type.
  • SC_CREATORID identifies the creator.

SCAPI code example that modifies one property on every table

Example of iterating over tables and changing a property.

The erwin API Reference for version 9.8 provides detailed information and further code examples.

Ready to move forward?

Talk to our experts about your specific challenges. We provide honest assessments and actionable recommendations.

Practical implementation

Turn this resource into an actionable next step

Discuss your current situation with heureka. Together, we can clarify priorities, ownership, and the most useful place to start.