查找增强程序

*&---------------------------------------------------------------------*
*& Report Z_FIND_EXIT_AND_BADI
*&
*&---------------------------------------------------------------------*
*&
*&
*&---------------------------------------------------------------------*
REPORT ZT_FIND_COMD NO STANDARD PAGE heading.
*&---------------------------------------------------------------------*
*& Enter the transaction code that you want to search through in order
*& to find which Standard SAP User Exits and BADIs
*&
*&---------------------------------------------------------------------*
*& For field 'SUBC' of table 'TRDIR':
*& M Module Pool
*& F Function group
*& S Subroutine Pool
*& J Interface pool
*& K Class pool
*& T Type Pool
*& X XSLT Program
*&---------------------------------------------------------------------*
*& Tables
*&---------------------------------------------------------------------*
TABLES: tstc , " SAP Transaction Codes
tadir , " Directory of Repository Objects
modsapt , " SAP Enhancements - Short Texts
sxs_attrt, " SAP BADI - short text
modact , " Modifications
trdir , " System table TRDIR
tfdir , " Function Module
enlfdir , " Additional Attributes for Function Modules
tstct . " Transaction Code Texts

*&---------------------------------------------------------------------*
*& Variables
*&---------------------------------------------------------------------*
DATA: jtab LIKE tadir OCCURS 0 WITH HEADER LINE.
DATA: field1(30).
DATA: v_devclass LIKE tadir-devclass.
DATA: object LIKE tadir-object.
DATA: bdcdata_wa TYPE bdcdata,
bdcdata_tab TYPE TABLE OF bdcdata.
DATA: opt TYPE ctu_params.

*&---------------------------------------------------------------------*
*& Selection Screen Parameters
*&---------------------------------------------------------------------*
selection-SCREEN BEGIN OF BLOCK a01 WITH FRAME TITLE TEXT-001.
selection-SCREEN SKIP.
PARAMETERS: p_tcode LIKE tstc-tcode obligatory.
selection-SCREEN SKIP.
PARAMETERS: EXIT RADIOBUTTON GROUP 1 DEFAULT 'X',
BADI RADIOBUTTON GROUP 1.
selection-SCREEN END OF BLOCK a01.

DEFINE bdc_program.
CLEAR bdcdata_wa.
bdcdata_wa-PROGRAM = &1.
bdcdata_wa-DYNPRO = &2.
bdcdata_wa-dynbegin = &3.
APPEND bdcdata_wa TO bdcdata_tab.
END-OF-DEFINITION.
DEFINE bdc_detail.
CLEAR bdcdata_wa.
bdcdata_wa-fnam = &1.
bdcdata_wa-fval = &2.
APPEND bdcdata_wa TO bdcdata_tab.
END-OF-DEFINITION.

*&---------------------------------------------------------------------*
*& Start of main program
*&---------------------------------------------------------------------*
start-OF-selection.
IF EXIT = 'X'.
object = 'SMOD'. " User-exit!
ELSE.
object = 'SXSD'. " BADI!
ENDIF.

* Validate Transaction Code:
SELECT SINGLE * FROM tstc WHERE tcode EQ p_tcode.
* Find Repository Objects for transaction code:
IF sy-subrc EQ 0. " IF 1
SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
AND object = 'PROG'
AND obj_name = tstc-pgmna."Program
* name!
MOVE: tadir-devclass TO v_devclass. " Package
IF sy-subrc NE 0.
SELECT SINGLE * FROM trdir WHERE name = tstc-pgmna.
IF trdir-subc EQ 'F'. " Function Group
SELECT SINGLE * FROM tfdir WHERE pname = tstc-pgmna.
SELECT SINGLE * FROM enlfdir WHERE funcname = tfdir-funcname.
SELECT SINGLE * FROM tadir WHERE pgmid = 'R3TR'
AND object = 'FUGR'
AND obj_name = enlfdir-area.
MOVE: tadir-devclass TO v_devclass.
ENDIF.
ENDIF.

