|
Please find attached a set of routines that we have created, and some parts
come from News/400. This will provide you with the information that you
would like to record. Note: It potentially could fill up your job's message
queue if you have a PC running a big batch program using the AS/400 as a
database server. If that is the case you may want to add some code to call
the Remove Program message API.
and here is an example of a trigger program that we use to update audit
stamps for a given file
h Debug(*Yes) Option(*SrcStmt) Indent('| ') Actgrp(*Caller)
h Bnddir('DAADITRG')
*----------------------------------------------------------------
* Program: DAADITRG - DAADIPD trigger program
* Author: Brent Sauser
* Date: 08/24/1999
*
* Description:
* This trigger program will add the create/change user, program
* and timestamp to the file based on the trigger event.
*
* Input: InBuffer - Input buffer of record images and offsets
* InBufLen - Input buffer length
*
* Output: Changes input buffer, which are then written to the file
*
* Special Instructions:
* When adding the trigger to the file, use ALWREPCHG(*YES)
* and TRGTIME(*BEFORE)
*----------------------------------------------------------------
* Before trigger image
d B_RecordP s *
d B_Record e ds Extname(DAADIPD ) Prefix(B_)
d Based(B_RecordP)
* After trigger image
d A_RecordP s *
d A_Record e ds Extname(DAADIPD ) Prefix(A_)
d Based(A_RecordP)
d InBuffer ds 32000
d TrgFile 1 10
d TrgEvent 31 31
d B_Offset 49 52i 0
d B_Length 53 56i 0
d A_Offset 65 68i 0
d A_Length 69 72i 0
d InBufLen s 10i 0
d InPSSR s N Inz(*off)
/Copy Qcpylesrc,Gettrginfh
c *Entry plist
c parm InBuffer
c parm InBufLen
c eval B_RecordP = %addr(InBuffer) + B_Offset
c eval A_RecordP = %addr(InBuffer) + A_Offset
* Trigger events
c select
* On insert, do both the created and changed audit stamp
c when TrgEvent = '1'
c callp GetTrgInf(A_Crtu95:A_Crtp95:A_Crts95)
c eval A_Chgu95 = A_Crtu95
c eval A_Chgp95 = A_Crtp95
c eval A_Chgs95 = A_Crts95
* On update, do the changed audit stamp
c when TrgEvent = '3'
c callp GetTrgInf(A_Chgu95:A_Chgp95:A_Chgs95)
c endsl
c eval *inlr = *on
c return
*---------------------------------------------------------------------
c *PSSR begsr
c if InPSSR = *off
c eval InPSSR = *on
c dump
c endif
c endsr '*CANCL'
I hope that helps!
Eric
______________________________________________
Eric N. Wilson
President
Doulos Software & Computer Services
2913 N Alder St.
Tacoma WA 98407
----- Original Message -----
From: Bill Graziano <Bill.Graziano@besi.com>
To: <RPG400-L@midrange.com>
Sent: Friday, October 22, 1999 4:21 AM
Subject: Trigger program
> I have a file that is being written to an excessive number of times. For
> example, one record should be written for each of 40 business locations.
> Instead of one record, as many as 400 records are being written for some
> business locations. I am trying to pin down when and by which program are
> the records being written. According to my system administrator,
journaling
> did not help determine this. I believe that I need to add a physical file
> trigger and write a trigger program.
>
> I have not written any trigger programs and need some suggestions. I have
> identified the file update program. What I need to know is when is this
> update program being executed and, if possible, what program is calling
the
> file update program. Any suggestions or ideas will be greatly appreciated.
>
> Thanks,
> Bill Graziano
>
> +---
> | This is the RPG/400 Mailing List!
> | To submit a new message, send your mail to RPG400-L@midrange.com.
> | To subscribe to this list send email to RPG400-L-SUB@midrange.com.
> | To unsubscribe from this list send email to RPG400-L-UNSUB@midrange.com.
> | Questions should be directed to the list owner/operator:
david@midrange.com
> +---
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.