# Dynamic formation of logical condition

**URL:** <https://techcommunity.softwareag.com/t/dynamic-formation-of-logical-condition/178562>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Mainframes\
**Created:** [September 17, 2014, 8:05am UTC](https://techcommunity.softwareag.com/t/dynamic-formation-of-logical-condition/178562 "2014-09-17T08:05:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sachin\_SS](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@Sachin\_SS](https://techcommunity.softwareag.com/u/Sachin_SS)\
**Post date:** [September 17, 2014, 8:05am UTC](https://techcommunity.softwareag.com/t/dynamic-formation-of-logical-condition/178562/1 "2014-09-17T08:05:47Z")

</div>

Hi,

I was wondering if we can evaluate any dynamic condition in Natural. eg please have a look at this program  
DEFINE DATA  
LOCAL  
1 #A (L)  
1 #B (L)  
1 #ST (A10)  
END-DEFINE  
#ST := ‘#A OR #B’  
IF #ST /\* \<----- THIS IS WRONG OBVIOUSLY.  
WRITE ‘=’ #ST  
END-IF  
END

I tried using a copycode for this. But that too did not work out because of type checking.

Can this be done in natural?

---

<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:** [September 17, 2014, 10:45am UTC](https://techcommunity.softwareag.com/t/dynamic-formation-of-logical-condition/178562/2 "2014-09-17T10:45:16Z")

</div>

No, that won’t work, copycodes are evaluated during compile time, their main purpose is reuse of code fragments.

The only way to get real “dynamic” stuff is to generate the code at runtime.

---

<div class="post-metadata">

**Author:** ![Sachin\_SS](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@Sachin\_SS](https://techcommunity.softwareag.com/u/Sachin_SS)\
**Post date:** [September 17, 2014, 11:01am UTC](https://techcommunity.softwareag.com/t/dynamic-formation-of-logical-condition/178562/3 "2014-09-17T11:01:19Z")

</div>

Exactly … and I am not able to come up with any sort of workaround for this.  
Very frustrating … It shouldn’t be this difficult.

---

<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 17, 2014, 12:03pm UTC](https://techcommunity.softwareag.com/t/dynamic-formation-of-logical-condition/178562/4 "2014-09-17T12:03:16Z")

</div>

Education, education, education.

You are obviously new to Natural, and have never had any education in Natural.

Wolfgang told you what had to be done, but you have no idea how to do it.

Consider the following program excerpt:

:::  
IF #FIELD = &CONDITION  
::

At compile time, Natural looks for a global variable (old style), or a variable in a GDA (new style) that is called +CONDITION. The compiler then takes the contents of +CONDITION and replaces &CONDITION in the program.

So, you need a “driver” program, such as shown below (old style)

INPUT ‘enter logical condition here==\>’ +CONDITION (A50)

- validate entered value here
- 

IF condition entered is okay  
RUN ‘REPORT’ /\* where REPORT is the program with the &CONDITION above.

Suppose the user enters #TEST-VALUE for +CONDITION

When you RUN ‘REPORT’ the first thing Natural does is compile the program REPORT. When Natural “sees” &CONDITION, it replaces it with #TEST-VALUE. You now have a valid Natural statement, namely  
IF #FIELD = #TEST-VALUE

Suppose the user enters ‘ABC’ for +CONDITION  
You now have the valid Natural statement  
IF #FIELD = ‘ABC’

Your employer should supply Natural education !!

---

<div class="post-metadata">

**Author:** ![Sachin\_SS](https://avatars.discourse-cdn.com/v4/letter/s/f475e1/32.png) [@Sachin\_SS](https://techcommunity.softwareag.com/u/Sachin_SS)\
**Post date:** [September 17, 2014, 12:53pm UTC](https://techcommunity.softwareag.com/t/dynamic-formation-of-logical-condition/178562/5 "2014-09-17T12:53:59Z")

</div>

Thanks for your reply. You totally got me there.  
I was looking at USR4208N for this. But this works perfectly and solves the purpose.  
I think I need to find a documentation on natural compile time validation.  
Thanks again!!

---

<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, 3:32pm UTC](https://techcommunity.softwareag.com/t/dynamic-formation-of-logical-condition/178562/6 "2021-04-02T15:32:03Z")

</div>


