Hiding the Execute button in an ABAP report selection screen

I thought it might be worthwhile sharing some of the tips and tricks I have learned over the years. This technique is one I am particularly fond of, as I found how to do this after scratching around in system programs for a long time.

ABAP report programs (type ‘1’) are used for a lot of things besides reports, and often it’s useful just to write some kind of utility program to do something small like change some settings or kick off something.

In those cases, you sometimes want a screen with a few buttons on it and, instead of running the report, just execute whatever you want from the AT SELECTION-SCREEN event. In this case, it would be nice to hide the standard execute button (function code ‘ONLI’).

noexec

Removing the execute button is not a practical consideration, merely a cosmetic one.

Here is a sample report selection screen from which we would like to remove the execute button:

before

 

To remove the button, what we want to do is to call the subroutine INSERT_INTO_EXCL in system program RSDBRUNT during the AT SELECTION-SCREEN OUTPUT event, passing the function code of the function code we wish to exclude, in this case ‘ONLI’ (the function code of the execute button on the generated selection screen 1000).

By adding the following code to your program, the button will be hidden.

at selection-screen output.
  perform insert_into_excl(rsdbrunt) using 'ONLI'.

And when you run it:

after

It turns out the same technique can be used to disable the Save button on the selection screen. After all, if there are no input fields, what is the point of saving a variant?

at selection-screen output.
* Remove Execute and Save functions on report selection screen
  perform insert_into_excl(rsdbrunt) using 'ONLI'.
  perform insert_into_excl(rsdbrunt) using 'SPOS'.

If you have defined additional selection screens in your report program, you should note that the function code for the execute button on the other screens is not ‘ONLI’, but ‘CRET’. So:

at selection-screen output.
  perform insert_into_excl(rsdbrunt) using 'SPOS'.
  if sy-dynnr = '1000'.
    perform insert_into_excl(rsdbrunt) using 'ONLI'.
  else.
    perform insert_into_excl(rsdbrunt) using 'CRET'.
  endif.