ZFIND_ENHANCEMENT(找增强点-新)
阅读原文时间:2023年07月16日阅读:1

REPORT ZFIND_ENHANCEMENT.
*&--------------------------------------------------------------------&*
*& Report: Z_USEREXIT (V9) &*
*& PJA Consultancy Services (www.pjas.com) &*
*&--------------------------------------------------------------------&*
*& This report attmpts to find Enhancements, Program-Exits, BADIs &*
*& and Business Transaction Events in a particular program/tcode. &*
*& Last updated: May &*
*&--------------------------------------------------------------------&*
*& Selection Texts:
*& P_ALV ALV format
*& P_AUTH Include authority-check search
*& P_BADI Display BADIs
*& P_BTE Display business trans events
*& P_DEVC Show development class exits
*& P_EXIT Display user exits
*& P_FUNC Show function modules
*& P_LIMIT Limit no. of submits to search
*& P_LST Standard list format
*& P_PNAME Program name
*& P_PROG Display program exits
*& P_SUBM Show submits
*& P_TCODE Transaction code
*& P_TEXT Search for text
*& P_WFLOW Display workflow links
*&--------------------------------------------------------------------&*
*& Text symbols:
*& M01 Enter TCode or program
*& M02 Enter at least one scope criteria
*& S01 Selection data (TCode takes precedence over program name)
*& S02 Scope criteria
*& S03 Display criteria
*&--------------------------------------------------------------------&*
*report z_userexit no standard page heading line-size .

TABLES:
SXS_ATTR,
TOBJT,
TSTCT, "TCode texts
TRDIRT, "Program texts
SXC_EXIT. "BADI exits

TYPE-POOLS: SLIS. "Globale Typen fьr generische Listbausteine

DATA:TABIX LIKE SY-TABIX,
W_LINNUM TYPE I ,
W_OFF TYPE I ,
W_INDEX LIKE SY-TABIX,
W_INCLUDE LIKE TRDIR-NAME,
W_PROG LIKE TRDIR-NAME,
W_INCL LIKE TRDIR-NAME,
W_AREA LIKE RS38L-AREA,
W_LEVEL,
W_STR() TYPE C ,
W_CNT() TYPE C ,
W_FUNCNAME LIKE TFDIR-FUNCNAME,
W_FSEL LIKE SY-UCOMM, " Determination of screen field
W_GRIDTXT() TYPE C . "ALV grid title

CONSTANTS:
C_FMOD() TYPE C VALUE 'Function modules searched: ' ,
C_SUBM() TYPE C VALUE 'Submit programs searched: ' ,
C_DEVC() TYPE C VALUE 'User-exits from development classes in function modules' ,
C_COL1() TYPE C VALUE 'Enhanmt Type' ,
C_COL2() TYPE C VALUE 'Enhancement' ,
C_COL3() TYPE C VALUE 'Program/Include' ,
C_COL4() TYPE C VALUE 'Enhancement Name' ,
C_COL5() TYPE C VALUE 'Enhancement Description' ,
C_COL6() TYPE C VALUE 'Project' ,
C_COL7() TYPE C VALUE 'S' ,
C_COL8() TYPE C VALUE 'ChangeName' ,
C_COL9() TYPE C VALUE 'ChangeDate' ,
C_X TYPE C VALUE 'X' .

* Work Areas: ABAP Workbench
DATA : BEGIN OF WA_D010INC.
DATA : MASTER TYPE D010INC-MASTER.
DATA : END OF WA_D010INC.

DATA : BEGIN OF WA_TFDIR.
DATA : FUNCNAME TYPE TFDIR-FUNCNAME,
PNAME TYPE TFDIR-PNAME,
INCLUDE TYPE TFDIR-INCLUDE .
DATA : END OF WA_TFDIR.

DATA : BEGIN OF WA_TADIR.
DATA : DEVCLASS TYPE TADIR-DEVCLASS.
DATA : END OF WA_TADIR.

DATA : BEGIN OF WA_TSTC.
DATA : PGMNA TYPE TSTC-PGMNA.
DATA : END OF WA_TSTC.

DATA : BEGIN OF WA_TSTCP.
DATA : PARAM TYPE TSTCP-PARAM.
DATA : END OF WA_TSTCP.

DATA : BEGIN OF WA_ENLFDIR.
DATA : AREA TYPE ENLFDIR-AREA.
DATA : END OF WA_ENLFDIR.

* Work Areas: BADIs
DATA : BEGIN OF WA_SXS_ATTR.
DATA : EXIT_NAME TYPE SXS_ATTR-EXIT_NAME.
DATA : END OF WA_SXS_ATTR.

DATA : BEGIN OF WA_SXS_ATTRT.
DATA : TEXT TYPE SXS_ATTRT-TEXT .
DATA : END OF WA_SXS_ATTRT.

* Work Areas: Enhancements
DATA : BEGIN OF WA_MODSAP.
DATA : MEMBER TYPE MODSAP-MEMBER.
DATA : END OF WA_MODSAP.

DATA : BEGIN OF WA_MODSAPA.
DATA : NAME TYPE MODSAPA-NAME.
DATA : END OF WA_MODSAPA.

DATA : BEGIN OF WA_MODSAPT.
DATA : MODTEXT TYPE MODSAPT-MODTEXT.
DATA : END OF WA_MODSAPT.

* Work Areas: Business Transaction Events
DATA : BEGIN OF WA_TBE01T.
DATA : TEXT1 TYPE TBE01T-TEXT1.
DATA : END OF WA_TBE01T.

DATA : BEGIN OF WA_TPS01T.
DATA : TEXT1 TYPE TPS01T-TEXT1.
DATA : END OF WA_TPS01T.

* user-exits
TYPES : BEGIN OF TY_MOD,
MEMBER LIKE MODACT-MEMBER,
NAME LIKE MODACT-NAME,
STATUS LIKE MODATTR-STATUS,
ANAM LIKE MODATTR-ANAM,
ADAT LIKE MODATTR-ADAT,
END OF TY_MOD.
DATA : W_MOD TYPE TY_MOD.

TYPES : BEGIN OF T_USEREXIT,
TYPE() TYPE C,
PNAME LIKE TRDIR-NAME,
TXT(),
LEVEL TYPE C ,
MODNAME() TYPE C ,
MODTEXT() TYPE C ,
MODATTR TYPE TY_MOD,
COLOUR() TYPE C ,
END OF T_USEREXIT.
DATA : I_USEREXIT TYPE STANDARD TABLE OF T_USEREXIT WITH HEADER LINE .

* Function module developmnet classes
TYPES : BEGIN OF T_DEVCLASS,
CLAS LIKE TRDIR-CLAS,
END OF T_DEVCLASS.
DATA : I_DEVCLASS TYPE STANDARD TABLE OF T_DEVCLASS WITH HEADER LINE .

* Submit programs
TYPES : BEGIN OF T_SUBMIT,
PNAME LIKE TRDIR-NAME,
LEVEL,
DONE,
END OF T_SUBMIT.
DATA : I_SUBMIT TYPE STANDARD TABLE OF T_SUBMIT WITH HEADER LINE .

