Adding toolbar buttons on selection screen

In this recipe, we will see how toolbar buttons (and their relevant click code) may be added to selection screens. In this recipe, we will create a program that will display a selection screen having three toolbar buttons, each of which when clicked, takes us to a different transaction.

How to do it...

For adding buttons on your selection screen toolbar, proceed as follows:

  1. First, declare the dictionary structure, sscrfields.
  2. Here we define buttons with function keys 1, 2, and 3 using the selection-screen statement.
  3. Also, an integer abc is defined.
    How to do it...
  4. Within the initialization event, the respective texts for the buttons are assigned to the functxt_01, functxt_02, and functxt_03 fields of the structure sscrfields.
    How to do it...
  5. Next, within the at selection-screen event, we check the value of the field sscrfields-ucomm. The FC01, FC02, and FC03 values represent the button-click event of the first, second, and third buttons respectively. We call the respective transactions, SE38, SE80, and SBWP, for each button-click.
    How to do it...

How it works...

We will now see how the coding works in displaying the toolbar buttons along with the necessary button text, and how the respective transactions are called after button-click events.

The selection-screen statements' coding and the initialization creates the three toolbar buttons and the relevant texts, ABAP Editor, Object Navigator, and Business Workplace. The function code FC01, FC02, and FC03 are assigned to the three buttons. When any of the buttons are pressed, the at selection-screen event is called. The value of the field sscrfields-ucomm is checked. Depending on which button, the UCOMM field is automatically populated with FC01, FC02, or FC03. After checking the value, the relevant transaction code is called via the call transaction statement and the user is taken to the appropriate transaction.

How it works...
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.119.131.10