Add a new UserGroupRight to control access to open/close months.
[capital-apms-progress.git] / trigger / crnewbch.p
blobaa401fe479ecfc71c760e2c7f4a7014471bd646c
1 TRIGGER PROCEDURE FOR CREATE OF NewBatch.
3 DO:
5 DEF VAR batch-code AS INT NO-UNDO.
6 DEF VAR person-code LIKE Person.PersonCode NO-UNDO.
7 DEF VAR user-name AS CHAR NO-UNDO.
9 DEF BUFFER LastNewBatch FOR NewBatch.
10 DEF BUFFER LastBatch FOR Batch.
12 FIND LAST LastNewBatch /* WHERE LastNewBatch.BatchType <> "ACCR" */ NO-LOCK NO-ERROR.
13 FIND LAST LastBatch NO-LOCK NO-ERROR.
15 batch-code =
16 IF AVAILABLE LastNewBatch AND AVAILABLE LastBatch THEN
17 MAXIMUM( LastNewBatch.BatchCode, LastBatch.BatchCode ) + 1 ELSE
18 IF NOT AVAILABLE LastNewBatch AND AVAILABLE LastBatch THEN
19 LastBatch.BatchCode + 1 ELSE
20 IF AVAILABLE LastNewBatch AND NOT AVAILABLE LastBatch THEN
21 LastNewBatch.BatchCode + 1 ELSE 1.
23 user-name = OS-GETENV( "PROPUSER" ).
24 IF user-name = ? THEN user-name = "Unknown".
26 FIND Usr WHERE Usr.UserName = user-name NO-LOCK NO-ERROR.
27 IF AVAILABLE(Usr) THEN person-code = Usr.PersonCode. ELSE person-code = 0.
29 ASSIGN
30 NewBatch.BatchCode = batch-code
31 NewBatch.PersonCode = person-code.
33 END.