# "SET KEY" statements in maps?

**URL:** <https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-on-Linux\
**Created:** [May 15, 2006, 2:54pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983 "2006-05-15T14:54:34Z")\
**Posts on this page:** 18\
**Page:** 1

<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:** [May 15, 2006, 2:54pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/1 "2006-05-15T14:54:34Z")

</div>

In a Natural-MAP, it’s possible to code a so called PF-KEY rule. Imagine the following PF-KEY rule:

```auto
if *PF-KEY = 'PF24'
  #cv-hidden-information := (AD=D)
  reinput 'Hidden information displayed...'
end-if
```

In the program which calls the map, a “SET KEY PF24” is necessary.  
My (stupid) question: Is it possible to include this “SET KEY PF24” into the map? That would be better than coding the “SET KEY PF24” in every calling program…

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [May 15, 2006, 9:03pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/2 "2006-05-15T21:03:56Z")

</div>

Why do you not use “SET KEY ALL” in the calling program or in the main program?

---

<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:** [May 15, 2006, 9:15pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/3 "2006-05-15T21:15:38Z")

</div>

As I wrote:

> [@](#):
>
> That would be better than coding the “SET KEY PF24” in every calling program…

That means: Currently I am using “SET KEY PF24” in every calling program and it works. But today I was just wondering, if it’s possible to do it in the map. I need this KEY only inside the map. At the moment my coding looks like this:

```auto
SET KEY PF24
INPUT USING MAP
SET KEY PF24=OFF
```

The statement “SET KEY PF24=OFF” can be moved to the PF-KEY-Rules inside the map. But what about the “SET KEY PF24”?

---

<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:** [May 15, 2006, 10:09pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/4 "2006-05-15T22:09:43Z")

</div>

> [@Matthias](#):
>
> The statement “SET KEY PF24=OFF” can be moved to the PF-KEY-Rules inside the map. But what about the “SET KEY PF24”?

It can’t, because the SET KEY would have to be executed before the INPUT statement.

---

<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:** [May 15, 2006, 11:44pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/5 "2006-05-15T23:44:51Z")

</div>

Two points.

First, REINPUT FULL, not just REINPUT, otherwise you will not see the hidden information.

Now for the fun stuff.

Natural has the equivalent of a “pre-processing rule” where you could place the SET KEY statement. I have used this technique many times, but never with a PF key, so you will have to be the guinea pig.

In the Map, you will want to have specified a Dynamic Layout, call it MYSTART for example. MYSTART must have a single non displayable field otherwise Natural ignores the Layout. Define a PF Key processing rule for the Layout which has the SET KEY statement.

Step 1) Create and STOW MYSTART

Step 2) Change your Map to have the Layout MYSTART and re-stow.

Step 3) Keep fingers crossed and try it.

steve

p.s. would love to claim credit for this technique, but Andreas showed it to me.

---

<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:** [May 16, 2006, 12:44pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/6 "2006-05-16T12:44:05Z")

</div>

@Wolfgang Winter:

