Solved

trigger on source physical file

Posted on 2004-04-21
13
1,051 Views
Last Modified: 2007-12-19
Hello friends,
I have read somwhere that it is possible to write trigger on source physical file .
if it is ..then is it possible to write before delete of any member of source physical file i want to take backup of that member in other library ?? how can i write trigger and
how can i backup that member before deletion
(option 4 ) ??
thanks n waiting..
0
Comment
Question by:raj28
  • 5
  • 4
  • 2
13 Comments
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Hi

you use the following command to add the trigger to thev data base

ADDPFTRG FILE(DSLIBEE/QRPGLESRC) TRGTIME(*BEFORE) TRGEVENT(*INSERT) PGM(DSLIBEE/SRCTRG)

and the program looks somthing like



h                                                                              
 ********************************************************************          
 **                                                                **          
 **  Function: Program call via OS/400 on any data base activity   **          
 **            relating to file plp04U. Tis program is run         **          
 **            prior to the databse beng updated.                  **          
 **                                                                **          
 **            Use the ADDPFTRG or RMVPFTRG to attach this         **          
 **            program to the database.                            **          
 **                                                                **          
 **                                                                **          
 ********************************************************************          
D src           E DS                  EXTNAME(QRPGLESRC)                        
 ********************************************************************          
D PARM1           DS                                                            
 * File name                                                                    
D  FNAME                  1     10                                              
 * Library name                                                                
D  LNAME                 11     20                                              
 * Member name                                              
D  MNAME                 21     30                          
 * Trigger event  1=Insert 2=delete 3=change                
D  TEVEN                 31     31                          
 * Trigger time   1=after 2=before                          
D  TTIME                 32     32                          
 * Commit lock level                                        
D  CMTLCK                33     33                          
 * Reserved                                                  
D  FILL1                 34     36                          
 * CCSID                                                    
D  CCSID                 37     40B 0                        
 * Reserved                                                  
D  FILL2                 41     48                          
 * Offset to the original record                            
D  OLDOFF                49     52B 0                        
 * Length of the original record                            
D  OLDLEN                53     56B 0                        
 * Offset to the original record null byte map              
D  ONOFF                 57     60B 0                        
0051.00  * Length of the null byte map                                                      
0052.00 D  NNLEN                 77     80B 0                                              
0053.00  * MAXLEN                                                                          
0054.00 D  MAXLEN              8000   8000                                                  
0055.00  ********************************************************************              
0056.00 D PARM2           DS                                                                
0057.00 D  LENG                   1      4B 0                                              
0064.00  ********************************************************************              
0065.00 C     *ENTRY        PLIST                                                          
0066.00 C                   PARM                    PARM1                                  
0067.00 C                   PARM                    PARM2                                  
0068.00 C                   EVAL      SRC   =%SUBST(parm1:OLDOFF+1:OLDLEN)                  
0069.00 C                   EVAL      *INLR=*ON                                            
0070.00 C                   RETURN                                                          



This will log all records that are added to the source file, there is an after image

0068.00 C                   EVAL      SRC   =%SUBST(parm1:NEWOFF+1:NEWLEN)                  

Dave
0
 

Author Comment

by:raj28
Comment Utility
Hi daveslater,
I have tried using the following code but it's not working . I have written a before delete trigger on srcpf (srcfile) in which i'm calling rpgle pgm(delpgmrpg ) . I also set a breakpoint in rpgle pgm but it doesn't stop when i'm deleting using option 4.  

I have written rpglr pgm like this -

D Buffer          DS         32767                                    
D  TrgEvent              31     31                                    
D  TrgTime               32     32                                    
D  OldOff                49     52B 0                                
D  OldLen                53     56B 0                                
D  NewOff                65     68B 0                                
D  NewLen                69     72B 0                                
                                                                     
 * Total Buffer length                                                
D BufLen          DS                                                  
D  Leng                   1      4B 0                                
                                                                     
D Start           s              5P 0                                
D filen         E DS                  EXTNAME(SRCFILE)                
 *----------------------------------------------------------------    
C     *entry        Plist  
C     Buffer        Parm                    Buffer      
C     BufLen        Parm                    BufLen      
 *                                                      
C                   Select                              
C                   When      TrgEvent = '2'            
C                   Exsr      CheckDelete                
C                   Endsl                                
 *                                                      
c                   call      'DELPGMCL'                
c                   parm                    filen        
c                                                        
C                   Return                              
 *                                                      
