Really, this should be it, for the passing income.
[capital-apms-progress.git] / trigger / wrvaritn.p
blobdce8d3e704ea634e25c3f0782f8de6bc0ef73c3a
1 TRIGGER PROCEDURE FOR WRITE OF Variation OLD BUFFER old-VAR.
3 /* {inc/audit.i "Variation"} */
5 FUNCTION get-last-variation RETURNS INTEGER
6 ( INPUT prj-code AS INTEGER ) FORWARD.
9 IF NEW Variation THEN
10 Variation.VariationCode = get-last-variation(Variation.ProjectCode).
11 ELSE IF Variation.ProjectCode <> old-Var.ProjectCode
12 OR Variation.VariationCode <> old-Var.VariationCode THEN DO:
13 IF Variation.ProjectCode <> old-Var.ProjectCode THEN
14 Variation.VariationCode = get-last-variation(Variation.ProjectCode).
15 FOR EACH VariationFlow OF old-Var EXCLUSIVE-LOCK:
16 VariationFlow.ProjectCode = Variation.ProjectCode.
17 VariationFlow.VariationCode = Variation.VariationCode.
18 END.
19 END.
23 FUNCTION get-last-variation RETURNS INTEGER ( INPUT prj-code AS INTEGER ).
24 DEF BUFFER LastVar FOR Variation.
26 FIND LAST LastVar WHERE LastVar.ProjectCode = prj-code
27 AND RECID(LastVar) <> RECID(Variation) NO-LOCK NO-ERROR.
28 IF AVAILABLE(LastVar) THEN RETURN LastVar.VariationCode + 1.
29 RETURN 1.
31 END FUNCTION.