# Executing an dynamically created command

**URL:** <https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [June 27, 2005, 5:35pm UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026 "2005-06-27T17:35:05Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![havinash](https://avatars.discourse-cdn.com/v4/letter/h/85f322/32.png) [@havinash](https://techcommunity.softwareag.com/u/havinash)\
**Post date:** [June 27, 2005, 5:35pm UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026/1 "2005-06-27T17:35:05Z")

</div>

[b]can you execute a dynamically created command in naturall on runtime.  
qn1. i have a map called from a pgm.  
#ws-command := ‘reinput “error” mark 1 alarm’  
how can i execute #ws-command on certain conditions.

qn2. can i SET KEY PF1 = ‘RUN ABC’ and the execute this from the program?

please help  
cheers  
[/b]

---

<div class="post-metadata">

**Author:** ![Chad\_Scott](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chad\_Scott](https://techcommunity.softwareag.com/u/Chad_Scott)\
**Post date:** [July 7, 2005, 8:57pm UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026/2 "2005-07-07T20:57:32Z")

</div>

You may be able to use copycode with substitution for your first question.

For your second question, try using ‘Fetch ABC’ rather than RUN ABC.

---

<div class="post-metadata">

**Author:** ![Ednei](https://avatars.discourse-cdn.com/v4/letter/e/9de0a6/32.png) [@Ednei](https://techcommunity.softwareag.com/u/Ednei)\
**Post date:** [November 2, 2005, 1:57am UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026/3 "2005-11-02T01:57:28Z")

</div>

can you give me an exemplo of how to use substitution with copycode?

---

<div class="post-metadata">

**Author:** ![Angel\_Mendoza\_O](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Angel\_Mendoza\_O](https://techcommunity.softwareag.com/u/Angel_Mendoza_O)\
**Post date:** [November 23, 2005, 5:44am UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026/4 "2005-11-23T05:44:12Z")

</div>

include “copycode” 8)

---

<div class="post-metadata">

**Author:** ![Chad\_Scott](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@Chad\_Scott](https://techcommunity.softwareag.com/u/Chad_Scott)\
**Post date:** [November 25, 2005, 10:10pm UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026/5 "2005-11-25T22:10:43Z")

</div>

Close, 😉

include ‘copycode’ ‘#ws-command’

then the copycode would look like:

&1&

I haven’t actually tried this so there’s no money back guarantee :lol:

---

<div class="post-metadata">

**Author:** ![Angel\_Mendoza\_O](https://avatars.discourse-cdn.com/v4/letter/a/5fc32e/32.png) [@Angel\_Mendoza\_O](https://techcommunity.softwareag.com/u/Angel_Mendoza_O)\
**Post date:** [November 28, 2005, 11:13pm UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026/6 "2005-11-28T23:13:57Z")

</div>

cheers,

qn1. Puedes hacerlo con la instruccion “STACK TOP DATA FORMATTED #FIELD1 #FIELD2” pero el manejo es un poco complicado, dificil, no recomendable.

qn2. Yes, si puedes hacerlo.

Saludos 8)

---

<div class="post-metadata">

**Author:** ![Wei](https://avatars.discourse-cdn.com/v4/letter/w/90ced4/32.png) [@Wei](https://techcommunity.softwareag.com/u/Wei)\
**Post date:** [November 30, 2005, 4:40pm UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026/7 "2005-11-30T16:40:06Z")

</div>

Hi!  
INCLUDE will not work.  
As I think, the only time Natural parses and interprets Statements is during CATATLOG, STOW or RUN.  
I know 2 ways to use this “dynamic”:

1. Dynamic Soucecodegeneration (Filed(s) with name that starts with + in GDA; Saved program with this fields as Statments; Execute the saved Programm via “RUN”) - But this will Reset the CALL-Structure - Call Level will be 1. For example the REINPUT-statement will return Runtimeerror 1108.  
We use this only for Debugging and Access to different Databases with the same Program.
2. Creating/Changing and Stowing Natural objects with Userexits - and then Calling them. I never tried this - and I see many troubles with it (NSC Restrictions, unique Programnames for differnt User/Sessions …)

---

<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:** [December 1, 2005, 3:39pm UTC](https://techcommunity.softwareag.com/t/executing-an-dynamically-created-command/60026/8 "2005-12-01T15:39:09Z")

</div>

Hello Wolfgang!

We got a related discussion in the “Open Systems Forum”.  
[http://natural.forums.softwareag.com/viewtopic.php?t=136](http://natural.forums.softwareag.com/viewtopic.php?t=136)

Maybe you can find something interesting there.

Regards,

Matthias

---

<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/executing-an-dynamically-created-command/60026/9 "2021-04-02T14:40:11Z")

</div>


