HI Koray,
i think your button already have a function code, right?
then you can in your z-program run define a period or times, it`s used to restract how many times this button will run.
Do n TIEMS.
call function 'SAPGUI_SET_FUNCTIONCODE'
exporting
functioncode = '&BUTTON' "this is function code of your button.
* EXCEPTIONS
* FUNCTION_NOT_SUPPORTED = 1
* OTHERS = 2
.
wait up to 5 seconds. " the second decided by your frequency.
ENDDO.
hope can help you.
Regards,
Archer