SM30 Disable Delete Icon Add Custom Button

作者:郑德鼎 约 4 分钟阅读 更新日期:2024-02-22 2 年前更新 标签:ABAP, 开发

How to Disable Delete Icon in SAP Table Maintenance Generator?

December 23, 2012 ABAP Dictionary 2

To disable icons in SAP table maintenance generator, first go to Table Maintenance Dialog Generator (SE56).

Enter the Table/View name for which you want to regenerate the TMG and click on Display button.

Double click on the screen number (i.e. 1 in this case) on which you want to disable the delete icon to navigate to screen painter.

Click on change icon and add a module (MODULE disable_icons). Double click on the MODULE disable_icons to add code.

Click on Yes button to create the disable_icons module.

Select LZEMPL001 and press continue to create a new include. The disable_icons module will be created inside this new (LZEMPL001) include.

Press continue button. This is just a warning,

Press Yes button to save the current program since we have added the disable_icons module in the screen painter flow logic and not yet saved.

In disable_icons module inside LZEMPL001 include add the above code. Just fill the exclude function table with function codes of icons that you want to disable. Activate the include  program.

Select all the related objects and press continue to activate all the objects.

Now to test it, go to Maintain Table Views (SM30).

Enter Table/View name and press Maintain button. Observe the DELETE icon is disabled after making the above changes.

Note: If you regenerate the table maintenance generator, then all the above changes will be lost. To avoid this we have another method to disable delete icon in table maintenance generator.

To disable the icons in the application toolbar of SAP table maintenance generator, use the following steps.

Just create a report program and use the function module “VIEW_MAINTENANCE_CALL” to maintain the view.

Fill the excluding table with function codes of icons that you want to disable.

*---------------------------------------------------------------------*

• Data Declaration

*---------------------------------------------------------------------*

DATA: gt_excl TYPE TABLE OF vimexclfun,

gwa_excl TYPE vimexclfun.

*---------------------------------------------------------------------*

• START-OF-SELECTION

*---------------------------------------------------------------------*

START-OF-SELECTION.

" Fill the function codes in exclude table that you want to disable

gwa_excl-function = 'DELE'. " Function code for delete icon
APPEND gwa_excl TO gt_excl.
CALL FUNCTION 'VIEW_MAINTENANCE_CALL'

EXPORTING

action = 'U'

view_name = 'ZEMPL'

TABLES

excl_cua_funct = gt_excl

EXCEPTIONS

client_reference = 1

foreign_lock = 2

invalid_action = 3

no_clientindependent_auth = 4

no_database_function = 5

no_editor_function = 6

no_show_auth = 7

no_tvdir_entry = 8

no_upd_auth = 9

only_show_allowed = 10

system_failure = 11

unknown_field_in_dba_sellist = 12

view_not_found = 13

maintenance_prohibited = 14

OTHERS = 15.

IF sy-subrc <> 0.

MESSAGE ID sy-msgid TYPE sy-msgty NUMBER sy-msgno

WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.

ENDIF.

Add Custom Button on Maintianence View (SM30)

By Naimesh Patel | September 23, 2008 | Table Maintenance | 38,155 | 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.

*

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

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

郑德鼎

关于作者:郑德鼎

企业信息化与 SAP 技术顾问,长期专注 SAP ABAP、FI/CO、MM、SD 等模块的技术分享与实战经验总结。查看更多介绍

来源说明:本文内容由「SM30 Disable Delete Icon Add Custom Button .docx」整理生成,仅用于内部技术分享与学习交流。