Userexits in a Transaction

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Listing UserExits in Transactions

SDN Community Contribution


(This is not an official SAP document.)

Disclaimer & Liability Notice

This document may discuss sample coding or other information that does not include SAP official interfaces
and therefore is not supported by SAP. Changes made based on this information are not supported and can
be overwritten during an upgrade.

SAP will not be held liable for any damages caused by using or misusing the information, code or methods
suggested in this document, and anyone using these methods does so at his/her own risk.

SAP offers no guarantees and assumes no responsibility or liability of any type with respect to the content of
this technical article or code sample, including any liability resulting from incompatibility between the content
within this document and the materials and services offered by SAP. You agree that you will not hold, or seek
to hold, SAP responsible or liable with respect to the content of this document.

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 1


Listing UserExits in Transactions

Applies To:
SAP 4.6C and SAP SAP 4.7 Enterprise Edition

Summary
To display and list out the Userexits for a given transaction.

By: Rajasekhar Dinavahi

Company: Intelligroup Asia

Date: 15 Nov 2005

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 2


Listing UserExits in Transactions

*&---------------------------------------------------------------------*

*& Report Z_USEREXIT_DISPLAY *

*& *

*&---------------------------------------------------------------------*

*& *

*& *

*&---------------------------------------------------------------------*

* Title : Display UserExits *

* Object Owner : RAJ *

* Functional Consultant : *

* Technical Consultant : Mr. Rajasekhar Dinavahi *

* Date : 15-Nov-2005 *

* Transport Request No : *

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

* Modification Log *

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

* ModNo Date Consultant Description of Change(s) *

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

* *

************************************************************************

REPORT Z_USEREXIT_DISPLAY

NO STANDARD PAGE HEADING

LINE-SIZE 200

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 3


Listing UserExits in Transactions

MESSAGE-ID ZZ.

*&---------------------------------------------------------------------*

* TABLE DECLARATIONS *

*&---------------------------------------------------------------------*

TABLES: TFTIT,

E071,

E070.

*&---------------------------------------------------------------------*

* STRUCTURE DECLARATIONS *

*&---------------------------------------------------------------------*

TYPES: BEGIN OF X_TSTC,

TCODE TYPE TCODE,

PGMNA TYPE PROGRAM_ID,

END OF X_TSTC.

TYPES: BEGIN OF X_TADIR,

OBJ_NAME TYPE SOBJ_NAME,

DEVCLASS TYPE DEVCLASS,

END OF X_TADIR.

TYPES: BEGIN OF X_SLOG,

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 4


Listing UserExits in Transactions

OBJ_NAME TYPE SOBJ_NAME,

END OF X_SLOG.

TYPES: BEGIN OF X_FINAL,

NAME TYPE SMODNAME,

MEMBER TYPE MODMEMBER,

INCLUDE(15), "Include name

END OF X_FINAL.

*&---------------------------------------------------------------------*

* INTERNAL TABLE DECLARATIONS *

*&---------------------------------------------------------------------*

DATA: IT_TSTC TYPE STANDARD TABLE OF X_TSTC WITH HEADER LINE.

DATA: IT_TADIR TYPE STANDARD TABLE OF X_TADIR WITH HEADER LINE.

DATA: IT_JTAB TYPE STANDARD TABLE OF X_SLOG WITH HEADER LINE.

DATA: IT_FINAL TYPE STANDARD TABLE OF X_FINAL WITH HEADER LINE.

*&---------------------------------------------------------------------*

* VARIABLES DECLARATIONS *

*&---------------------------------------------------------------------*

*&---------------------------------------------------------------------*

* USER INPUTS SCREEN *

*&---------------------------------------------------------------------*

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 5


Listing UserExits in Transactions

*&---------------------------------------------------------------------*

* SELECTION SCREEN *

*&---------------------------------------------------------------------*

SELECTION-SCREEN: BEGIN OF BLOCK BLK01 WITH FRAME TITLE TEXT-T01.

PARAMETERS: P_TCODE LIKE TSTC-TCODE OBLIGATORY.

SELECTION-SCREEN END OF BLOCK BLK01.

*&---------------------------------------------------------------------*

* Start of Selection *

*&---------------------------------------------------------------------*

START-OF-SELECTION.

PERFORM GET_TCODES. "Get Tcodes

PERFORM GET_OBJECTS. "Get Objects

*&---------------------------------------------------------------------*

* End of Selection *

*&---------------------------------------------------------------------*

END-OF-SELECTION.

PERFORM DISPLAY_RESULTS. "Display Results

*&---------------------------------------------------------------------*

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 6


Listing UserExits in Transactions

*& Form get_tcodes

*&---------------------------------------------------------------------*

* Get Tcodes

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

FORM GET_TCODES.

SELECT TCODE

PGMNA

INTO TABLE IT_TSTC

FROM TSTC

WHERE TCODE = P_TCODE.

IF SY-SUBRC = 0.

SORT IT_TSTC BY TCODE.

ENDIF.

ENDFORM. " get_tcodes

*&---------------------------------------------------------------------*

*& Form get_objects

*&---------------------------------------------------------------------*

* Get Objects

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

FORM GET_OBJECTS.

DATA: L_FNAME LIKE RS38L-NAME,

L_GROUP LIKE RS38L-AREA,

L_INCLUDE LIKE RS38L-INCLUDE,

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 7


Listing UserExits in Transactions

L_NAMESPACE LIKE RS38L-NAMESPACE,

