The GetCallerInfo procedure retrieves the name of the calling program, or the calling procedure, or both.
calling-proc/pgm GetCallerInfo( szOption 10A Const OPTIONS(*NOPASS:*OMIT) |
| *PRV or *PREV | Returns the calling program's program, module or procedure name. (This is the default.) |
| *PGM | The program name is sent back at the return value. |
| *PROC | The procedure name is sent back as the return value. |
| *MODULE | The module name is sent back as the return value |
| *SAME or * | Returns the current program, module, or procedure name instead of the callers. |
If the function succeeds, the return value is the procedure, program or module name, as specified on the szOption parameter. The return value may be ignored when using the szRtnPgm, szRtnProc, or szRtnModule parameters.
.....DName+++++++++++EUDS.......Length+TDc.Functions+++++++++++++++++++++++++
D callingProc S 256A Varying
D pgmName S 10A
.....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++
C eval pgmName = GetCallerInfo()
C eval CallingProc = GetCallerInfo('*PROC')
In this example, the caller's program name is returned, and then the caller's procedure name is returned. Note the length of a procedure name may be up to 256 characters, hence the lengthy CALLINGPROC variable declaration.
.....DName+++++++++++EUDS.......Length+TDc.Functions+++++++++++++++++++++++++
D callingProc S 256A Varying
D pgmName S 10A
.....CSRn01..............OpCode(ex)Extended-factor2++++++++++++++++++++++++++
C eval pgmName = GetCallerInfo('*SAME')
C callp GetCallerInfo('*':pgmName:CallingProc)
In this example, the *SAME and '*' option tell the GetCallerInfo procedure to return information about "this" procedure, rather than its caller. The first statement returns the name of the program, whereas the second statement returns the name of the program and the procedure name.