1 TRIGGER PROCEDURE FOR CREATE OF NewBatch.
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.
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.
30 NewBatch.BatchCode
= batch-code
31 NewBatch.PersonCode
= person-code.