Hello,
I am trying to get a trigger program to update a field in a file with the current timestamp to show when that record was last updated. I have the trigger set to this program whenever an update operation is performed on the file itself. In this trigger program, I am setting the timestamp field of the file in the after image to the current timestamp. Then I am updating the after image of the trigger buffer. I run this through debug and everything looks good but after the program runs, there is no change to the timestamp field in the file. Can anybody help me get this to work? Or is this even possible? My trigger program is below.
Thank you!
I am trying to get a trigger program to update a field in a file with the current timestamp to show when that record was last updated. I have the trigger set to this program whenever an update operation is performed on the file itself. In this trigger program, I am setting the timestamp field of the file in the after image to the current timestamp. Then I am updating the after image of the trigger buffer. I run this through debug and everything looks good but after the program runs, there is no change to the timestamp field in the file. Can anybody help me get this to work? Or is this even possible? My trigger program is below.
Thank you!
Code:
d PGMNAME pr d TrgBuffer_ like(TrgBuffer) d TrgBufLen_ like(TrgBufLen) d BefImg e ds extname(FILENAME) prefix(b_) d AftImg e ds extname(FILENAME) prefix(a_) d FILENAMER pi d p$TrgBuffer like(TrgBuffer) d p$TrgBufLen like(TrgBufLen) TrgBuffer = p$TrgBuffer; TrgBufLen = p$TrgBufLen; NRO = NewRecOff + 1; NRL = NewRecLen; ORO = OrgRecOff + 1; ORL = OrgRecLen; // Set Before / After Images BefImg = %subst(TrgBuffer:ORO:ORL); AftImg = %subst(TrgBuffer:NRO:NRL); select; // Update when TrgEvent = '3'; // Set last updated timestamp on record. a_lstupd = %timestamp(); %subst(TrgBuffer:NRO:NRL) = AftImg; p$TrgBuffer = TrgBuffer;
Comment