C     CheckDelete   Begsr                                
C                   Exsr      GetOldFields              
C                   Endsr                                
 *                                                                  
C     GetOldFields  Begsr                                          
 * "Before" image                                                  
C                   Eval      Start = OldOff + 1                    
C                   Eval      filen = %subst(Buffer:Start:OldLen)  
 *                                                                  
C                   Endsr                                          

The code in CL pgm (delpgmcl) is like this -      
PGM (&FILENAME)                                              
             DCL        VAR(&FILENAME) TYPE(*CHAR) LEN(10)  
             CPYSRCF    FROMFILE(RAJLIB/SRCFILE) +          
             TOFILE(PARAGLIB/QCLSRC) FROMMBR(&FILENAME)      
ENDPGM                                                      
                                   

waiting ....

0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Hi
for that what you need is the QIBM_QZDA_INIT format ZDAI0100 exit point

http://publib.boulder.ibm.com/iseries/v5r2/ic2924/index.htm?info/rzaik/rzaik719.htm

Dave
0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
0
 

Author Comment

by:raj28
Comment Utility
hello daveslater,
I couldn't understood how ir works in my program ..(i.e how can i debug that rpgle pgm  using this )
pls explain me in detail ( steps )..

thanks n waiting
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Hi Raj
The above program will not work as an exit point program. I will generate an example later on today and post it.

Regards

Dave
0
 
LVL 27

Expert Comment

by:tliotta
Comment Utility
raj28:

You'll probably have a problem using a trigger program because they react at a record level. If you open a member in SEU, make a change to one source line, then save the member, every single source record is deleted and every line is rewritten to the member... except... SEU doesn't do a record delete; it does a clear-member operation and that's not allowed when the file has a *DELETE trigger. Good thing, too, because a *DELETE trigger would fire for every individual source line.

I imagine most source editors work similarly, though I haven't looked. They load the entire member and rewrite the entire member which generates the clear-member.

I'm not really sure what you need. There are a few after-the-fact notifications such as audit journal entries, but they arrive too late. By the time any program reacts, the member is already cleared -- gone.

I suspect what you need is source control -- apply proper authorities/security to your source and disallow deletions (source changes) except through controlled interfaces. The interfaces will be in charge of automated backups.

What OS/400 VRM?

Tom
0
 

Author Comment

by:raj28
Comment Utility
Hi tliotta ,
Do u mean that  *DELETE trigger on source physical file will not work in my case ?? our version is V4R4 .
0
 
LVL 14

Expert Comment

by:daveslater
Comment Utility
Hi Raj28, Tom
I generated an exit point program on the
 QIBM_QZDA_NDB1 format ZDAD0100      
I thought this would work but when I came to try it - nothing. Bang goes my idea.

Dave

0
 
LVL 27

Accepted Solution

by:
tliotta earned 250 total points
Comment Utility
raj28:

AFAIK, it won't work. Further, I believe it will stop most editors, such as SEU, from being able to update source members. Finally, if it _did_ work, I believe it wouldn't give the result you wanted because the trigger would fire for each individual source line; a source member with 500 lines would cause the trigger to execute 500 times every time an editor saved a member that was being edited. Easiest test is to create a temporary PF-SRC file, put a source member into it, add the PF trigger and try updating the member.

Editors don't generally do "database" operations in the normal sense. These aren't regular physical files; they have the PF-SRC attribute and they act differently. Members are commonly loaded into memory all at once, source changes happen against the copy in memory, then the entire member is rewritten. This is what allows sequence number to be maintained throughout the entire member even if you insert/delete only a single line.

Unfortunately, the only things I can think of to help you (except for creating or buying a change management product) are (1) after-the-fact procedures that get notified too late or (2) network exit programs that wouldn't work for local editors such as SEU.

You know, a home-grown CM product might not be as difficult as you might worry about. Start by considering which issues need to be overcome. I'm pretty sure we can supply solutions for each issue.

Tom
0
 

Author Comment

by:raj28
Comment Utility
Hi tliotta,
I also agree with you. Thnaks for your responses .
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

HOW TO: Connect to the VMware vSphere Hypervisor 6.5 (ESXi 6.5) using the vSphere (HTML5 Web) Host Client 6.5, and perform a simple configuration task of adding a new VMFS 6 datastore.
A procedure for exporting installed hotfix details of remote computers using powershell
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now