> [@Wolfgang Winter](#):
>
> It can’t, because the SET KEY would have to be executed before the INPUT statement.

Yes, I understand. But if you have a look at the real coding of a map, there are some format-settings done before the input-statement. So I wondered if could put my “SET KEY” there.

@Steve: Thanks for the tip. I’ll try it out. But it’s sounds a bit “dirty” to me 😉

---

<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:** [May 16, 2006, 1:15pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/7 "2006-05-16T13:15:37Z")

</div>

Your (or Andreas’) idea doesn’t work. Here are my codes to check, whether I did it right or not.

```auto
define data local
01 #a10 (A10)
end-define
*
set key all
set key PF24=OFF
input using map 'TST-MAP1'
end
```

TST-MAP1 is:

```auto
* MAP2: PROTOTYPE --- CREATED BY WNT 6.1.1 ---
* INPUT USING MAP 'XXXXXXXX'
* #A10
DEFINE DATA PARAMETER
1 #A10 (A010)
END-DEFINE
FORMAT PS=005 LS=021 ZP=OFF SG=OFF KD=OFF IP=OFF
SET CONTROL 'Q' ' ' INPUT USING MAP 'LAYOUT '
* MAP2: MAP PROFILES *****************************200***********
* .TTAAAMMOO D I D I N D I D I ?_)^&:+( *
* 005020LAYOUT N0YNUCN X 01 SYSDBA NR *
************************************************************************
INPUT NO ERASE ( IP=OFF /*
                                                                       )
/
 003T '#a10'
 009T #A10 (AD=DLMFHT' ' ) /*.99U010 A010 .
/
/
/
* MAP2: VALIDATION *****************************************************
RULEVAR F00*PF-KEY
INCDIC ;
display *PF-KEY
* MAP2: END OF MAP *****************************************************
END
```

LAYOUT is:

```auto
* MAP2: PROTOTYPE --- CREATED BY WNT 6.1.1 ---
* INPUT USING MAP 'XXXXXXXX'
FORMAT PS=005 LS=021 ZP=OFF SG=OFF KD=OFF IP=OFF
* MAP2: MAP PROFILES *****************************200***********
* .TTAAAMMOO D I D I N D I D I ?_)^&:+( *
* 005020 N0NNUCN X 01 SYSDBA NR *
************************************************************************
INPUT ( IP=OFF /*
                                                                       )
/
/
/
 011T *USER (AD=NLOFHT ) /*.01S008 A008 .
/
* MAP2: VALIDATION *****************************************************
RULEVAR F00*PF-KEY
INCDIC ;
write 'SET KEY PF24'
SET KEY PF24
* MAP2: END OF MAP *****************************************************
END
```

---

<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:** [May 16, 2006, 5:05pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/8 "2006-05-16T17:05:02Z")

</div>

During lunch, I thought about the layout-trick again. Now it’s clear to me, why a PF-KEY-Setting in a Layout-MAP doesn’t work.

Once upon a time in a SAG-training, I’ve learned that an INPUT USING MAP is a kind of CALLNAT with automatic parameter. And in a CALLNAT it’s also impossible to do a PF-KEY-Setting for the calling program.

```auto
SET KEY ALL
SET KEY PF24=OFF
callnat 'TST-PF24' 
* code of TST-PF24:
* SET KEY PF24
* END
*
input 'Press a PF-KEY!'
write *PF-KEY
end
```

But maybe in future I can use this Layout-thing for other purposes.  
So thanks anyway!

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [May 16, 2006, 9:59pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/9 "2006-05-16T21:59:41Z")

</div>

[quote="Wilfried B

---

<div class="post-metadata">

**Author:** ![FerozImtiaz](https://avatars.discourse-cdn.com/v4/letter/f/dbc845/32.png) [@FerozImtiaz](https://techcommunity.softwareag.com/u/FerozImtiaz)\
**Post date:** [May 16, 2006, 10:23pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/10 "2006-05-16T22:23:30Z")

</div>

The quickest is to provide a button. The PFKEY is set in the botton.

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [May 16, 2006, 10:26pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/11 "2006-05-16T22:26:21Z")

</div>

And the layout map will do the trick:

1. The first processing rule in the layout map issues: SET CONTROL ‘Q’ (or ‘QS’ or ‘N’)
2. In the other map you have a local variable #PF24-IS-ON(L) which is initially FALSE
3. Then there is the first processing rule in the map which contains:

```auto
IF NOT #PF24-IS-SET
  SET KEY PF24
  #PF24-IS-SET := TRUE
  REINPUT *0
END-IF
```

1. In one of the following processing rules you can catch the keypress.

How does it work?

When you INPUT the map Natural first issues an INPUT for the layout map, but with a preceding SET CONTROL ‘Q’ (or ‘QS’)) which does a “keypress” for you (without showing the map). Then the processing rules of the layout map are executed which also issue a SET CONTROL ‘Q’. Then the desired map is executed. As there is a pending SET CONTROL ‘Q’, a keypress is simulated and the processing rules of the map are executed. To show the map, the REINPUT is required.

Caveats:

1. You have to add addition code to show the correct message (if a message should be shown),
2. You have to add additional code to position the cursor if you want to
3. You may have problems with REINPUT in the calling program!

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [May 16, 2006, 10:29pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/12 "2006-05-16T22:29:00Z")

</div>

> [@Feroz Imtiaz](#):
>
> The quickest is to provide a button. The PFKEY is set in the botton.

…and to set the button a PF-KEY has to be set… :?

---

<div class="post-metadata">

**Author:** ![FerozImtiaz](https://avatars.discourse-cdn.com/v4/letter/f/dbc845/32.png) [@FerozImtiaz](https://techcommunity.softwareag.com/u/FerozImtiaz)\
**Post date:** [May 16, 2006, 10:41pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/13 "2006-05-16T22:41:09Z")

</div>

[quote="Wilfried B

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [May 16, 2006, 11:18pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/14 "2006-05-16T23:18:53Z")

</div>

And how comes the button onto the map? (We are talking about maps, not dialogs)

---

<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:** [May 17, 2006, 1:09pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/15 "2006-05-17T13:09:10Z")

</div>

[quote="Wilfried B

---

<div class="post-metadata">

**Author:** ![Wilfried\_B](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/wilfried_b/32/83_2.png) [@Wilfried\_B](https://techcommunity.softwareag.com/u/Wilfried_B)\
**Post date:** [May 17, 2006, 1:17pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/16 "2006-05-17T13:17:02Z")

</div>

You wanted a trick and you have got a trick 😉

SAG introduced the trick with SET CONTROL ‘Q’ to enable dynamic map layouts. I only behaved like a Japanese: copied and improved the trick.

BTW. A trick becomes a technique if it is used more than once! :lol:

> [@](#):
>
> I’m sure that I won’t understand this coding in a year.

You can add a comment with a link [http://natural.forums.softwareag.com/viewtopic.php?t=371#1622](http://natural.forums.softwareag.com/viewtopic.php?t=371#1622) to this thread into your coding to remind you (and any other maintainer) of this “dirty trick”. 🙂

---

<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:** [May 17, 2006, 2:31pm UTC](https://techcommunity.softwareag.com/t/set-key-statements-in-maps/60983/17 "2006-05-17T14:31:42Z")

</div>

[quote="Wilfried B

---

<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/set-key-statements-in-maps/60983/18 "2021-04-02T14:40:39Z")

</div>