* Source code
TYPES : BEGIN OF T_SOURCETAB, "#EC * (SLIN lьgt!)
LINE(), "#EC * (SLIN lьgt!)
END OF T_SOURCETAB. "#EC * (SLIN lьgt!)
DATA : SOURCETAB TYPE STANDARD TABLE OF T_SOURCETAB WITH HEADER LINE .
DATA C_OVERFLOW() TYPE C .

* Description of an ABAP/ source analysis token
*data: i_stoken type standard table of stokex with header line.
DATA : I_STOKEN TYPE STANDARD TABLE OF STOKEN WITH HEADER LINE .

DATA WA_STOKEN LIKE I_STOKEN.

* Description of an ABAP/ source analysis statement
DATA : I_SSTMNT TYPE STANDARD TABLE OF SSTMNT WITH HEADER LINE . "#EC NEEDED

* keywords for searching ABAP code
TYPES : BEGIN OF T_KEYWORDS,
WORD(),
END OF T_KEYWORDS.
DATA : KEYWORDS TYPE STANDARD TABLE OF T_KEYWORDS WITH HEADER LINE .

* function modules within program
TYPES :
BEGIN OF T_FMODULE,
NAME LIKE RS38L-NAME,
PNAME LIKE TRDIR-NAME,
PNAME2 LIKE TRDIR-NAME,
LEVEL,
BAPI,
DONE,
END OF T_FMODULE.
DATA : I_FMODULE TYPE STANDARD TABLE OF T_FMODULE WITH HEADER LINE .

* ALV definitions
DATA I_FIELDCAT TYPE SLIS_T_FIELDCAT_ALV WITH HEADER LINE .
DATA I_LAYOUT TYPE SLIS_LAYOUT_ALV.
DATA I_SORT TYPE SLIS_T_SORTINFO_ALV WITH HEADER LINE .

*&--------------------------------------------------------------------&*
*& Selection Options &*
*&--------------------------------------------------------------------&*
SELECTION-SCREEN BEGIN OF BLOCK SELSCR1 WITH FRAME TITLE TEXT-S01.
PARAMETER : P_PNAME LIKE TRDIR-NAME,
P_TCODE LIKE SYST-TCODE,
P_LIMIT() TYPE N DEFAULT .
SELECTION-SCREEN SKIP .
SELECTION-SCREEN END OF BLOCK SELSCR1.

SELECTION-SCREEN BEGIN OF BLOCK SELSCR2 WITH FRAME TITLE TEXT-S02.
PARAMETER : P_BADI AS CHECKBOX DEFAULT C_X,
P_BTE AS CHECKBOX DEFAULT C_X,
P_EXIT AS CHECKBOX DEFAULT C_X,
P_PROG AS CHECKBOX DEFAULT C_X,
P_WFLOW AS CHECKBOX ,
P_AUTH AS CHECKBOX .
SELECTION-SCREEN SKIP .
PARAMETER : P_TEXT() TYPE C .
SELECTION-SCREEN END OF BLOCK SELSCR2.

SELECTION-SCREEN BEGIN OF BLOCK SELSCR3 WITH FRAME TITLE TEXT-S03.
PARAMETER : P_ALV RADIOBUTTON GROUP RAD1 DEFAULT 'X' ,
P_LST RADIOBUTTON GROUP RAD1.
SELECTION-SCREEN SKIP .
PARAMETER : P_DEVC LIKE RIHEA-DY_OFN DEFAULT ' ' MODIF ID A01,
P_FUNC LIKE RIHEA-DY_OFN DEFAULT ' ' MODIF ID A01,
P_SUBM LIKE RIHEA-DY_OFN DEFAULT ' ' MODIF ID A01.
SELECTION-SCREEN END OF BLOCK SELSCR3.

*&--------------------------------------------------------------------&*
*& START-OF-SELECTION &*
*&--------------------------------------------------------------------&*
START-OF-SELECTION.

IF P_PNAME IS INITIAL AND P_TCODE IS INITIAL .
MESSAGE I000(G01) WITH TEXT-M01.
STOP .
ENDIF .

IF P_BADI IS INITIAL AND
P_EXIT IS INITIAL AND
P_BTE IS INITIAL AND
P_WFLOW IS INITIAL AND
P_AUTH IS INITIAL AND
P_PROG IS INITIAL .
MESSAGE I000(G01) WITH TEXT-M02.
STOP .
ENDIF .

* ensure P_LIMIT is not zero.
IF P_LIMIT = .
P_LIMIT = .
ENDIF .

PERFORM DATA_SELECT.
PERFORM GET_SUBMIT_DATA.
PERFORM GET_FM_DATA.
PERFORM GET_ADDITIONAL_DATA.
PERFORM DATA_DISPLAY.

*&--------------------------------------------------------------------&*
*& Form DATA_SELECT &*
*&--------------------------------------------------------------------&*
*& &*
*&--------------------------------------------------------------------&*
FORM DATA_SELECT.

* data selection message to sap gui
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
DESTINATION 'SAPGUI'
KEEPING LOGICAL UNIT OF WORK
EXPORTING
TEXT = 'Get programs/includes' "#EC NOTEXT
EXCEPTIONS
SYSTEM_FAILURE
COMMUNICATION_FAILURE
. "#EC *

* get TCode name for ALV grid title
CLEAR W_GRIDTXT.
IF NOT P_TCODE IS INITIAL .
SELECT SINGLE * FROM TSTCT WHERE TCODE = P_TCODE
AND SPRSL = SY-LANGU.
CONCATENATE 'TCode:' P_TCODE TSTCT-TTEXT INTO W_GRIDTXT
SEPARATED BY SPACE.
ENDIF .
* get program name for ALV grid title
IF NOT P_PNAME IS INITIAL .
SELECT SINGLE * FROM TRDIRT WHERE NAME = P_PNAME
AND SPRSL = SY-LANGU.
CONCATENATE 'Program:' P_PNAME TSTCT-TTEXT INTO W_GRIDTXT
SEPARATED BY SPACE.
ENDIF .

* determine search words
KEYWORDS-WORD = 'CALL' .
APPEND KEYWORDS.
KEYWORDS-WORD = 'FORM' .
APPEND KEYWORDS.
KEYWORDS-WORD = 'PERFORM' .
APPEND KEYWORDS.
KEYWORDS-WORD = 'SUBMIT' .
APPEND KEYWORDS.
KEYWORDS-WORD = 'INCLUDE' .
APPEND KEYWORDS.
KEYWORDS-WORD = 'AUTHORITY-CHECK' .
APPEND KEYWORDS.

