# AIV Variables

**URL:** <https://techcommunity.softwareag.com/t/aiv-variables/79686>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [December 3, 2008, 7:59pm UTC](https://techcommunity.softwareag.com/t/aiv-variables/79686 "2008-12-03T19:59:46Z")\
**Posts on this page:** 5\
**Page:** 2

<div class="post-metadata">

**Author:** ![Douglas\_Kelly](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/douglas_kelly/32/102_2.png) [@Douglas\_Kelly](https://techcommunity.softwareag.com/u/Douglas_Kelly)\
**Post date:** [June 25, 2010, 9:03pm UTC](https://techcommunity.softwareag.com/t/aiv-variables/79686/21 "2010-06-25T21:03:59Z")

</div>

Your confusion reflects why Natural was changed to introduce the Global Data Area.

The AIV needs to have a definition before the program can be compiled. So, if you don’t want to put the definition in “SUBPROG”, then you have to do something to define the AIV before you can compile SUBPROG - such as running a program that already has the AIV defined. That puts the AIVs in the program in the AIV area in the workspace (try edit +V to see them). When you compile SUBPROG with reference to an AIV that is already in the AIV area, the definition is added to the compiled object.

Another approach was to always include the definition of the AIVs in the programs that were going to use them. The danger of this approach was that the definitions were not always compatible or correct, resulting in run time errors or data loss. So the alternative Graeme mentions became the best practice - always have a single module that does nothing but define the AIVs, catalog it and run it before compiling any programs. No format/length definitions should then be included in the programs/subprograms/etc.

Like all “global data”, AIVs are inherently non-modular and non-object oriented. Operations in one module can have side effects in other modules when global data (AIVs) is used.

---

<div class="post-metadata">

**Author:** ![Michele1](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@Michele1](https://techcommunity.softwareag.com/u/Michele1)\
**Post date:** [August 6, 2010, 5:12am UTC](https://techcommunity.softwareag.com/t/aiv-variables/79686/22 "2010-08-06T05:12:08Z")

</div>

I did not start another post, but I am having a problem with +AIV variables and putting them on the map.

How can I assign an +AIV variable as display only in a map when the AIV variable was populated in a different program?

Thanks for your help in advance…Michele :?:

---

<div class="post-metadata">

**Author:** ![Brian\_Johnson1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/brian_johnson1/32/163_2.png) [@Brian\_Johnson1](https://techcommunity.softwareag.com/u/Brian_Johnson1)\
**Post date:** [August 6, 2010, 7:56pm UTC](https://techcommunity.softwareag.com/t/aiv-variables/79686/23 "2010-08-06T19:56:03Z")

</div>

Hi Michele,

You would add an AIV to a map the same way you define local variables:

Ob M Ob D CLS ATT DEL CLS ATT DEL   
. . T D Blnk T I ?  
. . A D \_ A I )  
. . A N ¬ M D &  
. . M I : O D +  
. . O I (   
. .   
008 --010—±—±—±–030—±—±—±–050—±—±—±–070—±—  
ERROR-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
DATA-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
DATA-REQUEST-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
TRANS-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
TRANS-REQUEST-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
ERROR-REPLY-HOBJ (9999999999  
LE ID (XX  
NATPROC (XXXXXXXX

Edit the field with .E to provide your AIV name and format/length and AD attribute for display-only:

## Fld +LE-NATPROC Fmt A8

AD= OIL\_\_\_\_\_\_\_ ZP= SG= HE= \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Rls 0   
AL= \_\_\_\_\_ CD= \_\_ CV= \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ Mod User  
PM= \_\_ DF= DY= \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_   
EM= \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_ SB= \_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_

008 --010—±—±—±–030—±—±—±–050—±—±—±–070—±—  
ERROR-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
DATA-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
DATA-REQUEST-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
TRANS-REPLY-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
TRANS-REQUEST-QUEUE (XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX  
ERROR-REPLY-HOBJ (9999999999  
LE ID (XX  
NATPROC .EXXXXXXX

Try your map with a sample program:

> ```
> > + Program TESTPGM Lib DBALIB   
> 
> ```

All …+…1…+…2…+…3…+…4…+…5…+.Mode Structured.  
0010 INPUT USING MAP ‘TESTMAP’  
0020 END  
0030   
0040   
0050

This will work, displaying the given values of your AIV, even if defined previously.

---

<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:** [August 18, 2010, 3:20am UTC](https://techcommunity.softwareag.com/t/aiv-variables/79686/24 "2010-08-18T03:20:04Z")

</div>

Douglas Kelly mentioned that you can use “Edit +V” to see the AIVs.  
Another (shorter) command, to do the same thing, is “AIV” 🙂

---

<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:51pm UTC](https://techcommunity.softwareag.com/t/aiv-variables/79686/25 "2021-04-02T14:51:14Z")

</div>



[Previous page](https://techcommunity.softwareag.com/t/aiv-variables/79686.md?page=1)
