Please let me know if this is the correct trigger to achieve what is required.I would use the DB2 Post-Query (PQ) trigger instead of the Key-Exeqry trigger. In the Key-Exeqry - you are probably looping through your DB2 block and evaluating each record. By moving the code to the DB2 PQ trigger - you don't have to loop through your block as the PQ trigger fires for each record displayed in the block. This is more efficient that looping through your block and it will allow you to encapsulate your validation/enabling logic (see comment below) so you can write your validation/enabling logic once and reuse it.
Based on the value of item1 , item 2 ,3, 4 etc are either insert allowed or update allowed.This is achieved by using the set_item_instance_property on the when validate item of item (Enabling the insert allowed or updated allowed as needed) >
Wondering if the same logic at when validate item level is repeted at KEY_EXEQRY of the header block as mentioned in the initial post..will it workDon't repeat the logic! Instead, I suggest you create a Forms Program Unit (Procedure) and move your logic from the When-Validate-Item to the Procedure. Then call your Procedure from your When-Validate-Item and your Post-Query triggers.