IF NOT P_TCODE IS INITIAL .
* get program name from TCode
SELECT SINGLE PGMNA FROM TSTC INTO WA_TSTC-PGMNA
WHERE TCODE EQ P_TCODE.
IF NOT WA_TSTC-PGMNA IS INITIAL .
P_PNAME = WA_TSTC-PGMNA.
* TCode does not include program name, but does have reference TCode
ELSE .
SELECT SINGLE PARAM FROM TSTCP INTO WA_TSTCP-PARAM
WHERE TCODE EQ P_TCODE.
IF SY-SUBRC = .
CHECK WA_TSTCP-PARAM() = '/' .
CHECK WA_TSTCP-PARAM+() = '*' .
IF WA_TSTCP-PARAM CA ' ' .
ENDIF .
W_OFF = SY-FDPOS + .
SUBTRACT FROM SY-FDPOS.
IF SY-FDPOS GT .
P_TCODE = WA_TSTCP-PARAM+(SY-FDPOS).
ENDIF .
SELECT SINGLE PGMNA FROM TSTC INTO WA_TSTC-PGMNA
WHERE TCODE EQ P_TCODE.
P_PNAME = WA_TSTC-PGMNA.
IF SY-SUBRC <> .
MESSAGE S110(/SAPTRX/ASC) WITH 'No program found for: ' P_TCODE. "#EC NOTEXT
STOP .
ENDIF .
ELSE .
MESSAGE S110(/SAPTRX/ASC) WITH 'No program found for: ' P_TCODE. "#EC NOTEXT
STOP .
ENDIF .

ENDIF .  

ENDIF .

* Call customer-function aus Program coding
READ REPORT P_PNAME INTO SOURCETAB.
IF SY-SUBRC > .
MESSAGE E017(ENHANCEMENT) WITH P_PNAME RAISING NO_PROGRAM. "#EC *
ENDIF .

*scan abap-source sourcetab tokens into i_stoken
*statements into i_sstmnt
*keywords from keywords
*overflow into c_overflow
*with ANALYSIS. "#EC

**********************************
SCAN ABAP-SOURCE SOURCETAB TOKENS INTO I_STOKEN
STATEMENTS INTO I_SSTMNT
KEYWORDS FROM KEYWORDS
OVERFLOW INTO C_OVERFLOW
WITH INCLUDES. "#EC
**********************************
IF SY-SUBRC > . "keine/syntakt. falsche Ablauflog./Fehler im Skanner
MESSAGE E130(ENHANCEMENT) RAISING SYNTAX_ERROR. "#EC
ENDIF .

* check I_STOKEN for entries
CLEAR W_LINNUM.
DESCRIBE TABLE I_STOKEN LINES W_LINNUM.
IF W_LINNUM GT .
W_LEVEL = '' .
W_PROG = '' .
W_INCL = '' .
PERFORM DATA_SEARCH TABLES I_STOKEN USING W_LEVEL W_PROG W_INCL.
ENDIF .

ENDFORM . "DATA_SELECT

*&--------------------------------------------------------------------&*
*& Form GET_FM_DATA # &*
*&--------------------------------------------------------------------&*
*& &*
*&--------------------------------------------------------------------&*
FORM GET_FM_DATA.

* data selection message to sap gui
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
DESTINATION 'SAPGUI'
KEEPING LOGICAL UNIT OF WORK
EXPORTING
TEXT = 'Get function module data' "#EC NOTEXT
EXCEPTIONS
SYSTEM_FAILURE
COMMUNICATION_FAILURE
. "#EC *

* Function module data
SORT I_FMODULE BY NAME.
DELETE ADJACENT DUPLICATES FROM I_FMODULE COMPARING NAME.

LOOP AT I_FMODULE WHERE DONE NE C_X.

CLEAR : I\_STOKEN, I\_SSTMNT, SOURCETAB, WA\_TFDIR, W\_INCLUDE .  
REFRESH : I\_STOKEN, I\_SSTMNT, SOURCETAB.

CLEAR  WA\_TFDIR.  
SELECT  SINGLE  FUNCNAME PNAME INCLUDE  FROM  TFDIR INTO  WA\_TFDIR  
WHERE  FUNCNAME = I\_FMODULE-NAME.  
CHECK  SY-SUBRC =  .

CALL FUNCTION 'FUNCTION\_INCLUDE\_SPLIT'  
  EXPORTING  
    PROGRAM = WA\_TFDIR-PNAME  
  IMPORTING  
    GROUP   = W\_AREA.

CONCATENATE  'L'  W\_AREA 'U'  WA\_TFDIR-INCLUDE  INTO  W\_INCLUDE.  
I\_FMODULE-PNAME = W\_INCLUDE.  
I\_FMODULE-PNAME2 = WA\_TFDIR-PNAME.  
MODIFY  I\_FMODULE.

READ  REPORT  I\_FMODULE-PNAME INTO  SOURCETAB.  
IF  SY-SUBRC =  .

  SCAN  ABAP-SOURCE SOURCETAB TOKENS INTO  I\_STOKEN  
   STATEMENTS INTO  I\_SSTMNT  
   KEYWORDS FROM  KEYWORDS  
  WITH  INCLUDES.  
  IF  SY-SUBRC >  .  
    MESSAGE  E130(ENHANCEMENT) RAISING  SYNTAX\_ERROR.  
  ENDIF .

* check i_stoken for entries
CLEAR W_LINNUM.
DESCRIBE TABLE I_STOKEN LINES W_LINNUM.
IF W_LINNUM GT .
W_LEVEL = '' .
W_PROG = I_FMODULE-PNAME2.
W_INCL = I_FMODULE-PNAME.
PERFORM DATA_SEARCH TABLES I_STOKEN USING W_LEVEL W_PROG W_INCL.
ENDIF .
ENDIF .

ENDLOOP .

* store development classes
IF P_DEVC = C_X.
LOOP AT I_FMODULE.
CLEAR : WA_TADIR, WA_ENLFDIR.

  SELECT  SINGLE  AREA FROM  ENLFDIR INTO  WA\_ENLFDIR-AREA  
  WHERE  FUNCNAME = I\_FMODULE-NAME.  
  CHECK  NOT  WA\_ENLFDIR-AREA IS  INITIAL .

  SELECT  SINGLE  DEVCLASS INTO  WA\_TADIR-DEVCLASS  
  FROM  TADIR WHERE  PGMID = 'R3TR'  
  AND  OBJECT = 'FUGR'  
  AND  OBJ\_NAME = WA\_ENLFDIR-AREA.  
  CHECK  NOT  WA\_TADIR-DEVCLASS IS  INITIAL .  
  MOVE  WA\_TADIR-DEVCLASS TO  I\_DEVCLASS-CLAS.  
  APPEND  I\_DEVCLASS.  
  I\_FMODULE-DONE = C\_X.  
  MODIFY  I\_FMODULE.  
ENDLOOP .

SORT  I\_DEVCLASS.  
DELETE  ADJACENT  DUPLICATES  FROM  I\_DEVCLASS.  

ENDIF .

ENDFORM . "GET_FM_DATA

*&--------------------------------------------------------------------&*
*& Form GET_SUBMIT_DATA &*
*&--------------------------------------------------------------------&*
*& &*
*&--------------------------------------------------------------------&*
FORM GET_SUBMIT_DATA.

* data selection message to sap gui
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
DESTINATION 'SAPGUI'
KEEPING LOGICAL UNIT OF WORK
EXPORTING
TEXT = 'Get submit data' "#EC NOTEXT
EXCEPTIONS
SYSTEM_FAILURE
COMMUNICATION_FAILURE
. "#EC *

