SL5/6 Design Triggers
I read another reply you gave noticed you where on SL5+.
If you can trigger this event on a GUI maintenance screen, you may choose to use a entry or leave trigger. You can make this change clicking Design Button and selecting Triggers tab.
This will allow you to simply recompile on upgrades.
However, if you choose a db trigger, take into consideration that you must make sure trigger gets carried forward on upgrades. Many other downsides exist for db triggers. Vantage (DCD) was full of them and it was a nightmare.
I have included examples of both.
Good luck.
A. Entry/Leave Trigger (search help on trig-def).
Launches a custom program when you enter a screen-object. The trigger is a custom program written by the user or developer for a specific purpose, for example, setting default values, validating fields, confirming changes, or prompting for additional information when a user enters a field. After selecting the Override Default toggle-box, enter a program which will activate when you enter a screen-object.
EXAMPLE 1:
{lib/trig-def.i &object=cs/v-coitem}
IF coitem.item BEGINS "Widget"
AND coitem.qty-ordered-conv > 100 THEN DO:
MESSAGE "You may order only 100 Widgets!".
coitem.qty-ordered-conv = 100.0.
END.
EXAMPLE 2:
{lib/trig-def.i &object=item/v-itmhdr}
IF item.item BEGINS "Bolt" THEN
/* All Bolts have the same basic characteristics: */
ASSIGN
item.u-m = "EA"
item.product-code = "PP"
item.backflush = YES
item.bflush-loc = "PUR-1"
p-auto-save = YES.
Copyright © 2000 Symix Systems, Inc.
B. DB Trigger (Jobmatl Audit)
TRIGGER PROCEDURE FOR WRITE OF jobmatl OLD BUFFER old-jobmatl.
/* Procedure: triggers/jobmatl/update.p
*
* Revision XXXXXXXXXXXXXXXXXXXX
* XXXXXXXXXXXXXXXXXXXXXXXXXXX
*
*/
def new global shared var call-var as char.
def shared var call-var as char.
def var tz-audit-action like z-audmtl.audit-action init "A".
def var tz-audit-seq like z-audmtl.audit-seq init "1".
if jobmatl.item <> old-jobmatl.item or
jobmatl.matl-qty <> old-jobmatl.matl-qty then do:
find last z-audmtl no-lock where
z-audmtl.job = jobmatl.job and
z-audmtl.suffix = jobmatl.suffix and
z-audmtl.oper-num = jobmatl.oper-num and
z-audmtl.sequence = jobmatl.sequence no-error.
if avail z-audmtl then
assign
tz-audit-action = "U"
tz-audit-seq = z-audmtl.audit-seq + 1.
create z-audmtl.
assign
z-audmtl.job = jobmatl.job
z-audmtl.suffix = jobmatl.suffix
z-audmtl.oper-num = jobmatl.oper-num
z-audmtl.sequence = jobmatl.sequence
z-audmtl.audit-seq = tz-audit-seq
z-audmtl.audit-date = today
z-audmtl.audit-time = time
z-audmtl.audit-user = caps(call-var)
z-audmtl.audit-action = tz-audit-action
z-audmtl.audit-prog = "JOBMATL"
z-audmtl.item = jobmatl.item
z-audmtl.matl-qty = jobmatl.matl-qty
.
release z-audmtl.
end.
/* EOF */