# Independent Variables as Object

**URL:** <https://techcommunity.softwareag.com/t/independent-variables-as-object/60575>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [February 15, 2006, 4:23pm UTC](https://techcommunity.softwareag.com/t/independent-variables-as-object/60575 "2006-02-15T16:23:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![magsbg](https://avatars.discourse-cdn.com/v4/letter/m/f4b2a3/32.png) [@magsbg](https://techcommunity.softwareag.com/u/magsbg)\
**Post date:** [February 15, 2006, 4:23pm UTC](https://techcommunity.softwareag.com/t/independent-variables-as-object/60575/1 "2006-02-15T16:23:34Z")

</div>

We use independent variables (AIV) a lot. Is there a way to define an object (like LDA, PDA, GDA) and to write something like INDEPENDENT USING … ?

---

<div class="post-metadata">

**Author:** ![Peter\_Pag](https://avatars.discourse-cdn.com/v4/letter/p/eb9ed0/32.png) [@Peter\_Pag](https://techcommunity.softwareag.com/u/Peter_Pag)\
**Post date:** [February 15, 2006, 8:19pm UTC](https://techcommunity.softwareag.com/t/independent-variables-as-object/60575/2 "2006-02-15T20:19:55Z")

</div>

If you use AIVs “a lot” why don’t you use a GDA?

However, if you nest programs with CALLNAT this approach will not work.

But in this case you should decide to write an “AIV-Server”, e.g. a class, that serves all put and get requests to global variables. Then you only have to have a handle to that AIV-Server to get all the values you need. This handle can reside in a single independent.

You can use

```auto
DEFINE DATA INDEPENDENT 
1 +AIV-SERVER HANDLE OF OBJECT 
```

in each program.  
Or you can initialize this variable at logon time (then the variable is available at compile time). To achieve this, you should create a GDA named COMMON (with a single, unused field) and a program ACOMMON containing

```auto
DEFINE DATA 
GLOBAL USING COMMON
INDEPENDENT 
1 +AIV-SERVER HANDLE OF OBJECT 
END-DEFINE
CREATE OBJECT +AIV-SERVER OF CLASS "aiv-server"
do some inits here
END
```

At logon time Natural searches for a couple COMMON and ACOMMON and if available, it executes ACOMMON, which initializes the AIV. In you programs you can then use +AIV-SERVER without the need to define this variable.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/techcommunity/original/3X/c/d/cd19967bb605d28a72d77eb83a1cae22f3df2eb8.svg) [@system](https://techcommunity.softwareag.com/u/system)\
**Post date:** [April 2, 2021, 2:40pm UTC](https://techcommunity.softwareag.com/t/independent-variables-as-object/60575/3 "2021-04-02T14:40:28Z")

</div>


