What you need to do is have a function code assigned to the pushbutton on the screen that has the function type "Exit".
Then you can use the event AT SELECTION-SCREEN ON EXIT-COMMAND
in your report (I assume you are talking about a report because you talk about selection screens). This event is called by the system before validating the fields on the screen. Here you can implement all your necessary logic.
However, the only way I can think how to do that is to copy the standard GUI status %_00
from program RSSYSTDB
to your program and add your function code and make it a type "exit". Then in AT SELECTION-SCREEN OUTPUT
you can use the SET PF-STATUS
command to override the standard GUI status. (Otherwise if you assign a function code to your pushbutton, but it will not receive special treatment to trigger the ON EXIT-COMMAND
event).
EDIT:
I just tried this and it works, but not when assigning the function code to a pushbutton (using SELECTION-SCREEN PUSHBUTTON
). Instead, I had to add the function code as a button on the toolbar. Then it triggers the AT SELECTION-SCREEN OUTPUT
event).
EDIT 2: (Just copied my comment from below into here because it is important to note) By the way, I had to rename the %_00 GUI status to something else when I copied it. Otherwise, even when specifying the addition FROM PROGRAM in SET PF-STATUS, it would still use the old GUI status from RSSYSTDB.