| 
 | 
Booth, Here is a sample program: I think that this should work fine. There is one drawback in this day and age. Who is the user in a DDM job? Who is the user in a PC job? Yes, on the PC you do have to log on to the 400, but does your job run under that user or under: Subsystem/Job User Type CPU % Function Status QSERVER QSYS SBS .0 DEQW QPWFSERV QUSER PJ .0 DEQW boothm@ibm.net on 06/29/98 06:07:26 PM Please respond to MIDRANGE-L@midrange.com@Internet To: MIDRANGE-L@midrange.com@Internet cc: Subject: re triggers I'd like to do a simple trigger program. What I'd really like to do is to fill in a "timestamp" and a "updated by" field on a record anytime it is created or changed, regardless of where it is done. The physical file is in arrrival sequence and unindexed. It seemed simple enough - a ADDPFTRG after *UPDATE with a simple program that moved the SDS's User field, and a TIME command into the correct fields, and update. That was where I realized I was in trouble... how do I find the relative record number that was just processed so I can easily find the correct record? Or is that the wrong approach altogether? -- ----------------------------------------------------------- boothm@ibm.net Booth Martin ----------------------------------------------------------- +--- | This is the Midrange System Mailing List! | To submit a new message, send your mail to MIDRANGE-L@midrange.com. | To subscribe to this list send email to MIDRANGE-L-SUB@midrange.com. | To unsubscribe from this list send email to MIDRANGE-L-UNSUB@midrange.com. | Questions should be directed to the list owner/operator: david@midrange.com +---
     F* Log of changes to file.
     FTESTLOGF  O    E             DISK
     D* Table of commit lock codes to their descriptions
     D TABLCK          S              1    DIM(4) CTDATA PERRCD(1) ASCEND
     D TABLDS          S              5    DIM(4) ALT(TABLCK)
     D* Table of file operations codes to their descriptions
     D TABOPC          S              1    DIM(3) CTDATA PERRCD(1) ASCEND
     D TABOPD          S              6    DIM(3) ALT(TABOPC)
     D* Table of when trigger occurred to it's description
     D TABTMC          S              1    DIM(2) CTDATA PERRCD(1) ASCEND
     D TABTMD          S             30    DIM(2) ALT(TABTMC)
     D* Data structure of parameter passed by file operation.
     D TRIG            DS
     D* Physical file name
     D  FILNAM                 1     10
     D* Physical file library
     D  LIBNAM                11     20
     D* Member name
     D  MBRNAM                21     30
     D* Trigger event, see table TABOPC
     D  EVENT                 31     31
     D* Trigger time, see table TABTMC
     D  TRTIME                32     32
     D* Commit lock level, see table TABLCK
     D  LCKLVL                33     33
     D* CCSID-Something to do with Character Code Set
     D  CCSID                 37     40B 0
     D* Offset to the original record
     D  OROFF                 49     52B 0
     D* Length of the original record
     D  ORRCL                 53     56B 0
     D* Offset to the original record null byte map
     D  ORNOFF                57     60B 0
     D* Length of the original byte map.  Should equal # of fields
     D  ORNLEN                61     64B 0
     D* Offset to the new record
     D  NWOFF                 65     68B 0
     D* Length of the new record
     D  NWRCL                 69     72B 0
     D* Offset to the new record null byte map
     D  NWNOFF                73     76B 0
     D* Length of the new record null byte map
     D  NWNLEN                77     80B 0
     D* Reserved data and record data.
     D  DATASTUFF             81    500
     D TRIGLENDS       DS
     D* Trigger buffer length
     D  TRIGLEN                1      4B 0
     D* External description of file being updated.
     D NEWREC        E DS                  EXTNAME(TESTFILE)
     C     *ENTRY        PLIST
     C                   PARM                    TRIG
     C                   PARM                    TRIGLENDS
     C* If this is a delete then move the old record data into the data
     C* structure.  Otherwise move the new data information.
     C                   Z-ADD     *ZEROS        START             5 0
     C                   Z-ADD     *ZEROS        SIZE              5 0
     C     EVENT         IFEQ      '2'
     C                   EVAL      START = OROFF-80+1
     C                   EVAL      SIZE  = ORRCL
     C                   ELSE
     C                   EVAL      START = NWOFF-80+1
     C                   EVAL      SIZE  = NWRCL
     C                   ENDIF
     C                   EVAL      NEWREC = %subst(datastuff:start:size)
     C* Retrieve job user profile
     C                   CALL      'RTVUSR'
     C                   PARM                    LUSERNAME
     C* Write out changes to log file.
     C                   EVAL      LRECKEY = RECKEY
     C                   EVAL      LACTION = EVENT
     C*                  EVAL      LUSERNAME =
     C                   TIME                    LTIMESTAMP
     C                   WRITE     TESTLOG
     C* On writes or updates, attempt to change record
     C     EVENT         IFNE      '2'
     C                   MOVEL     LUSERNAME     USERNAME
     C                   MOVE      LTIMESTAMP    DATTIM
     C                   EVAL      %subst(datastuff:start:size)=newrec
     C                   ENDIF
     C                   RETURN
**  TABLCK
0*NONE
1*CHG
2*CS
3*ALL
**  TABOPC
1INSERT
2DELETE
3UPDATE
**  TABTMC
1After the change operation
2Before the change operation
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.