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?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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:
Found = *On;
leave;
endif;
endfor;
if (Found);
return RCVM0200.Receiver;
else;
return *blanks;
endif;
/end-free
P E
Dave
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
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
there is an API available that gives the library and the program but it a lot slower.
Dave