[NEWSboard IBMi Forum]

Threaded View

  1. #1
    Registriert seit
    Apr 2012
    Beiträge
    360

    Trigger Sql-updates

    Hallo,

    ich habe mir im Internet folgendes Pgm gefunden, was das aufrufende Programm ermittelt

    Code:
    Which program fired the trigger  
    * Prototype for the AppPgmName proceduree                     
    D AppPgmName      PR            10                             
    D  DummyPrm                      1    Options( *Omit )         
     * Procedure to return the name of the application             
     * program which fired the trigger                             
    P AppPgmName      B                   Export                   
                                                                  
    D AppPgmName      PI            10                             
    D  DummyPrm                      1    Options( *Omit )         
                                                                  
     * Prototypess                                                 
    D SndMsg          PR                  ExtPgm( 'QMHSNDPM')      
    D  MsgId                         7    Const                    
    D  QlMsgfName                   20    Const                    
    D  MsgDta                      256    Const                    
    D                                     Options( *VarSize )      
    D  LenMsgDta                    10I 0 Const                    
    D  MsgType                      10    Const                    
    D  ClStkEntry                   10    Const                    
    D  ClStkCounter                 10I 0 Const                    
    D  MsgKey                        4                             
    D  ApiErr                      272                             
                                                                  
    D RcvMsg          PR                  ExtPgm( 'QMHRCVPM' )     
    D  MsgInf                      120                        
    D  LenMsgIfn                    10I 0 Const               
    D  FmtName                       8    Const               
    D  ClStkEntry                   10    Const               
    D  ClStkCounter                 10I 0 Const               
    D  MsgType                      10    Const               
    D  MsgKey                        4    Const               
    D  WaitTime                     10I 0 Const               
    D  MsgAct                       10    Const               
    D  ApiErr                      272                        
                                                             
     * Local data                                             
    D MsgKey          S              4                        
                                                             
    D ApiErr          DS                                      
    D  AeBytesProv                  10I 0 Inz( 272 )          
    D  AeBytesAvl                   10I 0                     
    D  AeMsgId                       7                        
    D                                1                        
    D  AeMsgDta                    256                        
                                                             
    D MsgInf          DS                                      
    D  MiBytesRetd            1      4B 0                     
    D  MiBytesAvl             5      8B 0 Inz( 120 )          
    D  MiPgmName            111    120                                             
                                                                                  
    D TrgPgmName      S             10                                             
    D CurrPgmName     S             10                                             
    D PgmNameChanges  S              1P 0                                          
    D ClStkCounter    S             10I 0                                          
    D*                                                                             
     * Send a dummy message to the trigger                                         
    C                   CallP     SndMsg( 'CPF9898': 'QCPFMSG   QSYS':             
    C                                     ' ':       1:                            
    C                                     '*INFO':   '*PGMBDY':                    
    C                                     1:         MsgKey:                       
    C                                     ApiErr                         )         
    C*                                                                             
     * Receive the message back and pick up the trigger program name               
    C                   CallP     RcvMsg( MsgInf:      %Size( MsgInf ):            
    C                                     'RCVM0200':  '*':                        
    C                                     *Zero:       '*INFO':                    
    C                                     MsgKey:      0:                          
    C                                     '*REMOVE':   ApiErr          )           
    C*                                                                             
    C                   Eval      TrgPgmName = MiPgmName                           
    C*                                                                             
     * Keep going backward in the call stack until the program name changes        
    * twice. The second change to the program name will be the name of         
     * the application which caused the trigger to fire.                        
    C*                                                                          
    C                   Eval      CurrPgmName = TrgPgmName                      
    C                   Eval      PgmNameChanges = *Zero                        
    C                   Eval      ClStkCounter = 2                              
    C                   DoU       PgmNameChanges = 2                            
    C*                                                                          
    C                   CallP     SndMsg( 'CPF9898':     'QCPFMSG   QSYS':      
    C                                     ' ':           1:                     
    C                                     '*INFO':       '*PGMBDY':             
    C                                     ClStkCounter:  MsgKey:                
    C                                     ApiErr                         )      
    C*                                                                          
    C                   CallP     RcvMsg( MsgInf:      %Size( MsgInf ):         
    C                                     'RCVM0200':  '*':                     
    C                                     *Zero:       '*INFO':                 
    C                                     MsgKey:      0:                       
    C                                     '*REMOVE':   ApiErr          )        
    C*                                                                          
    C                   If        MiPgmName <> CurrPgmName                      
    C                   Eval      CurrPgmName    = MiPgmName                    
    C                   Eval      PgmNameChanges = PgmNameChanges + 1           
    C                   Else                                                    
    C                   Eval      ClStkCounter = ClStkCounter + 1            
    C                   EndIf                                                
    C*                                                                       
    C                   EndDo                                                
    C*                                                                       
    C                   Return    CurrPgmName                                
    C*                                                                       
    P AppPgmName      E
    Das klappt ja auch toll, aber falls updates über Sql-Statements erfolgen wird mir immer QSQRUN3 zurückgeliefert.
    Click image for larger version. 

Name:	Neue Bitmap.jpg 
Views:	19 
Size:	29,1 KB 
ID:	275

    Welche Möglichkeiten würden bestehen um trotzdem das aufrunfende Programm zu ermitteln?

    Mir fällt da nur die Datenstruktur UDS ein.

    Code:
    D MyPGM          UDS
    Dank im Voraus für eure Hilfe.

    Tarki
    Angehängte Grafiken Angehängte Grafiken

Similar Threads

  1. Grundkonzept Trigger
    By froehlich in forum IBM i Hauptforum
    Antworten: 2
    Letzter Beitrag: 06-02-03, 14:37
  2. Trigger mit Servicepgm
    By Robi in forum IBM i Hauptforum
    Antworten: 1
    Letzter Beitrag: 28-05-02, 16:45
  3. Trigger ab 5.1
    By lorenzen in forum IBM i Hauptforum
    Antworten: 2
    Letzter Beitrag: 11-01-02, 13:49
  4. Trigger Programme
    By Liebhoff in forum IBM i Hauptforum
    Antworten: 3
    Letzter Beitrag: 20-11-01, 19:52
  5. Trigger / ILE RPG
    By Frank Pusch in forum IBM i Hauptforum
    Antworten: 3
    Letzter Beitrag: 17-05-01, 09:34

Berechtigungen

  • Neue Themen erstellen: Nein
  • Themen beantworten: Nein
  • You may not post attachments
  • You may not edit your posts
  •