Hi,
For dynamic screen manipulation you have to write code in PBO only as PBO will be called after each PAI. So move your code to PBO.
Here in your case, take a global variable and set it in PAI, Then in PBO check that attribute and change the screen attribute.
Sample:
Data gv_button_click type boole_d.
PBO..
Module output.
loop at screen.
if screen-name = 'BUTTON' " button is button's screen name.
if gv_button_click = abap_true.
screen-invisible = '1'.
endif.
endif.
Modify screen.
endloop.
PAI..
Module Input..
case ok_code.
when 'SUBMIT' " submit is function code for button.
gv_button_click = abap_true. " setting the global variable value
endcase.
Hope this helps u,
Regards,
Kiran