Detecting which field was changed in PostTransVal

Iann

New Member
Hello,
i would like to ask a simple question and if anyone knows and tells me, it would be great.
Is there a way to check if a concrete field is changed in PostTransactionValidation? I know that i can look in RowObjUpd.RowMod for the "U" flag, but this only indicates, that the update has been made. I want to start an operation if one field was changed and so far only option i see is checking the row in database using RowObjUpd.RowIdent. I also know i can compare RowObjUpd and RowObject in some preTraVal or beginTraVal, but i have my reasons why i want it in postTraVal.

Thanks for replies and please dont mind my grammar.
 

sunilnair

Member
in update mode there are two records in rowObjMod , one with rowmod = 'U' and another with rowmod = ''.

1) the record rowObjMod.rowmod = 'U' contains the updated values
2) the record with rowmod = '' , contains the pre-update values ...

A comparison of the two will tell you which field was updated.

I am not sure if this will work in postTransactionValidate , but it's worth a try ..

HTH
Sunil.
 
Hi there!

Two possible methods - find the before-image copy in the rowObjUpd table and compare to the updated copy, or use the ADM2's changedFields list. Both approaches work fine in postTransactionValidate (checked using v10.1A02). Here's some code demonstrating both approaches:

DEFINE VARIABLE cChangedFields AS CHARACTER NO-UNDO.
DEFINE BUFFER bRowObjUpd FOR rowObjUpd.

FOR EACH rowObjUpd WHERE CAN-DO("A,C,U",rowObjUpd.RowMod):

MESSAGE rowObjUpd.changedFields
VIEW-AS ALERT-BOX INFO BUTTONS OK.

FIND bRowObjUpd WHERE bRowObjUpd.rowNum = rowObjUpd.rowNum
AND bRowObjUpd.rowMod = ""
NO-ERROR.

IF AVAILABLE bRowObjUpd THEN
DO:
BUFFER-COMPARE bRowObjUpd EXCEPT rowMod TO rowObjUpd SAVE RESULT IN cChangedFields.

MESSAGE cChangedFields
VIEW-AS ALERT-BOX INFO BUTTONS OK.

END.
END.
 

Iann

New Member
Thanks a lot for both replies. I didnt know the changedFields fields, so i will try this out as soon as possible:).

Really thank you for advices, solved my struggle with whitepapers.

EDIT: I just realized, that theres before image and after image in RowObjUpd, its even in white papers, now i feel dumb...
 
Top