Add Custom Button on Maintianence View (SM30)

By | September 23, 2008 | Table Maintenance | 22,789 | 17

Whenever we generate the table maintianence, SAP generates some new code and use the Shared code for the Table maintainence generator. Since long time, I was wondering how can I add my own custom PF buttons in the table maintainence screen which comes in SM30. Today, this discussion in the SDN form raised this point in my mind again – Adding Custon button on Maintainance View.

I have started searching the GUI status in the Function Group which I have provided in the Table maintainence generator, but I didn’t find it in the object browser (SE80) of the Function group. So, I thought this must be taken care by the Events in the Table maintainence. I searched the list and I found suitable one – ST (GUI Menu Main Program Name). Follow this link for mor information on Table maintenace events – Extended Table Maintenance Events

To add a custom button we need to follow couple of steps:
1. Create Table Maintainence.
Obviously today’s discussion is based on the Table maintaince, we must have that before we start it. For a information purpose, I will attach a screen shot of the Table maintaince.

2. Copy user Interface of program SAPLSVIM to our FG
We will copy all the user interface of the main table maintainence program to our Fuction Group. Table maintainence runtime uses the user interface from the program SAPLSVIM. So, we are unable to find any user interface in our FG.

There will be one popup of language compatability, which you can pass it on by pressing Enter.

3. Add Custom Button in the PF-Status
Here we need to identify the proper PF-Status from all the statues. We will use the EULG pf-status which is being called when you enter in SM30 with Change mode. We will add the button with code “0POPUP” We can simply check which pf-status is being used in the each screen of the SM30 by going System > Status > GUI status. We will activate the changed status.

4. Add Event ST in the Table modification Events
Open the table maintainence generator screen and follow: Environment -> Modification -> Events. Select ST from the values and enter the FG main program name. For this example SAPLZTEST_TABLES.

5. Add PAI module in the Screen
Now, we need to create a new PAI module in the Screen flow. We will create the module 0CUSTOM_PF_BUTTON in the Screen. We will create this module in a New Custom include by selecting it from the popup.

In this code snippet, I am showing how to handle our user command. Here I am just giving information popup when user interact with the button in the change mode.
Code Snippet for Handling custom button

***INCLUDE LZTEST_TABLESI01 .
*----------------------------------------------------------------------*
*&---------------------------------------------------------------------*
*&      Module  CUSTOM_PF_BUTTON  INPUT
*&---------------------------------------------------------------------*
*       Custom Button Handling
*       Here TOTAL table is avliable with all the data. 
*       User command is stored in the field FUNCTION
*----------------------------------------------------------------------*
MODULE 0custom_pf_button INPUT.
*
  DATAl_count TYPE i.
* Table of the same structure of the TOTAL which can be exported
  DATABEGIN OF itab OCCURS 0.
        INCLUDE STRUCTURE ztest_pf_status.
        INCLUDE STRUCTURE vimflagtab.
  DATAEND OF itab.
*
  CASE function.
    WHEN '0POPUP'.
      itab[] total[].
*
      DELETE itab WHERE mark IS INITIAL.
      DESCRIBE TABLE itab LINES l_count.
*
      CALL FUNCTION 'POPUP_TO_INFORM'
        EXPORTING
          titel         'Information'
          txt1          'Selected number of entries'
          txt2          l_count.
*
      CLEAR l_count.
*
  ENDCASE.
*
ENDMODULE.                 " CUSTOM_PF_BUTTON  INPUT

Don’t forget to activate the Function Group, since we have created a new include in it.

6. Custom button on the SM30
Here is the screenshot of the SM30 with our new added custom button.

After pressing button, it will react like this:

Like It? Share!!

Don't miss an Update

Get notified of the new post, right into your inbox

Naimesh Patel{272 articles}

I'm SAP ABAP Consultant for more than a decade. I like to experiment with ABAP especially OO. I have been SDN Top Contributor.
Follow :

Explore all of his 272 articles.

Load comments

17 Comments

  • Good post !!

  • Anonymous

    A Very Useful Posting….Keep up the good work.. :)

  • Anonymous

    Thanks Man :)
    It is Very helpfull post.
    Keep going in same fashion, CIAO !!!

  • Thanks alot…
    your post is very helpful to all
    really i impressed alot.

    thanks,
    laxmi

  • nafi925

    there are much more things we can do using table control. I mean some go to the option of creating a module pool program when entering information but there are lots of flexibilities on table maintanence

  • Anonymous

    but if you'll regenerate your screen you module will disapear. is there any solution?

  • Anonymous

    Good work…Thanks a lot of sharing the knowledge.

  • Bruce Tjosvold

    I have modified table maintenance dialogs in the past. This can be a very useful thing to do.

    One thing to be aware of, if the table ever changes, and the maintenance dialog is deleted and recreated, all custom changes to the maintenance dialog will be lost.

    I add all code that is in each event into the table documentation. This allows me to be able to easily and quickly recreate the events and their associated code.

    Keep up the good work.
    Bruce

  • Anonymous

    thank you so much :)

  • Anonymous

    It has been very helpful for me.
    But I still have the following problem: if I select some records and push an execution button that does some functionality, I want to delete from the view the successful records.
    But I'm able to do that only in PAI – using the function DELE. But it is not correct, it should be in PBO.
    Can anyone has a solution?
    Thank you very much!

  • Anonymous

    very good dude

  • Anonymous

    i have added new button to Ztable and then i have created include this table programs. but when i push the button it doesn't works. i need that, push this button it must call another programs (report in se38).
    how can i do that?

  • Anonymous

    Good Work…..

  • Anonymous

    It was very helpful!! solved a lot of issues. even the sample code u wrote ws very helpful!good work!

  • Raghu

    It has been very helpful for me.

  • Hi Naimesh

    Thanks for wonderful documentation. I appreciate you for sharing your knowledge.

  • Ram

    The above implementation looks promising, it would be better if you would have also mentioned how to handle future modifications / changes.
    ** Like, what if i regenerate the maintenance?
    ** How to make the changes without effecting our custom code? etc..,

Comments on this Post are now closed. If you have something important to share, you can always contact me.

You seem to be new here. Subscribe to stay connected.