L_STR_AREA LIKE RS38L-STR_AREA.

DATA: V_INCLUDE LIKE RODIOBJ-IOBJNM.

DATA: E_T_INCLUDE TYPE STANDARD TABLE OF ABAPSOURCE WITH HEADER


LINE.

DATA: L_LINE TYPE STRING,

L_TABIX LIKE SY-TABIX.

IF NOT IT_TSTC[] IS INITIAL.

SELECT OBJ_NAME

DEVCLASS

INTO TABLE IT_TADIR

FROM TADIR FOR ALL ENTRIES IN IT_TSTC

WHERE PGMID = 'R3TR' AND

OBJECT = 'PROG' AND

OBJ_NAME = IT_TSTC-PGMNA.

IF SY-SUBRC = 0.

SORT IT_TADIR BY OBJ_NAME DEVCLASS.

SELECT OBJ_NAME

INTO TABLE IT_JTAB

FROM TADIR FOR ALL ENTRIES IN IT_TADIR

WHERE PGMID = 'R3TR' AND

OBJECT = 'SMOD' AND

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 8


Listing UserExits in Transactions

DEVCLASS = IT_TADIR-DEVCLASS.

IF SY-SUBRC = 0.

SORT IT_JTAB BY OBJ_NAME.

ENDIF.

ENDIF.

ENDIF.

*- Get UserExit names

LOOP AT IT_JTAB.

SELECT NAME

MEMBER

INTO (IT_FINAL-NAME, IT_FINAL-MEMBER)

FROM MODSAP

WHERE NAME = IT_JTAB-OBJ_NAME AND

TYP = 'E'.

APPEND IT_FINAL.

CLEAR IT_FINAL.

ENDSELECT.

ENDLOOP.

*- Process it_final contents.

LOOP AT IT_FINAL.

L_TABIX = SY-TABIX.

CLEAR: L_FNAME,

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 9


Listing UserExits in Transactions

L_GROUP,

L_INCLUDE,

L_NAMESPACE,

L_STR_AREA.

L_FNAME = IT_FINAL-MEMBER.

CALL FUNCTION 'FUNCTION_EXISTS'

EXPORTING

FUNCNAME = L_FNAME

IMPORTING

GROUP = L_GROUP

INCLUDE = L_INCLUDE

NAMESPACE = L_NAMESPACE

STR_AREA = L_STR_AREA

EXCEPTIONS

FUNCTION_NOT_EXIST = 1

OTHERS = 2.

IF SY-SUBRC = 0.

IF NOT L_INCLUDE IS INITIAL.

*- Get Source code of include.

CLEAR: V_INCLUDE, E_T_INCLUDE, E_T_INCLUDE[].

V_INCLUDE = L_INCLUDE.

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 10


Listing UserExits in Transactions

CALL FUNCTION 'MU_INCLUDE_GET'

EXPORTING

I_INCLUDE = V_INCLUDE

TABLES

E_T_INCLUDE = E_T_INCLUDE.

IF SY-SUBRC = 0.

LOOP AT E_T_INCLUDE.

IF E_T_INCLUDE-LINE CS 'INCLUDE'.

CLEAR L_LINE.

L_LINE = E_T_INCLUDE-LINE.

CONDENSE L_LINE NO-GAPS.

TRANSLATE L_LINE USING '. '.

L_LINE = L_LINE+7(9).

IT_FINAL-INCLUDE = L_LINE.

MODIFY IT_FINAL INDEX L_TABIX TRANSPORTING INCLUDE.

ENDIF.

ENDLOOP.

ENDIF.

ENDIF.

ENDIF.

ENDLOOP.

ENDFORM. " get_objects

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 11


Listing UserExits in Transactions

*&---------------------------------------------------------------------*

*& Form display_results

*&---------------------------------------------------------------------*

* Display Results

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

FORM DISPLAY_RESULTS.

FORMAT COLOR COL_HEADING.

WRITE:/1(150) SY-ULINE.

WRITE:/ SY-VLINE,

2(23) 'Extension Name',

24 SY-VLINE,

25(39) 'Exit Name',

64 SY-VLINE,

65(74) 'Description',

140 SY-VLINE,

141(9) 'Include',

150 SY-VLINE.

WRITE:/1(150) SY-ULINE.

FORMAT RESET.

SORT IT_FINAL BY NAME MEMBER.

LOOP AT IT_FINAL.

CLEAR TFTIT.

SELECT SINGLE STEXT

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 12


Listing UserExits in Transactions

INTO TFTIT-STEXT

FROM TFTIT

WHERE SPRAS = 'EN' AND

FUNCNAME = IT_FINAL-MEMBER.

WRITE:/ SY-VLINE,

IT_FINAL-NAME COLOR COL_KEY, 24 SY-VLINE,

25 IT_FINAL-MEMBER, 64 SY-VLINE,

65 TFTIT-STEXT, 140 SY-VLINE,

141 IT_FINAL-INCLUDE, 150 SY-VLINE.

WRITE:/1(150) SY-ULINE.

ENDLOOP.

ENDFORM. " display_results

Author Bio

Mr.Rajasekhar Dinavahi is an SAP Systems Analyst specializing in on-line application development in ABAP/4,
Working for Intelligroup Asia Pvt. Ltd. Has 5 years of experience in SAP and an overall experience of 7 years in the
IT Industry.

© 2005 SAP AG The SAP Developer Network: http://sdn.sap.com 13

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy