Cybersecurity
DevOps Cloud (ADM)
IT Operations Cloud
Is there any way to know the name of the program that is currently running, besides calling another program and in that program using the "C$CALLEDBY" routine?
In version 6.2.0 the following C$MYFILE library routine was introduced.
This routine returns the filename of the disk file containing the currently executing program. Here is an example of how to use it:
WORKING-STORAGE SECTION.
77 PROGRAM-NAME pic x(80) value spaces.
77 CALL-STATUS pic s99 value 0.
Main Section.
CALL "C$MYFILE"
USING PROGRAM-NAME
GIVING CALL-STATUS.
display program-name.
accept OMITTED.
Stop Run.
Where CALL-STATUS PIC contains one of the following values:
1 PROGRAM-NAME was filled successfully
-1 Program name unknown
When successfully called, it indicates the name of the disk file containing the currently executing program, if it is known, for example:
C:\Program Files\Acucorp\Acucbl800\AcuGT\sample\acubench\object\File1.acu
The runtime will use as much space for the name of the file as the COBOL program allows.
The PROGRAM-NAME parameter will contain the filename just as the runtime received it.
If the program is part of a COBOLl object library, for example, mylib.lib contains File1.acu, along with other COBOL objects; after calling the "C$MYFILE" library routine, PROGRAM-NAME will have a value of:
C:\Program Files\Acucorp\Acucbl800\AcuGT\sample\acubench\object\mylib.lib
which is the COBOL library name instead the name of the program.