Calling a subprogram can find program/subprogram name in the one upper levels.
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.
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:
* 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 (6.11 KB)
CALLER.txt (6.57 KB)
Many thanks for your help