* Find SAP Modifactions:
SELECT * FROM tadir INTO TABLE jtab WHERE pgmid = 'R3TR'
* AND object = 'SMOD'
AND object = object
AND devclass = v_devclass.
SELECT SINGLE * FROM tstct WHERE sprsl EQ sy-langu
AND tcode EQ p_tcode.

FORMAT COLOR col_positive INTENSIFIED off.
WRITE: /(19) 'Transaction Code - ',
20(20) p_tcode,
45(50) tstct-ttext.
SKIP.
IF NOT jtab[] IS INITIAL. " IF 2
WRITE: /(95) sy-ULINE.
FORMAT COLOR col_heading INTENSIFIED ON.
* Exit:
IF EXIT = 'X'.
WRITE: /1 sy-vline,
'Exit Name',
sy-vline ,
'Description',
sy-vline.
* BADI:
ELSE.
WRITE: /1 sy-vline,
'BADI Name',
sy-vline ,
'Description',
sy-vline.
ENDIF.
WRITE:/(95) sy-ULINE.
LOOP AT jtab.
* EXIT:
IF EXIT = 'X'.
SELECT SINGLE * FROM modsapt WHERE sprsl = sy-langu
AND name = jtab-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED off.
WRITE: /1 sy-vline,
jtab-obj_name HOTSPOT ON,
sy-vline ,
modsapt-modtext,
sy-vline.
* BADI:
ELSE.
SELECT SINGLE * FROM sxs_attrt WHERE sprsl = sy-langu
AND exit_name =
jtab-obj_name.
FORMAT COLOR COL_NORMAL INTENSIFIED off.
WRITE: /1 sy-vline,
jtab-obj_name HOTSPOT ON,
sy-vline ,
sxs_attrt-TEXT,
sy-vline.
ENDIF.
ENDLOOP.
WRITE: /(95) sy-ULINE.
DESCRIBE TABLE jtab.
SKIP.
FORMAT COLOR col_total INTENSIFIED ON.
IF EXIT = 'X'.
WRITE: / 'No of Exits:', sy-tfill.
ELSE.
WRITE: / 'No of BADIs:', sy-tfill.
ENDIF.
ELSE. " IF 2
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE: /(95) 'No User Exit exists'.
ENDIF. " IF 2
ELSE. " IF 1
FORMAT COLOR COL_NEGATIVE INTENSIFIED ON.
WRITE: /(95) 'Transaction Code Does Not Exist'.
ENDIF. " IF 1


* Take the user to SMOD for the Exit that was selected:
AT LINE-selection.
GET CURSOR FIELD field1.
CHECK field1(4) EQ 'JTAB'.
* For exit:
IF EXIT = 'X'.
SET PARAMETER ID 'MON' FIELD sy-lisel+1(10).
CALL TRANSACTION 'SMOD' AND SKIP FIRST SCREEN.
* For BADI:
ELSE.
CLEAR: bdcdata_wa, bdcdata_tab[].
bdc_program 'SAPLSEXO' '0100' 'X'.
bdc_detail 'BDC_CURSOR' 'G_IS_BADI'.
bdc_detail 'BDC_OKCODE' '=ISSPOT'.
bdc_detail 'G_IS_BADI' 'X'.
bdc_program 'SAPLSEXO' '0100' 'X'.
bdc_detail 'BDC_CURSOR' 'G_BADINAME'.
bdc_detail 'BDC_OKCODE' '=SHOW'.
bdc_detail 'G_BADINAME' sy-lisel+1(20).
opt-dismode = 'E'.
opt-defsize = 'X'.
CALL TRANSACTION 'SE18' USING bdcdata_tab options FROM opt.
ENDIF.

 

上一篇:2019 Wannafly Winter Camp


下一篇:前端vue项目本地调用post接口403报错