Avatar of DebbieSamonte
DebbieSamonte
 asked on

Getting name of calling program

I have trigger over a file that's being initiated before and after record update. How can I get the name of the program or utility that's updating the file?
IBM System i

Avatar of undefined
Last Comment
Member_2_276102

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
daveslater

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
daveslater

Ps
there is an API available that gives the library and the program but it a lot slower.

Dave
daveslater

Hi
here is an ILE sup procedure using the message api's

   P GetCaller       B
    D GetCaller       PI            10A
     *
     * Receive Program Message API
     *
    D QMHRCVPM        PR                  ExtPgm('QMHRCVPM')
    D   MsgInfo                  32767A   options(*varsize)
    D   MsgInfoLen                  10I 0 const
    D   Format                       8A   const
    D   StackEntry                  10A   const
    D   StackCount                  10I 0 const
    D   MsgType                     10A   const
    D   MsgKey                       4A   const
    D   WaitTime                    10I 0 const
    D   MsgAction                   10A   const
    D   ErrorCode                 8000A   options(*varsize)

     *
     * Send Program Message API
     *
    D QMHSNDPM        PR                  ExtPgm('QMHSNDPM')
    D   MessageID                    7A   const
    D   QualMsgF                    20A   const
    D   MsgData                  32767A   const options(*varsize)
    D   MsgDtaLen                   10I 0 const
    D   MsgType                     10A   const
    D   CallStkEnt                  10A   const
    D   CallStkCnt                  10I 0 const
    D   MessageKey                   4A
    D   ErrorCode                 8000A   options(*varsize)

    D RCVM0200        DS                  qualified
    D  Receiver             111    120A

    D ErrorCode       ds                  qualified
    D   BytesProv                   10I 0 inz(%size(ErrorCode))
    D   BytesAvail                  10I 0 inz(0)

    D Found           s              1N
    D MsgKey          s              4A
    D stack_entry     s             10I 0

     /free

         Found = *OFF;

         for stack_entry = 3 to 10;

             QMHSNDPM( ''
                     : ''
                     : 'WCM'
                     : 3
                     : '*RQS'
                     : '*'
                     : stack_entry
                     : MsgKey
                     : ErrorCode  );

             if (ErrorCode.BytesAvail > 0);
                return *blanks;
             endif;

             QMHRCVPM( RCVM0200
                     : %size(RCVM0200)
                     : 'RCVM0200'
                     : '*'
                     : stack_entry
                     : '*RQS'
                     : MsgKey
                     : 0
                     : '*REMOVE'
                     : ErrorCode );

             if (ErrorCode.BytesAvail > 0);
                return *blanks;
             endif;

             if (%subst(RCVM0200.Receiver:1:1) <> 'Q');
                Found = *On;
                leave;
             endif;

         endfor;

         if (Found);
            return RCVM0200.Receiver;
         else;
            return *blanks;
         endif;

     /end-free
    P                 E


Dave
Member_2_276102

DebbieSamonte:

What VRM of OS/400? Do you need to act on the program name or are you simply logging it? Is it for debug or live work?

An API is available that can be used in V5R3, I think. Maybe V5R2, too. But there might be easier things to do depending on what's needed.

Tom
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck