How to check if data has been changed
There is a system variable SY-DATAR. If any value is changed in the screen it will have 'X'.Otherwise it will be initial.
SY-DATAR is to be used along with a flag.
In PAI set flag using SY-DATAR.
ie
if sy-datar is not initial. flag = 1. endif.
Now in
Module exit_command..
if sy-datar is initial and flag is initial.
...
else.
.....
endif
endmodule

refer to:http://scn.sap.com/thread/787703