HI,
Gui button means, You need to capture sy-ucomm After pressing the button.
Now you can use modify command .
If the value will be change then matnr field will be updated. else It will be created.
If you want to use insert. You need to check matnr is avaibale or not with key field in the table
else. if the value is changed (modified) after you created compare this value from screen to
table if yes then you can use update or modify.