SORT I_SUBMIT.
DELETE ADJACENT DUPLICATES FROM I_SUBMIT COMPARING PNAME.
W_LEVEL = '' .

LOOP AT I_SUBMIT WHERE DONE NE C_X.

CLEAR : I\_STOKEN, I\_SSTMNT, SOURCETAB.  
REFRESH : I\_STOKEN, I\_SSTMNT, SOURCETAB.

READ  REPORT  I\_SUBMIT-PNAME INTO  SOURCETAB.  
IF  SY-SUBRC =  .

  SCAN  ABAP-SOURCE SOURCETAB TOKENS INTO  I\_STOKEN  
   STATEMENTS INTO  I\_SSTMNT  
   KEYWORDS FROM  KEYWORDS  
  WITH  INCLUDES.  
  IF  SY-SUBRC >  .  

* message e130(enhancement) raising syntax_error.
CONTINUE .
ENDIF .

* check i_stoken for entries
CLEAR W_LINNUM.
DESCRIBE TABLE I_STOKEN LINES W_LINNUM.
IF W_LINNUM GT .
W_PROG = I_SUBMIT-PNAME.
W_INCL = '' .
PERFORM DATA_SEARCH TABLES I_STOKEN USING W_LEVEL W_PROG W_INCL.
ENDIF .
ENDIF .

* restrict number of submit program selected for processing
DESCRIBE TABLE I_SUBMIT LINES W_LINNUM.
IF W_LINNUM GE P_LIMIT.
W_LEVEL = '' .
ENDIF .
I_SUBMIT-DONE = C_X.
MODIFY I_SUBMIT.
ENDLOOP .

ENDFORM . "GET_SUBMIT_DATA

*&--------------------------------------------------------------------&*
*& Form DATA_SEARCH &*
*&--------------------------------------------------------------------&*
*& &*
*&--------------------------------------------------------------------&*
FORM DATA_SEARCH TABLES P_STOKEN STRUCTURE STOKEN
USING P_LEVEL L_PROG L_INCL.

LOOP AT P_STOKEN.

CLEAR  I\_USEREXIT.

* Workflow
IF P_WFLOW = C_X.
IF P_LEVEL EQ '' . " do not perform for function modules (2nd pass)
IF P_STOKEN-STR+() CS 'SWE_EVENT_CREATE' .
REPLACE ALL OCCURRENCES OF '''' IN P_STOKEN-STR WITH '' .
I_USEREXIT-TYPE = 'WorkFlow' .
I_USEREXIT-TXT = P_STOKEN-STR.
CONCATENATE L_PROG '/' L_INCL INTO I_USEREXIT-PNAME.
APPEND I_USEREXIT.
ENDIF .
ENDIF .
ENDIF .

TABIX = SY-TABIX +  .  
I\_USEREXIT-LEVEL = P\_LEVEL.  
IF  I\_USEREXIT-LEVEL = '' .  
  IF  L\_INCL IS  INITIAL .  
    I\_USEREXIT-PNAME = P\_PNAME.  
  ELSE .  
    CONCATENATE  P\_PNAME '-'  L\_INCL INTO  I\_USEREXIT-PNAME.  
  ENDIF .  
ELSE .  
  IF  L\_INCL IS  INITIAL .  
    I\_USEREXIT-PNAME = L\_PROG.  
  ELSE .  
    CONCATENATE  L\_PROG '-'  L\_INCL INTO  I\_USEREXIT-PNAME.  
  ENDIF .  
ENDIF .

* AUTHORITY-CHECKS
IF P_AUTH = C_X.
IF P_STOKEN-STR EQ 'AUTHORITY-CHECK' .
CHECK P_LEVEL EQ '' . " do not perform for function modules (2nd pass)
W_INDEX = SY-TABIX + .
READ TABLE P_STOKEN INDEX W_INDEX INTO WA_STOKEN.
CHECK NOT WA_STOKEN-STR CS 'STRUCTURE' .
CHECK NOT WA_STOKEN-STR CS 'SYMBOL' .
READ TABLE I_SUBMIT WITH KEY PNAME = WA_STOKEN-STR.
IF SY-SUBRC <> .
I_USEREXIT-PNAME = I_SUBMIT-PNAME.
I_USEREXIT-TYPE = 'AuthCheck' .
I_USEREXIT-TXT = WA_STOKEN-STR.
REPLACE ALL OCCURRENCES OF '''' IN I_USEREXIT-TXT WITH SPACE.
CLEAR TOBJT.
SELECT SINGLE * FROM TOBJT WHERE OBJECT = I_USEREXIT-TXT
AND LANGU = SY-LANGU.
I_USEREXIT-MODNAME = 'AUTHORITY-CHECK' .
I_USEREXIT-MODTEXT = TOBJT-TTEXT.
APPEND I_USEREXIT.
ENDIF .
ENDIF .
ENDIF .

* Text searches
IF NOT P_TEXT IS INITIAL .
IF P_STOKEN-STR CS P_TEXT.
I_USEREXIT-PNAME = I_SUBMIT-PNAME.
I_USEREXIT-TYPE = 'TextSearch' .
I_USEREXIT-TXT = WA_STOKEN-STR.
I_USEREXIT-MODNAME = 'Text Search' .
I_USEREXIT-MODTEXT = P_STOKEN-STR.
APPEND I_USEREXIT.
ENDIF .
ENDIF .

* Include (SE38)
IF P_STOKEN-STR EQ 'INCLUDE' .
CHECK P_LEVEL EQ '' . " do not perform for function modules (2nd pass)
W_INDEX = SY-TABIX + .
READ TABLE P_STOKEN INDEX W_INDEX INTO WA_STOKEN.
CHECK NOT WA_STOKEN-STR CS 'STRUCTURE' .
CHECK NOT WA_STOKEN-STR CS 'SYMBOL' .
READ TABLE I_SUBMIT WITH KEY PNAME = WA_STOKEN-STR.
IF SY-SUBRC <> .
I_SUBMIT-PNAME = WA_STOKEN-STR.
I_SUBMIT-LEVEL = P_LEVEL.
APPEND I_SUBMIT.
ENDIF .
ENDIF .

