[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

12/26/2007 at 07:38AM PST, ID: 23043136
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

7.8

Trigger program to log changes and inserts

Asked by ScottParker in Programming for iSeries / AS400

Tags: program, after, changes, log

I really need to stop Windows type programming and get back to RPG....
That being said, we are a JDE shop and my boss told me he wants me to put a "Trigger" on a file to log inserts and changes.
(Years ago, I added a trigger to another file to do something different.)

So I start remembering my old program (code gotten from this very web site) and well I am just stuck on one part. (I think)
The File name is F4102.. I made a copy of the file and called it FG4102AUD.

I'm stuck on the last part.. In the Sub SWRTF I am just trying to copy the "After" image into the DLOG data structure so I can then write the record. (dont laugh, I have been trying for hours to figure this out again)

Help!!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
0001.00      H/TITLE PG4102TRG - F4102 TRIGGER PROGRAM FOR AUDIT LOG           
0002.00      H* ---------------------------------------------------------------
0003.00      H*                                                                
0004.00      H*    PROGRAM REVISION LOG                                        
0005.00      H*    --------------------                                        
0006.00      H*                                                                
0007.00      H*          Date     Programmer     Nature of Revision            
0008.00      H*        --------   ----------  ---------------------------------
0009.00      H*        12/21/07   MAISAD22    Creation of Program.             
0010.00      ***********************************************************       
0011.00      H                                                                 
0012.00      H Option(*NODEBUGIO)                                              
0013.00      H DftActGrp(*No)                                                  
0014.00      H ActGrp('Trigger')                                               
0015.00      ***********************************************************       
0016.00      FFG4102AUD UF A E             DISK    USROPN                      
0016.01      D DSLOG         E DS                  EXTNAME(FG4102AUD)     
0016.02      D                                     PREFIX(L_)             
0017.00      ***********************************************************  
0018.00       * THE FOLLOWING WORKS LIKE AN *ENTRY PLIST:                 
0019.00      D MAINLINE        PR                  EXTPGM('F4102')        
0020.00      D   BUF                               LIKEDS(PARM1)          
0021.00      D   LENGTH                      10I 0                        
0022.00      D MAINLINE        PI                                         
0023.00      D   BUF                               LIKEDS(PARM1)          
0024.00      D   LENGTH                      10I 0                        
0025.00       *********************************************************** 
0026.00      D CMDTEXT         DS            80                           
0027.00      D  LIB1                   7     16A                          
0028.00      D  FILE1                 26     35A                          
0029.00      D CMDTEXT2        DS            80                           
0030.00      D  LIBFILE2              30     50A                          
0031.00      D CMDTEXT3        DS            80                          
0032.00      D  FILE2                 39     47A                         
0033.00      D  FILE3                 60     68A                         
0034.00       ***********************************************************
0035.00       ** STANDARD SPECIFICATION FOR ALL TRIGGER PROGRAMS         
0036.00       ***********************************************************
0037.00      D PARM1           DS                  QUALIFIED             
0038.00      D   FILE                        10A                         
0039.00      D   LIBRARY                     10A                         
0040.00      D   MEMBER                      10A                         
0041.00      D   EVENT                        1A                         
0042.00      D   TIME                         1A                         
0043.00      D   COMMITLOCK                   1A                         
0044.00      D   RES1                         3A                         
0045.00      D   CCSID                       10I 0                       
0046.00      D   DBRRN                       10I 0                       
0047.00      D   RES2                         4A                         
0048.00      D   BOFFSET                     10I 0                  
0049.00      D   BLEN                        10I 0                  
0050.00      D   BNULLOFFSET                 10I 0                  
0051.00      D   BNULLLEN                    10I 0                  
0052.00      D   AOFFSET                     10I 0                  
0053.00      D   ALEN                        10I 0                  
0054.00      D   ANULLOFFSET                 10I 0                  
0055.00      D   ANULLLEN                    10I 0                  
0056.00       **------------------------------------------          
0057.00       **  CONSTANTS                                         
0058.00      D BEFOREEVENT     C                   CONST('2')       
0059.00      D AFTEREVENT      C                   CONST('1')       
0060.00      D INSERT          C                   CONST('1')       
0061.00      D UPDATE          C                   CONST('3')       
0062.00      D DELETE          C                   CONST('2')       
0063.00      D READ            C                   CONST('4')       
0064.00       ** STANDARD WORK FIELDS                                    
0065.00      D ERROR           S               N                         
0066.00       ***********************************************************
0067.00       **  USE ORIGINAL FILE TO DEFINE BEFORE AND AFTER IMAGE     
0068.00       **                                                         
0069.00      D PTR_BEFORE      S               *                         
0070.00      D DBDSB         E DS                  EXTNAME(F4102)        
0071.00      D                                     BASED(PTR_BEFORE)     
0072.00      D                                     QUALIFIED             
0073.00      D PRT_AFTER       S               *                         
0074.00      D DBDSA         E DS                  EXTNAME(F4102)        
0075.00      D                                     BASED(PTR_AFTER)      
0076.00      D                                     QUALIFIED             
0077.00      ** ORIGINAL DB DEFINITION TO POPULATE                       
0078.00      D DBDS          E DS                  EXTNAME(F4102)        
0079.00      *********************************************************** 
0080.00      DARY              S             80A   DIM(5) CTDATA         
0081.00      ***********************************************************       
0082.00      ** IF CALL WITH NO PARMS THEN EXIT                                
0083.00      C                   IF        %PARMS = 0                          
0084.00      C                   EVAL      *INLR=*ON                           
0085.00      C                   RETURN                                        
0086.00      C                   ENDIF                                         
0087.00      ** POPULATE DATA STRUCTURES USING MEMORP POINTERS                 
0088.00       ** BEFORE IMAGE                                                  
0089.00      C                   IF        BUF.EVENT = UPDATE   OR             
0090.00      C                             BUF.EVENT = DELETE   OR             
0091.00      C                             BUF.EVENT = READ                    
0092.00      C                   EVAL      PTR_BEFORE = %ADDR(BUF) + BUF.BOFFSE
0093.00      C                   ENDIF                                         
0094.00       ** AFTER IMAGE                                                   
0095.00      C                   IF        BUF.EVENT = UPDATE   OR             
0096.00      C                             BUF.EVENT = INSERT                  
0097.00      C                   EVAL      PTR_AFTER = %ADDR(BUF) + BUF.AOFFSET
0098.00       ********                                                  
0099.00      C                   EXSR      SWRTF                        
0100.00      C                   ENDIF                                  
0101.00       ********                                                  
0102.00       ** SET FIELDS                                             
0103.00      C**                 EVAL      DBDSA.ZAALPH = 'MY VALUE'    
0104.00      C**                 EVAL      DBDSA.ZADSC1 = 'MY VALUE'    
0105.00       **  & EXIT                                                
0106.00      C                   EVAL      *INLR=*ON                    
0107.00      C                   RETURN                                 
0108.00      C*                                                         
0109.00      C*    END MAINLINE PROGRAM                                 
0110.00      C*    --------------------                                 
0111.00       **********************************************************
0112.00       *    SUBROUTINE SWRTF                                     
0114.00       **********************************************************       
0115.00      C     SWRTF         BEGSR                                         
0126.00       *                                                                
0126.01      C                   MOVE      DBDSA    DSLOG                      
0126.03      C                   IF        NOT %OPEN(FG4102AUD)                
0126.04      C                   OPEN      FG4102AUD                           
0126.05      C                   ENDIF                                         
0126.06      C                   WRITE     IG4102AUD                           
0126.07      C                   IF        %OPEN(FG4102AUD)                    
0126.08      C                   CLOSE     FG4102AUD                           
0126.09      C                   ENDIF                                         
0189.00      C                   ENDSR                                         
0190.00      C*****************************************************************
[+][-]12/26/07 09:25 AM, ID: 20529916

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/26/07 09:34 AM, ID: 20529959

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/26/07 09:38 AM, ID: 20529983

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/26/07 09:41 AM, ID: 20529998

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/26/07 09:49 AM, ID: 20530031

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/26/07 10:05 AM, ID: 20530099

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/26/07 10:19 AM, ID: 20530158

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/26/07 10:24 AM, ID: 20530176

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/26/07 11:58 AM, ID: 20530624

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/26/07 12:57 PM, ID: 20530873

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/26/07 05:14 PM, ID: 20531882

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/27/07 05:16 AM, ID: 20533748

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/27/07 08:35 AM, ID: 20535045

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/27/07 09:08 AM, ID: 20535301

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/27/07 11:06 AM, ID: 20536172

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]12/27/07 12:36 PM, ID: 20536975

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]12/27/07 02:26 PM, ID: 20537825

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Programming for iSeries / AS400
Tags: program, after, changes, log
Sign Up Now!
Solution Provided By: tliotta
Participating Experts: 3
Solution Grade: A
 
 
[+][-]12/28/07 02:16 AM, ID: 20540801

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20090824-EE-VQP-74 / EE_QW_2_20070628