# Views Definition Object

> Source: https://manual.pvxplus.com/views-system/views-definition-object/overview

The views definition object, **[ViewCtl](https://manual.pvxplus.com/views-system/views-definition-object/viewctl)**, can be used to create, update and delete data sources, views and data groups. It provides the same functionality programmatically that is available via **[Data Source Maintenance](https://manual.pvxplus.com/views-system/data-source-maintenance/overview)** and **[View Maintenance](https://manual.pvxplus.com/views-system/view-maintenance/overview)**.

This object *(\*views/viewctl.pvc*) embodies the entire view definition and can be created from the beginning or loaded from the definition stored in the view definition files, updated and then saved back into the definition files.

**ViewCtl**is created by the following command:

```
ObjID = NEW ("*views/viewctl [,ViewsDirectory$], ERR=stmtref)
```

***Structural Overview***

The main **[ViewCtl](https://manual.pvxplus.com/views-system/views-definition-object/viewctl)** object delegates functionality to subordinate objects for dealing with individual view, data source and data group definitions. These objects will in turn delegate functionality to another level of subordinates for dealing with calculated items, views items, data source items, and relationships.

Subordinate objects to **ViewCtl** include **[ViewDef](https://manual.pvxplus.com/views-system/views-definition-object/viewdef)**, **[CalcItem](https://manual.pvxplus.com/views-system/views-definition-object/calcitem)**, **[ViewItem](https://manual.pvxplus.com/views-system/views-definition-object/viewitem)**, **[DataGroup](https://manual.pvxplus.com/views-system/views-definition-object/datagroup)**, **[DataSource](https://manual.pvxplus.com/views-system/views-definition-object/datasource)**, **[DS_Item](https://manual.pvxplus.com/views-system/views-definition-object/ds-item)** and **[DS_Link](https://manual.pvxplus.com/views-system/views-definition-object/ds-link)**.

The structure of the views definition object is depicted in the following chart:

![](https://manual.pvxplus.com/migration-assets/800efa50595618693d7d3ed610e10c084d38a875c847831786b99a8d44146fdf.png)

**[ViewCtl](https://manual.pvxplus.com/views-system/views-definition-object/viewctl)** creates a group of **[ViewDef](https://manual.pvxplus.com/views-system/views-definition-object/viewdef)** objects to hold view information (one per view). More than one view can be maintained using this method. Each **[ViewDef](https://manual.pvxplus.com/views-system/views-definition-object/viewdef)** object creates a group of **[CalcItem](https://manual.pvxplus.com/views-system/views-definition-object/calcitem)** objects to define calculated expressions that are available to the view (one object per item), as well as **[ViewItem](https://manual.pvxplus.com/views-system/views-definition-object/viewitem)** objects to define the selected items within the view (one object per item).

**[DataSource](https://manual.pvxplus.com/views-system/views-definition-object/datasource)** objects are created to hold the definition of the primary data source of each view, as well as the definitions for related (or linked) data sources used by the views. Each DataSource object will in turn create a group of **[DS_Item](https://manual.pvxplus.com/views-system/views-definition-object/ds-item)** objects (one for each defined element in the data source) and a group of **[DS_Link](https://manual.pvxplus.com/views-system/views-definition-object/ds-link)** objects to define the parent-child relationships that exist for the data source.

Finally, a group of **[DataGroup](https://manual.pvxplus.com/views-system/views-definition-object/datagroup)** objects will define to which data groups the views and their data sources are assigned (one object per data group). Object groups are created using the **\*obj/group** utility that defines lists of related objects.

For a detailed list of the different components within the views definition structure, see **[ViewCtl Properties](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#viewctl_properties)** and **[ViewCtl Methods](https://manual.pvxplus.com/views-system/views-definition-object/viewctl#viewctl_methods)**, as well as its **[Subordinate Objects](https://manual.pvxplus.com/views-system/views-definition-object/subordinate-objects)**. In each of these, assume that the **Add *xxx*( )** and **Load *xxx*( )** methods return the object identifier of the object that has been added or loaded successfully, or 0 (zero) if not. All other methods return values of 1 (success) and 0 (failure), unless otherwise indicated.
