How To Add Custom Button To View.

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

Adding Custom Button to Maintenance View (SM30)

Whenever we generate the table maintenance, SAP generates some new code and use the Shared code for the Table maintenance generator. Since long time, I was wondering how can I add my own custom PF buttons in the table maintenance screen which comes in SM30. Today, this discussion in the SDN form raised this point in my mind again - Adding Custom button on Maintenance View. I have started searching the GUI status in the Function Group which I have provided in the Table maintenance 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 maintenance. I searched the list and I found suitable one - ST (GUI Menu Main Program Name). Follow this link for mor information on Table maintenance events - Extended Table Maintenance Events To add a custom button we need to follow couple of steps: 1. Create Table Maintenance. Obviously today's discussion is based on the Table maintenance, we must have that before we start it. For a information purpose, I will attach a screen shot of the Table maintenance.

2. Copy user Interface of program SAPLSVIM to our FG We will copy all the user interface of the main table maintenance program to our Fuction Group. Table maintenance 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 pfstatus 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 maintenance 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. * DATA: l_count TYPE i. * Table of the same structure of the TOTAL which can be exported DATA: BEGIN OF itab OCCURS 0. INCLUDE STRUCTURE ztest_pf_status. INCLUDE STRUCTURE vimflagtab. DATA: END 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

You might also like