ibmi-brunch-learn

Announcement

Collapse
No announcement yet.

Which CL program is this

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Which CL program is this

    Is there a way to retrieve the name of the current CL program that is running?

  • #2
    Try this:

    Code:
                 DCL        VAR(&PGMID)      TYPE(*CHAR) LEN(10)
                 DCL        VAR(&MSGKEY)     TYPE(*CHAR) LEN(04)
                 DCL        VAR(&SENDER)     TYPE(*CHAR) LEN(80)
    
    /* Send a diagnostic message to the current program message queue,   */
    /* receive message and extract the program-id from the SENDER data   */
    
                 SNDPGMMSG  MSGID(CPI2401) MSGF(QCPFMSG) MSGTYPE(*DIAG) +  
                              KEYVAR(&MSGKEY)                              
                 RCVMSG     PGMQ(*PRV) MSGKEY(&MSGKEY) SENDER(&SENDER)     
                 CHGVAR     VAR(&PGMID) VALUE(%SST(&SENDER 27 10))

    Comment

    Working...
    X