* Enhancements (SMOD)
IF P_EXIT = C_X.
IF P_STOKEN-STR EQ 'CUSTOMER-FUNCTION' .
CLEAR W_FUNCNAME.
READ TABLE P_STOKEN INDEX TABIX.
TRANSLATE P_STOKEN-STR USING ''' ' .
CONDENSE P_STOKEN-STR.
IF L_PROG IS INITIAL .
CONCATENATE 'EXIT' P_PNAME P_STOKEN-STR INTO W_FUNCNAME
SEPARATED BY '_' .
ELSE .
CONCATENATE 'EXIT' L_PROG P_STOKEN-STR INTO W_FUNCNAME
SEPARATED BY '_' .
ENDIF .
SELECT SINGLE MEMBER FROM MODSAP INTO WA_MODSAP-MEMBER
WHERE MEMBER = W_FUNCNAME.
IF SY-SUBRC = . " check for valid enhancement
I_USEREXIT-TYPE = 'Enhancement' .
I_USEREXIT-TXT = W_FUNCNAME.
APPEND I_USEREXIT.
ELSE .
CLEAR WA_D010INC.
SELECT SINGLE MASTER INTO WA_D010INC-MASTER
FROM D010INC
WHERE INCLUDE = L_PROG.
CONCATENATE 'EXIT' WA_D010INC-MASTER P_STOKEN-STR INTO W_FUNCNAME
SEPARATED BY '_' .
I_USEREXIT-TYPE = 'Enhancement' .
I_USEREXIT-TXT = W_FUNCNAME.
ENDIF .
ENDIF .
ENDIF .

* BADIs (SE18)
IF P_BADI = C_X.
IF P_STOKEN-STR CS 'cl_exithandler=' .
W_INDEX = SY-TABIX + .
READ TABLE P_STOKEN INDEX W_INDEX INTO WA_STOKEN.
I_USEREXIT-TXT = WA_STOKEN-STR.
REPLACE ALL OCCURRENCES OF '''' IN I_USEREXIT-TXT WITH SPACE.
I_USEREXIT-TYPE = 'BADI' .
CLEAR SXS_ATTR. " ensure a real BADI
SELECT SINGLE * FROM SXS_ATTR WHERE EXIT_NAME = I_USEREXIT-TXT.
IF SY-SUBRC = .
APPEND I_USEREXIT.
ENDIF .
ENDIF .
ENDIF .

* Business transaction events (FIBF)
IF P_BTE = C_X.
IF P_STOKEN-STR CS 'OPEN_FI_PERFORM' .
I_USEREXIT-TYPE = 'BusTrEvent' .
I_USEREXIT-TXT = P_STOKEN-STR.
REPLACE ALL OCCURRENCES OF '''' IN I_USEREXIT-TXT WITH SPACE.
I_USEREXIT-MODNAME = I_USEREXIT-TXT+().
CASE I_USEREXIT-TXT+().
WHEN 'E' .
CLEAR WA_TBE01T.
SELECT SINGLE TEXT1 INTO WA_TBE01T-TEXT1 FROM TBE01T
WHERE EVENT = I_USEREXIT-TXT+()
AND SPRAS = SY-LANGU.
IF WA_TBE01T-TEXT1 IS INITIAL .
I_USEREXIT-MODTEXT = '' . "#EC NOTEXT
ELSE .
I_USEREXIT-MODTEXT = WA_TBE01T-TEXT1.
ENDIF .
I_USEREXIT-MODNAME+ = '/P&S' . "#EC NOTEXT
WHEN 'P' .
CLEAR WA_TPS01T.
SELECT SINGLE TEXT1 INTO WA_TPS01T-TEXT1 FROM TPS01T
WHERE PROCS = I_USEREXIT-TXT+()
AND SPRAS = SY-LANGU.
I_USEREXIT-MODTEXT = WA_TPS01T-TEXT1.
I_USEREXIT-MODNAME+ = '/Process' .
ENDCASE .

    APPEND  I\_USEREXIT.  
  ENDIF .  
ENDIF .

* Program exits (SE38)
IF P_PROG = C_X.
IF P_STOKEN-STR CS 'USEREXIT_' .
CHECK NOT P_STOKEN-STR CS '-' . " ensure not USEREXIT_XX-XXX
CHECK NOT P_STOKEN-STR CS '(' . " ensure not SUBMIT_XX(X)
I_USEREXIT-TYPE = 'Program Exit' .
I_USEREXIT-TXT = P_STOKEN-STR.
REPLACE ALL OCCURRENCES OF '''' IN I_USEREXIT-TXT WITH SPACE.
APPEND I_USEREXIT.
ENDIF .
ENDIF .

