Added capital works blank section. Synced calling screen.
[capital-apms-progress.git] / rplctn / wreptrig.i
blob78388b6f57c7f46af206b34710d84d29f2a05212
1 /*
2 System: Property Management and Finance System
3 Program: wreptrig.i
4 Author: Donald Christie
5 Date: 26/08/97
6 Description: Generic include file to create replication entries in the
7 replication log table on modify
8 Goes on the Replication-Write trigger which also handles create events
9 (the write triggers always fire).
10 Usage: Pass in the table name and action.
11 &rtable = <name of the table of this trigger>
13 Modification Notes:
14 On By Because
15 6/4/1999 Andrew The batch processor (process/bq-processor.p) updates an
16 OfficeSettings record every five seconds and since the
17 record is designed to indicate that the local batch queue
18 is not dead yet, the record should not be replicated.
19 Really, the better solution would be to change the batch
20 processor to use an RP record, but there's no guarantee
21 someone wouldn't replicate them either.
22 The perfect solution would be to use a file which cannot
23 be replicated (i.e. is explicitly excluded from replication).
24 Meanwhile, the record is explicitly excluded instead.
27 {inc\ofc-this.i}
29 /* check that replication is valid at this site...*/
30 /* Use a can-find because sometimes progress stuffs up
31 and reports that it can't find a repltrigger record
32 although there is a no-error clause on the find */
34 IF CAN-FIND( FIRST ReplTrigger WHERE ReplTrigger.TableToRepl = "{&rtable}" ) THEN
35 DO:
37 /*** Following 3 lines added by Andrew on 6 April 1999 ***/
38 &IF "{&rtable}" = "OfficeSettings" &THEN
39 IF newOfficeSettings.SetName = "Batch-Queue-Enabled" THEN RETURN.
40 &ENDIF
42 FIND FIRST ReplTrigger WHERE ReplTrigger.TableToRepl = "{&rtable}"
43 NO-LOCK NO-ERROR.
44 IF INDEX (ReplTrigger.Activity, "M") = 0 OR
45 INDEX (ReplTrigger.Activity, "C") = 0 THEN RETURN.
47 /* because the NEW function does not work we have created a
48 blank repl entry in the replication create trigger
49 if this is a new record...*/
50 FOR EACH ReplLog WHERE ReplLog.TableToRepl = '{&rtable}'
51 AND ReplLog.TransactID = DBTASKID (LDBNAME (BUFFER {&rtable}))
52 AND ReplLog.TableRowID = RECID (new{&rtable})
53 EXCLUSIVE-LOCK:
54 LEAVE.
55 END.
57 IF AVAILABLE ReplLog /* must be a created record */
58 AND INDEX (ReplTrigger.Activity, "C") <> 0
59 THEN DO:
60 RAW-TRANSFER new{&rtable} to ReplLog.ReplAI.
61 ReplLog.ReplBI = ?.
62 END.
64 ELSE IF NOT AVAILABLE ReplLog
65 AND INDEX (ReplTrigger.Activity, "M") <> 0
66 THEN DO: /* must be an existing record */
67 CREATE ReplLog.
69 ASSIGN ReplLog.ReplID = NEXT-VALUE (Replid)
70 ReplLog.OfficeCode = Office.OfficeCode
71 ReplLog.TableToRepl = '{&rtable}'
72 ReplLog.TransactID = DBTASKID (LDBNAME (BUFFER {&rtable}))
73 ReplLog.TableRowid = RECID (new{&rtable})
74 ReplLog.ReplDate = TODAY
75 ReplLog.ReplTime = TIME
76 ReplLog.ReplEvent = "M".
78 END. /* IF NOT AVAILABLE */
80 IF AVAILABLE ReplLog
81 AND ReplLog.ReplEvent = "M" THEN DO:
82 RAW-TRANSFER new{&rtable} to ReplLog.ReplAI.
83 RAW-TRANSFER old{&rtable} to ReplLog.ReplBI.
84 END.
86 END. /* if available repltrigger */