# find the name of the program name

**URL:** <https://techcommunity.softwareag.com/t/find-the-name-of-the-program-name/93287>\
**Category:** Forum\
**Tags:** Adabas-Natural, Natural, Natural-Code-Samples\
**Created:** [April 9, 2010, 12:27am UTC](https://techcommunity.softwareag.com/t/find-the-name-of-the-program-name/93287 "2010-04-09T00:27:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ekangal](https://avatars.discourse-cdn.com/v4/letter/e/edb3f5/32.png) [@Ekangal](https://techcommunity.softwareag.com/u/Ekangal)\
**Post date:** [April 9, 2010, 12:27am UTC](https://techcommunity.softwareag.com/t/find-the-name-of-the-program-name/93287/1 "2010-04-09T00:27:29Z")

</div>

Calling a subprogram can find program/subprogram name in the one upper levels.

---

<div class="post-metadata">

**Author:** ![Ralph\_Zbrog](https://sea1.discourse-cdn.com/techcommunity/user_avatar/techcommunity.softwareag.com/ralph_zbrog/32/78_2.png) [@Ralph\_Zbrog](https://techcommunity.softwareag.com/u/Ralph_Zbrog)\
**Post date:** [April 9, 2010, 5:05am UTC](https://techcommunity.softwareag.com/t/find-the-name-of-the-program-name/93287/2 "2010-04-09T05:05:27Z")

</div>

Logon to library SYSEXT and look at USR0600P/USR0600N.

ps This forum is for posting code samples. Requests such as this should be posted in the “Natural Miscellaneous” forum.

---

<div class="post-metadata">

**Author:** ![Anthony\_Rose](https://avatars.discourse-cdn.com/v4/letter/a/94ad74/32.png) [@Anthony\_Rose](https://techcommunity.softwareag.com/u/Anthony_Rose)\
**Post date:** [April 27, 2010, 8:31pm UTC](https://techcommunity.softwareag.com/t/find-the-name-of-the-program-name/93287/3 "2010-04-27T20:31:44Z")

</div>

I have a function which makes this call easier.  
See source attached (rename extension .txt to .NS7)

Example: PRINT CALLER(\<\>) prints the name of the module calling yours.

The functon has some filter options too so that you can retrieve a lower or higher module and/or specify the type.

Example: PRINT CALLER(\< 1,‘P’\>) will print the top-level Program name  
Example: PRINT CALLER(\<-1,‘P’\>) will print the lowest-level Program above you.

Note you still need SYSEXT as a steplib, and if you use the ObjTypeFilter parameter, you’ll need function S$OBJTYP (source attached) as well.

Here’s the program header info:

```auto

* Function : CALLER(<[Target],[ObjTypeFilter],[ModuleFilter],[Level]>)
*
* Action : Returns the name of a calling module
*
* Returns : CallingModule (A1-8)
*
* Parameters : Target (A1-8) Optional Default=your PROGRAM
*
* ObjTypeFilter (A1) Optional Filter on .NSx
*
* ModuleFilter 0-3 Optional Default=No Recurse,Sys
* Output
* Level (I1) Optional
*
* Target : The name of the module whose caller you are seeking;
* OR the relative position of the caller you are seeking,
* where -1 = your caller, -2 = caller's caller, etc.,
* and 1 = the top-most program and 2 = its child, etc.
*
* The default Target is you - the module using CALLER
* - so the default Calling Module returned is your caller.
*
* This excludes direct recursive calls made by any module,
* and modules listed in the independent +SYS-MODULE$(*),
* unless you specify the Module Filter parameter.
*
* If a target module is specified which is active but has
* no higher calling module (of the Obj Type if specified),
* or the relative caller pos is just one level too high,
* blank is returned.
*
* If a target module is specified which is NOT active,
* or a relative pos is more than one level too high,
* 'No Find' is returned.
*
* ObjTypFiltr: Filter on the extension's last letter.
* This ignores calling modules of other types.
*
* NB! This option requires function S$OBJTYP(<>)
*
* For example,
* CALLER(< ,'P'>) returns the lowest Program above you
* CALLER(<-1,'P'>) is the same.
* CALLER(<-2,'P'>) returns the next Program above that
* CALLER(< 1,'S'>) returns the top calling Subroutine
*
* ModuleFiltr: By default CALLER ignores direct recursive calls
* and modules listed in +SYS-MODULE$(*).
*
* Set Module Filter = 1 to include direct recursive calls,
* or = 2 to include +SYS-MODULE$(*) or = 3 to include both
*
* Level : Returns the *LEVEL-NR of the CallingModule returned.
*
* This is 0 if blank is returned (target has no caller)
* and -1 if 'No Find' is returned (target is not active).
*
* Note : You can find out if a specific module is active by
* passing the module name as the Target.
* If the module is not active, 'No Find' will be returned
* with -1 as the Calling Level.
```

[S$OBJTYP.txt](https://techcommunity.softwareag.com/uploads/short-url/1QSe86sNQMiijQyJ9bD3eAyDvsp.txt) (6.11 KB)  
[CALLER.txt](https://techcommunity.softwareag.com/uploads/short-url/uyT07tT6hhaT6l5w8DrnkwoEgXU.txt) (6.57 KB)

---

<div class="post-metadata">

**Author:** ![Ekangal](https://avatars.discourse-cdn.com/v4/letter/e/edb3f5/32.png) [@Ekangal](https://techcommunity.softwareag.com/u/Ekangal)\
**Post date:** [May 4, 2010, 5:00pm UTC](https://techcommunity.softwareag.com/t/find-the-name-of-the-program-name/93287/4 "2010-05-04T17:00:51Z")

</div>

Many thanks for your help

---

<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:58pm UTC](https://techcommunity.softwareag.com/t/find-the-name-of-the-program-name/93287/5 "2021-04-02T14:58:19Z")

</div>