* Submit programs (SE38)
IF P_STOKEN-STR CS 'SUBMIT' .
CHECK P_LEVEL EQ '' . " do not perform for function modules (2nd pass)
CHECK NOT P_STOKEN-STR CS '_' . " ensure not SUBMIT_XXX
W_INDEX = SY-TABIX + .
READ TABLE P_STOKEN INDEX W_INDEX INTO WA_STOKEN.
CHECK NOT WA_STOKEN-STR CS '_' . " ensure not SUBMIT_XXX
REPLACE ALL OCCURRENCES OF '''' IN WA_STOKEN-STR WITH SPACE.
READ TABLE I_SUBMIT WITH KEY PNAME = WA_STOKEN-STR.
IF SY-SUBRC <> .
I_SUBMIT-PNAME = WA_STOKEN-STR.
I_SUBMIT-LEVEL = P_LEVEL.
APPEND I_SUBMIT.
ENDIF .
ENDIF .

* Perform routines (which reference external programs)
IF P_STOKEN-STR CS 'PERFORM' .
CHECK P_LEVEL EQ '' . " do not perform for function modules (2nd pass)
W_INDEX = SY-TABIX + .
READ TABLE P_STOKEN INDEX W_INDEX INTO WA_STOKEN.
IF NOT WA_STOKEN-OVFL IS INITIAL .
W_OFF = WA_STOKEN-OFF1 + .
W_STR = C_OVERFLOW+W_OFF().
FIND ')' IN W_STR MATCH OFFSET W_OFF.
IF SY-SUBRC = .
W_OFF = W_OFF + .
WA_STOKEN-STR = W_STR(W_OFF).
ENDIF .
ENDIF .

  CHECK  WA\_STOKEN-STR CS  '(' .  
  W\_OFF =  .  
  WHILE  SY-SUBRC =  .  
    IF  WA\_STOKEN-STR+W\_OFF() EQ  '(' .  
      REPLACE  SECTION  OFFSET W\_OFF LENGTH   OF  WA\_STOKEN-STR WITH  '' .  
      REPLACE  ALL  OCCURRENCES  OF  ')'  IN  WA\_STOKEN-STR WITH  SPACE.  
      READ  TABLE  I\_SUBMIT WITH  KEY  PNAME = WA\_STOKEN-STR.  
      IF  SY-SUBRC <>  .  
        I\_SUBMIT-PNAME = WA\_STOKEN-STR.  
        APPEND  I\_SUBMIT.  
      ENDIF .  
      EXIT .  
    ELSE .  
      REPLACE  SECTION  OFFSET W\_OFF LENGTH   OF  WA\_STOKEN-STR WITH  '' .  
      SHIFT  WA\_STOKEN-STR LEFT  DELETING LEADING  SPACE.  
    ENDIF .  
  ENDWHILE .  
ENDIF .

* Function modules (SE37)
IF P_STOKEN-STR CS 'FUNCTION' .

  CLEAR  I\_FMODULE.  
  IF  P\_LEVEL EQ  '' . " do not perform for function modules (2nd pass)  
    W\_INDEX = SY-TABIX +  .  
    READ  TABLE  P\_STOKEN INDEX  W\_INDEX INTO  WA\_STOKEN.

    IF  WA\_STOKEN-STR CS  'BAPI' .  
      I\_FMODULE-BAPI = C\_X.  
    ENDIF .

    REPLACE  FIRST  OCCURRENCE OF  ''''  IN  WA\_STOKEN-STR WITH  SPACE.  
    REPLACE  FIRST  OCCURRENCE OF  ''''  IN  WA\_STOKEN-STR WITH  SPACE.  
    IF  SY-SUBRC =  . " didn't find 2nd quote (ie name truncated)  
      CLEAR  WA\_TFDIR.  
      CONCATENATE  WA\_STOKEN-STR '%'  INTO  WA\_STOKEN-STR.  
      SELECT  SINGLE  FUNCNAME INTO  WA\_TFDIR-FUNCNAME FROM  TFDIR  
      WHERE  FUNCNAME LIKE  WA\_STOKEN-STR.  
      IF  SY-SUBRC =  .  
        I\_FMODULE-NAME = WA\_TFDIR-FUNCNAME.  
      ELSE .  
        CONTINUE .  
      ENDIF .  
    ELSE .  
      I\_FMODULE-NAME = WA\_STOKEN-STR.  
    ENDIF .  
    I\_FMODULE-LEVEL = P\_LEVEL.  
    APPEND  I\_FMODULE.  
  ENDIF .  
ENDIF .

ENDLOOP .

ENDFORM . "DATA_SEARCH

*&--------------------------------------------------------------------&*
*& Form GET_ADDITIONAL_DATA &*
*&--------------------------------------------------------------------&*
*& &*
*&--------------------------------------------------------------------&*
FORM GET_ADDITIONAL_DATA.

* data selection message to sap gui
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
DESTINATION 'SAPGUI'
KEEPING LOGICAL UNIT OF WORK
EXPORTING
TEXT = 'Get additional data' "#EC NOTEXT
EXCEPTIONS
SYSTEM_FAILURE
COMMUNICATION_FAILURE
. "#EC *

LOOP AT I_USEREXIT.

* Workflow
IF I_USEREXIT-TYPE EQ 'WorkFlow' .
CONTINUE .
ENDIF .

* Enhancement data
IF I_USEREXIT-TYPE CS 'Enh' .
CLEAR : WA_MODSAPA.
SELECT SINGLE NAME INTO WA_MODSAPA-NAME FROM MODSAP
WHERE MEMBER = I_USEREXIT-TXT.
CHECK SY-SUBRC = .
I_USEREXIT-MODNAME = WA_MODSAPA-NAME.

  CLEAR  WA\_MODSAPT.  
  SELECT  SINGLE  MODTEXT INTO  WA\_MODSAPT-MODTEXT FROM  MODSAPT  
  WHERE  NAME = WA\_MODSAPA-NAME  
  AND  SPRSL = SY-LANGU.  
  I\_USEREXIT-MODTEXT = WA\_MODSAPT-MODTEXT.

* Get the CMOD project name
CLEAR W_MOD.
SELECT SINGLE MODACT~MEMBER MODACT~NAME MODATTR~STATUS
MODATTR~ANAM MODATTR~ADAT
INTO W_MOD
FROM MODACT
INNER JOIN MODATTR
ON MODATTR~NAME = MODACT~NAME
WHERE MODACT~MEMBER = WA_MODSAPA-NAME
AND MODACT~TYP = SPACE.
IF SY-SUBRC = .
I_USEREXIT-MODATTR = W_MOD.
ENDIF .
ENDIF .

* BADI data
IF I_USEREXIT-TYPE EQ 'BADI' .
CLEAR WA_SXS_ATTR.
SELECT SINGLE EXIT_NAME INTO WA_SXS_ATTR-EXIT_NAME FROM SXS_ATTR
WHERE EXIT_NAME = I_USEREXIT-TXT.
IF SY-SUBRC = .
I_USEREXIT-MODNAME = I_USEREXIT-TXT.
ELSE .
I_USEREXIT-MODNAME = 'Dynamic call' . "#EC NOTEXT
ENDIF .
CLEAR WA_SXS_ATTRT.
SELECT SINGLE TEXT INTO WA_SXS_ATTRT-TEXT FROM SXS_ATTRT
WHERE EXIT_NAME = WA_SXS_ATTR-EXIT_NAME
AND SPRSL = SY-LANGU.
I_USEREXIT-MODTEXT = WA_SXS_ATTRT-TEXT .
ENDIF .

* BADI Implementation
IF I_USEREXIT-TYPE EQ 'BADI' .
CLEAR SXC_EXIT.
SELECT COUNT( * ) FROM SXC_EXIT WHERE EXIT_NAME = I_USEREXIT-TXT.
W_CNT = SY-DBCNT.
* determine id BADI is for interal or external use
CLEAR SXS_ATTR.
SELECT SINGLE * FROM SXS_ATTR WHERE EXIT_NAME = I_USEREXIT-TXT.
IF SXS_ATTR-INTERNAL = 'X' .
WA_SXS_ATTRT-TEXT = 'SAP ' .
ELSE .
WA_SXS_ATTRT-TEXT = 'CUST' .
ENDIF .
* concatenate wa_sxs_attrt-text w_cnt into i_userexit-modattr-name
* separated by space.
WRITE WA_SXS_ATTRT-TEXT TO I_USEREXIT-MODATTR-NAME.
WRITE W_CNT TO I_USEREXIT-MODATTR-NAME+ .
ENDIF .

MODIFY  I\_USEREXIT.  

ENDLOOP .

* get enhancements via program package
CLEAR WA_TADIR.
SELECT SINGLE DEVCLASS INTO WA_TADIR-DEVCLASS FROM TADIR
WHERE PGMID = 'R3TR'
AND OBJECT = 'PROG'
AND OBJ_NAME = P_PNAME.
IF SY-SUBRC = .
CLEAR : WA_MODSAPA, WA_MODSAPT.
SELECT NAME FROM MODSAPA INTO WA_MODSAPA-NAME
WHERE DEVCLASS = WA_TADIR-DEVCLASS.
SELECT SINGLE MODTEXT FROM MODSAPT INTO WA_MODSAPT-MODTEXT
WHERE NAME = WA_MODSAPA-NAME
AND SPRSL = SY-LANGU.

  CLEAR  I\_USEREXIT.  
  READ  TABLE  I\_USEREXIT WITH  KEY  MODNAME = WA\_MODSAPA-NAME.  
  IF  SY-SUBRC <>  .  
    I\_USEREXIT-MODTEXT = WA\_MODSAPT-MODTEXT.  
    I\_USEREXIT-TYPE  = 'Enhancement' .                  "#EC NOTEXT  
    I\_USEREXIT-MODNAME = WA\_MODSAPA-NAME.  
    I\_USEREXIT-TXT = 'Determined from program DevClass' . "#EC NOTEXT  
    I\_USEREXIT-PNAME = 'Unknown' .                      "#EC NOTEXT  
    APPEND  I\_USEREXIT.  
  ENDIF .  
ENDSELECT .  

ENDIF .

* set row colour.
LOOP AT I_USEREXIT.
CASE I_USEREXIT-TYPE .
WHEN 'BADI' .
I_USEREXIT-COLOUR = 'C601' .
WHEN 'Enhancement' .
I_USEREXIT-COLOUR = 'C501' .
WHEN 'Program Exit' .
I_USEREXIT-COLOUR = 'C401' .
WHEN 'WorkFlow' .
I_USEREXIT-COLOUR = 'C301' .
WHEN 'BusTrEvent' .
I_USEREXIT-COLOUR = 'C201' .
ENDCASE .
MODIFY I_USEREXIT.
ENDLOOP .

ENDFORM . "GET_ADDITIONAL_DATA

*&--------------------------------------------------------------------&*
*& Form DATA_DISPLAY &*
*&--------------------------------------------------------------------&*
*& &*
*&--------------------------------------------------------------------&*
FORM DATA_DISPLAY.

* data selection message to sap gui
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
DESTINATION 'SAPGUI'
KEEPING LOGICAL UNIT OF WORK
EXPORTING
TEXT = 'Prepare screen for display' "#EC NOTEXT
EXCEPTIONS
SYSTEM_FAILURE
COMMUNICATION_FAILURE
. "#EC *

SORT I_USEREXIT BY TYPE TXT MODNAME.
DELETE ADJACENT DUPLICATES FROM I_USEREXIT COMPARING TXT PNAME MODNAME.

* ensure records selected.
DESCRIBE TABLE I_USEREXIT LINES W_LINNUM.
IF W_LINNUM = .
MESSAGE S003(G00). "No data records were selected
EXIT .
ENDIF .

IF P_ALV = ' ' .

* format headings
WRITE : 'Enhancements from main program: ' , P_PNAME.
WRITE : 'Enhancements from TCode: ' , P_TCODE.
WRITE : '' .
ULINE .
FORMAT COLOR COL_HEADING.
WRITE : / SY-VLINE,
() C_COL1, "Enhanmt Type
SY-VLINE,
() C_COL2, "Enhancement
SY-VLINE,
() C_COL3, "Program/Include
SY-VLINE,
() C_COL4, "Enhancement name
SY-VLINE,
() C_COL5, "Enhancement description
SY-VLINE,
() C_COL6, "Project
SY-VLINE,
() C_COL7, "S
SY-VLINE,
() C_COL8, "ChangeName
SY-VLINE,
() C_COL9, "ChangeDate
SY-VLINE.
FORMAT RESET .
ULINE .

* format lines
LOOP AT I_USEREXIT.
* set line colour
CASE I_USEREXIT-TYPE .
WHEN 'Enhancement' .
FORMAT COLOR INTENSIFIED OFF.
WHEN 'BADI' .
FORMAT COLOR INTENSIFIED OFF.
WHEN 'BusTrEvent' .
FORMAT COLOR INTENSIFIED OFF.
WHEN 'Program Exit' .
FORMAT COLOR INTENSIFIED OFF.
WHEN OTHERS .
FORMAT RESET .
ENDCASE .
WRITE : / SY-VLINE,
I_USEREXIT-TYPE ,
SY-VLINE,
I_USEREXIT-TXT(),
SY-VLINE,
I_USEREXIT-PNAME(),
SY-VLINE,
I_USEREXIT-MODNAME(),
SY-VLINE,
I_USEREXIT-MODTEXT(),
SY-VLINE.

  WRITE : I\_USEREXIT-MODATTR-NAME,  
   SY-VLINE,  
   I\_USEREXIT-MODATTR-STATUS,  
   SY-VLINE,  
   I\_USEREXIT-MODATTR-ANAM,  
   SY-VLINE,  
   I\_USEREXIT-MODATTR-ADAT NO-ZERO,  
   SY-VLINE.  
  HIDE : I\_USEREXIT-MODNAME, I\_USEREXIT-TYPE , I\_USEREXIT-MODATTR-NAME.

ENDLOOP .  
FORMAT  RESET .  
ULINE .

* user-exits from development class of function modules
IF P_DEVC = C_X.
WRITE : /.
WRITE : / C_DEVC.
WRITE : '' .
ULINE ().
WRITE : '' .

  LOOP  AT  I\_DEVCLASS.  
    CLEAR  WA\_MODSAPA.  
    SELECT  NAME FROM  MODSAPA INTO  WA\_MODSAPA  
    WHERE  DEVCLASS = I\_DEVCLASS-CLAS.  
      SELECT  SINGLE  NAME MODTEXT INTO  CORRESPONDING FIELDS  OF  WA\_MODSAPT  
      FROM  MODSAPT  
      WHERE  NAME = WA\_MODSAPA-NAME  
      AND  SPRSL = SY-LANGU.  
      FORMAT  COLOR    INTENSIFIED  OFF.  
      WRITE : / SY-VLINE,  
       () 'Enhancement' ,  
       SY-VLINE,  
       WA\_MODSAPA-NAME,  
       SY-VLINE,  
       WA\_MODSAPT-MODTEXT,  
       SY-VLINE.  
    ENDSELECT .  
  ENDLOOP .  
  WRITE : '' .  
  ULINE  ().  
  FORMAT  RESET .  
ENDIF .

* display fuction modules used in program
WRITE /.
DESCRIBE TABLE I_FMODULE LINES W_LINNUM.
WRITE : / C_FMOD , AT W_LINNUM. "#EC NOTEXT
WRITE : '' .

IF  P\_FUNC = C\_X.  
  ULINE  ().  
  WRITE : '' .  
  LOOP  AT  I\_FMODULE.  
    WRITE : SY-VLINE,  
     I\_FMODULE-NAME,  
     SY-VLINE,  
     I\_FMODULE-BAPI,  
     SY-VLINE.  
    WRITE : '' .  
  ENDLOOP .  
  WRITE : '' .  
  ULINE  ().  
ENDIF .

* display submit programs used in program
WRITE /.
DESCRIBE TABLE I_SUBMIT LINES W_LINNUM.
WRITE : / C_SUBM , AT W_LINNUM. "#EC NOTEXT
WRITE : '' .
IF P_SUBM = C_X.
ULINE ().
WRITE : '' .
LOOP AT I_SUBMIT.
WRITE : SY-VLINE,
I_SUBMIT-PNAME,
SY-VLINE.
WRITE : '' .
ENDLOOP .
WRITE : '' .
ULINE ().
ENDIF .

* issue message with number of user-exits displayed
DESCRIBE TABLE I_USEREXIT LINES W_LINNUM.
MESSAGE S697() WITH W_LINNUM.

ELSE . " Show in alv format

* issue message with number of user-exits displayed
DESCRIBE TABLE I_USEREXIT LINES W_LINNUM.
MESSAGE S697() WITH W_LINNUM.

* Create field catalog
PERFORM CREATE_FIELD_CATALOG USING 'TYPE' 'T_USEREXIT' ' ' 'Type' .
PERFORM CREATE_FIELD_CATALOG USING 'PNAME' 'T_USEREXIT' ' ' 'Prog#am name' .
PERFORM CREATE_FIELD_CATALOG USING 'TXT' 'T_USEREXIT' ' ' 'Enhancement' .
PERFORM CREATE_FIELD_CATALOG USING 'LEVEL' 'T_USEREXIT' C_X 'Level' .
PERFORM CREATE_FIELD_CATALOG USING 'MODNAME' 'T_USEREXIT' ' ' 'Enhancement name' .
PERFORM CREATE_FIELD_CATALOG USING 'MODTEXT' 'T_USEREXIT' ' ' 'Enhancement text' .
PERFORM CREATE_FIELD_CATALOG USING 'MODATTR-MEMBER' 'T_USEREXIT' C_X 'Member' .
PERFORM CREATE_FIELD_CATALOG USING 'MODATTR-NAME' 'T_USEREXIT' ' ' 'Project' .
PERFORM CREATE_FIELD_CATALOG USING 'MODATTR-STATUS' 'T_USEREXIT' ' ' 'Status' .
PERFORM CREATE_FIELD_CATALOG USING 'MODATTR-ANAM' 'T_USEREXIT' ' ' 'Changed by' .
PERFORM CREATE_FIELD_CATALOG USING 'MODATTR-ADAT' 'T_USEREXIT' ' ' 'Change date' .

* Layout
CLEAR I_LAYOUT.
I_LAYOUT-COLWIDTH_OPTIMIZE = C_X.
I_LAYOUT-INFO_FIELDNAME = 'COLOUR' .

* Sort
CLEAR I_SORT.
I_SORT-FIELDNAME = 'TYPE' .
I_SORT-TABNAME = 'T_USEREXIT' .
I_SORT-UP = C_X.
APPEND I_SORT.

CALL FUNCTION 'REUSE\_ALV\_GRID\_DISPLAY'  
  EXPORTING  
    I\_CALLBACK\_PROGRAM      = SY-CPROG  
    I\_CALLBACK\_USER\_COMMAND = 'USER\_COMMAND'  
    IS\_LAYOUT               = I\_LAYOUT  
    IT\_FIELDCAT             = I\_FIELDCAT\[\]  
    IT\_SORT                 = I\_SORT\[\]  
    I\_DEFAULT               = C\_X  
    I\_SAVE                  = 'A'  
    I\_GRID\_TITLE            = W\_GRIDTXT  
  TABLES  
    T\_OUTTAB                = I\_USEREXIT.

ENDIF .

* issue message with number of user-exits displayed
DESCRIBE TABLE I_USEREXIT LINES W_LINNUM.
MESSAGE S697() WITH W_LINNUM.

ENDFORM . "DATA_DISPLAY

*&---------------------------------------------------------------------&*
*& Form CREATE_FIELD_CATALOG &*
*&---------------------------------------------------------------------&*
FORM CREATE_FIELD_CATALOG USING P_FIELDNAME
P_TABNAME
P_HIDE
P_TEXT.

I_FIELDCAT-FIELDNAME = P_FIELDNAME.
I_FIELDCAT-TABNAME = P_TABNAME.
I_FIELDCAT-NO_OUT = P_HIDE.
I_FIELDCAT-SELTEXT_L = P_TEXT.

APPEND I_FIELDCAT.

ENDFORM . " CREATE_FIELD_CATALOG

*&---------------------------------------------------------------------&*
*& Form CREATE_FIELD_CATALOG &*
*&---------------------------------------------------------------------&*
FORM USER_COMMAND USING R_UCOMM LIKE SY-UCOMM
RS_SELFIELD TYPE SLIS_SELFIELD.
READ TABLE I_USEREXIT INDEX RS_SELFIELD-TABINDEX.
CHECK SY-SUBRC = .
CASE R_UCOMM.
WHEN '&IC1' .
CASE RS_SELFIELD-SEL_TAB_FIELD.
WHEN 'T_USEREXIT-MODNAME' .
READ TABLE I_USEREXIT INDEX RS_SELFIELD-TABINDEX.
CASE I_USEREXIT-TYPE .
WHEN 'Enhancement' .
SET PARAMETER ID 'MON' FIELD I_USEREXIT-MODNAME.
CALL TRANSACTION 'SMOD' .
WHEN 'BADI' .
SET PARAMETER ID 'EXN' FIELD I_USEREXIT-MODNAME.
CALL TRANSACTION 'SE18' AND SKIP FIRST SCREEN .
WHEN 'BusTrEvent' .
SUBMIT RFOPFI00 WITH EVENT = I_USEREXIT-MODNAME() AND RETURN .
WHEN OTHERS .
MESSAGE S030(CJ). "Navigation not possible
ENDCASE .
WHEN 'T_USEREXIT-MODATTR-NAME' .
IF NOT I_USEREXIT-MODATTR-NAME IS INITIAL .
SET PARAMETER ID 'MON_KUN' FIELD I_USEREXIT-MODATTR-NAME.
CALL TRANSACTION 'CMOD' .
ELSE .
MESSAGE S030(CJ)."Navigation not possible
ENDIF .
WHEN OTHERS .
MESSAGE S030(CJ)."Navigation not possible
ENDCASE .
ENDCASE .

ENDFORM . "user_command

*&--------------------------------------------------------------------&*
*& AT LINE-SELECTION #*
*&--------------------------------------------------------------------&*
AT LINE-SELECTION.

GET CURSOR FIELD W_FSEL.

CASE W_FSEL.

WHEN  'I\_USEREXIT-MODNAME' .  
  CASE  I\_USEREXIT-TYPE .  
    WHEN  'Enhancement' .  
      SET  PARAMETER  ID  'MON'  FIELD  I\_USEREXIT-MODNAME.  
      CALL  TRANSACTION  'SMOD' .  
    WHEN  'BADI' .  
      SET  PARAMETER  ID  'EXN'  FIELD  I\_USEREXIT-MODNAME.  
      CALL  TRANSACTION  'SE18'  AND  SKIP  FIRST  SCREEN .  
    WHEN  'BusTrEvent' .  
      SUBMIT  RFOPFI00 WITH  EVENT  = I\_USEREXIT-MODNAME() AND  RETURN .  
    WHEN  OTHERS .  
      MESSAGE  S030(CJ)."Navigation not possible  
  ENDCASE .

WHEN  'I\_USEREXIT-MODATTR-NAME' .  
  IF  NOT  I\_USEREXIT-MODATTR-NAME IS  INITIAL .  
    SET  PARAMETER  ID  'MON\_KUN'  FIELD  I\_USEREXIT-MODATTR-NAME.  
    CALL  TRANSACTION  'CMOD' .  
  ELSE .  
    MESSAGE  S030(CJ)."Navigation not possible  
  ENDIF .

WHEN  OTHERS .  
  MESSAGE  S030(CJ)."Navigation not possible

ENDCASE .

*&--------------------------------------------------------------------&*
*& AT SELECTION-SCREEN &*
*&--------------------------------------------------------------------&*
AT SELECTION-SCREEN ON RADIOBUTTON GROUP RAD1.

* grey-out checkboxes if ALV selected
AT SELECTION-SCREEN OUTPUT .
LOOP AT SCREEN .
IF P_ALV = C_X.
IF SCREEN-GROUP1 = 'A01' .
SCREEN-INPUT = '' .
MODIFY SCREEN .
ENDIF .
ELSE .
IF SCREEN-GROUP1 = 'A01' .
SCREEN-INPUT = '' .
MODIFY SCREEN .
ENDIF .
ENDIF .
ENDLOOP .

手机扫一扫

移动阅读更方便

阿里云服务器
腾讯云服务器
七牛云服务器

你可能感兴趣的文章