The "easiest" way to do this today, is simply code in a "constant" in your WS at compile-time (and "manually" put the name from Program-Id there).
If you want truly generic methods (on MVS), you really need to (currently) chase internal control blocks (not all that difficult - but also not that wonderful).
If your site belongs to SHARE (IBM User Group), you might be interested in the following SHARE Requirement:
"SSLNGC0313587 - New LE Callable Service to get (various) Program Names
A new LE callable service (with capabilities well beyond CEE3GRN) should be created to obtain various program names. This should include options to obtain:
- The currently executing program's name
- The name of the program that "activated" (Called, Invoked, whatever) the currently executing program
- The name of the program at the "top" of the current LE "enclave"
- The name of the program at the "top" of the current LE "thread"
For each of these, sub-options may be required to provide information such as
- Any "alias" by with the program was entered
- Any "long-name" (with mixed characters) as supported by the Binder
- Any Entry-point name when other than the modules name
Finally, although not necessarily a part of this callable service, it would also be desirable to be able to obtain the "data set name" (HFS, PDS, PDSE, LPA member, or whatever) from which each of these entities was obtained."
If you work for a "large shop" and know your (COBOL) systems programmer who has contact with your local IBM branch office, you can submit a "REQUEST" via your branch and reference this SHARE requirement - indicating that it is important to your company.
Bill Klein