# Run time DDM name for database access

**URL:** <https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [September 23, 2010, 1:15pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789 "2010-09-23T13:15:18Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [September 23, 2010, 1:15pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/1 "2010-09-23T13:15:18Z")

</div>

Friends,

I have a requirement where:

1. On a map user should enter a ddm-name (with it’s few related fileds) to be read
2. The ddm-name with fields should be passed to prepare a view definition within DEFINE DATA in a program
3. Start reading
4. Show results

I have issues with step 2 that view syntax doesn’t support ( :?: neither structured nor reporting mode) a variable-name (where we got the input from user) but only ddm-name.

Not sure if this can be leveraged. Please share your thoughts.

---

<div class="post-metadata">

**Author:** ![Steve\_Robinson](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/steve_robinson/32/107_2.png) [@Steve\_Robinson](https://techcommunity.softwareag.com/u/Steve_Robinson)\
**Post date:** [September 23, 2010, 2:29pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/2 "2010-09-23T14:29:16Z")

</div>

Views are interpreted by Natural at compile time, not execution time. Hence what you want to do is not possible.

That said, there are ways to accomplish what you would like to do.

I suggest you read about “ampersand variables” which allow you to create program “skeletons”. You can then take user input, store the input values in global variables, and then RUN the program skeletons.

Education, education, education.

steve

---

<div class="post-metadata">

**Author:** ![Peter\_Thorn](https://avatars.discourse-cdn.com/v4/letter/p/e495f1/32.png) [@Peter\_Thorn](https://techcommunity.softwareag.com/u/Peter_Thorn)\
**Post date:** [September 24, 2010, 5:50am UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/3 "2010-09-24T05:50:01Z")

</div>

One option, that I have done in the past, is to generate the Adabas Direct Calls from the DDM list and then use USR1043N to issue the direct call and display the results. Direct calls are easy, it is not rocket science, and I am a firm believer that everyone using Adabas should understand how it works.

---

<div class="post-metadata">

**Author:** ![Matthias1](https://avatars.discourse-cdn.com/v4/letter/m/9fc348/32.png) [@Matthias1](https://techcommunity.softwareag.com/u/Matthias1)\
**Post date:** [September 24, 2010, 4:21pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/4 "2010-09-24T16:21:03Z")

</div>

I think the easiest way is to read all fields every time and reduce the data before displaying it.

Of course: You can write a program dynamically by printing it into natural’s source area, compile it, etc. … But I think this is too complex.

---

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [September 24, 2010, 5:09pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/5 "2010-09-24T17:09:03Z")

</div>

Thanks Steve, Peter and Matthias. I got it!

---

<div class="post-metadata">

**Author:** ![Arkantos](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@Arkantos](https://techcommunity.softwareag.com/u/Arkantos)\
**Post date:** [September 27, 2010, 8:45pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/6 "2010-09-27T20:45:17Z")

</div>

As specified by Peter, you can use USR routines. USR1058 will read the DDM into an array.Then you can format the array and create the view using USR2014.

Cheers  
Arkantos

---

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [September 28, 2010, 12:00pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/7 "2010-09-28T12:00:02Z")

</div>

Thanks Arkantos,

Currently, I got it resolved with Steves’ suggestion. Will definitely look into USRs suggested by Peter and you once I have some spare time.

---

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [September 29, 2010, 3:13pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/8 "2010-09-29T15:13:51Z")

</div>

Is it possible to achieve this with any other option (FETCH RETURN etc). The reason being I want control back to my driver program. RUN doesn’t allow this. Well, to add I am starting a READ loop before RUN ‘prog’ and need to continue with the loop in driver program. A STACK TOP COMMAND would have helped but seems doesn’t continue the processing loop initiated.

Any thoughts?

---

<div class="post-metadata">

**Author:** ![Finn\_the\_Dane1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/finn_the_dane1/32/132_2.png) [@Finn\_the\_Dane1](https://techcommunity.softwareag.com/u/Finn_the_Dane1)\
**Post date:** [September 29, 2010, 6:56pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/9 "2010-09-29T18:56:53Z")

</div>

You can use  
STACK COMMAND “MYPROG”  
to call “yourself” after execution.

(Sounds a bit like a life after death - but don’t worry;-)

---

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [September 29, 2010, 7:59pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/10 "2010-09-29T19:59:50Z")

</div>

I already tried this Finn but didn’t help (Am I missing anything?)

The scene is:

```auto
READ WORK FILE ..
DECIDE ON FIRST VALUE ...
VALUE ..
RUN 'skeleton1'
VALUE ..
RUN 'skeleton2'
NONE VALUE
..
END-DECIDE
...
```

I need control back to driver (after the DECIDE) to continue READ WORK once skeleton is executed and not to start again.

---

<div class="post-metadata">

**Author:** ![Finn\_the\_Dane1](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/finn_the_dane1/32/132_2.png) [@Finn\_the\_Dane1](https://techcommunity.softwareag.com/u/Finn_the_Dane1)\
**Post date:** [September 29, 2010, 8:26pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/11 "2010-09-29T20:26:09Z")

</div>

I didn’t quite have your scenario present, but I guess you could stack all the “runs” for execution after all records has been read and the program terminated ?  
Finn

---

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [September 29, 2010, 10:31pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/12 "2010-09-29T22:31:04Z")

</div>

Finn,

My apology, but I really didn’t get your point :oops:

Let me be more precise on what I am after:

1. I need to read no of DDMs and passing the names to driver from a work file
2. Based on a value I need to decide what program should be executed
3. Due to different and multiple ddm names I chosen to make it dynamic as per Steve’s suggestion (accessing it as globals in the driver and referring as amphersand variable in RUN ‘prog’
4. The need is to read all the DDMs from workfile and process them.

After reading first record from workfile my driver goes to related RUN ‘prog’ but doesn’t come back to driver where my READ WORK has started a loop. Trying to find a way to complete this process.

I hope it makes sense :oops:

---

<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:** [September 30, 2010, 5:49am UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/13 "2010-09-30T05:49:33Z")

</div>

If I understand your dilemma correctly, you are trying to set the value of the global variables (the &things) based on input from the workfile - and using the RUN approach causes control fall out of the loop.

An alternative is that you have a stackable program that fills in the values on each invocation:

```auto
READ WORK FILE ..
DECIDE ON FIRST VALUE ...
VALUE ...
STACK COMMAND 'stackset "skeleton1" "ddm-name"'
VALUE ..
STACK COMMAND 'stackset "skeleton2" "ddm-name"'
NONE VALUE
..
END-DECIDE 
```

‘stackset’ would be a program that accepts skeleton and ddm-name as input, assigns the appropriate global variables and RUNs the appropriate program (skeleton?). Something like:

```auto
INPUT skeleton(a8) +ddm(a32)
RUN skeleton
END
```

If you have control over the work file that is input, then put the commands in front of the data:

```auto
stackset skeleton1 ddm1
stackset skelton2 ddm2
...
```

and input this workfile to CMOBJIN

---

<div class="post-metadata">

**Author:** ![Ats](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Ats](https://techcommunity.softwareag.com/u/Ats)\
**Post date:** [October 1, 2010, 3:31pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/14 "2010-10-01T15:31:28Z")

</div>

Hi Douglas,

Thanks for the valuable suggestion. It worked successfully :D. I believe Finn tried to convey the same but I was unable to get it.

Cheers!!!

---

<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:59pm UTC](https://techcommunity.softwareag.com/t/run-time-ddm-name-for-database-access/94789/15 "2021-04-02T14:59:08Z")

</div>


