NATURAL Is there a way to know what program called a sub-program without passing *PROGRAM when the subprogram is called?

NATURAL Is there a way to know what program called a sub-program without passing *PROGRAM when the subprogram is called?

Yes, at least on our version on the mainframe, there is a module we call to get the chain of modules up to the current module, USR0600N.

...
1 #CHAIN (A8/20)
1 #LEVEL (P3/20)
...
CALLNAT 'USR0600N' #CHAIN (*) #LEVEL (*)
...

I hope it works for you.

Maybe the RETURN* command is something you can use.
RETURN

RETURN

I

``
*

This command is used to return to a previous (or initial) Natural application.

Application programming interface: USR1026N. See SYSEXT - Natural Application Programming Interfaces in the documentation.

RETURN |

If RETURN is specified without any parameters, control will be returned to the previous application (as defined with the system command SETUP). All information about this previous application will be deleted. If no previous application exists, control is returned to the initial application.



If RETURN is issued and no return point is set, the RETURN command will be ignored.

Under Natural Security:


A LOGOFF command will be executed if RETURN is issued and no return point has been set.

|

  • | - |
    RETURN I | This command causes control to be returned directly to the initial application. This option also causes Natural to delete all definitions of previous applications (except that of the initial application). |
    RETURN | This command causes control to be returned to the th previous application. When this option is used, all information for applications subsequent to the th application is deleted. |
    RETURN * | This command will display a list of all return points which are currently set up. On the list you may then select the return point to which you wish to return. |

See the SETUP command for further information and examples.