How to create custom button in TMG

Adding Custom button in Table maintenance Generator and their functionality        

Multiple events are defined by SAP to  handle PF status.

Following are the steps to create our own custom button on TMG.

Our example table is ZTEST.

pic1.PNG

   Create Table maintenance generator for ZTEST.

pic2.PNG

Now Go to the Event tab on table maintenance generator as shown in below screen shot.

Go to Environment->modification->events.

 

pic3.PNG

 

Click on New entries.

pic4.PNG

SAP has predefined events maintained for TMG, in which you can write your own logic if you want to do some processing. This events are triggered based on its criteria.

pic5.PNG

pic6.PNG

We are going to add one custom button in PF status.So enter event no as ‘ST’.Enter Form Routine no and press enter.You will get an error message as shown below.

pic7.PNG

pic23.PNG

Now enter the correct routine name and press enter.

pic8.PNG

Now click on Editor. Menu painter screen will open.

pic9.PNG

 

Now click on ‘Copy Interface’ as shown below.

pic10.PNG

 

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

 

pic11.PNG

Press Continue.

You will get one popup of language compatibility. Press Continue.

pic12.PNG

pic13.PNG

Now interface from the main program is copied to our FG.

We can check the status our table is using. Go to SM30.Give your table name.

Go to System->status->GUI status.

pic14.PNG

Now enter status name as ‘EULG’ and press Change.

pic15.PNG

Add another button.

pic16.PNG

Save and activate.

Now go to TMG. Go to Environment->Modification->Maintenance Screens.

pic17.PNG

Press Enter.

 

pic18.PNG

Now create a module in PAI.

pic19.PNG

pic20.PNG

pic21.PNG

pic22.PNG

You can add your functionality of pushbutton here.

Add this piece of code to your module.

 

CASE function.

WHEN 'POP'.
CALL FUNCTION 'POPUP_TO_INFORM'EXPORTING
titel =
'Information'
txt1 =
'No of selected entries are'
txt2 = mark_extract.endcase.

ENDCASE.

 

 

Scenario 2:

Add another pushbutton to our status.

Functionality: To download all the entries on action of a pushbutton.

Add the below code to your same module to achieve this functionality.

data l_filename like IBIPPARMS-PATH.data l_filename1 type string.

 

when 'DOWNLOAD'.
   
CALL FUNCTION 'F4_FILENAME'
    
EXPORTING
       PROGRAM_NAME        = sy-repid*     

      DYNPRO_NUMBER       = SYST-DYNNR*    

       FIELD_NAME          = ' '
    
IMPORTING
       FILE_NAME           = l_filename
              .
    l_filename1 = l_filename.

 

 

CALL FUNCTION 'GUI_DOWNLOAD'
 
EXPORTING*   BIN_FILESIZE                    =
    filename                        = l_filename1*   FILETYPE                        =
 
tables
    data_tab                        = extract[] .

 

 

Test the POPUP functionality:

 

Go TO SM30 and enter out table name ‘ZTEST’. Click on Maintain.

 

 

pic24.PNG

pic25.PNG

Remember that our TMG should be in change mode as we have added the pushbuttons to our change view status i.e. EULG.

Now we have 4 entries.

Select 3 entries and click on Pushbutton POPUP.

pic26.PNG

pic27.PNG

 

Test the DOWNLOAD functionality:

Now go back and click on DOWNLOAD pushbutton.

You will be asked to enter your file name into which you want to download your entries.

pic28.PNG

Give file name and enter.

 

pic29.PNG

pic30.PNG

猜你喜欢

转载自comtoexe.iteye.com/blog/2325961