Sample Program - Find Where Used Exits & Enhancements - Via CMOD & SMOD.



This sample program will help you to find whether a function module exit has already been assigned to any enhancements. Also it will give information regarding Project name & enhancement name related to the function module exit.


SAMPLE PROGRAM:



REPORT z_test_where_used_exit_smod_cmod.

SELECTION-SCREEN BEGIN OF SCREEN 100 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(30) userexit FOR FIELD member1.
PARAMETERS: member1 TYPE modsap-member. "Function Module (User EXIT)
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF SCREEN 100.


SELECTION-SCREEN BEGIN OF SCREEN 200 AS SUBSCREEN.
SELECTION-SCREEN BEGIN OF LINE.
SELECTION-SCREEN COMMENT 1(20) enhname FOR FIELD member2.
PARAMETERS: member2 TYPE modact-member. "Enhancement (SMOD)
SELECTION-SCREEN END OF LINE.
SELECTION-SCREEN END OF SCREEN 200.


SELECTION-SCREEN: BEGIN OF TABBED BLOCK mytab FOR 5 LINES,
TAB (40) button1 USER-COMMAND push1,
TAB (40) button2 USER-COMMAND push2 ,
END OF BLOCK mytab.


DATA: it_bdc TYPE STANDARD TABLE OF bdcdata.
DATA: et_modsap TYPE modsap,
et_modact TYPE modact,
et_bdc TYPE bdcdata,
v_cursorfield(20) TYPE c.

INITIALIZATION.

userexit = 'Function Module (User EXIT)'(001).
enhname = 'Enhancement (SMOD)'(002).
button1 = 'Where used - EXIT -> SMOD -> CMOD'(003).
button2 = 'Where used - Enhancement -> SMOD -> CMOD'(004).
mytab-prog = sy-repid.
mytab-dynnr = 100.
mytab-activetab = 'PUSH1'.

AT SELECTION-SCREEN.

CASE sy-dynnr.

WHEN 1000.

CASE sy-ucomm.
WHEN 'PUSH1'.
mytab-dynnr = 100.
WHEN 'PUSH2'.
mytab-dynnr = 200.
WHEN OTHERS.
ENDCASE.

ENDCASE.


START-OF-SELECTION.

CLEAR: et_modsap,
et_modact.
IF mytab-activetab = 'PUSH1'.

IF NOT member1 IS INITIAL.
SELECT SINGLE * FROM modsap
INTO et_modsap
WHERE member = member1 AND
typ = 'E'.
IF NOT et_modsap-name IS INITIAL.
SELECT SINGLE * FROM modact
INTO et_modact
WHERE member = et_modsap-name.
ENDIF.
ENDIF.

ELSE.

IF NOT member2 IS INITIAL.
SELECT SINGLE * FROM modact
INTO et_modact
WHERE member = member2.
ENDIF.

ENDIF.


END-OF-SELECTION.

IF mytab-activetab = 'PUSH1'.

IF NOT et_modact-name IS INITIAL.
WRITE: 'Project:'(005), et_modact-name.
ELSE.
WRITE: 'Project: not found'(006).
ENDIF.

IF NOT et_modsap-name IS INITIAL.
WRITE: / 'Enhancement:'(007), et_modsap-name.
ELSE.
WRITE: / 'Enhancement: not found'(008).
ENDIF.

ELSE.

IF NOT et_modact-name IS INITIAL.
WRITE: 'Project:'(005), et_modact-name.
ELSE.
WRITE: 'Project: not found'(006).
ENDIF.

ENDIF.


AT LINE-SELECTION.

CLEAR v_cursorfield.
GET CURSOR FIELD v_cursorfield.
CHECK NOT v_cursorfield IS INITIAL.
IF v_cursorfield = 'ET_MODACT-NAME'.

et_bdc-program = 'SAPMSMOD'.
et_bdc-dynpro = '1010'.
et_bdc-dynbegin = 'X'.
APPEND et_bdc TO it_bdc.
CLEAR et_bdc.

et_bdc-fnam = 'MOD0-NAME'.
et_bdc-fval = et_modact-name.
APPEND et_bdc TO it_bdc.
CLEAR et_bdc.

et_bdc-fnam = 'BDC_OKCODE'.
et_bdc-fval = '=SHOW'.
APPEND et_bdc TO it_bdc.
CLEAR et_bdc.

et_bdc-fnam = 'MODF-HEAD'.
et_bdc-fval = 'X'.
APPEND et_bdc TO it_bdc.

CALL TRANSACTION 'CMOD' USING it_bdc MODE 'E'.

ENDIF.

IF v_cursorfield = 'ET_MODSAP-NAME'.

et_bdc-program = 'SAPMSMOD'.
et_bdc-dynpro = '2010'.
et_bdc-dynbegin = 'X'.
APPEND et_bdc TO it_bdc.
CLEAR et_bdc.

et_bdc-fnam = 'MOD0-NAME'.
et_bdc-fval = et_modsap-name.
APPEND et_bdc TO it_bdc.
CLEAR et_bdc.

et_bdc-fnam = 'BDC_OKCODE'.
et_bdc-fval = '=SHOW'.
APPEND et_bdc TO it_bdc.
CLEAR et_bdc.

et_bdc-fnam = 'MODF-HEAS'.
et_bdc-fval = 'X'.
APPEND et_bdc TO it_bdc.

SET PARAMETER ID 'MON' FIELD et_modsap-name.
CALL TRANSACTION 'SMOD' USING it_bdc MODE 'E'.

ENDIF.


Output Screen:




Output will give you the name of the enhancement and the project name as shown below:



Similarly if you know the enhancement name



On executing you get the project name as shown:





Second Method to find the Project name and enhancement name of any function module exit:

Say you have function module exit - EXIT_SAPMM06E_006

Go to SE11 --> Table MODSAP --> In the enhancement field type the function module exit name and you will get the enhancement name for the function module exit.





Next Go to SE11 --> Table MODACT --> In the enhancement field type the enhancement name 'MM06E005' and you will get the project name for the enhancement.





RELATED POSTS:


- USER EXITS - Introduction, Importance & How To Find Them.

- Difference Between BADI & ENHANCEMENTS?

- Customer Exits - Introduction, Importance & It's Types.

- Difference between User Exits & Customer Exits?

- Function Module Exits (Customer Exits) - Introduction & How To Find Them.


- Finding Customer Exits - CALL CUSTOMER-FUNCTION Keyword.

- Finding Customer Exits Via SMOD Transaction.

- Finding Customer Exits Via SE81 SAP Transaction.

- Difference Between CMOD & SMOD SAP Transaction Codes?

- Implementing Customer Exits / Function Module Exits - With Example.


- Finding Project Name & Enhancement Name Of Function Module Exit & Vice-Versa - Sample Porgram With Example.

- Sample Program On Implementing Customer Exit - Step-By-Step.



Your suggestions and comments are welcome in this section.

Please mail all your contributions to administrator@abapmadeeasy.com We request you to mention your Name, Designation, Experience & Organization you are working for. Your posts will be verified and posted in this site with your name.