Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
Former Member
32,894

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.

   Create Table maintenance generator for ZTEST.

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

Go to Environment->modification->events.

Click on New entries.

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.

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.

Now enter the correct routine name and press enter.

Now click on Editor. Menu painter screen will open.

Now click on ‘Copy Interface’ as shown below.

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.

Press Continue.

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

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.

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

Add another button.

Save and activate.

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

Press Enter.

Now create a module in PAI.

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.

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.

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.

Give file name and enter.

11 Comments
Former Member
0 Kudos

Never tried this, as the event list for TMG is too long and this option is at bottom and icing over the cake am very lazy :wink: .

Seems useful.

Former Member
0 Kudos

Thanks.Better you try this one. :smile:

Former Member
0 Kudos

But I think this code will go away if I have to regenerate the screen.

(Screenshot after "Now create a module in PAI.")

eg. If I add a new field, I will have to regenerate the screen. At that point, my module statement would be erased, right? I am not sure what happens to events or GUI statuses. I guess that will be retained, but my module statement will definitely go away.

Is there any standard alternative to avoid this?

0 Kudos

Hi ,

I tried to create custom button , But it was not displayed once activated. I followed the same steps , with scenario 1 . But when i went to sm30 i could just see my screen. Please help

ec1
Active Participant
0 Kudos

Hi Sukanya,

Make sure you have added your button to the correct GUI status. The example above uses status EULG which is used when you change the table maintenance records.

kiran_k8
Active Contributor
0 Kudos

Thanks for sharing this Dipti.Will be damn usefull when we work with a more demanding client who is well verssed with Custom screens and the possibilities 🙂

Chinmay,

While regenerating you will get the option to what all needs to be considered for regeneration in the form of checkboxes.May be unchecking the maintenance screen checkbox will avoid the code getting erased.Have to be explored.

K.Kiran.

amy_king
Active Contributor
0 Kudos

Hi Diptilata,

Fantastic!! I just got this working and it's exactly what I needed. Thanks for writing this up with such detailed steps.

Cheers,

Amy King

former_member481085
Discoverer
0 Kudos
Excellent article.. Worked perfectly.. Thanks..
uba_heraeus
Discoverer
0 Kudos
Great! Very well done! Just what i needed.

It certainly would have taken quite some time to figure that one out.

Thank you.

Ulf

copy the status but still shows different program and Screen Number



 

sutthawee
Explorer
0 Kudos

Thank you a lot for sharing this. This is exactly the guide I need for the latest requirement I've got. 

But there's still a concern that it will be deleted once someone re-generate the maint view is still quite uneasy to prevent. 

 

If anyone read past my message and have any suggestion, could you please leave your message. Thank you in advance! 🙏🙏🙏

Labels in this area